class Matterhorn::JavaProperties

Matterhorn::JavaProperties ===

Public Class Methods

generate_xml(hash, options = {}) click to toggle source
# File lib/matterhorn/java_properties.rb, line 19
def self.generate_xml(hash, options = {})
  Nokogiri::XML::Builder.new(:encoding => 'UTF-8') do |xml|
    xml.doc.create_internal_subset('properties', nil, 'http://java.sun.com/dtd/properties.dtd')
    xml.properties do
      xml.comment_(options[:comment])    unless options[:comment].nil?
      hash.each_pair do |key, value|
        if options[:cdata] && options[:cdata].include?(key)
          xml.entry(:key => key) do
            xml.cdata(value)
          end
        else
          xml.entry(value, :key => key)
        end
      end
    end
  end.doc.to_xml
end
write(hash, path, options = {}) click to toggle source

———————————————————————————– methodes —

# File lib/matterhorn/java_properties.rb, line 13
def self.write(hash, path, options = {})
  xml = generate_xml(hash, options)
  File.write(path, generate_xml(hash, options))
end