Class: Bibliothecary::Parsers::Rubygems
- Inherits:
-
Object
- Object
- Bibliothecary::Parsers::Rubygems
- Extended by:
- MultiParsers::BundlerLikeManifest
- Includes:
- Analyser
- Defined in:
- lib/bibliothecary/parsers/rubygems.rb
Constant Summary collapse
- NAME_VERSION =
'(?! )(.*?)(?: \(([^-]*)(?:-(.*))?\))?'.freeze
- NAME_VERSION_4 =
/^ {4}#{NAME_VERSION}$/
Class Method Summary collapse
- .mapping ⇒ Object
- .parse_gemfile(file_contents, options: {}) ⇒ Object
- .parse_gemfile_lock(file_contents, options: {}) ⇒ Object
- .parse_gemspec(file_contents, options: {}) ⇒ Object
Methods included from MultiParsers::BundlerLikeManifest
Methods included from Analyser
create_analysis, create_error_analysis, included
Class Method Details
.mapping ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/bibliothecary/parsers/rubygems.rb', line 12 def self.mapping { match_filenames("Gemfile", "gems.rb") => { kind: 'manifest', parser: :parse_gemfile, related_to: [ 'manifest', 'lockfile' ] }, match_extension(".gemspec") => { kind: 'manifest', parser: :parse_gemspec, related_to: [ 'manifest', 'lockfile' ] }, match_filenames("Gemfile.lock", "gems.locked") => { kind: 'lockfile', parser: :parse_gemfile_lock, related_to: [ 'manifest', 'lockfile' ] } } end |
.parse_gemfile(file_contents, options: {}) ⇒ Object
49 50 51 52 |
# File 'lib/bibliothecary/parsers/rubygems.rb', line 49 def self.parse_gemfile(file_contents, options: {}) manifest = Gemnasium::Parser.send(:gemfile, file_contents) parse_ruby_manifest(manifest) end |
.parse_gemfile_lock(file_contents, options: {}) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/bibliothecary/parsers/rubygems.rb', line 35 def self.parse_gemfile_lock(file_contents, options: {}) file_contents.lines(chomp: true).map do |line| match = line.match(NAME_VERSION_4) next unless match name = match[1] version = match[2].gsub(/\(|\)/,'') { name: name, requirement: version, type: 'runtime' } end.compact end |
.parse_gemspec(file_contents, options: {}) ⇒ Object
54 55 56 57 |
# File 'lib/bibliothecary/parsers/rubygems.rb', line 54 def self.parse_gemspec(file_contents, options: {}) manifest = Gemnasium::Parser.send(:gemspec, file_contents) parse_ruby_manifest(manifest) end |