Sha256: 787525b7ea8b59ac786eeefcd10ec61b827a1a7396e9adba32c34237252c3808

Contents?: true

Size: 1.63 KB

Versions: 24

Compression:

Stored size: 1.63 KB

Contents

module Bibliothecary
  module Parsers
    class Carthage
      include Bibliothecary::Analyser

      def self.mapping
        {
          match_filename("Cartfile") => {
            kind: 'manifest',
            parser: :parse_cartfile
          },
          match_filename("Cartfile.private") => {
            kind: 'manifest',
            parser: :parse_cartfile_private
          },
          match_filename("Cartfile.resolved") => {
            kind: 'lockfile',
            parser: :parse_cartfile_resolved
          }
        }
      end

      add_multi_parser(Bibliothecary::MultiParsers::DependenciesCSV)

      def self.parse_cartfile(file_contents, options: {})
        map_dependencies(file_contents, 'cartfile')
      end

      def self.parse_cartfile_private(file_contents, options: {})
        map_dependencies(file_contents, 'cartfile.private')
      end

      def self.parse_cartfile_resolved(file_contents, options: {})
        map_dependencies(file_contents, 'cartfile.resolved')
      end

      def self.map_dependencies(manifest, path)
        response = Typhoeus.post("#{Bibliothecary.configuration.carthage_parser_host}/#{path}", params: { body: manifest })
        raise Bibliothecary::RemoteParsingError.new("Http Error #{response.response_code} when contacting: #{Bibliothecary.configuration.carthage_parser_host}/#{path}", response.response_code) unless response.success?
        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

24 entries across 24 versions & 1 rubygems

Version Path
bibliothecary-8.7.4 lib/bibliothecary/parsers/carthage.rb
bibliothecary-8.7.3 lib/bibliothecary/parsers/carthage.rb
bibliothecary-8.7.2 lib/bibliothecary/parsers/carthage.rb
bibliothecary-8.7.1 lib/bibliothecary/parsers/carthage.rb
bibliothecary-8.7.0 lib/bibliothecary/parsers/carthage.rb
bibliothecary-8.6.5 lib/bibliothecary/parsers/carthage.rb
bibliothecary-8.6.4 lib/bibliothecary/parsers/carthage.rb
bibliothecary-8.6.3 lib/bibliothecary/parsers/carthage.rb
bibliothecary-8.6.2 lib/bibliothecary/parsers/carthage.rb
bibliothecary-8.6.1 lib/bibliothecary/parsers/carthage.rb
bibliothecary-8.6.0 lib/bibliothecary/parsers/carthage.rb
bibliothecary-8.5.1 lib/bibliothecary/parsers/carthage.rb
bibliothecary-8.5.0 lib/bibliothecary/parsers/carthage.rb
bibliothecary-8.4.6 lib/bibliothecary/parsers/carthage.rb
bibliothecary-8.4.5 lib/bibliothecary/parsers/carthage.rb
bibliothecary-8.4.4 lib/bibliothecary/parsers/carthage.rb
bibliothecary-8.4.3 lib/bibliothecary/parsers/carthage.rb
bibliothecary-8.4.2 lib/bibliothecary/parsers/carthage.rb
bibliothecary-8.4.1 lib/bibliothecary/parsers/carthage.rb
bibliothecary-8.4.0 lib/bibliothecary/parsers/carthage.rb