Class: DogEventer::DogEventer

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

Instance Method Summary collapse

Constructor Details

#initialize(api_key, application_key = nil) ⇒ DogEventer

Returns a new instance of DogEventer.



7
8
9
10
# File 'lib/dogeventer.rb', line 7

def initialize(api_key, application_key=nil)
  @dog = Dogapi::Client.new(api_key, application_key)
  @events = []
end

Instance Method Details

#generate(start_time, &block) ⇒ Object



12
13
14
15
16
17
18
19
20
# File 'lib/dogeventer.rb', line 12

def generate(start_time, &block)
  @start_time = start_time
  instance_eval &block

  @events.each do |event|
    puts event.inspect
    @dog.emit_event(Dogapi::Event.new('', event), :host => event[:host])
  end
end

#host(host_name, &block) ⇒ Object



22
23
24
25
# File 'lib/dogeventer.rb', line 22

def host(host_name, &block)
  h = Host.new(@start_time, host_name)
  @events += (h.instance_eval &block)
end

#url(url, &block) ⇒ Object



27
28
29
30
# File 'lib/dogeventer.rb', line 27

def url(url, &block)
  u = Url.new(@start_time, url)
  @events += (u.instance_eval &block)
end