Class: Retrospec::Module
Instance Method Summary collapse
-
#find_plugin_type(module_path, name = nil) ⇒ Object
finds a suitable plugin given the name of the plugin or via a supported discovery method.
-
#initialize(supplied_module_path, opts = {}) ⇒ Module
constructor
module path is the relative or absolute path to the module that we should retrofit opts hash contains additional flags and options that can be user to control the creation of the tests opts.
Methods included from Plugins
#available_plugins, #discover_plugin, #discover_plugin_by_name, #get_remote_data, #installed_plugins, #load_plugins, #plugin_classes
Constructor Details
#initialize(supplied_module_path, opts = {}) ⇒ Module
module path is the relative or absolute path to the module that we should retrofit opts hash contains additional flags and options that can be user to control the creation of the tests opts
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/retrospec.rb', line 11 def initialize(supplied_module_path, opts={}) # locates the plugin class that can be used with this module directory begin opts[:name] ||= File.basename(supplied_module_path) # use the name or derive it from the dir name plugin_class = find_plugin_type(supplied_module_path, opts[:name]) # load any save data in the config file config_data = Retrospec::Config.config_data(opts[:config_map]) plugin_data = Retrospec::Config.plugin_context(config_data, plugin_class.send(:plugin_name)) # merge the passed in options plugin_data.merge!(opts) # create the instance of the plugin plugin = plugin_class.send(:new, supplied_module_path, plugin_data) plugin.run rescue NoSuitablePluginFoundException puts "No gem was found to support this code type, please install a gem that supports this module.".fatal end end |
Instance Method Details
#find_plugin_type(module_path, name = nil) ⇒ Object
finds a suitable plugin given the name of the plugin or via a supported discovery method
30 31 32 33 34 35 36 37 |
# File 'lib/retrospec.rb', line 30 def find_plugin_type(module_path, name=nil) if name # when the user wants to create a module give the module type discover_plugin_by_name(name) else discover_plugin(module_path) end end |