Skip to content

Instantly share code, notes, and snippets.

@knzai
Created February 14, 2010 01:40
Show Gist options
  • Save knzai/303783 to your computer and use it in GitHub Desktop.
Save knzai/303783 to your computer and use it in GitHub Desktop.
## require in config/environment.rb before init starts
#require 'config/add_explicit_path_to_config_gem'
#Rails::Initializer.run do |config|
#config.gem 'my_gem', :version => '0.0.1', :explicit_path => "#{RAILS_ROOT}/vendor/local_gemfiles/my_gem-0.0.1.gem" #or
#config.gem 'my_gem', :version => '0.0.1', :explicit_path => "http://github.com/myname/myrepo/raw/master/mygem.gem" #or
module Rails
class GemDependency < Gem::Dependency
def initialize(name, options = {})
require 'rubygems' unless Object.const_defined?(:Gem)
if options[:requirement]
req = options[:requirement]
elsif options[:version]
req = Gem::Requirement.create(options[:version])
else
req = Gem::Requirement.default
end
@lib = options[:lib]
@source = options[:source]
@loaded = @frozen = @load_paths_added = false
@explicit_path = options[:explicit_path]
super(name, req)
end
private
def install_command
cmd = %w(install) << (@explicit_path || name)
cmd << "--version" << %("#{requirement.to_s}") if requirement
cmd << "--source" << @source if @source
cmd
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment