Class: Bolt::Module
- Inherits:
-
Object
- Object
- Bolt::Module
- Defined in:
- lib/bolt/module.rb
Constant Summary collapse
- CONTENT_NAME_REGEX =
/\A[a-z][a-z0-9_]*(::[a-z][a-z0-9_]*)*\z/.freeze
- MODULE_NAME_REGEX =
/\A[a-z][a-z0-9_]*\z/.freeze
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(name, path) ⇒ Module
constructor
A new instance of Module.
- #plugin? ⇒ Boolean
- #plugin_data_file ⇒ Object
Constructor Details
#initialize(name, path) ⇒ Module
Returns a new instance of Module.
35 36 37 38 |
# File 'lib/bolt/module.rb', line 35 def initialize(name, path) @name = name @path = path end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
33 34 35 |
# File 'lib/bolt/module.rb', line 33 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
33 34 35 |
# File 'lib/bolt/module.rb', line 33 def path @path end |
Class Method Details
.discover(modulepath, project) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/bolt/module.rb', line 9 def self.discover(modulepath, project) mods = {} if project.load_as_module? mods[project.name] = Bolt::Module.new(project.name, project.path.to_s) end modulepath.each do |path| next unless File.exist?(path) && File.directory?(path) Dir.children(path) .map { |dir| File.join(path, dir) } .select { |dir| File.directory?(dir) } .each do |dir| module_name = File.basename(dir) if module_name =~ MODULE_NAME_REGEX # Puppet will load some objects from shadowed modules but this won't mods[module_name] ||= Bolt::Module.new(module_name, dir) end end end mods end |
Instance Method Details
#plugin? ⇒ Boolean
44 45 46 47 48 49 50 51 52 |
# File 'lib/bolt/module.rb', line 44 def plugin? if File.exist?(File.join(path, 'bolt-plugin.json')) msg = "Found bolt-plugin.json in module #{name} at #{path}. Bolt looks for " \ "bolt_plugin.json to determine if the module contains plugins. " \ "Rename the file for Bolt to recognize it." Bolt::Logger.warn_once('plugin_file_name', msg) end File.exist?(plugin_data_file) end |
#plugin_data_file ⇒ Object
40 41 42 |
# File 'lib/bolt/module.rb', line 40 def plugin_data_file File.join(path, 'bolt_plugin.json') end |