diff options
author | Carlhuda <carlhuda@engineyard.com> | 2010-07-20 16:11:53 -0700 |
---|---|---|
committer | Carlhuda <carlhuda@engineyard.com> | 2010-07-20 16:11:53 -0700 |
commit | 7c01c7e7fb17763c9a0b709a83443b536494d048 (patch) | |
tree | 49a638cce7b42e5a01c418d167a1a6feb9831b33 | |
parent | 499025206d31837b0afe014f79b8ff68b14e7849 (diff) | |
download | bundler-7c01c7e7fb17763c9a0b709a83443b536494d048.tar.gz |
Support multiple version dependencies
-rw-r--r-- | lib/bundler/dsl.rb | 4 | ||||
-rw-r--r-- | lib/bundler/lockfile_parser.rb | 3 | ||||
-rw-r--r-- | spec/install/gems/simple_case_spec.rb | 20 | ||||
-rw-r--r-- | spec/lock/flex_spec.rb | 21 |
4 files changed, 45 insertions, 3 deletions
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index 6f63f79205..4523a8c304 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -51,7 +51,7 @@ module Bundler end options = Hash === args.last ? args.pop : {} - version = args.last || ">= 0" + version = args || [">= 0"] if group = options[:groups] || options[:group] options[:group] = group end @@ -202,7 +202,7 @@ module Bundler # Normalize git and path options ["git", "path"].each do |type| if param = opts[type] - options = _version?(version) ? opts.merge("name" => name, "version" => version) : opts.dup + options = _version?(version.first) ? opts.merge("name" => name, "version" => version.first) : opts.dup source = send(type, param, options, :prepend => true) {} opts["source"] = source end diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb index b49b68e132..2522b7a32f 100644 --- a/lib/bundler/lockfile_parser.rb +++ b/lib/bundler/lockfile_parser.rb @@ -61,6 +61,7 @@ module Bundler def parse_dependency(line) if line =~ %r{^ {2}#{NAME_VERSION}(!)?$} name, version, pinned = $1, $2, $4 + version = version.split(",").map { |d| d.strip } if version dep = Bundler::Dependency.new(name, version) @@ -71,7 +72,7 @@ module Bundler # to use in the case that there are no gemspecs present. A fake # gemspec is created based on the version set on the dependency # TODO: Use the version from the spec instead of from the dependency - if version =~ /^= (.+)$/ && dep.source.is_a?(Bundler::Source::Path) + if version && version.size == 1 && version.first =~ /^= (.+)$/ && dep.source.is_a?(Bundler::Source::Path) dep.source.name = name dep.source.version = $1 end diff --git a/spec/install/gems/simple_case_spec.rb b/spec/install/gems/simple_case_spec.rb index 213f377e63..7d22eae6ab 100644 --- a/spec/install/gems/simple_case_spec.rb +++ b/spec/install/gems/simple_case_spec.rb @@ -45,6 +45,26 @@ describe "bundle install with gem sources" do should_be_installed("rack 1.0.0") end + it "fetches gems when multiple versions are specified" do + install_gemfile <<-G + source "file://#{gem_repo1}" + gem 'rack', "> 0.9", "< 1.0" + G + + default_bundle_path("gems/rack-0.9.1").should exist + should_be_installed("rack 0.9.1") + end + + it "fetches gems when multiple versions are specified take 2" do + install_gemfile <<-G + source "file://#{gem_repo1}" + gem 'rack', "< 1.0", "> 0.9" + G + + default_bundle_path("gems/rack-0.9.1").should exist + should_be_installed("rack 0.9.1") + end + it "raises an appropriate error when gems are specified using symbols" do status = install_gemfile(<<-G, :exit_status => true) source "file://#{gem_repo1}" diff --git a/spec/lock/flex_spec.rb b/spec/lock/flex_spec.rb index 768d65cc8f..55f6b53c5b 100644 --- a/spec/lock/flex_spec.rb +++ b/spec/lock/flex_spec.rb @@ -495,4 +495,25 @@ describe "the lockfile format" do rack G end + + it "works correctly with multiple version dependencies" do + install_gemfile <<-G + source "file://#{gem_repo1}" + gem "rack", "> 0.9", "< 1.0" + G + + lockfile_should_be <<-G + GEM + remote: file:#{gem_repo1}/ + specs: + rack (0.9.1) + + PLATFORMS + ruby + + DEPENDENCIES + rack (> 0.9, < 1.0) + G + + end end |