lib/csv2hash/yaml_loader.rb in csv2hash-0.6.3 vs lib/csv2hash/yaml_loader.rb in csv2hash-0.6.4

- old
+ new

@@ -6,11 +6,11 @@ attr_reader :conf attr_accessor :definition def initialize file - @conf = YAML.load_file(file) + @conf = load_config_file file self.conf.deep_symbolize_keys! end def load! mapping = self.conf.fetch(:mapping) @@ -27,7 +27,18 @@ definition.cells << Cell.new(rule) end Main[self.conf.fetch(:name)] = self.definition end + + private + + def load_config_file file + if file.to_s =~ /(?<ext>\.erb\.)/ + YAML.load(ERB.new(File.read(file)).result) + else + YAML.load_file(file) + end + end + end end