lib/inspec/plugin/v2/config_file.rb in inspec-4.7.3 vs lib/inspec/plugin/v2/config_file.rb in inspec-4.7.18

- old
+ new

@@ -55,10 +55,11 @@ # Removes an entry specified by plugin name. def remove_entry(name) unless existing_entry?(name) raise Inspec::Plugin::V2::ConfigError, "No such entry with plugin name '#{name}'" end + @data[:plugins].delete_if { |entry| entry[:name] == name.to_sym } end # Save the file to disk as a JSON structure at the path. def save @@ -112,10 +113,11 @@ # Check for duplicates plugin_entries.each_with_index do |other_entry, other_idx| next if idx == other_idx next unless other_entry.is_a? Hash # We'll catch that invalid entry later next if plugin_entry[:name] != other_entry[:name] + indices = [idx, other_idx].sort raise Inspec::Plugin::V2::ConfigError, "Malformed plugins.json file - duplicate plugin entry '#{plugin_entry[:name]}' detected at index #{indices[0]} and #{indices[1]}" end end end @@ -132,12 +134,13 @@ # Symbolize the name. plugin_entry[:name] = plugin_entry[:name].to_sym if plugin_entry.key? :installation_type seen_type = plugin_entry[:installation_type] - unless [:gem, :path].include? seen_type.to_sym + unless %i{gem path}.include? seen_type.to_sym raise Inspec::Plugin::V2::ConfigError, "'plugins' entry with unrecognized installation_type (must be one of 'gem' or 'path')" end + plugin_entry[:installation_type] = seen_type.to_sym if plugin_entry[:installation_type] == :path && !plugin_entry.key?(:installation_path) raise Inspec::Plugin::V2::ConfigError, "'plugins' entry with a 'path' installation_type missing installation path" end