lib/mixlib/versioning.rb in mixlib-versioning-1.1.0 vs lib/mixlib/versioning.rb in mixlib-versioning-1.2.1

- old
+ new

@@ -1,9 +1,10 @@ # # Author:: Seth Chisamore (<schisamo@chef.io>) # Author:: Christopher Maier (<cm@chef.io>) # Copyright:: Copyright (c) 2013 Opscode, Inc. +# Copyright:: Copyright (c) 2017 Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -15,22 +16,23 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. # -require 'mixlib/versioning/exceptions' -require 'mixlib/versioning/format' +require "mixlib/versioning/exceptions" +require "mixlib/versioning/format" module Mixlib # @author Seth Chisamore (<schisamo@chef.io>) # @author Christopher Maier (<cm@chef.io>) class Versioning DEFAULT_FORMATS = [ Mixlib::Versioning::Format::GitDescribe, Mixlib::Versioning::Format::OpscodeSemVer, Mixlib::Versioning::Format::SemVer, Mixlib::Versioning::Format::Rubygems, + Mixlib::Versioning::Format::PartialSemVer, ].freeze # Create a new {Format} instance given a version string to parse, and an # optional format type. # @@ -53,11 +55,11 @@ # # @return # def self.parse(version_string, format = nil) if version_string.is_a?(Mixlib::Versioning::Format) - return version_string + version_string else formats = if format [format].flatten.map { |f| Mixlib::Versioning::Format.for(f) } else DEFAULT_FORMATS @@ -69,11 +71,11 @@ break parsed_version = version.new(version_string) rescue Mixlib::Versioning::ParseError next end end - return parsed_version + parsed_version end end # Selects the most recent version from `all_versions` that satisfies the # filtering constraints provided by `filter_version`, @@ -133,11 +135,11 @@ use_build_versions = false) # attempt to parse a `Mixlib::Versioning::Format` instance if we were # passed a string unless filter_version.nil? || - filter_version.is_a?(Mixlib::Versioning::Format) + filter_version.is_a?(Mixlib::Versioning::Format) filter_version = Mixlib::Versioning.parse(filter_version) end all_versions.map! do |v| if v.is_a?(Mixlib::Versioning::Format) @@ -179,16 +181,16 @@ end in_release_line && if use_prerelease_versions && use_build_versions v.prerelease_build? elsif !use_prerelease_versions && - use_build_versions + use_build_versions v.release_build? elsif use_prerelease_versions && - !use_build_versions + !use_build_versions v.prerelease? elsif !use_prerelease_versions && - !use_build_versions + !use_build_versions v.release? end end.max # select the most recent version end # if end # self.find_target_version