Class: CsvCop::ConfigLoader
- Inherits:
-
Object
- Object
- CsvCop::ConfigLoader
- Defined in:
- lib/csvcop/config_loader.rb
Constant Summary collapse
- DOTFILE =
'.csvcop.yml'
- CSVCOP_HOME =
File.realpath(File.join(File.dirname(__FILE__), '..', '..'))
- DEFAULT_FILE =
File.join(CSVCOP_HOME, 'config', 'default.yml')
Instance Method Summary collapse
-
#initialize(rule_file_path = nil) ⇒ ConfigLoader
constructor
A new instance of ConfigLoader.
- #load ⇒ Object
Constructor Details
#initialize(rule_file_path = nil) ⇒ ConfigLoader
Returns a new instance of ConfigLoader.
12 13 14 15 16 17 18 |
# File 'lib/csvcop/config_loader.rb', line 12 def initialize(rule_file_path=nil) unless rule_file_path.nil? raise ConfigNotFoundError unless File.exist?(rule_file_path) @original_rule = YAML.load_file(rule_file_path) end @rule = YAML.load_file(DEFAULT_FILE) end |
Instance Method Details
#load ⇒ Object
20 21 22 23 |
# File 'lib/csvcop/config_loader.rb', line 20 def load return @rule if @original_rule.nil? merge_yaml(@rule, @original_rule) end |