Module: PeepingTom::DSL
- Defined in:
- lib/peeping_tom/dsl.rb
Instance Method Summary collapse
- #channel(type, *opts) ⇒ Object
- #channels ⇒ Object
- #errors ⇒ Object
- #group(name, &block) ⇒ Object
- #no_errors ⇒ Object
- #ping(site) ⇒ Object
- #proxy_site(*args) ⇒ Object
- #site(name, site, opts = {}) ⇒ Object
- #verify(site) ⇒ Object
- #watch(name) ⇒ Object
- #with(*args) ⇒ Object
Instance Method Details
#channel(type, *opts) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/peeping_tom/dsl.rb', line 57 def channel(type, *opts) if type == :irc require File.join(File.dirname(__FILE__), "notifier", "irc") channel = PeepingTom::Notifier::IRC.new(*opts) elsif type == :email require File.join(File.dirname(__FILE__), "notifier", "email") channel = PeepingTom::Notifier::Email.new(*opts) else raise ArgumentError, "unknown channel type: #{type}" end @channels ||= [] @channels << channel end |
#channels ⇒ Object
8 9 10 |
# File 'lib/peeping_tom/dsl.rb', line 8 def channels @channels end |
#errors ⇒ Object
41 42 43 44 |
# File 'lib/peeping_tom/dsl.rb', line 41 def errors return unless @errors yield end |
#group(name, &block) ⇒ Object
51 52 53 54 55 |
# File 'lib/peeping_tom/dsl.rb', line 51 def group(name, &block) PeepingTom.set_peeper(name) yield PeepingTom.reset_peeper end |
#no_errors ⇒ Object
46 47 48 49 |
# File 'lib/peeping_tom/dsl.rb', line 46 def no_errors return if @errors yield end |
#ping(site) ⇒ Object
12 13 14 |
# File 'lib/peeping_tom/dsl.rb', line 12 def ping(site) @site.ping(*@site.with_args) end |
#proxy_site(*args) ⇒ Object
75 76 77 |
# File 'lib/peeping_tom/dsl.rb', line 75 def proxy_site(*args) @site.with(*args) end |
#site(name, site, opts = {}) ⇒ Object
71 72 73 |
# File 'lib/peeping_tom/dsl.rb', line 71 def site(name, site, opts = {}) PeepingTom.peeper.register(name, site, opts) end |
#verify(site) ⇒ Object
16 17 18 |
# File 'lib/peeping_tom/dsl.rb', line 16 def verify(site) @site.verify(*@site.with_args) end |
#watch(name) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/peeping_tom/dsl.rb', line 24 def watch(name) alias :old_site :site alias :site :proxy_site PeepingTom.peeper(name).sites.each_value do |site| @site = site yield if site.error? @errors = true $stdout.puts "#{site.name} has an ERROR" (@channels || []).each {|c| c.notify!(site)} end end alias :site :old_site end |
#with(*args) ⇒ Object
20 21 22 |
# File 'lib/peeping_tom/dsl.rb', line 20 def with(*args) args end |