lib/xcmultilingual/writer.rb in xcmultilingual-0.1.1 vs lib/xcmultilingual/writer.rb in xcmultilingual-0.1.2

- old
+ new

@@ -1,14 +1,15 @@ require 'erb' module Xcmultilingual class Writer - attr_accessor :name, :verbose + attr_accessor :name, :template_path, :verbose def initialize(destination, bundle_data) @destination = destination @bundle_data = bundle_data + @template_path = template_path() @filename = File.basename(@destination) end def write puts "+ START UPDATING\n\n" if @verbose @@ -18,23 +19,19 @@ puts "\n+ FAILED UPDATING\n" if @verbose return end File.open("#{@destination}", "w") do |file| - template_file = templates_file(default_templates_dir) - body = ERB.new(File.open(template_file).read, nil, '-').result(binding) + path = File.expand_path(@template_path) + body = ERB.new(File.open(path).read, nil, '-').result(binding) file.write(body) end puts "+ END UPDATING\n\n" if @verbose end private - def default_templates_dir - File.dirname(__FILE__) + '/templates' - end - - def templates_file(dir) - dir + "/swift.erb" + def template_path() + File.dirname(__FILE__) + '/templates/swift.erb' end end end