Module: Snarl::SNP::AutoSNP

Included in:
Autotest::Snarl
Defined in:
lib/snarl/snp/autosnp.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#hostObject

Returns the value of attribute host.



14
15
16
# File 'lib/snarl/snp/autosnp.rb', line 14

def host
  @host
end

#icon_failObject



40
# File 'lib/snarl/snp/autosnp.rb', line 40

def icon_fail ; @icon_fail ||= "fail.png" ; end

#icon_okObject

%HOME%Application Datafull phatsnarlstylesok.png works fine



39
# File 'lib/snarl/snp/autosnp.rb', line 39

def icon_ok ; @icon_ok ||= "ok.png" ; end

#icon_pendingObject



41
# File 'lib/snarl/snp/autosnp.rb', line 41

def icon_pending ; @icon_pending ||= "pending.png" ; end

#icondirObject

Windows Snarl shortcut’s “working folder” (left click property) %HOME%Application Datafull phatsnarlstyles



36
# File 'lib/snarl/snp/autosnp.rb', line 36

def icondir ; @icondir ||= './' ; end

#portObject

Returns the value of attribute port.



14
15
16
# File 'lib/snarl/snp/autosnp.rb', line 14

def port
  @port
end

#timeout_failObject



44
# File 'lib/snarl/snp/autosnp.rb', line 44

def timeout_fail ; @timeout_fail ||= 10 ; end

#timeout_okObject



43
# File 'lib/snarl/snp/autosnp.rb', line 43

def timeout_ok ; @timeout_ok ||= 5 ; end

Instance Method Details

#classname(state) ⇒ Object



54
55
56
# File 'lib/snarl/snp/autosnp.rb', line 54

def classname(state)
  state.to_s
end

#snarl(title, text, state) ⇒ Object



58
59
60
61
62
63
64
65
66
# File 'lib/snarl/snp/autosnp.rb', line 58

def snarl(title, text, state)
  snp.notification(
                   :title   => title,
                   :text    => text,
                   :icon    => state.to_s,
                   :timeout => timeout(state),
                   :class   => classname(state)
                   )
end

#snpObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/snarl/snp/autosnp.rb', line 17

def snp
  Snarl::SNP.load("host : \#{host}\nport : \#{port}\napp  : Autotest::Snarl\n\"class\" :\n  - ['green', 'test ok']\n  - ['red', 'test fail']\n  - ['yellow', 'test pending']\n  - ['info', 'system message']\niconset :\n   green  : \#{File.join(icondir, icon_ok)}\n   red    : \#{File.join(icondir, icon_fail)}\n   yellow : \#{File.join(icondir, icon_pending)}\n")
end

#timeout(state) ⇒ Object



46
47
48
49
50
51
52
# File 'lib/snarl/snp/autosnp.rb', line 46

def timeout(state)
  case state
  when :green then timeout_ok.to_i
  when :red   then timeout_fail.to_i
  else 5
  end
end