Method: Jamf::Utility#parse_jss_version
- Defined in:
- lib/jamf/utility.rb
#parse_jss_version(version) ⇒ Hash{Symbol => String, Gem::Version}
Parse a JSS Version number into something comparable.
This method returns a Hash with these keys:
-
:major => the major version, Integer
-
:minor => the minor version, Integor
-
:maint => the revision, Integer (also available as :patch and :revision)
-
:build => the revision, String
-
:version => a Gem::Version object built from :major, :minor, :revision which can be easily compared with other Gem::Version objects.
NOTE: the :version value ignores build numbers, so comparisons only compare major.minor.maint
560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 |
# File 'lib/jamf/utility.rb', line 560 def parse_jss_version(version) major, second_part, *_rest = version.split('.') raise Jamf::InvalidDataError, 'JSS Versions must start with "x.x" where x is one or more digits' unless major =~ /\d$/ && second_part =~ /^\d/ release, build = version.split(/-/) major, minor, revision = release.split '.' minor ||= 0 revision ||= 0 { major: major.to_i, minor: minor.to_i, revision: revision.to_i, maint: revision.to_i, patch: revision.to_i, build: build, version: Gem::Version.new("#{major}.#{minor}.#{revision}") } end |