Class: Bibliothecary::Parsers::CocoaPods
- Inherits:
-
Object
- Object
- Bibliothecary::Parsers::CocoaPods
- Extended by:
- MultiParsers::BundlerLikeManifest
- Includes:
- Analyser
- Defined in:
- lib/bibliothecary/parsers/cocoapods.rb
Constant Summary collapse
- NAME_VERSION =
'(?! )(.*?)(?: \(([^-]*)(?:-(.*))?\))?'- NAME_VERSION_4 =
/^ {4}#{NAME_VERSION}$/
Class Method Summary collapse
- .mapping ⇒ Object
- .parse_json_manifest(file_contents, options: {}) ⇒ Object
- .parse_podfile(file_contents, options: {}) ⇒ Object
- .parse_podfile_lock(file_contents, options: {}) ⇒ Object
- .parse_podspec(file_contents, options: {}) ⇒ Object
Methods included from MultiParsers::BundlerLikeManifest
Methods included from Analyser
create_analysis, create_error_analysis, included
Class Method Details
.mapping ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/bibliothecary/parsers/cocoapods.rb', line 15 def self.mapping { match_filename("Podfile") => { kind: "manifest", parser: :parse_podfile, }, match_extension(".podspec") => { kind: "manifest", parser: :parse_podspec, can_have_lockfile: false, }, match_filename("Podfile.lock") => { kind: "lockfile", parser: :parse_podfile_lock, }, match_extension(".podspec.json") => { kind: "manifest", parser: :parse_json_manifest, can_have_lockfile: false, }, } end |
.parse_json_manifest(file_contents, options: {}) ⇒ Object
68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/bibliothecary/parsers/cocoapods.rb', line 68 def self.parse_json_manifest(file_contents, options: {}) manifest = JSON.parse(file_contents) dependencies = manifest["dependencies"].inject([]) do |deps, dep| deps.push(Dependency.new( platform: platform_name, name: dep[0], requirement: dep[1], type: "runtime", source: .fetch(:filename, nil) )) end.uniq ParserResult.new(dependencies: dependencies) end |
.parse_podfile(file_contents, options: {}) ⇒ Object
62 63 64 65 66 |
# File 'lib/bibliothecary/parsers/cocoapods.rb', line 62 def self.parse_podfile(file_contents, options: {}) manifest = Gemnasium::Parser.send(:podfile, file_contents) dependencies = parse_ruby_manifest(manifest, platform_name, .fetch(:filename, nil)) ParserResult.new(dependencies: dependencies) end |
.parse_podfile_lock(file_contents, options: {}) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/bibliothecary/parsers/cocoapods.rb', line 40 def self.parse_podfile_lock(file_contents, options: {}) manifest = YAML.load file_contents dependencies = manifest["PODS"].map do |row| pod = row.is_a?(String) ? row : row.keys.first match = pod.match(/(.+?)\s\((.+?)\)/i) Dependency.new( platform: platform_name, name: match[1].split("/").first, requirement: match[2], type: "runtime", source: .fetch(:filename, nil) ) end.compact ParserResult.new(dependencies: dependencies) end |
.parse_podspec(file_contents, options: {}) ⇒ Object
56 57 58 59 60 |
# File 'lib/bibliothecary/parsers/cocoapods.rb', line 56 def self.parse_podspec(file_contents, options: {}) manifest = Gemnasium::Parser.send(:podspec, file_contents) dependencies = parse_ruby_manifest(manifest, platform_name, .fetch(:filename, nil)) ParserResult.new(dependencies: dependencies) end |