Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Add :gist option for gems embedded in gists
Browse files Browse the repository at this point in the history
  • Loading branch information
jgaskins committed Jun 2, 2012
1 parent 14a0648 commit a3a3efa
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/bundler/dsl.rb
Expand Up @@ -200,7 +200,7 @@ def _normalize_hash(opts)
def _normalize_options(name, version, opts)
_normalize_hash(opts)

valid_keys = %w(group groups git github path name branch ref tag require submodules platform platforms type)
valid_keys = %w(group groups git gist github path name branch ref tag require submodules platform platforms type)
invalid_keys = opts.keys - valid_keys
if invalid_keys.any?
plural = invalid_keys.size > 1
Expand Down Expand Up @@ -234,6 +234,10 @@ def _normalize_options(name, version, opts)
opts["git"] = "git://github.com/#{github}.git"
end

if gist = opts.delete("gist")
opts["git"] = "git://gist.github.com/#{gist}.git"
end

["git", "path"].each do |type|
if param = opts[type]
if version.first && version.first =~ /^\s*=?\s*(\d[^\s]*)\s*$/
Expand Down
12 changes: 12 additions & 0 deletions spec/bundler/dsl_spec.rb
Expand Up @@ -13,6 +13,18 @@
subject.dependencies.first.source.uri.should == github_uri
end

it "should convert numeric :gist to :git" do
subject.gem("not-really-a-gem", :gist => 2859988)
github_uri = "git://gist.github.com/2859988.git"
subject.dependencies.first.source.uri.should == github_uri
end

it "should convert :gist to :git" do
subject.gem("not-really-a-gem", :gist => "2859988")
github_uri = "git://gist.github.com/2859988.git"
subject.dependencies.first.source.uri.should == github_uri
end

it "should convert 'rails' to 'rails/rails'" do
subject.gem("rails", :github => "rails")
github_uri = "git://github.com/rails/rails.git"
Expand Down

0 comments on commit a3a3efa

Please sign in to comment.