Class: Bundler::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/bundler08/environment.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bundle) ⇒ Environment

Returns a new instance of Environment.



11
12
13
14
15
16
17
18
19
# File 'lib/bundler08/environment.rb', line 11

def initialize(bundle)
  @bundle = bundle # TODO: remove this
  @default_sources  = default_sources
  @sources          = []
  @priority_sources = []
  @dependencies     = []
  @rubygems         = true
  @system_gems      = true
end

Instance Attribute Details

#dependenciesObject (readonly)

Returns the value of attribute dependencies.



8
9
10
# File 'lib/bundler08/environment.rb', line 8

def dependencies
  @dependencies
end

#rubygemsObject Also known as: rubygems?

Returns the value of attribute rubygems.



9
10
11
# File 'lib/bundler08/environment.rb', line 9

def rubygems
  @rubygems
end

#system_gemsObject Also known as: system_gems?

Returns the value of attribute system_gems.



9
10
11
# File 'lib/bundler08/environment.rb', line 9

def system_gems
  @system_gems
end

Instance Method Details

#add_priority_source(source) ⇒ Object



45
46
47
# File 'lib/bundler08/environment.rb', line 45

def add_priority_source(source)
  @priority_sources << source
end

#add_source(source) ⇒ Object



41
42
43
# File 'lib/bundler08/environment.rb', line 41

def add_source(source)
  @sources << source
end

#clear_sourcesObject



49
50
51
52
# File 'lib/bundler08/environment.rb', line 49

def clear_sources
  @sources.clear
  @default_sources.clear
end

#environment_rb(specs, options) ⇒ Object



21
22
23
24
25
26
27
28
29
# File 'lib/bundler08/environment.rb', line 21

def environment_rb(specs, options)
  load_paths = load_paths_for_specs(specs, options)
  bindir     = @bundle.bindir.relative_path_from(@bundle.gem_path).to_s
  filename   = @bundle.gemfile.relative_path_from(@bundle.gem_path).to_s

  template = File.read(File.join(File.dirname(__FILE__), "templates", "environment.erb"))
  erb = ERB.new(template, nil, '-')
  erb.result(binding)
end

#require_env(env = nil) ⇒ Object



31
32
33
# File 'lib/bundler08/environment.rb', line 31

def require_env(env = nil)
  dependencies.each { |d| d.require_env(env) }
end

#sourcesObject



35
36
37
38
39
# File 'lib/bundler08/environment.rb', line 35

def sources
  sources = @priority_sources + [SystemGemSource.new(@bundle)] + @sources + @default_sources
  sources.reject! {|s| !s.local? } if Bundler.local?
  sources
end