lib/ruboclean/rubocop_configuration_path.rb in ruboclean-0.2.1 vs lib/ruboclean/rubocop_configuration_path.rb in ruboclean-0.3.0

- old
+ new

@@ -1,13 +1,15 @@ # frozen_string_literal: true -require 'pathname' -require 'yaml' +require "pathname" +require "yaml" module Ruboclean # Interface for reading and writing the `.rubocop.yml` file class RubocopConfigurationPath + PERMITTED_CLASSED = [Regexp].freeze + # Thrown if given path is invalid class InvalidPathError < StandardError def initialize(path) super "path does not exist: '#{path}'" end @@ -15,11 +17,11 @@ def initialize(path) input_path = Pathname.new(path) @rubocop_configuration_path = if input_path.directory? - input_path.join('.rubocop.yml') + input_path.join(".rubocop.yml") else input_path end raise InvalidPathError, @rubocop_configuration_path unless @rubocop_configuration_path.exist? @@ -39,9 +41,9 @@ def sanitize_yaml(data) data.gsub(/^([a-zA-Z]+)/, "\n\\1") end def load_yaml - YAML.safe_load(@rubocop_configuration_path.read) + YAML.safe_load(@rubocop_configuration_path.read, permitted_classes: PERMITTED_CLASSED) end end end