Class: PoolParty::Plugin
Class Method Summary collapse
-
.create_methods(name, klass, opts = {}) ⇒ Object
Create a class-level method for the name on the class For instance: create_methods :install, RemoteInstance will give the following methods to the class before_install and after_install on the RemoteInstance.
- .define_custom_package(name = :userpackage, &block) ⇒ Object
- .define_global_file(name, &block) ⇒ Object
- .define_node_file(name, &block) ⇒ Object
- .user_tasks(str) ⇒ Object
Instance Method Summary collapse
Class Method Details
.create_methods(name, klass, opts = {}) ⇒ Object
Create a class-level method for the name on the class For instance:
create_methods :install, RemoteInstance
will give the following methods to the class
before_install and after_install on the RemoteInstance
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/poolparty/plugin.rb', line 15 def self.create_methods(name, klass, opts={}) str = "" %w(before after).each do |time| str << <<-EOE def self.#{time}_#{name}(*meth) callee = self #{klass}.class_eval do meth.each {|m| #{time} :#{name}, {m.to_sym => callee.to_s }} end end EOE end eval str end |
.define_custom_package(name = :userpackage, &block) ⇒ Object
34 35 36 |
# File 'lib/poolparty/plugin.rb', line 34 def self.define_custom_package name=:userpackage, &block PoolParty::Provider.define_custom_package name, &block end |
.define_global_file(name, &block) ⇒ Object
38 39 40 |
# File 'lib/poolparty/plugin.rb', line 38 def self.define_global_file(name, &block) PoolParty::Master.define_global_user_file(name, &block) end |
.define_node_file(name, &block) ⇒ Object
42 43 44 |
# File 'lib/poolparty/plugin.rb', line 42 def self.define_node_file(name, &block) PoolParty::Master.define_node_user_file(name, &block) end |
.user_tasks(str) ⇒ Object
30 31 32 |
# File 'lib/poolparty/plugin.rb', line 30 def self.user_tasks str PoolParty::RemoteInstance.user_tasks << str end |
Instance Method Details
#add_user_data(h = {}) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/poolparty/plugin.rb', line 46 def add_user_data(h={}) case h.class.to_s when "String" PoolParty::Application.user_data << h when "Hash" PoolParty::Application.hash_to_launch_with.merge!(h) end end |
#read_config_file(filename) ⇒ Object
55 56 57 58 |
# File 'lib/poolparty/plugin.rb', line 55 def read_config_file(filename) return {} unless filename YAML.load(open(filename).read) end |