Sha256: e69a8763cb533f7bf27800ed673ad672f50900c322022a214244f0d2d3afa5f1

Contents?: true

Size: 1.03 KB

Versions: 3

Compression:

Stored size: 1.03 KB

Contents

module Bibliothecary
  module Parsers
    class Carthage
      include Bibliothecary::Analyser

      def self.mapping
        {
          /^Cartfile$/ => :parse_cartfile,
          /^Cartfile\.private$/ => :parse_cartfile_private,
          /^Cartfile\.resolved$/ => :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("https://carthageparser.herokuapp.com/#{path}", params: {body: manifest})
        json = JSON.parse(response.body)

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

Version data entries

3 entries across 3 versions & 1 rubygems

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