Class: LicenseFinder::GoDep

Inherits:
PackageManager show all
Defined in:
lib/license_finder/package_managers/go_dep.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PackageManager

#active?, #capture, command_exists?, current_packages, #current_packages_with_relations, installed?, package_managers

Constructor Details

#initialize(options = {}) ⇒ GoDep

Returns a new instance of GoDep.



6
7
8
9
# File 'lib/license_finder/package_managers/go_dep.rb', line 6

def initialize(options={})
  super
  @full_version = options[:go_full_version]
end

Class Method Details

.package_management_commandObject



26
27
28
# File 'lib/license_finder/package_managers/go_dep.rb', line 26

def self.package_management_command
  "godep"
end

Instance Method Details

#current_packagesObject



11
12
13
14
15
16
17
18
19
20
# File 'lib/license_finder/package_managers/go_dep.rb', line 11

def current_packages
  json = JSON.parse(package_path.read)
  # godep includes subpackages as a seperate dependency, we can de-dup that
  deps = json['Deps'].each do |d|
    next unless d['ImportPath'].include?('github.com')

    d['ImportPath'] = d['ImportPath'].split('/')[0..2].join('/')
  end
  deps.uniq.map { |dep| GoPackage.from_dependency(dep, install_prefix, @full_version) }
end

#package_pathObject



22
23
24
# File 'lib/license_finder/package_managers/go_dep.rb', line 22

def package_path
  project_path.join('Godeps/Godeps.json')
end