Class: Prebundler::GemfileInterpreter
- Inherits:
-
Object
- Object
- Prebundler::GemfileInterpreter
- Defined in:
- lib/prebundler/gemfile_interpreter.rb
Instance Attribute Summary collapse
-
#bundle_path ⇒ Object
readonly
Returns the value of attribute bundle_path.
-
#gemfile_path ⇒ Object
readonly
Returns the value of attribute gemfile_path.
-
#gems ⇒ Object
readonly
Returns the value of attribute gems.
Class Method Summary collapse
Instance Method Summary collapse
- #current_context ⇒ Object
- #gem(name, *args) ⇒ Object
- #gemspec ⇒ Object
- #group(*groups) ⇒ Object
-
#initialize(gemfile_path, bundle_path) ⇒ GemfileInterpreter
constructor
A new instance of GemfileInterpreter.
- #path(dir) ⇒ Object
- #source(url) ⇒ Object
Constructor Details
#initialize(gemfile_path, bundle_path) ⇒ GemfileInterpreter
Returns a new instance of GemfileInterpreter.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/prebundler/gemfile_interpreter.rb', line 11 def initialize(gemfile_path, bundle_path) @gems = {} @current_groups = [:global] @gemfile_path = gemfile_path @bundle_path = bundle_path instance_eval(File.read(gemfile_path)) lockfile = Bundler::LockfileParser.new(File.read("#{gemfile_path}.lock")) lockfile.specs.each do |spec| gems[spec.name] ||= GemRef.create(spec.name, bundle_path) gems[spec.name].spec = spec gems[spec.name].dependencies = spec.dependencies.map(&:name) end end |
Instance Attribute Details
#bundle_path ⇒ Object (readonly)
Returns the value of attribute bundle_path.
9 10 11 |
# File 'lib/prebundler/gemfile_interpreter.rb', line 9 def bundle_path @bundle_path end |
#gemfile_path ⇒ Object (readonly)
Returns the value of attribute gemfile_path.
9 10 11 |
# File 'lib/prebundler/gemfile_interpreter.rb', line 9 def gemfile_path @gemfile_path end |
#gems ⇒ Object (readonly)
Returns the value of attribute gems.
9 10 11 |
# File 'lib/prebundler/gemfile_interpreter.rb', line 9 def gems @gems end |
Class Method Details
Instance Method Details
#current_context ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/prebundler/gemfile_interpreter.rb', line 27 def current_context { path: @current_path, groups: @current_groups, source: @current_source } end |
#gem(name, *args) ⇒ Object
35 36 37 38 |
# File 'lib/prebundler/gemfile_interpreter.rb', line 35 def gem(name, *args) = args.find { |a| a.is_a?(Hash) } || {} gems[name] = GemRef.create(name, bundle_path, current_context.merge()) end |
#gemspec ⇒ Object
58 59 60 |
# File 'lib/prebundler/gemfile_interpreter.rb', line 58 def gemspec # do nothing end |
#group(*groups) ⇒ Object
52 53 54 55 56 |
# File 'lib/prebundler/gemfile_interpreter.rb', line 52 def group(*groups) @current_groups = groups yield if block_given? @current_groups = [:global] end |
#path(dir) ⇒ Object
40 41 42 43 44 |
# File 'lib/prebundler/gemfile_interpreter.rb', line 40 def path(dir) @current_path = File.join(File.dirname(gemfile_path), dir) yield if block_given? @current_path = nil end |
#source(url) ⇒ Object
46 47 48 49 50 |
# File 'lib/prebundler/gemfile_interpreter.rb', line 46 def source(url) @current_source = url yield if block_given? @current_source = nil end |