Module: GemfileInterpreter::Parser
- Defined in:
- lib/gemfile_interpreter/parser.rb
Class Method Summary collapse
Class Method Details
.parse(gems) ⇒ Object
6 7 8 9 10 11 12 |
# File 'lib/gemfile_interpreter/parser.rb', line 6 def parse gems hash = {} gems.each do |gem| hash[gem.name] = parse_gem gem end hash end |
.parse_gem(gem) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/gemfile_interpreter/parser.rb', line 14 def parse_gem gem hash = {} [:version, :full_name, :platform, :remote].map do |method| hash[method.to_s] = gem.send(method).to_s end hash['source'] = parse_source gem.source hash end |
.parse_source(source) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/gemfile_interpreter/parser.rb', line 23 def parse_source source source_type = if source.is_a? Bundler::Source::Rubygems 'rubygems' elsif source.is_a? Bundler::Source::Git 'git' elsif source.is_a? Bundler::Source::Path raise NotImplementedError, "A gem from a local path is currently not supported" else raise "unknown type #{source.inspect}" end {'type' => source_type}.merge(source.) end |