Skip to content

Instantly share code, notes, and snippets.

@maxim
Created September 13, 2009 00:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save maxim/186030 to your computer and use it in GitHub Desktop.
Save maxim/186030 to your computer and use it in GitHub Desktop.
# Install
#
# Move this file into config/preinitializer.rb
#
# Usage
#
# This line:
# config.github_gem "mislav-will_paginate"
# is equivalent to this line:
# config.gem "mislav-will_paginate", :lib => "will_paginate", :source => "http://gem.github.com"
#
# You can pass in options to override defaults such as this:
# config.github_gem "mislav-will_paginate", :source => "http://example.com", :version => "~ 2.1"
#
# which will be equivalent to this:
# config.gem "mislav_will_paginate", :lib => "will_paginate", :source => "http://example.com", :version => "~ 2.1"
#
# Lastly you can pass in multiple options
# config.github_gem "mislav-will_paginate", "josevalim-inherited_resources"
#
# Using options in latter case makes no sense, since they will be apply to every gem.
class Rails::Configuration
def github_gem(*gem_options)
overrides = gem_options.last.is_a?(Hash) ? gem_options.pop : {}
gem_options.each do |gem_name|
self.gem(gem_name, { :lib => gem_name.split('-')[1], :source => "http://gems.github.com" }.merge(overrides))
end
end
alias :github_gems :github_gem
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment