class Helpers
Public Class Methods
get_module_name()
click to toggle source
@return [String] - the name of the module
# File lib/retrospec/plugins/v1/plugin/helpers.rb, line 6 def self.get_module_name module_name = nil Dir['manifests/*.pp'].entries.each do |manifest| module_name = get_module_name_from_file(manifest) break unless module_name.nil? end module_name end
get_module_name_from_file(file)
click to toggle source
@param file [String] - the initial manifest file that contains the name of the module @return [String] - the name of the module
# File lib/retrospec/plugins/v1/plugin/helpers.rb, line 17 def self.get_module_name_from_file(file) p = Puppet::Parser::Lexer.new module_name = nil p.string = File.read(file) tokens = p.fullscan i = tokens.index { |token| [:CLASS, :DEFINE].include? token.first } module_name = tokens[i + 1].last[:value].split('::').first unless i.nil? module_name end
is_module_dir?(dir)
click to toggle source
@param dir [String] - the module dir @return [Boolean] - true if the module contains a manifests directory
# File lib/retrospec/plugins/v1/plugin/helpers.rb, line 31 def self.is_module_dir?(dir) Dir[File.join(dir, '*')].entries.include? 'manifests' end