Class: ConfiguratorPlugins
- Defined in:
- lib/ceedling/configurator_plugins.rb
Instance Attribute Summary collapse
-
#config_plugins ⇒ Object
readonly
Returns the value of attribute config_plugins.
-
#plugin_hash_defaults ⇒ Object
readonly
Returns the value of attribute plugin_hash_defaults.
-
#plugin_yml_defaults ⇒ Object
readonly
Returns the value of attribute plugin_yml_defaults.
-
#programmatic_plugins ⇒ Object
readonly
Returns the value of attribute programmatic_plugins.
-
#rake_plugins ⇒ Object
readonly
Returns the value of attribute rake_plugins.
Instance Method Summary collapse
-
#find_config_plugins(config, plugin_paths) ⇒ Object
Gather up and return config .yml filepaths that exist in plugin paths + config/.
-
#find_plugin_hash_defaults(config, plugin_paths) ⇒ Object
Gather up and return defaults generated by Ruby code in plugin paths + config/.
-
#find_plugin_yml_defaults(config, plugin_paths) ⇒ Object
Gather up and return default .yml filepaths that exist on-disk.
-
#find_programmatic_plugins(config, plugin_paths) ⇒ Object
Gather up names of .rb ‘Plugin` subclasses and root paths that exist in plugin paths + lib/.
-
#find_rake_plugins(config, plugin_paths) ⇒ Object
Gather up and return .rake filepaths that exist in plugin paths.
-
#inspect ⇒ Object
Override to prevent exception handling from walking & stringifying the object variables.
- #process_aux_load_paths(config) ⇒ Object
- #setup ⇒ Object
Instance Attribute Details
#config_plugins ⇒ Object (readonly)
Returns the value of attribute config_plugins.
14 15 16 |
# File 'lib/ceedling/configurator_plugins.rb', line 14 def config_plugins @config_plugins end |
#plugin_hash_defaults ⇒ Object (readonly)
Returns the value of attribute plugin_hash_defaults.
14 15 16 |
# File 'lib/ceedling/configurator_plugins.rb', line 14 def plugin_hash_defaults @plugin_hash_defaults end |
#plugin_yml_defaults ⇒ Object (readonly)
Returns the value of attribute plugin_yml_defaults.
14 15 16 |
# File 'lib/ceedling/configurator_plugins.rb', line 14 def plugin_yml_defaults @plugin_yml_defaults end |
#programmatic_plugins ⇒ Object (readonly)
Returns the value of attribute programmatic_plugins.
14 15 16 |
# File 'lib/ceedling/configurator_plugins.rb', line 14 def programmatic_plugins @programmatic_plugins end |
#rake_plugins ⇒ Object (readonly)
Returns the value of attribute rake_plugins.
14 15 16 |
# File 'lib/ceedling/configurator_plugins.rb', line 14 def rake_plugins @rake_plugins end |
Instance Method Details
#find_config_plugins(config, plugin_paths) ⇒ Object
Gather up and return config .yml filepaths that exist in plugin paths + config/
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 |
# File 'lib/ceedling/configurator_plugins.rb', line 109 def find_config_plugins(config, plugin_paths) @config_plugins = [] plugins_with_path = [] config[:plugins][:enabled].each do |plugin| if path = plugin_paths[(plugin + '_path').to_sym] config_plugin_path = File.join(path, "config", "#{plugin}.yml") if @file_wrapper.exist?( config_plugin_path ) @config_plugins << {:plugin => plugin, :path => config_plugin_path} end end end return @config_plugins end |
#find_plugin_hash_defaults(config, plugin_paths) ⇒ Object
Gather up and return defaults generated by Ruby code in plugin paths + config/
146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/ceedling/configurator_plugins.rb', line 146 def find_plugin_hash_defaults(config, plugin_paths) defaults_hash = {} config[:plugins][:enabled].each do |plugin| if path = plugin_paths[(plugin + '_path').to_sym] default_path = File.join(path, "config", "defaults_#{plugin}.rb") if @file_wrapper.exist?( default_path ) @system_wrapper.require_file( "defaults_#{plugin}.rb" ) object = eval("get_default_config()") defaults_hash[plugin.to_sym()] = object @plugin_hash_defaults << plugin end end end return defaults_hash end |
#find_plugin_yml_defaults(config, plugin_paths) ⇒ Object
Gather up and return default .yml filepaths that exist on-disk
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/ceedling/configurator_plugins.rb', line 128 def find_plugin_yml_defaults(config, plugin_paths) defaults_with_path = {} config[:plugins][:enabled].each do |plugin| if path = plugin_paths[(plugin + '_path').to_sym] default_path = File.join(path, 'config', 'defaults.yml') if @file_wrapper.exist?( default_path ) defaults_with_path[plugin.to_sym] = default_path @plugin_yml_defaults << plugin end end end return defaults_with_path end |
#find_programmatic_plugins(config, plugin_paths) ⇒ Object
Gather up names of .rb ‘Plugin` subclasses and root paths that exist in plugin paths + lib/
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/ceedling/configurator_plugins.rb', line 91 def find_programmatic_plugins(config, plugin_paths) @programmatic_plugins = [] config[:plugins][:enabled].each do |plugin| if path = plugin_paths[(plugin + '_path').to_sym] plugin_path = File.join( path, "lib", "#{plugin}.rb" ) if @file_wrapper.exist?( plugin_path ) @programmatic_plugins << {:plugin => plugin, :root_path => path} end end end return @programmatic_plugins end |
#find_rake_plugins(config, plugin_paths) ⇒ Object
Gather up and return .rake filepaths that exist in plugin paths
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 |
# File 'lib/ceedling/configurator_plugins.rb', line 73 def find_rake_plugins(config, plugin_paths) @rake_plugins = [] plugins_with_path = [] config[:plugins][:enabled].each do |plugin| if path = plugin_paths[(plugin + '_path').to_sym] rake_plugin_path = File.join(path, "#{plugin}.rake") if @file_wrapper.exist?( rake_plugin_path ) @rake_plugins << {:plugin => plugin, :path => rake_plugin_path} end end end return @rake_plugins end |
#inspect ⇒ Object
Override to prevent exception handling from walking & stringifying the object variables. Object variables are gigantic and produce a flood of output.
27 28 29 30 |
# File 'lib/ceedling/configurator_plugins.rb', line 27 def inspect # TODO: When identifying information is added to constructor, insert it into `inspect()` string return this.class.name end |
#process_aux_load_paths(config) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/ceedling/configurator_plugins.rb', line 33 def process_aux_load_paths(config) plugin_paths = {} # Add any base load path to Ruby's load path collection config[:plugins][:load_paths].each do |path| @system_wrapper.add_load_path( path ) end # If a load path contains an actual Ceedling plugin, load its subdirectories by convention config[:plugins][:enabled].each do |plugin| config[:plugins][:load_paths].each do |root| path = File.join(root, plugin) # Ceedling Ruby-based hash defaults plugin (or config for Ceedling programmatic plugin) is_config_plugin = ( not @file_wrapper.directory_listing( File.join( path, 'config', '*.rb' ) ).empty? ) # Ceedling programmatic plugin is_programmatic_plugin = ( not @file_wrapper.directory_listing( File.join( path, 'lib', '*.rb' ) ).empty? ) # Ceedling Rake plugin is_rake_plugin = ( not @file_wrapper.directory_listing( File.join( path, '*.rake' ) ).empty? ) if (is_config_plugin or is_programmatic_plugin or is_rake_plugin) plugin_paths[(plugin + '_path').to_sym] = path # Add paths to Ruby load paths that contain *.rb files @system_wrapper.add_load_path( File.join( path, 'config') ) if is_config_plugin @system_wrapper.add_load_path( File.join( path, 'lib') ) if is_programmatic_plugin # We found load_path/ + <plugin>/ path that exists, skip ahead break end end end return plugin_paths end |
#setup ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/ceedling/configurator_plugins.rb', line 16 def setup @rake_plugins = [] @programmatic_plugins = [] @config_plugins = [] @plugin_yml_defaults = [] @plugin_hash_defaults = [] end |