README.md in datacite-mapping-0.1.0 vs README.md in datacite-mapping-0.1.1

- old
+ new

@@ -13,27 +13,29 @@ ```ruby require 'datacite/mapping' include Datacite::Mapping -xml_text = File.read('resource.xml') -resource = Resource.load_from_xml(xml.root) -creators = resource.creators -citation = '' -citation << creators.map(&:name).join('; ') -citation << ' ' -citation << "(#{resource.publication_year})" -citation << ': ' -title = resource.titles[0].value -citation << title -citation << (title.end_with?('.') ? ' ' : '. ') -citation << resource.publisher +File.open('resource.xml', 'r') do |xml_file| + resource = Resource.parse_xml(xml_file) -puts("Citation: #{citation}") + creators = resource.creators + citation = '' + citation << creators.map(&:name).join('; ') + citation << ' ' + citation << "(#{resource.publication_year})" + citation << ': ' + title = resource.titles[0].value + citation << title + citation << (title.end_with?('.') ? ' ' : '. ') + citation << resource.publisher -abstract = resource.descriptions.find { |d| d.type = DescriptionType::ABSTRACT } -puts("Abstract: #{abstract.value}") + puts("Citation: #{citation}") + + abstract = resource.descriptions.find { |d| d.type = DescriptionType::ABSTRACT } + puts("Abstract: #{abstract.value}") +end ``` Results: ``` @@ -108,13 +110,10 @@ incorrect information).' ) ] ) -xml = resource.save_to_xml -formatter = REXML::Formatters::Pretty.new -formatter.compact = true -formatter.write(xml, $stdout) +puts resource.write_xml ``` Results: ```xml