class ERBLint::LinterConfig
Public Class Methods
array_of?(klass)
click to toggle source
# File lib/erb_lint/linter_config.rb, line 13 def array_of?(klass) lambda { |value| value.is_a?(Array) && value.all? { |s| s.is_a?(klass) } } end
new(config = {})
click to toggle source
Calls superclass method
# File lib/erb_lint/linter_config.rb, line 25 def initialize(config = {}) config = config.dup.deep_stringify_keys allowed_keys = self.class.properties.keys.map(&:to_s) given_keys = config.keys if (extra_keys = given_keys - allowed_keys).any? raise Error, "Given key is not allowed: #{extra_keys.join(", ")}" end super(config) rescue SmartProperties::InitializationError => e raise Error, "The following properties are required to be set: #{e.properties}" rescue SmartProperties::InvalidValueError => e raise Error, e.message end
to_array_of(klass)
click to toggle source
# File lib/erb_lint/linter_config.rb, line 17 def to_array_of(klass) lambda { |entries| entries.map { |entry| klass.new(entry) } } end
Public Instance Methods
[](name)
click to toggle source
Calls superclass method
# File lib/erb_lint/linter_config.rb, line 39 def [](name) unless self.class.properties.key?(name) raise Error, "No such property: #{name}" end super end
excludes_file?(filename)
click to toggle source
# File lib/erb_lint/linter_config.rb, line 54 def excludes_file?(filename) exclude.any? do |path| File.fnmatch?(path, filename) end end
to_hash()
click to toggle source
# File lib/erb_lint/linter_config.rb, line 46 def to_hash {}.tap do |hash| self.class.properties.to_hash.each_key do |key| hash[key.to_s] = self[key] end end end