Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add :github option to gem and make it even nicer as github() as well

  • Loading branch information...
commit c2bac6dca4f7f4d123a3caa0e8f640172477c517 1 parent 31a1fb9
@dhh dhh authored
Showing with 14 additions and 2 deletions.
  1. +14 −2 lib/bundler/dsl.rb
View
16 lib/bundler/dsl.rb
@@ -44,6 +44,14 @@ def gemspec(opts = nil)
end
end
+ def github(repo_name, *args)
+ options = Hash === args.last ? args.pop : {}
+ options[:github] = repo_name
+ args << options
+
+ gem(repo_name.split("/").last, *args)
+ end
+
def gem(name, *args)
if name.is_a?(Symbol)
raise GemfileError, %{You need to specify gem names as Strings. Use 'gem "#{name.to_s}"' instead.}
@@ -183,7 +191,7 @@ def _normalize_hash(opts)
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 github path name branch ref tag require submodules platform platforms)
if invalid_keys.any?
plural = invalid_keys.size > 1
message = "You passed #{invalid_keys.map{|k| ':'+k }.join(", ")} "
@@ -209,7 +217,11 @@ def _normalize_options(name, version, opts)
raise DslError, "`#{p}` is not a valid platform. The available options are: #{VALID_PLATFORMS.inspect}"
end
- # Normalize git and path options
+ if github = opts.delete(:github)
+ github = "#{github}/#{github}" unless github.include?("/")
+ opts["git"] = "git://github.com/#{github}.git"
+ end
+
["git", "path"].each do |type|
if param = opts[type]
if version.first && version.first =~ /^\s*=?\s*(\d[^\s]*)\s*$/
Please sign in to comment.
Something went wrong with that request. Please try again.