2014-07-14 11:31:34 +00:00
|
|
|
require 'yaml'
|
|
|
|
require 'erb'
|
|
|
|
module Hashie
|
|
|
|
module Extensions
|
|
|
|
module Parsers
|
|
|
|
class YamlErbParser
|
|
|
|
def initialize(file_path)
|
|
|
|
@content = File.read(file_path)
|
2014-09-16 08:49:23 +00:00
|
|
|
@file_path = file_path
|
2014-07-14 11:31:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def perform
|
2014-09-16 08:49:23 +00:00
|
|
|
template = ERB.new(@content)
|
|
|
|
template.filename = @file_path
|
|
|
|
YAML.load template.result
|
2014-07-14 11:31:34 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def self.perform(file_path)
|
|
|
|
new(file_path).perform
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|