class EverydayPlugins::Plugins
Public Class Methods
get(type, *args)
click to toggle source
# File lib/everyday-plugins/plugin.rb, line 59 def self.get(type, *args) instance.get(type, *args) end
get_var(name)
click to toggle source
# File lib/everyday-plugins/plugin.rb, line 79 def self.get_var(name) instance.get_var(name) end
get_vars(*names)
click to toggle source
# File lib/everyday-plugins/plugin.rb, line 83 def self.get_vars(*names) instance.get_vars(*names) end
instance()
click to toggle source
# File lib/everyday-plugins/plugin.rb, line 7 def self.instance @instance ||= Plugins.new end
load_plugins(path, error_fatal = false)
click to toggle source
# File lib/everyday-plugins/plugin.rb, line 11 def self.load_plugins(path, error_fatal = false) begin Gem.find_latest_files("/#{path}/plugin/*.plugin.rb").each { |plugin| #noinspection RubyResolve begin require plugin rescue LoadError => e puts "Error in loading plugin '#{plugin}'" puts e.inspect puts e.backtrace.join("\n") exit 1 if error_fatal end } rescue Exception => e puts 'Error in loading plugins' puts e.inspect puts e.backtrace.join("\n") exit 1 if error_fatal end end
new()
click to toggle source
# File lib/everyday-plugins/plugin.rb, line 32 def initialize @ext = {} @types = {} @vars = {} end
set_var(name, value)
click to toggle source
# File lib/everyday-plugins/plugin.rb, line 87 def self.set_var(name, value) instance.set_var(name, value) end
set_vars(vars = {})
click to toggle source
# File lib/everyday-plugins/plugin.rb, line 91 def self.set_vars(vars = {}) instance.set_vars(vars) end
Public Instance Methods
[](type)
click to toggle source
# File lib/everyday-plugins/plugin.rb, line 51 def [](type) @ext[type] || [] end
get(type, *args)
click to toggle source
# File lib/everyday-plugins/plugin.rb, line 55 def get(type, *args) @types[type].call(self[type], *args) end
get_var(name)
click to toggle source
# File lib/everyday-plugins/plugin.rb, line 63 def get_var(name) @vars[name] || nil end
get_vars(*names)
click to toggle source
# File lib/everyday-plugins/plugin.rb, line 67 def get_vars(*names) names.map { |name| get_var(name) } end
register(type, options = {}, &block)
click to toggle source
# File lib/everyday-plugins/plugin.rb, line 38 def register(type, options = {}, &block) @ext[type] ||= [] @ext[type] << { options: options, block: block } end
register_type(type, &block)
click to toggle source
# File lib/everyday-plugins/plugin.rb, line 43 def register_type(type, &block) @types[type] = block end
register_variable(name, value = nil)
click to toggle source
# File lib/everyday-plugins/plugin.rb, line 47 def register_variable(name, value = nil) @vars[name] = value end
set_var(name, value)
click to toggle source
# File lib/everyday-plugins/plugin.rb, line 71 def set_var(name, value) @vars[name] = value end
set_vars(vars = {})
click to toggle source
# File lib/everyday-plugins/plugin.rb, line 75 def set_vars(vars = {}) vars.each { |v| set_var(*v) } end