Class: Bibliothecary::Parsers::Carthage
- Inherits:
-
Object
- Object
- Bibliothecary::Parsers::Carthage
- Includes:
- Analyser
- Defined in:
- lib/bibliothecary/parsers/carthage.rb
Class Method Summary collapse
- .parse(filename, path) ⇒ Object
- .parse_cartfile(manifest) ⇒ Object
- .parse_cartfile_private(manifest) ⇒ Object
- .parse_cartfile_resolved(manifest) ⇒ Object
Methods included from Analyser
Class Method Details
.parse(filename, path) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/bibliothecary/parsers/carthage.rb', line 6 def self.parse(filename, path) if filename.match(/^Cartfile$/) file_contents = File.open(path).read parse_cartfile(file_contents) elsif filename.match(/^Cartfile\.private$/) file_contents = File.open(path).read parse_cartfile_private(file_contents) elsif filename.match(/^Cartfile\.resolved$/) file_contents = File.open(path).read parse_cartfile_resolved(file_contents) else [] end end |
.parse_cartfile(manifest) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/bibliothecary/parsers/carthage.rb', line 21 def self.parse_cartfile(manifest) response = Typhoeus.post("https://carthageparser.herokuapp.com/cartfile", params: {body: manifest}) json = JSON.parse(response.body) json.map do |dependency| { name: dependency['name'], version: dependency['version'], type: dependency["type"] } end end |
.parse_cartfile_private(manifest) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/bibliothecary/parsers/carthage.rb', line 34 def self.parse_cartfile_private(manifest) response = Typhoeus.post("https://carthageparser.herokuapp.com/cartfile.private", params: {body: manifest}) json = JSON.parse(response.body) json.map do |dependency| { name: dependency['name'], version: dependency['version'], type: dependency["type"] } end end |
.parse_cartfile_resolved(manifest) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/bibliothecary/parsers/carthage.rb', line 47 def self.parse_cartfile_resolved(manifest) response = Typhoeus.post("https://carthageparser.herokuapp.com/cartfile.resolved", params: {body: manifest}) json = JSON.parse(response.body) json.map do |dependency| { name: dependency['name'], version: dependency['version'], type: dependency["type"] } end end |