Sha256: a6e373c03bf4654534df3f1b81efe7d4b99f9af8251d2edc1fdc0e5432ee2a63

Contents?: true

Size: 1.01 KB

Versions: 16

Compression:

Stored size: 1.01 KB

Contents

require 'json'

module Bibliothecary
  module Parsers
    class Hex
      include Bibliothecary::Analyser

      def self.mapping
        {
          /^mix\.exs$/ => {
            kind: 'manifest',
            parser: :parse_mix
          },
          /^mix\.lock$/ => {
            kind: 'lockfile',
            parser: :parse_mix_lock
          }
        }
      end

      def self.parse_mix(manifest)
        response = Typhoeus.post("https://mix.libraries.io/", body: manifest)
        json = JSON.parse response.body

        json.map do |name, version|
          {
            name: name,
            version: version,
            type: "runtime"
          }
        end
      end

      def self.parse_mix_lock(manifest)
        response = Typhoeus.post("https://mix.libraries.io/lock", body: manifest)
        json = JSON.parse response.body

        json.map do |name, info|
          {
            name: name,
            version: info['version'],
            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/hex.rb
bibliothecary-5.6.1 lib/bibliothecary/parsers/hex.rb
bibliothecary-5.6.0 lib/bibliothecary/parsers/hex.rb
bibliothecary-5.5.5 lib/bibliothecary/parsers/hex.rb
bibliothecary-5.5.4 lib/bibliothecary/parsers/hex.rb
bibliothecary-5.5.3 lib/bibliothecary/parsers/hex.rb
bibliothecary-5.5.2 lib/bibliothecary/parsers/hex.rb
bibliothecary-5.5.1 lib/bibliothecary/parsers/hex.rb
bibliothecary-5.5.0 lib/bibliothecary/parsers/hex.rb
bibliothecary-5.4.0 lib/bibliothecary/parsers/hex.rb
bibliothecary-5.3.4 lib/bibliothecary/parsers/hex.rb
bibliothecary-5.3.3 lib/bibliothecary/parsers/hex.rb
bibliothecary-5.3.2 lib/bibliothecary/parsers/hex.rb
bibliothecary-5.3.1 lib/bibliothecary/parsers/hex.rb
bibliothecary-5.3.0 lib/bibliothecary/parsers/hex.rb
bibliothecary-5.2.0 lib/bibliothecary/parsers/hex.rb