Class: OSGi::VersionRange
Overview
:nodoc:
Instance Attribute Summary collapse
-
#max ⇒ Object
Returns the value of attribute max.
-
#max_inclusive ⇒ Object
Returns the value of attribute max_inclusive.
-
#max_infinite ⇒ Object
Returns the value of attribute max_infinite.
-
#min ⇒ Object
Returns the value of attribute min.
-
#min_inclusive ⇒ Object
Returns the value of attribute min_inclusive.
Class Method Summary collapse
-
.parse(string, max_infinite = false) ⇒ Object
Parses a string into a VersionRange.
Instance Method Summary collapse
-
#in_range(version) ⇒ Object
Returns true if the version is in the range of this VersionRange object.
-
#to_s ⇒ Object
:nodoc:.
Instance Attribute Details
#max ⇒ Object
Returns the value of attribute max.
87 88 89 |
# File 'lib/buildr4osgi/osgi/version.rb', line 87 def max @max end |
#max_inclusive ⇒ Object
Returns the value of attribute max_inclusive.
87 88 89 |
# File 'lib/buildr4osgi/osgi/version.rb', line 87 def max_inclusive @max_inclusive end |
#max_infinite ⇒ Object
Returns the value of attribute max_infinite.
87 88 89 |
# File 'lib/buildr4osgi/osgi/version.rb', line 87 def max_infinite @max_infinite end |
#min ⇒ Object
Returns the value of attribute min.
87 88 89 |
# File 'lib/buildr4osgi/osgi/version.rb', line 87 def min @min end |
#min_inclusive ⇒ Object
Returns the value of attribute min_inclusive.
87 88 89 |
# File 'lib/buildr4osgi/osgi/version.rb', line 87 def min_inclusive @min_inclusive end |
Class Method Details
.parse(string, max_infinite = false) ⇒ Object
Parses a string into a VersionRange. Returns false if the string could not be parsed.
92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/buildr4osgi/osgi/version.rb', line 92 def self.parse(string, max_infinite = false) return string if string.is_a?(VersionRange) || string.is_a?(Version) if !string.nil? && (match = string.match /\s*([\[|\(])([0-9|A-z|\.]*)\s*,\s*([0-9|A-z|\.]*)([\]|\)])/) range = VersionRange.new range.min = Version.new(match[2]) range.max = Version.new(match[3]) range.min_inclusive = match[1] == '[' range.max_inclusive = match[4] == ']' range elsif (!string.nil? && max_infinite && string.match(/[0-9|\.]*/)) range = VersionRange.new range.min = Version.new(string) range.max = nil range.min_inclusive = true range.max_infinite = true range else false end end |
Instance Method Details
#in_range(version) ⇒ Object
Returns true if the version is in the range of this VersionRange object. Uses OSGi versioning rules to determine if the version is in range.
120 121 122 123 124 125 126 127 128 |
# File 'lib/buildr4osgi/osgi/version.rb', line 120 def in_range(version) return in_range(version.min) && (version.max_infinite ? true : in_range(version.max)) if version.is_a?(VersionRange) result = min_inclusive ? min <= version : min < version if (!max_infinite) result &= max_inclusive ? max >= version : max > version end result end |
#to_s ⇒ Object
:nodoc:
113 114 115 |
# File 'lib/buildr4osgi/osgi/version.rb', line 113 def to_s #:nodoc: "#{ min_inclusive ? '[' : '('}#{min},#{max_infinite ? "infinite" : max}#{max_inclusive ? ']' : ')'}" end |