blob: 21f3de8854f163898aa536614edc19d5a82c9464 (
plain) (
blame)
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
# DO NOT MODIFY THIS FILE
module Bundler
dir = File.dirname(__FILE__)
<% unless options[:system_gems] -%>
ENV["GEM_HOME"] = dir
ENV["GEM_PATH"] = dir
<% end -%>
ENV["PATH"] = "#{dir}/<%= bindir %>:#{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 options[:rubygems] -%>
require "rubygems"
@bundled_specs = {}
<% spec_files.each do |name, path| -%>
@bundled_specs["<%= name %>"] = eval(File.read("#{dir}/<%= path %>"))
@bundled_specs["<%= name %>"].loaded_from = "#{dir}/<%= path %>"
<% 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(*) ; end
def only(env)
old, @only = @only, _combine_onlys(env)
yield
@only = old
end
def except(env)
old, @except = @except, _combine_excepts(env)
yield
@except = old
end
def gem(name, *args)
opt = args.last || {}
only = _combine_onlys(opt[:only] || opt["only"])
except = _combine_excepts(opt[:except] || opt["except"])
files = opt[:require_as] || opt["require_as"] || name
return unless !only || only.any? {|e| e == @env }
return if except && except.any? {|e| e == @env }
files.each { |f| require f }
yield if block_given?
true
end
private
def _combine_onlys(only)
return @only unless only
only = [only].flatten.compact.uniq.map { |o| o.to_s }
only &= @only if @only
only
end
def _combine_excepts(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))
end
end
<% if options[:rubygems] -%>
module Gem
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
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 -%>
|