class OkComputer::AppVersionCheck
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
Constants
- UnknownRevision
Attributes
Public Class Methods
Source
# 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
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
Public Instance Methods
Source
# File lib/ok_computer/built_in_checks/app_version_check.rb, line 24 def check mark_message "Version: #{version}" rescue UnknownRevision mark_failure mark_message "Unable to determine version" end
Public: Return the application version
Source
# 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
Public: The application version
Returns a String
Private Instance Methods
Source
# File lib/ok_computer/built_in_checks/app_version_check.rb, line 41 def version_from_env ENV[env] end
Private: Version stored in environment variable
Source
# File lib/ok_computer/built_in_checks/app_version_check.rb, line 46 def version_from_file path = Rails.root.join(file) File.read(path).chomp if File.exist?(path) end
Private: Version stored in Capistrano revision file