Class: Yardstick::RuleConfig

Inherits:
Object
  • Object
show all
Defined in:
lib/yardstick/rule_config.rb

Overview

Config class for rules

It is used to check if document should be validated or not.

Constant Summary collapse

METHOD_SEPARATOR =
/\#|\./.freeze

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Yardstick::RuleConfig

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Initializes new instance of rule config

Parameters:

  • options (Hash) (defaults to: {})

    optional configuration



19
20
21
22
# File 'lib/yardstick/rule_config.rb', line 19

def initialize(options = {})
  @enabled = options.fetch(:enabled, true)
  @exclude = options.fetch(:exclude, [])
end

Instance Method Details

#enabled_for_path?(path) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Checks if given path should be checked using this rule

Parameters:

  • path (String)

    document path, e.g “Foo::Bar#baz”

Returns:

  • (Boolean)

    true if path should be checked



33
34
35
# File 'lib/yardstick/rule_config.rb', line 33

def enabled_for_path?(path)
  @enabled && !exclude?(path)
end