Class: Bibliothecary::Parsers::Hex
- Inherits:
-
Object
- Object
- Bibliothecary::Parsers::Hex
- Includes:
- Analyser
- Defined in:
- lib/bibliothecary/parsers/hex.rb
Class Method Summary collapse
Methods included from Analyser
Class Method Details
.parse(filename, path) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/bibliothecary/parsers/hex.rb', line 8 def self.parse(filename, path) if filename.match(/^mix\.exs$/) file_contents = File.open(path).read parse_mix(file_contents) elsif filename.match(/^mix\.lock$/) file_contents = File.open(path).read parse_mix_lock(file_contents) else [] end end |
.parse_mix(manifest) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/bibliothecary/parsers/hex.rb', line 20 def self.parse_mix(manifest) response = Typhoeus.post("https://mix-deps-json.herokuapp.com/", body: manifest) json = JSON.parse response.body json.map do |name, version| { name: name, version: version, type: "runtime" } end rescue [] end |
.parse_mix_lock(manifest) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/bibliothecary/parsers/hex.rb', line 35 def self.parse_mix_lock(manifest) response = Typhoeus.post("https://mix-deps-json.herokuapp.com/lock", body: manifest) json = JSON.parse response.body json.map do |name, info| { name: name, version: info['version'], type: "runtime" } end rescue [] end |