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

Add :gist option for gems embedded in gists #1958

Merged
merged 1 commit into from Dec 8, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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