lib/rapporteur/checker.rb in rapporteur-1.0.1 vs lib/rapporteur/checker.rb in rapporteur-1.1.0
- old
+ new
@@ -52,10 +52,11 @@
# data for rendering.
#
# Returns a Rapporteur::Checker instance.
#
def self.run
+ instance.messages.clear
instance.errors.clear
instance.run
end
@@ -76,13 +77,39 @@
def add_error(message)
errors.add(:base, message)
self
end
+ ##
+ # Public: Adds a status message for inclusion in the success response.
+ #
+ # name - A String containing the name or identifier for your message. This
+ # is unique and may be overriden by other checks using the name
+ # message name key.
+ # message - A String or Numeric for the value of the message.
+ #
+ # Examples
+ #
+ # checker.add_message(:repository, 'git@github.com/user/repo.git')
+ # checker.add_message(:load, 0.934)
+ #
+ # Returns the Rapporteur::Checker instance.
+ #
+ def add_message(name, message)
+ messages[name] = message
+ self
+ end
+
# Public: Returns the Set of checks currently configured.
#
def checks
@checks ||= Set.new
+ end
+
+ # Public: Returns the Hash of messages currently configured.
+ #
+ def messages
+ @messages ||= Hash.new
end
# Public: Returns a String containing the current revision of the
# application.
#