lib/heartcheck.rb in heartcheck-1.0.5 vs lib/heartcheck.rb in heartcheck-1.0.6

- old
+ new

@@ -1,18 +1,20 @@ module Heartcheck require 'logger' require 'heartcheck/app' require 'heartcheck/checks' + require 'heartcheck/executors' require 'heartcheck/errors' require 'heartcheck/services' require 'heartcheck/logger' @checks = [] class << self # @attr [Array<Checks>] the checks to use when checking attr_accessor :checks + # @attr_writer [Object] change the default logger attr_writer :logger # Is used to log some messages when checking if the logger # is not set it's returns de default_logger. @@ -24,14 +26,16 @@ # @abstract # Is used to configure. # # @yield A bock that recieve the class + # # @example # Heartcheck.setup do |c| # puts c # end + # # @return [void] def setup yield(self) end @@ -40,14 +44,16 @@ # # @param [String] name to identify in the result page # @param [Hash] options the options to create an instance of a check. # @option options [String] :class The class name to get an instance # @yield a block to config the instance + # # @example # Heartcheck.add(:base) do |c| # c.name = 'Base check' # end + # # @return [void] def add(name, options = {}, &block) class_name = options.fetch(:class) { constantize(name) } instance = Checks.const_get(class_name).new @@ -98,12 +104,14 @@ log end # helper method to get a constant # + # @param [String] name of class + # # @example # contantize('my_check') => 'MyCheck' - # @param [String] name of class + # # @return [String] def constantize(name) name.to_s.split('_').map(&:capitalize).join end end