Class: Matterhorn::JavaProperties
- Inherits:
-
Object
- Object
- Matterhorn::JavaProperties
- Defined in:
- lib/matterhorn/java_properties.rb
Overview
Matterhorn::JavaProperties ===
Class Method Summary collapse
- .generate_xml(hash, options = {}) ⇒ Object
-
.write(hash, path, options = {}) ⇒ Object
———————————————————————————– methodes —.
Class Method Details
.generate_xml(hash, options = {}) ⇒ Object
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/matterhorn/java_properties.rb', line 19 def self.generate_xml(hash, = {}) 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_([:comment]) unless [:comment].nil? hash.each_pair do |key, value| if [:cdata] && [: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 = {}) ⇒ Object
———————————————————————————– methodes —
13 14 15 16 |
# File 'lib/matterhorn/java_properties.rb', line 13 def self.write(hash, path, = {}) xml = generate_xml(hash, ) File.write(path, generate_xml(hash, )) end |