Sha256: 6b54471bab8cee4ddcce34554905954eef744be61165d24966b82a1df2711e4c

Contents?: true

Size: 1.21 KB

Versions: 16

Compression:

Stored size: 1.21 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("https://carthage.libraries.io/#{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

16 entries across 16 versions & 1 rubygems

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