lib/pelusa/configuration.rb in pelusa-0.1.1 vs lib/pelusa/configuration.rb in pelusa-0.2.0
- old
+ new
@@ -2,34 +2,26 @@
# Public: Class providing configuration for the runner and lints
#
# Examples
#
# configuration = Pelusa::Configuration.new('my_pelusa_config.yml')
- # configuration.present? # => true
#
class Configuration
- YAML_PATH = './.pelusa.yml'
+ YAML_PATH = './.pelusa.yml'
+ DEFAULT_SOURCES = 'lib/**/*.rb'
# Public: Initializes a configuration instance
#
# yaml_path - optional path to the configuration file
def initialize(yaml_path = YAML_PATH)
- if File.exist?(yaml_path)
- @_configuration = YAML.load_file(yaml_path).freeze
- end
+ @_configuration = if File.exist?(yaml_path)
+ YAML.load_file(yaml_path)
+ else
+ {}
+ end.freeze
end
- # Public: Returns if a custom configuration is present
- #
- # Examples
- #
- # Pelusa.configuration.present? # => true
- #
- def present?
- not @_configuration.nil?
- end
-
# Public: Returns custom configuration for the given lint
#
# Examples
#
# Pelusa.configuration['LineRestriction'] # => {'limit' => 50}
@@ -44,15 +36,10 @@
# Examples
#
# Pelusa.configuration.sources # => lib/**/*.rb
#
def sources
- default = "lib/**/*.rb"
- if present?
- @_configuration.fetch('sources') { default }
- else
- default
- end
+ @_configuration.fetch('sources') { DEFAULT_SOURCES }
end
# Public: Returns an Array of enabled lints
#
# Examples