Sha256: 31bc14b4b9ace7dad2641a6497da984527ea68fa2391689354bd007b7436b0d2

Contents?: true

Size: 634 Bytes

Versions: 11

Compression:

Stored size: 634 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

11 entries across 11 versions & 1 rubygems

Version Path
idiom-0.7.3 lib/idiom/yaml.rb
idiom-0.7.2 lib/idiom/yaml.rb
idiom-0.7.1 lib/idiom/yaml.rb
idiom-0.7.0 lib/idiom/yaml.rb
idiom-0.6.0 lib/idiom/yaml.rb
idiom-0.5.5 lib/idiom/yaml.rb
idiom-0.5.4 lib/idiom/yaml.rb
idiom-0.5.3 lib/idiom/yaml.rb
idiom-0.5.2 lib/idiom/yaml.rb
idiom-0.5.1 lib/idiom/yaml.rb
idiom-0.5.0 lib/idiom/yaml.rb