Sha256: b82c84ef618f1df00bfd504ce97a4840fdce655b7ba4bc648da3d851c869ffeb

Contents?: true

Size: 900 Bytes

Versions: 6

Compression:

Stored size: 900 Bytes

Contents

require 'erb'

module Xcmultilingual
  class Writer
    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]" if @verbose

      if !File.exist?("#{@destination}")
        puts "There is no destination file." if @verbose
        puts "\n+ FAILED UPDATING\n" if @verbose
        exit 2
      end

      File.open("#{@destination}", "w") do |file|
        path = File.expand_path(@template_path)
        body = ERB.new(File.open(path).read, nil, '-').result(binding)
        file.write(body)
      end
      puts "[END UPDATING]" if @verbose
    end

    private

    def template_path()
      File.dirname(__FILE__) + '/templates/swift.erb'
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
xcmultilingual-0.3.1 lib/xcmultilingual/writer.rb
xcmultilingual-0.3.0 lib/xcmultilingual/writer.rb
xcmultilingual-0.2.3 lib/xcmultilingual/writer.rb
xcmultilingual-0.2.2 lib/xcmultilingual/writer.rb
xcmultilingual-0.2.1 lib/xcmultilingual/writer.rb
xcmultilingual-0.2.0 lib/xcmultilingual/writer.rb