Class: LicenseFinder::Glide

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

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PackageManager

#active?, #command_exists?, #current_packages_with_relations, #detected_package_path, id, #initialize, #installed?, #prepare, #project_root?

Constructor Details

This class inherits a constructor from LicenseFinder::PackageManager

Class Method Details

.takes_priority_overObject



30
31
32
# File 'lib/license_finder/package_managers/glide.rb', line 30

def self.takes_priority_over
  Go15VendorExperiment
end

Instance Method Details

#current_packagesObject



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/license_finder/package_managers/glide.rb', line 9

def current_packages
  detected_path = detected_package_path

  imports = if Gem::Version.new(Psych::VERSION) >= Gem::Version.new('3.1.0.pre1')
              YAML.safe_load(File.read(detected_path), permitted_classes: [Symbol, Time], aliases: true).fetch('imports')
            else
              YAML.safe_load(File.read(detected_path), [Symbol, Time], [], true).fetch('imports')
            end

  imports.map do |package_hash|
    import_path = package_hash.fetch('name')
    license_path = project_path.join('vendor', import_path)

    GoPackage.from_dependency({
                                'ImportPath' => import_path,
                                'InstallPath' => license_path,
                                'Rev' => package_hash.fetch('version')
                              }, nil, true)
  end
end

#package_management_commandObject



34
35
36
# File 'lib/license_finder/package_managers/glide.rb', line 34

def package_management_command
  'glide'
end

#possible_package_pathsObject



5
6
7
# File 'lib/license_finder/package_managers/glide.rb', line 5

def possible_package_paths
  [project_path.join('glide.lock')]
end

#prepare_commandObject



38
39
40
# File 'lib/license_finder/package_managers/glide.rb', line 38

def prepare_command
  'glide install'
end