Sha256: 1e0a597756a562e16b8a588362c970024fafe631d3f84cf92b67b263ce7c8928

Contents?: true

Size: 704 Bytes

Versions: 4

Compression:

Stored size: 704 Bytes

Contents

module Tolk
  class Export
    attr_reader :name, :data, :destination

    def initialize(args)
      @name = args.fetch(:name, '')
      @data = args.fetch(:data, {})
      @destination = args.fetch(:destination, self.class.dump_path)
    end

    def dump
      File.open("#{destination}/#{name}.yml", "w+") do |file|
        yml = if data.respond_to?(:ya2yaml)
          data.ya2yaml(:syck_compatible => true)
        else
          YAML.dump(data).force_encoding(file.external_encoding.name)
        end
        file.write(yml)
      end
    end

    class << self
      def dump(args)
        new(args).dump
      end

      def dump_path
        Tolk::Locale._dump_path
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
tolk-1.5.2 lib/tolk/export.rb
tolk-1.6.0.alpha1 lib/tolk/export.rb
tolk-1.5.1 lib/tolk/export.rb
tolk-1.5.0 lib/tolk/export.rb