Class: Packages::Go::Module
- Inherits:
-
Object
- Object
- Packages::Go::Module
- Includes:
- Gitlab::Utils::StrongMemoize
- Defined in:
- app/models/packages/go/module.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#project ⇒ Object
readonly
Returns the value of attribute project.
Instance Method Summary collapse
- #gomod_valid?(gomod) ⇒ Boolean
-
#initialize(project, name, path) ⇒ Module
constructor
A new instance of Module.
- #path_valid?(major) ⇒ Boolean
- #version_by(ref: nil, commit: nil) ⇒ Object
- #versions ⇒ Object
Constructor Details
#initialize(project, name, path) ⇒ Module
Returns a new instance of Module.
10 11 12 13 14 |
# File 'app/models/packages/go/module.rb', line 10 def initialize(project, name, path) @project = project @name = name @path = path end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
8 9 10 |
# File 'app/models/packages/go/module.rb', line 8 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
8 9 10 |
# File 'app/models/packages/go/module.rb', line 8 def path @path end |
#project ⇒ Object (readonly)
Returns the value of attribute project.
8 9 10 |
# File 'app/models/packages/go/module.rb', line 8 def project @project end |
Instance Method Details
#gomod_valid?(gomod) ⇒ Boolean
47 48 49 50 51 52 53 |
# File 'app/models/packages/go/module.rb', line 47 def gomod_valid?(gomod) if Feature.enabled?(:go_proxy_disable_gomod_validation, @project) return gomod&.start_with?("module ") end gomod&.split("\n", 2)&.first == "module #{@name}" end |
#path_valid?(major) ⇒ Boolean
36 37 38 39 40 41 42 43 44 45 |
# File 'app/models/packages/go/module.rb', line 36 def path_valid?(major) m = %r{/v(\d+)$}i.match(@name) case major when 0, 1 m.nil? else !m.nil? && m[1].to_i == major end end |
#version_by(ref: nil, commit: nil) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'app/models/packages/go/module.rb', line 21 def version_by(ref: nil, commit: nil) raise ArgumentError, 'no filter specified' unless ref || commit raise ArgumentError, 'ref and commit are mutually exclusive' if ref && commit if commit return version_by_sha(commit) if commit.is_a? String return version_by_commit(commit) end return version_by_name(ref) if ref.is_a? String version_by_ref(ref) end |
#versions ⇒ Object
16 17 18 |
# File 'app/models/packages/go/module.rb', line 16 def versions Packages::Go::VersionFinder.new(self).execute end |