Class: LicenseScout::DependencyManager::Gomod
- Inherits:
-
Base
- Object
- Base
- LicenseScout::DependencyManager::Gomod
show all
- Defined in:
- lib/license_scout/dependency_manager/gomod.rb
Instance Attribute Summary
Attributes inherited from Base
#directory
Instance Method Summary
collapse
Methods inherited from Base
#initialize
Instance Method Details
#dependencies ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
|
# File 'lib/license_scout/dependency_manager/gomod.rb', line 44
def dependencies
go_modules.map do |mod|
next if mod["Main"] == true
dep_name = mod["Path"]
dep_version = mod["Version"]
dep_path = mod["Dir"]
new_dependency(dep_name, dep_version, dep_path)
end.compact
end
|
#detected? ⇒ Boolean
40
41
42
|
# File 'lib/license_scout/dependency_manager/gomod.rb', line 40
def detected?
File.exist?(go_sum_file)
end
|
#go_modules ⇒ Object
60
61
62
|
# File 'lib/license_scout/dependency_manager/gomod.rb', line 60
def go_modules
FFI_Yajl::Parser.parse(go_modules_json)
end
|
#go_modules_json ⇒ Object
64
65
66
67
68
69
|
# File 'lib/license_scout/dependency_manager/gomod.rb', line 64
def go_modules_json
s = Mixlib::ShellOut.new("go list -m -json all", cwd: directory, environment: LicenseScout::Config.environment)
s.run_command
s.error!
"[" + s.stdout.gsub("}\n{", "},\n{") + "]"
end
|
#go_sum_file ⇒ Object
56
57
58
|
# File 'lib/license_scout/dependency_manager/gomod.rb', line 56
def go_sum_file
File.join(directory, "go.sum")
end
|
#install_command ⇒ Object
36
37
38
|
# File 'lib/license_scout/dependency_manager/gomod.rb', line 36
def install_command
"go mod download"
end
|
#name ⇒ Object
24
25
26
|
# File 'lib/license_scout/dependency_manager/gomod.rb', line 24
def name
"golang_modules"
end
|
#signature ⇒ Object
32
33
34
|
# File 'lib/license_scout/dependency_manager/gomod.rb', line 32
def signature
"go.sum file"
end
|
#type ⇒ Object
28
29
30
|
# File 'lib/license_scout/dependency_manager/gomod.rb', line 28
def type
"golang"
end
|