Module: PluginManagerHelpers

Included in:
PluginManagerCliInstall, PluginManagerCliList, PluginManagerCliSearch, PluginManagerCliUninstall, PluginManagerCliUpdate
Defined in:
lib/plugins/inspec-plugin-manager-cli/test/functional/helper.rb

Instance Method Summary collapse

Instance Method Details

#clear_empty_config_dirObject



30
31
32
33
34
35
36
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/helper.rb', line 30

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



24
25
26
27
28
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/helper.rb', line 24

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



18
19
20
21
22
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/helper.rb', line 18

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



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/helper.rb', line 38

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

#teardownObject



59
60
61
# File 'lib/plugins/inspec-plugin-manager-cli/test/functional/helper.rb', line 59

def teardown
  clear_empty_config_dir
end