class LicenseScout::DependencyManager::Gomod

Public Instance Methods

dependencies() click to toggle source
# 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?() click to toggle source
# File lib/license_scout/dependency_manager/gomod.rb, line 40
def detected?
  File.exist?(go_sum_file)
end
go_modules() click to toggle source
# File lib/license_scout/dependency_manager/gomod.rb, line 68
def go_modules
  if vendor_mode
    GoModulesTxtParser.parse(File.read(modules_txt_file), vendor_dir)
  else
    FFI_Yajl::Parser.parse(go_modules_json)
  end
end
go_modules_json() click to toggle source
# File lib/license_scout/dependency_manager/gomod.rb, line 83
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() click to toggle source
# File lib/license_scout/dependency_manager/gomod.rb, line 56
def go_sum_file
  File.join(directory, "go.sum")
end
install_command() click to toggle source
# File lib/license_scout/dependency_manager/gomod.rb, line 36
def install_command
  "go mod download"
end
modules_txt_file() click to toggle source
# File lib/license_scout/dependency_manager/gomod.rb, line 64
def modules_txt_file
  File.join(vendor_dir, "modules.txt")
end
name() click to toggle source
# File lib/license_scout/dependency_manager/gomod.rb, line 24
def name
  "golang_modules"
end
signature() click to toggle source
# File lib/license_scout/dependency_manager/gomod.rb, line 32
def signature
  "go.sum file"
end
type() click to toggle source
# File lib/license_scout/dependency_manager/gomod.rb, line 28
def type
  "golang"
end
vendor_dir() click to toggle source
# File lib/license_scout/dependency_manager/gomod.rb, line 60
def vendor_dir
  File.join(directory, "vendor")
end
vendor_mode() click to toggle source
# File lib/license_scout/dependency_manager/gomod.rb, line 76
def vendor_mode
  if @vendor_mode.nil?
    @vendor_mode = File.directory?(vendor_dir)
  end
  @vendor_mode
end