Class: Bundler::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/bowline/bundler/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/bowline/bundler/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/bowline/bundler/environment.rb', line 8

def dependencies
  @dependencies
end

#rubygemsObject Also known as: rubygems?

Returns the value of attribute rubygems.



9
10
11
# File 'lib/bowline/bundler/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/bowline/bundler/environment.rb', line 9

def system_gems
  @system_gems
end

Instance Method Details

#add_priority_source(source) ⇒ Object



43
44
45
# File 'lib/bowline/bundler/environment.rb', line 43

def add_priority_source(source)
  @priority_sources << source
end

#add_source(source) ⇒ Object



39
40
41
# File 'lib/bowline/bundler/environment.rb', line 39

def add_source(source)
  @sources << source
end

#clear_sourcesObject



47
48
49
50
# File 'lib/bowline/bundler/environment.rb', line 47

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/bowline/bundler/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

#gem_dependenciesObject



52
53
54
# File 'lib/bowline/bundler/environment.rb', line 52

def gem_dependencies
  @gem_dependencies ||= dependencies.map { |d| d.to_gem_dependency }
end

#require_env(env = nil) ⇒ Object



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

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

#sourcesObject



35
36
37
# File 'lib/bowline/bundler/environment.rb', line 35

def sources
  @priority_sources + [SystemGemSource.new(@bundle)] + @sources + @default_sources
end