Sha256: 1c057ef6bad05fec4458cfd580909431c397024ace0fe8d15ef8e5fe8d9dd451

Contents?: true

Size: 1.24 KB

Versions: 3

Compression:

Stored size: 1.24 KB

Contents

module Bibliothecary
  module Parsers
    class Carthage
      include Bibliothecary::Analyser

      def self.mapping
        {
          /^Cartfile$/ => {
            kind: 'manifest',
            parser: :parse_cartfile
          },
          /^Cartfile\.private$/ => {
            kind: 'manifest',
            parser: :parse_cartfile_private
          },
          /^Cartfile\.resolved$/ => {
            kind: 'lockfile',
            parser: :parse_cartfile_resolved
          }
        }
      end

      def self.parse_cartfile(manifest)
        map_dependencies(manifest, 'cartfile')
      end

      def self.parse_cartfile_private(manifest)
        map_dependencies(manifest, 'cartfile.private')
      end

      def self.parse_cartfile_resolved(manifest)
        map_dependencies(manifest, 'cartfile.resolved')
      end

      def self.map_dependencies(manifest, path)
        response = Typhoeus.post("#{Bibliothecary.configuration.carthage_parser_host}/#{path}", params: {body: manifest})
        json = JSON.parse(response.body)

        json.map do |dependency|
          {
            name: dependency['name'],
            requirement: dependency['version'],
            type: dependency["type"]
          }
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bibliothecary-6.2.1 lib/bibliothecary/parsers/carthage.rb
bibliothecary-6.2.0 lib/bibliothecary/parsers/carthage.rb
bibliothecary-6.1.0 lib/bibliothecary/parsers/carthage.rb