Sha256: b2b9cb451b80c3431f6e70566dd36fee46933937ee4b34aefe6b1e3b026028e7

Contents?: true

Size: 1.01 KB

Versions: 6

Compression:

Stored size: 1.01 KB

Contents

module LicenseFinder
  class Rebar < PackageManager
    def initialize(options={})
      super
      @command = options[:rebar_command] || "rebar"
      @deps_path = Pathname(options[:rebar_deps_dir] || "deps")
    end

    def current_packages
      rebar_ouput.map do |name, version_type, version_value, homepage|
        RebarPackage.new(
          name,
          "#{version_type}: #{version_value}",
          install_path: @deps_path.join(name),
          homepage: homepage,
          logger: logger
        )
      end
    end

    def self.package_management_command
      "rebar"
    end

    private

    def rebar_ouput
      command = "#{@command} list-deps"
      output, success = Dir.chdir(project_path) { capture(command) }
      raise "Command '#{command}' failed to execute: #{output}" unless success

      output
        .each_line
        .reject { |line| line.start_with?("=") }
        .map { |line| line.split(" ") }
    end

    def package_path
      project_path.join('rebar.config')
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
license_finder-2.1.2 lib/license_finder/package_managers/rebar.rb
license_finder-2.1.1 lib/license_finder/package_managers/rebar.rb
license_finder-2.1.0 lib/license_finder/package_managers/rebar.rb
license_finder-2.1.0.rc9 lib/license_finder/package_managers/rebar.rb
license_finder-2.1.0.rc8 lib/license_finder/package_managers/rebar.rb
license_finder-2.1.0.rc7 lib/license_finder/package_managers/rebar.rb