Class: DogWatch::DogFile

Inherits:
Object
  • Object
show all
Defined in:
lib/dogwatch/dogfile.rb

Overview

Manage the execution of the Dogfile

Instance Method Summary collapse

Instance Method Details

#configure(dogfile, api_key, app_key, timeout) ⇒ Object

Parameters:

  • dogfile (String)
  • api_key (String|Object)
  • app_key (String|Object)
  • timeout (Integer)


13
14
15
16
# 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) ⇒ Object

Parameters:

  • block (Proc)


19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# 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