Class: ScoutScout::Plugin
- Inherits:
-
Hashie::Mash
- Object
- Hashie::Mash
- ScoutScout::Plugin
- Defined in:
- lib/scout_scout/plugin.rb
Instance Attribute Summary collapse
-
#server ⇒ Object
Returns the value of attribute server.
Instance Method Summary collapse
-
#descriptors ⇒ Array
All descriptors for this plugin, including their name and current.
- #email_subscribers ⇒ Object
-
#initialize(hash) ⇒ Plugin
constructor
A new instance of Plugin.
- #triggers ⇒ Object
Constructor Details
#initialize(hash) ⇒ Plugin
Returns a new instance of Plugin.
4 5 6 7 8 9 10 |
# File 'lib/scout_scout/plugin.rb', line 4 def initialize(hash) if hash['descriptors'] && hash['descriptors']['descriptor'] @descriptor_hash = hash['descriptors']['descriptor'] hash.delete('descriptors') end super(hash) end |
Instance Attribute Details
#server ⇒ Object
Returns the value of attribute server.
2 3 4 |
# File 'lib/scout_scout/plugin.rb', line 2 def server @server end |
Instance Method Details
#descriptors ⇒ Array
All descriptors for this plugin, including their name and current
15 16 17 |
# File 'lib/scout_scout/plugin.rb', line 15 def descriptors @descriptors ||= @descriptor_hash.map { |d| decorate_with_server_and_plugin(ScoutScout::Descriptor.new(d)) } end |
#email_subscribers ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/scout_scout/plugin.rb', line 19 def email_subscribers response = ScoutScout.get("/#{ScoutScout.account}/clients/#{server.id}/email_subscribers?plugin_id=#{id}") doc = Nokogiri::HTML(response.body) table = doc.css('table.list').first user_rows = table.css('tr')[1..-1] # skip first row, which is headings user_rows.map do |row| name_td, receiving_notifications_td = *row.css('td') name = name_td.content.gsub(/[\t\n]/, '') checked = receiving_notifications_td.css('input').attribute('checked') receiving_notifications = checked && checked.value == 'checked' Hashie::Mash.new :name => name, :receiving_notifications => receiving_notifications end end |
#triggers ⇒ Object
36 37 38 39 |
# File 'lib/scout_scout/plugin.rb', line 36 def triggers response = ScoutScout.get("/#{ScoutScout.account}/clients/#{server.id}/triggers.xml?plugin_id=#{id}") response['triggers'].map { |trigger| decorate_with_server_and_plugin(ScoutScout::Trigger.new(trigger)) } end |