Module: StillActive::VersionHelper
- Extended by:
- VersionHelper
- Included in:
- CLI, VersionHelper, Workflow
- Defined in:
- lib/helpers/version_helper.rb
Instance Method Summary collapse
- #find_version(versions:, version_string: nil, pre_release: false) ⇒ Object
- #gem_version(version_hash:) ⇒ Object
- #release_date(version_hash:) ⇒ Object
- #up_to_date?(version_used:, latest_version: nil, latest_pre_release_version: nil) ⇒ Boolean
Instance Method Details
#find_version(versions:, version_string: nil, pre_release: false) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'lib/helpers/version_helper.rb', line 7 def find_version(versions:, version_string: nil, pre_release: false) if version_string && pre_release versions&.find { |v| v["number"] == version_string && v["prerelease"] == pre_release } elsif !version_string.nil? versions&.find { |v| v["number"] == version_string } else versions&.find { |v| v["prerelease"] == pre_release } end end |
#gem_version(version_hash:) ⇒ Object
40 41 42 |
# File 'lib/helpers/version_helper.rb', line 40 def gem_version(version_hash:) version_hash&.dig("number") end |
#release_date(version_hash:) ⇒ Object
44 45 46 47 48 |
# File 'lib/helpers/version_helper.rb', line 44 def release_date(version_hash:) release_date = version_hash&.dig("created_at") Time.parse(release_date) unless release_date.nil? end |
#up_to_date?(version_used:, latest_version: nil, latest_pre_release_version: nil) ⇒ Boolean
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/helpers/version_helper.rb', line 17 def up_to_date?(version_used:, latest_version: nil, latest_pre_release_version: nil) return nil if latest_version.nil? && latest_pre_release_version.nil? version_used = if version_used.is_a?(String) version_used else gem_version(version_hash: version_used) end latest_version = if latest_version.is_a?(String) latest_version else gem_version(version_hash: latest_version) end latest_pre_release_version = if latest_pre_release_version.is_a?(String) latest_pre_release_version else gem_version(version_hash: latest_pre_release_version) end [latest_version, latest_pre_release_version].include?(version_used) end |