diff options
author | Lars Gierth <lars.gierth@gmail.com> | 2011-06-17 00:53:12 +0200 |
---|---|---|
committer | Andre Arko <andre@arko.net> | 2011-08-09 11:30:48 -0700 |
commit | cc7637c2bdd0f35d0b5ec5ec22a73c208531d4eb (patch) | |
tree | 8d26c5b650916520f30ce93f4289861aedcb13a3 /lib | |
parent | e6ccb12e2a3e4a6c359a3cc92eb50d3ee519f4d6 (diff) | |
download | bundler-cc7637c2bdd0f35d0b5ec5ec22a73c208531d4eb.tar.gz |
Allow overriding development deps loaded by #gemspec
closes #1245
Diffstat (limited to 'lib')
-rw-r--r-- | lib/bundler/dependency.rb | 3 | ||||
-rw-r--r-- | lib/bundler/dsl.rb | 33 |
2 files changed, 26 insertions, 10 deletions
diff --git a/lib/bundler/dependency.rb b/lib/bundler/dependency.rb index e05b85a8..cb5709d1 100644 --- a/lib/bundler/dependency.rb +++ b/lib/bundler/dependency.rb @@ -24,7 +24,8 @@ module Bundler }.freeze def initialize(name, version, options = {}, &blk) - super(name, version) + type = options["type"] || :runtime + super(name, version, type) @autorequire = nil @groups = Array(options["group"] || :default).map { |g| g.to_sym } diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index e9a2bd7a..853b2ff0 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -34,7 +34,7 @@ module Bundler gem spec.name, :path => path group(development_group) do spec.development_dependencies.each do |dep| - gem dep.name, *dep.requirement.as_list + gem dep.name, *(dep.requirement.as_list + [:type => :development]) end end when 0 @@ -57,20 +57,34 @@ module Bundler dep = Dependency.new(name, version, options) + # if there's already a dependency with this name we try to prefer one if current = @dependencies.find { |d| d.name == dep.name } if current.requirement != dep.requirement - raise DslError, "You cannot specify the same gem twice with different version requirements. " \ - "You specified: #{current.name} (#{current.requirement}) and " \ - "#{dep.name} (#{dep.requirement})" + if current.type == :development + @dependencies.delete current + elsif dep.type == :development + return + else + raise DslError, "You cannot specify the same gem twice with different version requirements. " \ + "You specified: #{current.name} (#{current.requirement}) and " \ + "#{dep.name} (#{dep.requirement})" + end end if current.source != dep.source - raise DslError, "You cannot specify the same gem twice coming from different sources. You " \ - "specified that #{dep.name} (#{dep.requirement}) should come from " \ - "#{current.source || 'an unspecfied source'} and #{dep.source}" + if current.type == :development + @dependencies.delete current + elsif dep.type == :development + return + else + raise DslError, "You cannot specify the same gem twice coming from different sources. You " \ + "specified that #{dep.name} (#{dep.requirement}) should come from " \ + "#{current.source || 'an unspecfied source'} and #{dep.source}" + end end end - @dependencies << Dependency.new(name, version, options) + + @dependencies << dep end def source(source, options = {}) @@ -183,7 +197,8 @@ module Bundler def _normalize_options(name, version, opts) _normalize_hash(opts) - invalid_keys = opts.keys - %w(group groups git path name branch ref tag require submodules platform platforms) + invalid_keys = opts.keys - %w(group groups git path name branch ref tag require submodules platform platforms type) +#gemspec if invalid_keys.any? plural = invalid_keys.size > 1 message = "You passed #{invalid_keys.map{|k| ':'+k }.join(", ")} " |