Class: Checkups::Checkup
- Inherits:
-
Object
- Object
- Checkups::Checkup
- Defined in:
- lib/checkups/checkup.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#status_message ⇒ Object
readonly
Returns the value of attribute status_message.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#verbose ⇒ Object
readonly
Returns the value of attribute verbose.
Class Method Summary collapse
-
.checkups_by_frequency(frequency, _verbose: false) ⇒ Object
TODO: Remove verbose from method signature.
- .daily ⇒ Object
- .frequency ⇒ Object
- .hourly ⇒ Object
Instance Method Summary collapse
- #check ⇒ Object
- #check_and_notify!(&block) ⇒ Object
-
#initialize(verbose: false) ⇒ Checkup
constructor
A new instance of Checkup.
- #notify_message ⇒ Object
- #passed? ⇒ Boolean
Constructor Details
#initialize(verbose: false) ⇒ Checkup
Returns a new instance of Checkup.
29 30 31 32 33 34 |
# File 'lib/checkups/checkup.rb', line 29 def initialize(verbose: false) @notify_frequency = :always @verbose = verbose @name = nil ok end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
9 10 11 |
# File 'lib/checkups/checkup.rb', line 9 def name @name end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
9 10 11 |
# File 'lib/checkups/checkup.rb', line 9 def status @status end |
#status_message ⇒ Object (readonly)
Returns the value of attribute status_message.
9 10 11 |
# File 'lib/checkups/checkup.rb', line 9 def end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
9 10 11 |
# File 'lib/checkups/checkup.rb', line 9 def url @url end |
#verbose ⇒ Object (readonly)
Returns the value of attribute verbose.
9 10 11 |
# File 'lib/checkups/checkup.rb', line 9 def verbose @verbose end |
Class Method Details
.checkups_by_frequency(frequency, _verbose: false) ⇒ Object
TODO: Remove verbose from method signature
20 21 22 23 |
# File 'lib/checkups/checkup.rb', line 20 def self.checkups_by_frequency(frequency, _verbose: false) checkup_classes = ObjectSpace.each_object(::Class).select { |klass| klass < self } checkup_classes.select { |klass| klass.frequency == frequency } end |
.daily ⇒ Object
15 16 17 |
# File 'lib/checkups/checkup.rb', line 15 def self.daily checkups_by_frequency(:daily) end |
.frequency ⇒ Object
25 26 27 |
# File 'lib/checkups/checkup.rb', line 25 def self.frequency :never end |
.hourly ⇒ Object
11 12 13 |
# File 'lib/checkups/checkup.rb', line 11 def self.hourly checkups_by_frequency(:hourly) end |
Instance Method Details
#check ⇒ Object
54 55 56 |
# File 'lib/checkups/checkup.rb', line 54 def check ok end |
#check_and_notify!(&block) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/checkups/checkup.rb', line 36 def check_and_notify!(&block) check(&block) send_notification rescue => e # rubocop:disable Style/RescueStandardError handle_error(e) end |
#notify_message ⇒ Object
58 59 60 |
# File 'lib/checkups/checkup.rb', line 58 def "Checkup #{@status.to_s.capitalize}: " + end |
#passed? ⇒ Boolean
43 44 45 46 47 48 49 50 51 52 |
# File 'lib/checkups/checkup.rb', line 43 def passed? case check when nil, :ok, :info true when :warning, :error false else raise "Unknown status: #{check}" end end |