Module: RSence::Plugins
- Defined in:
- lib/rsence/plugins.rb,
lib/rsence/plugins.rb,
lib/rsence/plugins/plugin.rb,
lib/rsence/plugins/servlet.rb,
lib/rsence/plugins/guiparser.rb,
lib/rsence/plugins/gui_plugin.rb,
lib/rsence/plugins/plugin_base.rb,
lib/rsence/plugins/plugin_plugins.rb,
lib/rsence/plugins/plugin_sqlite_db.rb
Overview
Namespace for plugin classes and modules
Defined Under Namespace
Modules: PluginBase, PluginPlugins, PluginSqliteDB Classes: GUIParser, GUIPlugin__, Plugin__, Servlet__
Class Method Summary collapse
-
.bundle_loader(params) ⇒ Module
Loads bundle in an anonymous module with special environment options.
-
.GUIPlugin ⇒ GUIPlugin__
Creates the runtime GUIPlugin class from GUIPlugin__.
-
.Plugin ⇒ Plugin__
Creates the runtime Plugin class from Plugin__.
-
.Servlet ⇒ Servlet__
Creates the runtime Servlet class from Servlet__.
Class Method Details
.bundle_loader(params) ⇒ Module
Loads bundle in an anonymous module with special environment options.
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 |
# File 'lib/rsence/plugins.rb', line 98 def self.bundle_loader( params ) begin mod = Module.new do |m| if RUBY_VERSION.to_f >= 1.9 m.define_singleton_method( :_bundle_path ) do params[ :bundle_path ] end else m.module_eval( " def self._bundle_path; \#{params[:bundle_path].inspect}; end\n END\n )\n end\n \n # Makes a full path using the plugin bundle as the 'local path'.\n # The (optional) +prefix+ is a subdirectory in the bundle,\n # the +suffix+ is the file extension.\n def self.bundle_path( path=false, prefix=false, suffix=false )\n return _bundle_path if not path\n if suffix\n path = \"\#{path}\#{suffix}\" unless path.end_with?(suffix)\n end\n if prefix\n path = File.join( prefix, path )\n end\n path = File.expand_path( path, _bundle_path )\n return path\n end\n def self.inspect; \"#<module BundleWrapper of \#{self._bundle_path}}>\"; end\n def self.const_missing( name )\n if name == :Servlet\n return Plugins.Servlet.call( self )\n elsif name == :Plugin\n return Plugins.Plugin.call( self )\n elsif name == :GUIPlugin\n return Plugins.GUIPlugin.call( self )\n else\n warn \"Known const missing: \#{name.inspect}\"\n super\n end\n end\n begin\n plugin_src = params[:src]\n unless RUBY_VERSION.to_f >= 1.9\n plugin_src = \"_bundle_path = \#{params[:bundle_path].inspect};\" + plugin_src\n end\n m.module_eval( plugin_src )\n rescue SyntaxError => e\n src_path = params[:src_path]\n src_path = \"<undefined src_path>\" if src_path == nil\n params[:plugin_manager].plugin_error(\n e,\n 'BundleLoaderSyntaxError',\n \"The syntax of \#{params[:bundle_name]} is invalid.\",\n src_path\n )\n rescue => e\n src_path = params[:src_path]\n src_path = \"<undefined src_path>\" if src_path == nil\n params[:plugin_manager].plugin_error(\n e,\n 'BundleLoaderEvalError',\n \"An error occurred while evaluating the plugin bundle \#{params[:bundle_name]}.\",\n src_path\n )\n end\n end\n return mod\n rescue => e\n src_path = params[:src_path]\n src_path = \"<undefined src_path>\" if src_path == nil\n params[:plugin_manager].plugin_error(\n e,\n 'BundleLoaderError',\n \"An error occurred while loading the plugin bundle \#{params[:bundle_name]}.\",\n src_path\n )\n end\nend\n" |
.GUIPlugin ⇒ GUIPlugin__
Creates the runtime GUIPlugin class from GUIPlugin__
61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/rsence/plugins.rb', line 61 def self.GUIPlugin lambda do |ns| klass = Class.new( GUIPlugin__ ) do def self.ns=(ns) define_method( :bundle_info ) do ns.bundle_info end end end klass.ns = ns if ns klass end end |
.Plugin ⇒ Plugin__
Creates the runtime Plugin class from Plugin__
44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rsence/plugins.rb', line 44 def self.Plugin lambda do |ns| klass = Class.new( Plugin__ ) do def self.ns=(ns) define_method( :bundle_info ) do ns.bundle_info end end end klass.ns = ns if ns klass end end |
.Servlet ⇒ Servlet__
Creates the runtime Servlet class from Servlet__
78 79 80 81 82 83 84 85 86 87 88 89 90 |
# File 'lib/rsence/plugins.rb', line 78 def self.Servlet lambda do |ns| klass = Class.new( Servlet__ ) do def self.ns=(ns) define_method( :bundle_info ) do ns.bundle_info end end end klass.ns = ns if ns klass end end |