jerome (owner)

Fork Of

Revisions

gist: 187906 Download_button fork
public
Public Clone URL: git://gist.github.com/187906.git
Embed All Files: show embed
preinitializer.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# 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