Class: Makesure::Verify

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, cron, blk) ⇒ Verify

Returns a new instance of Verify.



7
8
9
10
11
# File 'lib/makesure/verify.rb', line 7

def initialize(name, cron, blk)
  @name = name
  @cron = cron
  @blk  = blk
end

Instance Attribute Details

#blkObject (readonly)

Returns the value of attribute blk.



5
6
7
# File 'lib/makesure/verify.rb', line 5

def blk
  @blk
end

#cronObject (readonly)

Returns the value of attribute cron.



5
6
7
# File 'lib/makesure/verify.rb', line 5

def cron
  @cron
end

#nameObject (readonly)

Returns the value of attribute name.



5
6
7
# File 'lib/makesure/verify.rb', line 5

def name
  @name
end

Instance Method Details

#run!Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/makesure/verify.rb', line 13

def run!
  begin
    
    blk.call
    Makesure.log "Everything is copacetic"
    
  rescue Exception => e
    Makesure.warn "Uh oh, something's up"
    Makesure.warn "\t" + e.message
    
    # send an email with the details
    body = ""
    body << "[#{Time.now.to_s}] Verification failure:\n\n"
    body << e.backtrace.join("\n")
    Makesure.send_alert("FAILED verification alert: #{e.message}", body)
    
    return false
  #else
  #ensure
  end
  
  true
end