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.
-
#prefix ⇒ Object
readonly
Returns the value of attribute prefix.
Class Method Summary collapse
Instance Method Summary collapse
- #current_context ⇒ Object
- #gem(name, *args) ⇒ Object
- #gemspec ⇒ Object
-
#git_source(*args) ⇒ Object
this is probably the wrong thing to do.
- #group(*groups) ⇒ Object
-
#initialize(gemfile_path, bundle_path, options) ⇒ GemfileInterpreter
constructor
A new instance of GemfileInterpreter.
- #path(dir) ⇒ Object
- #ruby(*args) ⇒ Object
- #source(url) ⇒ Object
Constructor Details
#initialize(gemfile_path, bundle_path, options) ⇒ GemfileInterpreter
Returns a new instance of GemfileInterpreter.
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# 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 @prefix = [:prefix] 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 # Get rid of gems without a spec, as they are likely not supposed # to be installed. This happens for gems like tzinfo-data which are # listed in the standard rails Gemfile but only installed on # certain platforms. gems.reject! { |_, g| g.spec.nil? } 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 |
#prefix ⇒ Object (readonly)
Returns the value of attribute prefix.
9 10 11 |
# File 'lib/prebundler/gemfile_interpreter.rb', line 9 def prefix @prefix end |
Class Method Details
Instance Method Details
#current_context ⇒ Object
34 35 36 37 38 39 40 41 |
# File 'lib/prebundler/gemfile_interpreter.rb', line 34 def current_context { path: @current_path, groups: @current_groups, source: @current_source, prefix: prefix } end |
#gem(name, *args) ⇒ Object
50 51 52 53 |
# File 'lib/prebundler/gemfile_interpreter.rb', line 50 def gem(name, *args) = args.find { |a| a.is_a?(Hash) } || {} gems[name] = GemRef.create(name, bundle_path, current_context.merge()) end |
#gemspec ⇒ Object
73 74 75 |
# File 'lib/prebundler/gemfile_interpreter.rb', line 73 def gemspec # do nothing end |
#git_source(*args) ⇒ Object
this is probably the wrong thing to do
47 48 |
# File 'lib/prebundler/gemfile_interpreter.rb', line 47 def git_source(*args) end |
#group(*groups) ⇒ Object
67 68 69 70 71 |
# File 'lib/prebundler/gemfile_interpreter.rb', line 67 def group(*groups) @current_groups = groups yield if block_given? @current_groups = [:global] end |
#path(dir) ⇒ Object
55 56 57 58 59 |
# File 'lib/prebundler/gemfile_interpreter.rb', line 55 def path(dir) @current_path = File.join(File.dirname(gemfile_path), dir) yield if block_given? @current_path = nil end |
#ruby(*args) ⇒ Object
43 44 |
# File 'lib/prebundler/gemfile_interpreter.rb', line 43 def ruby(*args) end |
#source(url) ⇒ Object
61 62 63 64 65 |
# File 'lib/prebundler/gemfile_interpreter.rb', line 61 def source(url) @current_source = url yield if block_given? @current_source = nil end |