Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
tree: 12c740f3d3
Fetching contributors…

Cannot retrieve contributors at this time

157 lines (139 sloc) 4.559 kb
# DO NOT MODIFY THIS FILE
module Bundler
file = File.expand_path(__FILE__)
dir = File.dirname(file)
<% unless system_gems? -%>
ENV["GEM_HOME"] = dir
ENV["GEM_PATH"] = dir
# handle 1.9 where system gems are always on the load path
if defined?(::Gem)
$LOAD_PATH.reject! do |p|
p != File.dirname(__FILE__) &&
Gem.path.any? { |gp| p.include?(gp) }
end
end
<% end -%>
ENV["PATH"] = "#{dir}/<%= bindir %><%= File::PATH_SEPARATOR %>#{ENV["PATH"]}"
ENV["RUBYOPT"] = "-r#{file} #{ENV["RUBYOPT"]}"
<% load_paths.each do |load_path| -%>
$LOAD_PATH.unshift File.expand_path("#{dir}/<%= load_path %>")
<% end -%>
@gemfile = "#{dir}/<%= filename %>"
<% if rubygems? -%>
require "rubygems" unless respond_to?(:gem) # 1.9 already has RubyGems loaded
@bundled_specs = {}
<% specs.each do |spec| -%>
<% if spec.no_bundle? -%>
gem "<%= spec.name %>", "<%= spec.version %>"
<% else -%>
<% path = spec_file_for(spec) -%>
@bundled_specs["<%= spec.name %>"] = eval(File.read("#{dir}/<%= path %>"))
@bundled_specs["<%= spec.name %>"].loaded_from = "#{dir}/<%= path %>"
<% end -%>
<% end -%>
def self.add_specs_to_loaded_specs
Gem.loaded_specs.merge! @bundled_specs
end
def self.add_specs_to_index
@bundled_specs.each do |name, spec|
Gem.source_index.add_spec spec
end
end
add_specs_to_loaded_specs
add_specs_to_index
<% end -%>
def self.require_env(env = nil)
context = Class.new do
def initialize(env) @env = env && env.to_s ; end
def method_missing(*) ; yield if block_given? ; end
def only(*env)
old, @only = @only, _combine_only(env.flatten)
yield
@only = old
end
def except(*env)
old, @except = @except, _combine_except(env.flatten)
yield
@except = old
end
def gem(name, *args)
opt = args.last.is_a?(Hash) ? args.pop : {}
only = _combine_only(opt[:only] || opt["only"])
except = _combine_except(opt[:except] || opt["except"])
files = opt[:require_as] || opt["require_as"] || name
files = [files] unless files.respond_to?(:each)
return unless !only || only.any? {|e| e == @env }
return if except && except.any? {|e| e == @env }
if files = opt[:require_as] || opt["require_as"]
files = Array(files)
files.each { |f| require f }
else
begin
require name
rescue LoadError
# Do nothing
end
end
yield if block_given?
true
end
private
def _combine_only(only)
return @only unless only
only = [only].flatten.compact.uniq.map { |o| o.to_s }
only &= @only if @only
only
end
def _combine_except(except)
return @except unless except
except = [except].flatten.compact.uniq.map { |o| o.to_s }
except |= @except if @except
except
end
end
context.new(env && env.to_s).instance_eval(File.read(@gemfile), @gemfile, 1)
end
end
<% if rubygems? -%>
module Gem
@loaded_stacks = Hash.new { |h,k| h[k] = [] }
def source_index.refresh!
super
Bundler.add_specs_to_index
end
end
<% else -%>
$" << "rubygems.rb"
module Kernel
def gem(*)
# Silently ignore calls to gem, since, in theory, everything
# is activated correctly already.
end
end
# Define all the Gem errors for gems that reference them.
module Gem
def self.ruby ; <%= Gem.ruby.inspect %> ; end
def self.dir ; @dir ||= File.dirname(File.expand_path(__FILE__)) ; end
class << self ; alias default_dir dir; alias path dir ; end
class LoadError < ::LoadError; end
class Exception < RuntimeError; end
class CommandLineError < Exception; end
class DependencyError < Exception; end
class DependencyRemovalException < Exception; end
class GemNotInHomeException < Exception ; end
class DocumentError < Exception; end
class EndOfYAMLException < Exception; end
class FilePermissionError < Exception; end
class FormatException < Exception; end
class GemNotFoundException < Exception; end
class InstallError < Exception; end
class InvalidSpecificationException < Exception; end
class OperationNotSupportedError < Exception; end
class RemoteError < Exception; end
class RemoteInstallationCancelled < Exception; end
class RemoteInstallationSkipped < Exception; end
class RemoteSourceException < Exception; end
class VerificationError < Exception; end
class SystemExitException < SystemExit; end
end
<% end -%>
Jump to Line
Something went wrong with that request. Please try again.