Class: LicenseFinder::GoWorkspace
- Inherits:
-
PackageManager
- Object
- PackageManager
- LicenseFinder::GoWorkspace
- Defined in:
- lib/license_finder/package_managers/go_workspace.rb
Defined Under Namespace
Classes: Submodule
Constant Summary collapse
- ENVRC_REGEXP =
/GOPATH|GO15VENDOREXPERIMENT/
Instance Method Summary collapse
- #active? ⇒ Boolean
- #current_packages ⇒ Object
-
#initialize(options = {}) ⇒ GoWorkspace
constructor
A new instance of GoWorkspace.
- #package_path ⇒ Object
Methods inherited from PackageManager
#capture, command_exists?, current_packages, #current_packages_with_relations, installed?, package_managers
Constructor Details
#initialize(options = {}) ⇒ GoWorkspace
Returns a new instance of GoWorkspace.
8 9 10 11 |
# File 'lib/license_finder/package_managers/go_workspace.rb', line 8 def initialize(={}) super @full_version = [:go_full_version] end |
Instance Method Details
#active? ⇒ Boolean
35 36 37 38 39 40 41 42 43 |
# File 'lib/license_finder/package_managers/go_workspace.rb', line 35 def active? return false unless self.class.installed?(logger) godep = LicenseFinder::GoDep.new({project_path: Pathname(project_path)}) # go workspace is only active if GoDep wasn't. There are some projects # that will use the .envrc and have a Godep folder as well. active = !! (!godep.active? && envrc_path && ENVRC_REGEXP.match(IO.read(envrc_path))) active.tap { |is_active| logger.active self.class, is_active } end |
#current_packages ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/license_finder/package_managers/go_workspace.rb', line 13 def current_packages go_list_packages = go_list git_modules.map do |submodule| # We are filtering the non-standard packages because the word "net" # seems to be common that can give false positive when filtering the git submodules import_path = go_list_packages.select { |gp| submodule.install_path =~ /#{repo_name(gp)}$/ }.first if import_path then GoPackage.from_dependency({ 'ImportPath' => repo_name(import_path), 'InstallPath' => submodule.install_path, 'Rev' => submodule.revision }, nil, @full_version) end end.compact end |
#package_path ⇒ Object
31 32 33 |
# File 'lib/license_finder/package_managers/go_workspace.rb', line 31 def package_path envrc_path.dirname end |