Sha256: e688a892b3fe7d617159827f7240039506bf2ee62d941bd13350dd2a1b24d6e0

Contents?: true

Size: 637 Bytes

Versions: 2

Compression:

Stored size: 637 Bytes

Contents

require 'idiom/base'

module Idiom #:nodoc:
  # Usage: 
  #   Translator::Yaml.new().copy
  #
  class Yaml < Base
    def destination_path(lang=nil)
      "#{source}.tmp"
    end
    
    def after_translation
      system "cat #{destination_path} >> #{source} && rm #{destination_path}"
    end
    
    def extension
      "yml"
    end
    
    def parse(path)
      YAML.load_file(path) || {}
    end
    
    def format(key, value)
      "#{key}: #{value}"
    end
    
    def key_and_value_from_line(line)
      if line =~ /^([^\:]+):(.*)/
        return $1, $2.strip
      else
        return nil, nil
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
idiom-0.4.4 lib/idiom/yaml.rb
idiom-0.4.3 lib/idiom/yaml.rb