Class: Packages::Go::ModuleFinder
- Inherits:
-
Object
- Object
- Packages::Go::ModuleFinder
- Includes:
- Gitlab::Golang
- Defined in:
- app/finders/packages/go/module_finder.rb
Instance Attribute Summary collapse
-
#module_name ⇒ Object
readonly
Returns the value of attribute module_name.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Instance Method Summary collapse
- #execute ⇒ Object
-
#initialize(project, module_name) ⇒ ModuleFinder
constructor
A new instance of ModuleFinder.
Methods included from Gitlab::Golang
#go_path, #local_module_prefix, #package_url, #parse_pseudo_version, #parse_semver, #pkg_go_dev_url, #pseudo_version?, #semver_tag?, #validate_pseudo_version
Constructor Details
#initialize(project, module_name) ⇒ ModuleFinder
Returns a new instance of ModuleFinder.
10 11 12 13 14 15 |
# File 'app/finders/packages/go/module_finder.rb', line 10 def initialize(project, module_name) module_name = Pathname.new(module_name).cleanpath.to_s @project = project @module_name = module_name end |
Instance Attribute Details
#module_name ⇒ Object (readonly)
Returns the value of attribute module_name.
8 9 10 |
# File 'app/finders/packages/go/module_finder.rb', line 8 def module_name @module_name end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
8 9 10 |
# File 'app/finders/packages/go/module_finder.rb', line 8 def project @project end |
Instance Method Details
#execute ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'app/finders/packages/go/module_finder.rb', line 17 def execute return if @module_name.blank? || !@module_name.start_with?(local_module_prefix) module_path = @module_name[local_module_prefix.length..].split('/') project_path = project.full_path.split('/') module_project_path = module_path.shift(project_path.length) return unless module_project_path == project_path Packages::Go::Module.new(@project, @module_name, module_path.join('/')) end |