Sha256: 5d7324fab0a19ddadbb27435bb2842a53620c4df37934d41989f4e296b1b52ec
Contents?: true
Size: 968 Bytes
Versions: 1
Compression:
Stored size: 968 Bytes
Contents
module JavaProperties module Generating # This module allows generating the content of a properties file # base on a {Properties} object (or any other hash like structure) # # @example # Generator.generate({:item => "something ה"}) => "item=something \u05d4" # module Generator # Character used for key-value separation # @return [String] KEY_VALUE_SEPARATOR = '=' # Generates a properties file content based on a hash # @param properties [Properties] or simple hash # @return [String] def self.generate(properties) lines = [] properties.each do |key, value| lines << build_line(key, value) end lines.join("\n") end private def self.build_line(key, value = '') Encoding.encode!(key.to_s.dup) + KEY_VALUE_SEPARATOR + Encoding.encode!(value.to_s.dup, Encoding::SKIP_SEPARATORS) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
java-properties-0.0.1 | lib/java-properties/generating/generator.rb |