Class: Dependabot::NpmAndYarn::Version
- Inherits:
-
Gem::Version
- Object
- Gem::Version
- Dependabot::NpmAndYarn::Version
- Defined in:
- lib/dependabot/npm_and_yarn/version.rb
Constant Summary collapse
- VERSION_PATTERN =
Gem::Version::VERSION_PATTERN + '(\+[0-9a-zA-Z\-.]+)?'
- ANCHORED_VERSION_PATTERN =
/\A\s*(#{VERSION_PATTERN})?\s*\z/.freeze
Instance Attribute Summary collapse
-
#build_info ⇒ Object
readonly
Returns the value of attribute build_info.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(version) ⇒ Version
constructor
A new instance of Version.
- #inspect ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(version) ⇒ Version
Returns a new instance of Version.
28 29 30 31 32 33 34 35 36 37 |
# File 'lib/dependabot/npm_and_yarn/version.rb', line 28 def initialize(version) @version_string = version.to_s version = version.gsub(/^v/, "") if version.is_a?(String) if version.to_s.include?("+") version, @build_info = version.to_s.split("+") end super end |
Instance Attribute Details
#build_info ⇒ Object (readonly)
Returns the value of attribute build_info.
15 16 17 |
# File 'lib/dependabot/npm_and_yarn/version.rb', line 15 def build_info @build_info end |
Class Method Details
.correct?(version) ⇒ Boolean
20 21 22 23 24 25 26 |
# File 'lib/dependabot/npm_and_yarn/version.rb', line 20 def self.correct?(version) version = version.gsub(/^v/, "") if version.is_a?(String) return false if version.nil? version.to_s.match?(ANCHORED_VERSION_PATTERN) end |
Instance Method Details
#inspect ⇒ Object
43 44 45 |
# File 'lib/dependabot/npm_and_yarn/version.rb', line 43 def inspect "#<#{self.class} #{@version_string}>" end |
#to_s ⇒ Object
39 40 41 |
# File 'lib/dependabot/npm_and_yarn/version.rb', line 39 def to_s @version_string end |