Class: ConfiguratorPlugins
- Defined in:
- lib/ceedling/configurator_plugins.rb
Instance Attribute Summary collapse
-
#rake_plugins ⇒ Object
readonly
Returns the value of attribute rake_plugins.
-
#script_plugins ⇒ Object
readonly
Returns the value of attribute script_plugins.
Instance Method Summary collapse
- #add_load_paths(config) ⇒ Object
-
#find_config_plugins(config, plugin_paths) ⇒ Object
gather up and return configuration .yml filepaths that exist on-disk.
-
#find_plugin_hash_defaults(config, plugin_paths) ⇒ Object
gather up and return.
-
#find_plugin_yml_defaults(config, plugin_paths) ⇒ Object
gather up and return default .yml filepaths that exist on-disk.
-
#find_rake_plugins(config, plugin_paths) ⇒ Object
gather up and return .rake filepaths that exist on-disk.
-
#find_script_plugins(config, plugin_paths) ⇒ Object
gather up and return just names of .rb classes that exist on-disk.
- #setup ⇒ Object
Instance Attribute Details
#rake_plugins ⇒ Object (readonly)
Returns the value of attribute rake_plugins.
6 7 8 |
# File 'lib/ceedling/configurator_plugins.rb', line 6 def rake_plugins @rake_plugins end |
#script_plugins ⇒ Object (readonly)
Returns the value of attribute script_plugins.
6 7 8 |
# File 'lib/ceedling/configurator_plugins.rb', line 6 def script_plugins @script_plugins end |
Instance Method Details
#add_load_paths(config) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/ceedling/configurator_plugins.rb', line 14 def add_load_paths(config) plugin_paths = {} config[:plugins][:enabled].each do |plugin| config[:plugins][:load_paths].each do |root| path = File.join(root, plugin) is_script_plugin = ( not @file_wrapper.directory_listing( File.join( path, 'lib', '*.rb' ) ).empty? ) is_rake_plugin = ( not @file_wrapper.directory_listing( File.join( path, '*.rake' ) ).empty? ) if is_script_plugin or is_rake_plugin plugin_paths[(plugin + '_path').to_sym] = path if is_script_plugin @system_wrapper.add_load_path( File.join( path, 'lib') ) @system_wrapper.add_load_path( File.join( path, 'config') ) end break end end end return plugin_paths end |
#find_config_plugins(config, plugin_paths) ⇒ Object
gather up and return configuration .yml filepaths that exist on-disk
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/ceedling/configurator_plugins.rb', line 78 def find_config_plugins(config, plugin_paths) 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) plugins_with_path << config_plugin_path end end end return plugins_with_path end |
#find_plugin_hash_defaults(config, plugin_paths) ⇒ Object
gather up and return
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/ceedling/configurator_plugins.rb', line 113 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 << object 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
96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/ceedling/configurator_plugins.rb', line 96 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 << default_path end end end return defaults_with_path end |
#find_rake_plugins(config, plugin_paths) ⇒ Object
gather up and return .rake filepaths that exist on-disk
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/ceedling/configurator_plugins.rb', line 41 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)) plugins_with_path << rake_plugin_path @rake_plugins << plugin end end end return plugins_with_path end |
#find_script_plugins(config, plugin_paths) ⇒ Object
gather up and return just names of .rb classes that exist on-disk
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/ceedling/configurator_plugins.rb', line 60 def find_script_plugins(config, plugin_paths) @script_plugins = [] config[:plugins][:enabled].each do |plugin| if path = plugin_paths[(plugin + '_path').to_sym] script_plugin_path = File.join(path, "lib", "#{plugin}.rb") if @file_wrapper.exist?(script_plugin_path) @script_plugins << plugin end end end return @script_plugins end |
#setup ⇒ Object
8 9 10 11 |
# File 'lib/ceedling/configurator_plugins.rb', line 8 def setup @rake_plugins = [] @script_plugins = [] end |