Class: OkComputer::AppVersionCheck
- Defined in:
- lib/ok_computer/built_in_checks/app_version_check.rb
Overview
Display app version SHA
-
If ‘ENV` is set, uses that value.
-
Otherwise, checks for Capistrano’s REVISION file in the app root.
-
Failing these, the check fails
Constant Summary
Constants inherited from Check
Instance Attribute Summary collapse
-
#env ⇒ Object
Returns the value of attribute env.
-
#file ⇒ Object
Returns the value of attribute file.
-
#transform ⇒ Object
Returns the value of attribute transform.
Attributes inherited from Check
#failure_occurred, #message, #registrant_name, #time
Instance Method Summary collapse
-
#check ⇒ Object
Public: Return the application version.
-
#initialize(file: "REVISION", env: "SHA", &transform) ⇒ AppVersionCheck
constructor
Public: Initialize a check for a backed-up Sidekiq queue.
-
#version ⇒ Object
Public: The application version.
Methods inherited from Check
#<=>, #clear, #mark_failure, #mark_message, #run, #success?, #to_json, #to_text, #with_benchmarking
Constructor Details
#initialize(file: "REVISION", env: "SHA", &transform) ⇒ AppVersionCheck
Public: Initialize a check for a backed-up Sidekiq queue
file - The path of the version file to check env - The key in ENV to check for a revision SHA transform - The block to optionally transform the version string
17 18 19 20 21 |
# File 'lib/ok_computer/built_in_checks/app_version_check.rb', line 17 def initialize(file: "REVISION", env: "SHA", &transform) self.file = file self.env = env self.transform = transform || proc { |v| v } end |
Instance Attribute Details
#env ⇒ Object
Returns the value of attribute env.
9 10 11 |
# File 'lib/ok_computer/built_in_checks/app_version_check.rb', line 9 def env @env end |
#file ⇒ Object
Returns the value of attribute file.
8 9 10 |
# File 'lib/ok_computer/built_in_checks/app_version_check.rb', line 8 def file @file end |
#transform ⇒ Object
Returns the value of attribute transform.
10 11 12 |
# File 'lib/ok_computer/built_in_checks/app_version_check.rb', line 10 def transform @transform end |
Instance Method Details
#check ⇒ Object
Public: Return the application version
24 25 26 27 28 29 |
# File 'lib/ok_computer/built_in_checks/app_version_check.rb', line 24 def check "Version: #{version}" rescue UnknownRevision mark_failure "Unable to determine version" end |
#version ⇒ Object
Public: The application version
Returns a String
34 35 36 |
# File 'lib/ok_computer/built_in_checks/app_version_check.rb', line 34 def version transform.call(version_from_env || version_from_file || raise(UnknownRevision)) end |