Class: Pelusa::Configuration
- Inherits:
-
Object
- Object
- Pelusa::Configuration
- Defined in:
- lib/pelusa/configuration.rb
Overview
Public: Class providing configuration for the runner and lints
Examples
configuration = Pelusa::Configuration.new('my_pelusa_config.yml')
Constant Summary collapse
- YAML_PATH =
'./.pelusa.yml'
- DEFAULT_SOURCES =
'lib/**/*.rb'
Instance Method Summary collapse
-
#[](name) ⇒ Object
Public: Returns custom configuration for the given lint.
-
#enabled_lints ⇒ Object
Public: Returns an Array of enabled lints.
-
#initialize(yaml_path = YAML_PATH) ⇒ Configuration
constructor
Public: Initializes a configuration instance.
-
#sources ⇒ Object
Public: Returns path to sources that should be analyzed.
Constructor Details
#initialize(yaml_path = YAML_PATH) ⇒ Configuration
Public: Initializes a configuration instance
yaml_path - optional path to the configuration file
15 16 17 18 19 20 21 |
# File 'lib/pelusa/configuration.rb', line 15 def initialize(yaml_path = YAML_PATH) @_configuration = if File.exist?(yaml_path) YAML.load_file(yaml_path) else {} end.freeze end |
Instance Method Details
#[](name) ⇒ Object
Public: Returns custom configuration for the given lint
Examples
Pelusa.configuration['LineRestriction'] # => {'limit' => 50}
name - the name of the lint
30 31 32 |
# File 'lib/pelusa/configuration.rb', line 30 def [](name) for_lint(name) end |
#enabled_lints ⇒ Object
Public: Returns an Array of enabled lints
Examples
Pelusa.configuration.enabled_lints # => [ Pelusa::Lint::DemeterLaw ]
50 51 52 |
# File 'lib/pelusa/configuration.rb', line 50 def enabled_lints (Lint.all - disabled_lints).uniq end |
#sources ⇒ Object
Public: Returns path to sources that should be analyzed
Examples
Pelusa.configuration.sources # => lib/**/*.rb
40 41 42 |
# File 'lib/pelusa/configuration.rb', line 40 def sources @_configuration.fetch('sources') { DEFAULT_SOURCES } end |