Changeset 413
- Timestamp:
- May 22, 2010, 12:57:55 PM (14 years ago)
- Location:
- ruby/trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
ruby/trunk/config/environment.rb
r297 r413 6 6 7 7 # Specifies gem version of Rails to use when vendor/rails is not present 8 #RAILS_GEM_VERSION = '2. 1.0' unless defined? RAILS_GEM_VERSION8 #RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION 9 9 10 10 # Bootstrap the Rails environment, frameworks, and default configuration -
ruby/trunk/lib/open_ehr/serializer.rb
r412 r413 121 121 end 122 122 123 def envelope124 end125 126 123 def merge 127 return header + description + definition+ ontology124 return header + NL + description + NL + definition + NL + ontology 128 125 end 129 126 … … 138 135 139 136 class XMLSerializer < BaseSerializer 140 141 137 def header 142 138 header = '' … … 216 212 xml.node_id ad.node_id 217 213 end 214 return definition 215 end 216 217 def ontology 218 ontology = '' 219 ao = @archetype.ontology 220 xml = Builder::XmlMarkup.new(:indent => 2, :target => ontology) 221 xml.ontology do 222 xml.specialisation_depth ao.specialisation_depth 223 xml.term_definitions do 224 ao.term_definitions.each do |lang, terms| 225 xml.language lang 226 xml.terms do 227 terms.each do |term| 228 xml.code term.code 229 xml.items do 230 term.items.each do |key, value| 231 xml.item do 232 xml.key key 233 xml.value value 234 end 235 end 236 end 237 end 238 end 239 end 240 end 241 end 218 242 end 219 243 220 244 def merge 221 245 archetype = "<?xml version='1.0' encoding='UTF-8'?>" + NL + 246 "<archetype xmlns=\"http://schemas.openehr.org/v1\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">" + NL + 247 header + description + definition + 248 ontology + '</archetype>' 249 return archetype 222 250 end 223 251 end -
ruby/trunk/spec/lib/open_ehr/serializer/openEHR-EHR-SECTION.test.v1.xml
r410 r413 1 <?xml version= "1.0" encoding="UTF-8"?>1 <?xml version='1.0' encoding='UTF-8'?> 2 2 <archetype xmlns="http://schemas.openehr.org/v1" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 3 3 <archetype_id> -
ruby/trunk/spec/lib/open_ehr/serializer/xml_serializer_spec.rb
r410 r413 19 19 @sample_description = xml.unindent(12, 27, 2) 20 20 @sample_definition = xml.unindent(28, 37, 2) 21 @sample_ontology = xml.unindent(38, 56, 2) 22 @sample_xml = xml.join 21 23 xml_file.close 22 24 end … … 42 44 end 43 45 44 def unindent(lines,n) 45 return lines.collect{|line| line[n..-1]}.join 46 it 'should return XML formatted ontology' do 47 @xml_serializer.ontology.should == @sample_ontology 48 end 49 50 it 'should equal sample hash' do 51 hashed_xml = Hash.from_xml @xml_serializer.serialize 52 archetype_hash = hashed_xml['archetype'] 53 hashed_sample = Hash.from_xml @sample_xml 54 sample_hash = hashed_sample['archetype'] 55 archetype_hash.should be_eql sample_hash 46 56 end 47 57 end
Note:
See TracChangeset
for help on using the changeset viewer.