aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bundler
diff options
context:
space:
mode:
authorAndre Arko <andre@arko.net>2013-02-10 14:53:47 -0800
committerTim Moore <tmoore@incrementalism.net>2014-07-30 14:16:36 +1000
commit75c0bed53a9c90643a1139a7bb62890662840cb4 (patch)
tree89cab14eb7da488985d736f194fb122bf39b6a26 /lib/bundler
parent53c296d2cf1823d3f9ff84af50b84a38938cd4a3 (diff)
downloadbundler-75c0bed53a9c90643a1139a7bb62890662840cb4.tar.gz
allow rubygem sources via block or :source option
Diffstat (limited to 'lib/bundler')
-rw-r--r--lib/bundler/dsl.rb18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb
index cc3e0da9..ef5c6fba 100644
--- a/lib/bundler/dsl.rb
+++ b/lib/bundler/dsl.rb
@@ -67,7 +67,7 @@ module Bundler
def gem(name, *args)
options = args.last.is_a?(Hash) ? args.pop.dup : {}
- version = args
+ version = args || [">= 0"]
normalize_options(name, version, options)
@@ -107,9 +107,13 @@ module Bundler
@dependencies << dep
end
- def source(source)
+ def source(source, &blk)
source = normalize_source(source)
- @sources.add_rubygems_remote(source)
+ if block_given?
+ with_source(@sources.add_rubygems_source("remotes" => source), &blk)
+ else
+ @sources.add_rubygems_remote(source)
+ end
end
def git_source(name, &block)
@@ -205,7 +209,7 @@ module Bundler
end
def valid_keys
- @valid_keys ||= %w(group groups git path name branch ref tag require submodules platform platforms type)
+ @valid_keys ||= %w(group groups git path name branch ref tag require submodules platform platforms type source)
end
def normalize_options(name, version, opts)
@@ -244,6 +248,12 @@ module Bundler
raise GemfileError, "`#{p}` is not a valid platform. The available options are: #{VALID_PLATFORMS.inspect}"
end
+ # Save sources passed in a key
+ if opts.has_key?("source")
+ source = normalize_source(opts["source"])
+ opts["source"] = @sources.add_rubygems_source("remotes" => source)
+ end
+
git_name = (git_names & opts.keys).last
if @git_sources[git_name]
opts["git"] = @git_sources[git_name].call(opts[git_name])