Module: PluginManagerHelpers
- Included in:
- PluginManagerCliInstall, PluginManagerCliList, PluginManagerCliSearch, PluginManagerCliUninstall, PluginManagerCliUpdate
- Defined in:
- lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb
Overview
—————————————————————————————–#
utilities
—————————————————————————————–#
Instance Method Summary collapse
- #clear_empty_config_dir ⇒ Object
- #copy_in_core_config_dir(fixture_name, dest = nil) ⇒ Object
- #copy_in_project_config_dir(fixture_name, dest = nil) ⇒ Object
- #parse_plugin_list_lines(stdout) ⇒ Object
- #teardown ⇒ Object
Instance Method Details
#clear_empty_config_dir ⇒ Object
36 37 38 39 40 41 42 |
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 36 def clear_empty_config_dir Dir.glob(File.join(project_config_dirs_path, "empty", "*")).each do |path| next if path.end_with? ".gitkeep" FileUtils.rm_rf(path) end end |
#copy_in_core_config_dir(fixture_name, dest = nil) ⇒ Object
30 31 32 33 34 |
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 30 def copy_in_core_config_dir(fixture_name, dest = nil) src = Dir.glob(File.join(core_config_dir_path, fixture_name, "*")) dest ||= File.join(project_config_dirs_path, "empty") src.each { |path| FileUtils.cp_r(path, dest) } end |
#copy_in_project_config_dir(fixture_name, dest = nil) ⇒ Object
24 25 26 27 28 |
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 24 def copy_in_project_config_dir(fixture_name, dest = nil) src = Dir.glob(File.join(project_config_dirs_path, fixture_name, "*")) dest ||= File.join(project_config_dirs_path, "empty") src.each { |path| FileUtils.cp_r(path, dest) } end |
#parse_plugin_list_lines(stdout) ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 44 def parse_plugin_list_lines(stdout) plugins = [] stdout.force_encoding("UTF-8").lines.each do |line| next if line.strip.empty? next if line.include? "─────" # This is some unicode glyphiness next if line.include? "Plugin Name" next if line.include? "plugin(s) total" parts = line.split(/│/u).map(&:strip!).compact plugins << { name: parts[0], version: parts[1], type: parts[2], generation: parts[3], raw: line, } end plugins end |
#teardown ⇒ Object
65 66 67 |
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/inspec-plugin_test.rb', line 65 def teardown clear_empty_config_dir end |