Class: Safedep::Policy::SemVer
- Inherits:
-
Object
- Object
- Safedep::Policy::SemVer
- Defined in:
- lib/safedep/policy/sem_ver.rb
Instance Attribute Summary collapse
-
#major ⇒ Object
readonly
Returns the value of attribute major.
-
#minor ⇒ Object
readonly
Returns the value of attribute minor.
-
#patch ⇒ Object
readonly
Returns the value of attribute patch.
-
#suffix ⇒ Object
readonly
Returns the value of attribute suffix.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(version) ⇒ SemVer
constructor
A new instance of SemVer.
- #version_specifiers ⇒ Object
Constructor Details
#initialize(version) ⇒ SemVer
Returns a new instance of SemVer.
10 11 12 13 14 15 16 17 18 |
# File 'lib/safedep/policy/sem_ver.rb', line 10 def initialize(version) @version = if version.is_a?(Gem::Version) version else Gem::Version.new(version) end decompose_version end |
Instance Attribute Details
#major ⇒ Object (readonly)
Returns the value of attribute major.
4 5 6 |
# File 'lib/safedep/policy/sem_ver.rb', line 4 def major @major end |
#minor ⇒ Object (readonly)
Returns the value of attribute minor.
4 5 6 |
# File 'lib/safedep/policy/sem_ver.rb', line 4 def minor @minor end |
#patch ⇒ Object (readonly)
Returns the value of attribute patch.
4 5 6 |
# File 'lib/safedep/policy/sem_ver.rb', line 4 def patch @patch end |
#suffix ⇒ Object (readonly)
Returns the value of attribute suffix.
4 5 6 |
# File 'lib/safedep/policy/sem_ver.rb', line 4 def suffix @suffix end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
4 5 6 |
# File 'lib/safedep/policy/sem_ver.rb', line 4 def version @version end |
Class Method Details
.version_specifiers(version) ⇒ Object
6 7 8 |
# File 'lib/safedep/policy/sem_ver.rb', line 6 def self.version_specifiers(version) new(version).version_specifiers end |
Instance Method Details
#version_specifiers ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/safedep/policy/sem_ver.rb', line 20 def version_specifiers specifiers = ['~> ' + [major, minor].join('.')] return specifiers if satisfy_specifiers?(specifiers) specifiers = [">= #{version}", "< #{major.to_i + 1}"] return specifiers if satisfy_specifiers?(specifiers) nil end |