Class: Hiptest::VersionChecker
- Inherits:
-
Object
- Object
- Hiptest::VersionChecker
- Defined in:
- lib/hiptest-publisher/version_checker.rb
Instance Attribute Summary collapse
-
#reporter ⇒ Object
readonly
Returns the value of attribute reporter.
Class Method Summary collapse
Instance Method Summary collapse
- #check_version ⇒ Object
- #get_latest_version ⇒ Object
-
#initialize(reporter) ⇒ VersionChecker
constructor
A new instance of VersionChecker.
Constructor Details
#initialize(reporter) ⇒ VersionChecker
Returns a new instance of VersionChecker.
14 15 16 |
# File 'lib/hiptest-publisher/version_checker.rb', line 14 def initialize(reporter) @reporter = reporter end |
Instance Attribute Details
#reporter ⇒ Object (readonly)
Returns the value of attribute reporter.
6 7 8 |
# File 'lib/hiptest-publisher/version_checker.rb', line 6 def reporter @reporter end |
Class Method Details
.check_version(reporter: nil) ⇒ Object
8 9 10 11 12 |
# File 'lib/hiptest-publisher/version_checker.rb', line 8 def self.check_version(reporter: nil) reporter ||= Reporter.new VersionChecker.new(reporter).check_version end |
Instance Method Details
#check_version ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/hiptest-publisher/version_checker.rb', line 18 def check_version latest = get_latest_version return if latest.nil? current = hiptest_publisher_version if latest == current puts I18n.t('check_version.up_to_date', current: current) else puts I18n.t('check_version.outdated', current: current, latest: latest) end end |
#get_latest_version ⇒ Object
31 32 33 34 35 36 37 38 39 |
# File 'lib/hiptest-publisher/version_checker.rb', line 31 def get_latest_version reporter. I18n.t('check_version.title') do latest_gem = Gem.latest_version_for('hiptest-publisher') raise RuntimeError, I18n.t('check_version.error') if latest_gem.nil? latest = latest_gem.version end end |