Sha256: 337100121c83ab3dc245cfb635f82642511734bce17ca0aa03b71e092f3d880d

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

# frozen_string_literal: true

module LicenseFinder
  class Erlangmk < PackageManager
    def package_management_command
      'make'
    end

    def package_management_command_with_path
      "#{package_management_command} --directory=#{project_path} --no-print-directory"
    end

    def prepare_command
      "#{package_management_command_with_path} fetch-deps"
    end

    def possible_package_paths
      [
        project_path.join('Erlang.mk'),
        project_path.join('erlang.mk')
      ]
    end

    def current_packages
      deps.map do |dep|
        ErlangmkPackage.new(dep)
      end
    end

    private

    def deps
      command = "#{package_management_command_with_path} QUERY='name fetch_method repo version absolute_path' query-deps"
      stdout, stderr, status = Cmd.run(command)
      raise "Command '#{command}' failed to execute: #{stderr}" unless status.success?

      dep_re = Regexp.new('^\s*DEP')
      line_re = Regexp.new('^[_a-z0-9]+:')

      stdout.each_line.map(&:strip).select { |line| !(line.start_with?('make') || line =~ dep_re) && line =~ line_re }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
license_finder-6.8.0 lib/license_finder/package_managers/erlangmk.rb