Class: Bibliothecary::Parsers::Clojars
- Inherits:
-
Object
- Object
- Bibliothecary::Parsers::Clojars
- Includes:
- Analyser
- Defined in:
- lib/bibliothecary/parsers/clojars.rb
Class Method Summary collapse
Methods included from Analyser
Class Method Details
.parse(filename, path) ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/bibliothecary/parsers/clojars.rb', line 9 def self.parse(filename, path) if filename.match(/^project\.clj$/) file_contents = File.open(path).read parse_manifest(file_contents) else [] end end |
.parse_manifest(manifest) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/bibliothecary/parsers/clojars.rb', line 18 def self.parse_manifest(manifest) response = Typhoeus.post("https://clojars-json.herokuapp.com/project.clj", body: manifest) json = JSON.parse response.body index = json.index("dependencies") return [] unless index; dependencies = json[index + 1] dependencies.map do |dependency| { name: dependency[0], version: dependency[1], type: "runtime" } end end |