Method: Pec::ConfigFile#read_file

Defined in:
lib/pec/config_file.rb

#read_file(file_name) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/pec/config_file.rb', line 16

def read_file(file_name)
  if File.exist?(file_name)
    case
      when file_name.match(/.erb$/)
        erb = ERB.new(File.read(file_name), nil, '%-')
        erb.result
      when file_name.match(/.yaml$/) || file_name.match(/.yml$/)
        File.read(file_name)
      else
        raise "not match file type must be yaml or erb"
    end
  else
    raise " #{file_name} not exiets!"
  end
end