Sha256: b955febc4f4689036290437004d521bebdab162ad186e427ae427f66fce86e88

Contents?: true

Size: 726 Bytes

Versions: 3

Compression:

Stored size: 726 Bytes

Contents

require 'json'
require 'typhoeus'

module Bibliothecary
  module Parsers
    class Clojars
      include Bibliothecary::Analyser

      def self.mapping
        {
          /^project\.clj$/ => :parse_manifest
        }
      end

      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
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bibliothecary-5.0.2 lib/bibliothecary/parsers/clojars.rb
bibliothecary-5.0.1 lib/bibliothecary/parsers/clojars.rb
bibliothecary-5.0.0 lib/bibliothecary/parsers/clojars.rb