Class: Chutney::Configuration
- Inherits:
-
SimpleDelegator
- Object
- SimpleDelegator
- Chutney::Configuration
- Defined in:
- lib/chutney/configuration.rb
Overview
gherkin_lint configuration object
Instance Attribute Summary collapse
-
#default_configuration_path ⇒ Object
Returns the value of attribute default_configuration_path.
-
#user_configuration_path ⇒ Object
Returns the value of attribute user_configuration_path.
Instance Method Summary collapse
-
#initialize(path) ⇒ Configuration
constructor
A new instance of Configuration.
- #load_configuration ⇒ Object
- #load_user_configuration ⇒ Object
- #quiet! ⇒ Object
- #quiet? ⇒ Boolean
- #using_user_configuration? ⇒ Boolean
Constructor Details
#initialize(path) ⇒ Configuration
Returns a new instance of Configuration.
10 11 12 13 14 15 |
# File 'lib/chutney/configuration.rb', line 10 def initialize(path) @default_configuration_path = path @config = load_configuration || {} load_user_configuration super(@config) end |
Instance Attribute Details
#default_configuration_path ⇒ Object
Returns the value of attribute default_configuration_path.
8 9 10 |
# File 'lib/chutney/configuration.rb', line 8 def default_configuration_path @default_configuration_path end |
#user_configuration_path ⇒ Object
Returns the value of attribute user_configuration_path.
8 9 10 |
# File 'lib/chutney/configuration.rb', line 8 def user_configuration_path @user_configuration_path end |
Instance Method Details
#load_configuration ⇒ Object
17 18 19 |
# File 'lib/chutney/configuration.rb', line 17 def load_configuration YAML.load_file default_configuration_path || '' if default_configuration_path end |
#load_user_configuration ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/chutney/configuration.rb', line 21 def load_user_configuration config_files = ['chutney.yml', '.chutney.yml'].map do |fname| ['.', 'config'].map do |dir| Dir["#{dir}#{File::SEPARATOR}#{fname}"] end end.flatten.compact self.user_configuration_path = config_files.first return unless !user_configuration_path.nil? && File.exist?(user_configuration_path) begin merge_config(user_configuration_path) rescue TypeError unless quiet? warn("Chutney: configuration file `#{user_configuration_path}` is not correctly formatted YAML, " \ 'falling back to gem defaults.') end end end |
#quiet! ⇒ Object
49 50 51 |
# File 'lib/chutney/configuration.rb', line 49 def quiet! @config['quiet'] = true end |
#quiet? ⇒ Boolean
45 46 47 |
# File 'lib/chutney/configuration.rb', line 45 def quiet? @config.fetch('quiet', false) end |
#using_user_configuration? ⇒ Boolean
41 42 43 |
# File 'lib/chutney/configuration.rb', line 41 def using_user_configuration? !user_configuration_path.nil? end |