diff options
author | Carlhuda <carlhuda@engineyard.com> | 2010-04-20 17:51:12 -0700 |
---|---|---|
committer | Carlhuda <carlhuda@engineyard.com> | 2010-04-20 17:51:12 -0700 |
commit | ba579f4a3e525fdd78d89531291450b26a009b07 (patch) | |
tree | cd0a51cbbfb2bb6038535d52c2702fb5e60845fa /lib/bundler/flex | |
parent | 4bfff00e3bfc24c92c2a4e24ed08ad4e40942db2 (diff) | |
download | bundler-ba579f4a3e525fdd78d89531291450b26a009b07.tar.gz |
Remove temporary flex stuff
Diffstat (limited to 'lib/bundler/flex')
-rw-r--r-- | lib/bundler/flex/definition.rb | 61 | ||||
-rw-r--r-- | lib/bundler/flex/environments.rb | 57 | ||||
-rw-r--r-- | lib/bundler/flex/lockfile_parser.rb | 82 |
3 files changed, 0 insertions, 200 deletions
diff --git a/lib/bundler/flex/definition.rb b/lib/bundler/flex/definition.rb deleted file mode 100644 index 76fa8df4..00000000 --- a/lib/bundler/flex/definition.rb +++ /dev/null @@ -1,61 +0,0 @@ -# TODO: In the 0.10 release, there shouldn't be a locked subclass of Definition -module Bundler - module Flex - class Definition - attr_reader :dependencies, :sources, :locked_specs - - def self.build(gemfile, lockfile) - gemfile = Pathname.new(gemfile).expand_path - - unless gemfile.file? - raise GemfileNotFound, "#{gemfile} not found" - end - - # TODO: move this back into DSL - builder = Dsl.new - builder.instance_eval(File.read(gemfile.to_s), gemfile.to_s, 1) - builder.to_flex_definition(lockfile) - end - - def initialize(lockfile, dependencies, sources) - @dependencies, @sources = dependencies, sources - - if lockfile && File.exists?(lockfile) - locked = LockfileParser.new(File.read(lockfile)) - @locked_deps = locked.dependencies - @locked_specs = SpecSet.new(locked.specs) - else - @locked_deps = [] - @locked_specs = SpecSet.new([]) - end - end - - # TODO: OMG LOL - def resolved_dependencies - locked_specs_as_deps + dependencies - end - - def groups - dependencies.map { |d| d.groups }.flatten.uniq - end - - # We have the dependencies from Gemfile.lock and the dependencies from the - # Gemfile. Here, we are finding a list of all dependencies that were - # originally present in the Gemfile that still satisfy the requirements - # of the dependencies in the Gemfile.lock - # - # This allows us to add on the *new* requirements in the Gemfile and make - # sure that the changes result in a conservative update to the Gemfile.lock. - def locked_specs_as_deps - deps = @dependencies & @locked_deps - - @dependencies.each do |dep| - next if deps.include?(dep) - deps << dep if @locked_specs.any? { |s| s.satisfies?(dep) } - end - - @locked_specs.for(deps).map { |s| Gem::Dependency.new(s.name, s.version) } - end - end - end -end
\ No newline at end of file diff --git a/lib/bundler/flex/environments.rb b/lib/bundler/flex/environments.rb deleted file mode 100644 index b3cb8f0b..00000000 --- a/lib/bundler/flex/environments.rb +++ /dev/null @@ -1,57 +0,0 @@ -module Bundler - module Flex - module Environment - def write_yml_lock - File.open("#{root}/Gemfile.lock", 'w') do |f| - f.puts details - end - end - - def details - output = "" - - pinned_sources = dependencies.map {|d| d.source } - all_sources = @definition.sources.map {|s| s } - - specified_sources = all_sources - pinned_sources - - unless specified_sources.empty? - output << "sources:\n" - - specified_sources.each do |source| - output << " #{source.to_lock}\n" - end - output << "\n" - end - - unless @definition.dependencies.empty? - output << "dependencies:\n" - @definition.dependencies.sort_by {|d| d.name }.each do |dependency| - output << dependency.to_lock - end - output << "\n" - end - - output << "specs:\n" - specs.sort_by {|s| s.name }.each do |spec| - output << spec.to_lock - end - - output - end - end - - class Installer < Bundler::Installer - include Environment - - def run(*) - super - lock - end - end - - class Runtime < Bundler::Runtime - include Environment - end - end -end
\ No newline at end of file diff --git a/lib/bundler/flex/lockfile_parser.rb b/lib/bundler/flex/lockfile_parser.rb deleted file mode 100644 index c04521ae..00000000 --- a/lib/bundler/flex/lockfile_parser.rb +++ /dev/null @@ -1,82 +0,0 @@ -require "strscan" - -module Bundler - module Flex - class LockfileParser - attr_reader :sources, :dependencies, :specs - - # Do stuff - def initialize(lockfile) - @sources = [] - @dependencies = [] - @specs = [] - - lockfile.split(/\n+/).each do |line| - case line - when "sources:" - @state = :source - when "dependencies:" - @state = :dependencies - when "specs:" - @state = :specs - else - send("parse_#{@state}", line) - end - end - end - - private - - TYPES = { - "git" => Bundler::Source::Git, - "gem" => Bundler::Source::Rubygems, - "path" => Bundler::Source::Path - } - - def parse_source(line) - @sources << parse_source_line(line) - end - - def parse_source_line(line) - type, source, option_line = line.match(/^\s+(\w+): ([^\s]*?)(?: (.*))?$/).captures - options = extract_options(option_line) - TYPES[type].from_lock(source, options) - end - - NAME_VERSION = '(?! )(.*?)(?: \((.*)\))?:?' - - def parse_dependencies(line) - if line =~ %r{^ {2}#{NAME_VERSION}$} - name, version = $1, $2 - - @current = Bundler::Dependency.new(name, version) - @dependencies << @current - else - @current.source = parse_source_line(line) - end - end - - def parse_specs(line) - if line =~ %r{^ {2}#{NAME_VERSION}$} - @current = LazySpecification.new($1, $2) - @specs << @current - else - line =~ %r{^ {4}#{NAME_VERSION}$} - @current.dependencies << Gem::Dependency.new($1, $2) - end - end - - def extract_options(line) - options = {} - return options unless line - - line.scan(/(\w+):"((?:|.*?[^\\])(?:\\\\)*)" ?/) do |k,v| - options[k] = v - end - - options - end - - end - end -end
\ No newline at end of file |