Class: Pipeline::Plugin
- Inherits:
-
Object
- Object
- Pipeline::Plugin
- Defined in:
- lib/pipeline/plugin.rb
Instance Attribute Summary collapse
-
#root ⇒ Object
readonly
Returns the value of attribute root.
Class Method Summary collapse
Instance Method Summary collapse
- #client ⇒ Object
- #config(key) ⇒ Object
-
#initialize(root) ⇒ Plugin
constructor
A new instance of Plugin.
- #run! ⇒ Object
Constructor Details
Instance Attribute Details
#root ⇒ Object (readonly)
Returns the value of attribute root.
28 29 30 |
# File 'lib/pipeline/plugin.rb', line 28 def root @root end |
Class Method Details
.inherited(subclass) ⇒ Object
11 12 13 |
# File 'lib/pipeline/plugin.rb', line 11 def self.inherited(subclass) Pipeline::Plugin.plugins << subclass end |
.plugins ⇒ Object
7 8 9 |
# File 'lib/pipeline/plugin.rb', line 7 def self.plugins @@plugins ||= Array.new end |
Instance Method Details
#client ⇒ Object
50 51 52 |
# File 'lib/pipeline/plugin.rb', line 50 def client @client ||= Pipeline::Client.boot(self.config('amqp')) end |
#config(key) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/pipeline/plugin.rb', line 36 def config(key) @config[key] ||= begin path = self.root.join("config/#{key}.json") data = JSON.parse(path.read) path = self.root.join("config/#{key}.local.json") data.merge!(JSON.parse(path.read)) if path.exist? data.reduce(Hash.new) do |buffer, (key, value)| buffer.merge!(key.to_sym => value) end end end |
#run! ⇒ Object
54 55 56 57 58 59 60 61 |
# File 'lib/pipeline/plugin.rb', line 54 def run! self.client.on_open do EM.add_timer(0.1) do # Oh my, yeah, whatever, it's for now only, dammit! puts "~ Running #{self.class}#run." self.run end end end |