Sha256: d6f54438e2e39777d5d6cf6b4d966e32e29fb0cb2bdae71f1c6fe383bb4b5ab7

Contents?: true

Size: 784 Bytes

Versions: 16

Compression:

Stored size: 784 Bytes

Contents

require 'json'
require 'typhoeus'

module Bibliothecary
  module Parsers
    class Clojars
      include Bibliothecary::Analyser

      def self.mapping
        {
          /^project\.clj$/ => {
            kind: 'manifest',
            parser: :parse_manifest
          }
        }
      end

      def self.parse_manifest(manifest)
        response = Typhoeus.post("https://clojars.libraries.io/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

16 entries across 16 versions & 1 rubygems

Version Path
bibliothecary-5.6.2 lib/bibliothecary/parsers/clojars.rb
bibliothecary-5.6.1 lib/bibliothecary/parsers/clojars.rb
bibliothecary-5.6.0 lib/bibliothecary/parsers/clojars.rb
bibliothecary-5.5.5 lib/bibliothecary/parsers/clojars.rb
bibliothecary-5.5.4 lib/bibliothecary/parsers/clojars.rb
bibliothecary-5.5.3 lib/bibliothecary/parsers/clojars.rb
bibliothecary-5.5.2 lib/bibliothecary/parsers/clojars.rb
bibliothecary-5.5.1 lib/bibliothecary/parsers/clojars.rb
bibliothecary-5.5.0 lib/bibliothecary/parsers/clojars.rb
bibliothecary-5.4.0 lib/bibliothecary/parsers/clojars.rb
bibliothecary-5.3.4 lib/bibliothecary/parsers/clojars.rb
bibliothecary-5.3.3 lib/bibliothecary/parsers/clojars.rb
bibliothecary-5.3.2 lib/bibliothecary/parsers/clojars.rb
bibliothecary-5.3.1 lib/bibliothecary/parsers/clojars.rb
bibliothecary-5.3.0 lib/bibliothecary/parsers/clojars.rb
bibliothecary-5.2.0 lib/bibliothecary/parsers/clojars.rb