Permalink
Browse files

Add github to the Gemfile DSL (thx DHH)

  • Loading branch information...
1 parent 31a1fb9 commit 8b2649eb89ac4d28d0f3c21fdadb7bcc23d457eb @indirect indirect committed Apr 18, 2011
Showing with 14 additions and 0 deletions.
  1. +14 −0 lib/bundler/dsl.rb
View
@@ -111,6 +111,14 @@ def git(uri, options = {}, source_options = {}, &blk)
source Source::Git.new(_normalize_hash(options).merge("uri" => uri)), source_options, &blk
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 to_definition(lockfile, unlock)
@sources << @rubygems_source
@sources.uniq!
@@ -209,6 +217,12 @@ def _normalize_options(name, version, opts)
raise DslError, "`#{p}` is not a valid platform. The available options are: #{VALID_PLATFORMS.inspect}"
end
+ # Convert github option into git option
+ if github = opts.delete(:github)
+ github = "#{github}/#{github}" unless github.include?("/")
+ opts[:git] = "git://github.com/#{github}.git"
+ end
+
# Normalize git and path options
["git", "path"].each do |type|
if param = opts[type]

7 comments on commit 8b2649e

Contributor

shtirlic replied Apr 18, 2011

Love it. and 222 line also great.

What's the motivation for coupling Bundler to a webservice like this? =S

@grimen, probably because it's the de facto standard for open source gems?

Owner

indirect replied Apr 18, 2011

if 90% of :git URLs are for github, it makes sense to make the common case easy.

OK, well I cannot say I agree but now I know at least.

Owner

indirect replied Apr 18, 2011

@grimen, what do you disagree with, exactly? This leaves the :git option the exact same way it has always been.

Not sure it is worthy discussion really. My thoughts around this have to do with some best practices to not couple general purpose libraries to explicit 3rd party sites no matter how great they are. GitHub might be my favorit service of all times, still it's syntax sugar over de-coupling. Oh well...if majority of you agree I think I'm getting old. ;)

Please sign in to comment.