diff options
author | Carl Lerche <carllerche@mac.com> | 2010-02-23 11:49:15 -0800 |
---|---|---|
committer | Carl Lerche <carllerche@mac.com> | 2010-02-23 11:49:15 -0800 |
commit | 3b1347df082c9bf9d75b9a35e31c44f70f498a22 (patch) | |
tree | 7495206f9c8921681c3b7672826216e025b75cf1 /lib/bundler/dsl.rb | |
parent | c79a6cede3534cb707eccc8ed7121d616d9bae8e (diff) | |
download | bundler-3b1347df082c9bf9d75b9a35e31c44f70f498a22.tar.gz |
Add block syntax to git and path in the Gemfile DSL
Diffstat (limited to 'lib/bundler/dsl.rb')
-rw-r--r-- | lib/bundler/dsl.rb | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index 57ab3302..309058a5 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -9,6 +9,7 @@ module Bundler end def initialize + @source = nil @sources = [] @dependencies = [] @group = nil @@ -28,22 +29,26 @@ module Bundler end def source(source, options = {}) - source = case source + @source = case source when :gemcutter, :rubygems, :rubyforge then Source::Rubygems.new("uri" => "http://gemcutter.org") when String then Source::Rubygems.new("uri" => source) else source end - options[:prepend] ? @sources.unshift(source) : @sources << source - source + options[:prepend] ? @sources.unshift(@source) : @sources << @source + + yield if block_given? + @source + ensure + @source = nil end - def path(path, options = {}, source_options = {}) - source Source::Path.new(_normalize_hash(options).merge("path" => Pathname.new(path))), source_options + def path(path, options = {}, source_options = {}, &blk) + source Source::Path.new(_normalize_hash(options).merge("path" => Pathname.new(path))), source_options, &blk end - def git(uri, options = {}, source_options = {}) - source Source::Git.new(_normalize_hash(options).merge("uri" => uri)), source_options + def git(uri, options = {}, source_options = {}, &blk) + source Source::Git.new(_normalize_hash(options).merge("uri" => uri)), source_options, &blk end def to_definition @@ -104,6 +109,8 @@ module Bundler end end + opts["source"] ||= @source + opts["group"] = group end |