class DogWatch::DogFile

Manage the execution of the Dogfile

Public Instance Methods

configure(dogfile, api_key, app_key, timeout) click to toggle source

@param [String] dogfile @param [String|Object] api_key @param [String|Object] app_key @param [Integer] timeout

# File lib/dogwatch/dogfile.rb, line 13
def configure(dogfile, api_key, app_key, timeout)
  @dogfile = dogfile
  @config = DogWatch::Model::Config.new(api_key, app_key, timeout)
end
create(&block) click to toggle source

@param [Proc] block

# File lib/dogwatch/dogfile.rb, line 19
def create(&block)
  monitor = instance_eval(IO.read(@dogfile), @dogfile, 1)

  if monitor.is_a?(DogWatch::Monitor)
    monitor.config = @config
    monitor.client

    monitor.get
    monitor.responses.each { |r| block.call(r) }
  else
    klass = Class.new do
      def to_thor
        [:none, 'File does not contain any monitors.', :yellow]
      end
    end

    block.call(klass.new)
  end
end
to_thor() click to toggle source
# File lib/dogwatch/dogfile.rb, line 30
def to_thor
  [:none, 'File does not contain any monitors.', :yellow]
end