read distances

This commit is contained in:
John Bintz 2011-03-15 11:16:10 -04:00
parent 6695575762
commit eec5743381
5 changed files with 103 additions and 12 deletions

View File

@ -94,14 +94,14 @@ module AVM
end
if node = refs[:avm].at_xpath('./avm:Distance')
list_values = node.search('.//ref:li').collect { |li| li.text }
list_values = node.search('.//rdf:li').collect { |li| li.text }
case list_values.length
when 1
options[:light_years] = list_values.first
when 2
options[:light_years] = (list_values.first == '-') ? nil : list_values.first
options[:redshift] = list_valueslast
options[:redshift] = list_values.last
end
end
end

View File

@ -90,23 +90,27 @@ describe AVM::Image do
has_most_options
its(:redshift) { should be_nil }
its(:light_years) { should == light_years }
end
context "distaince in redshift" do
let(:file_path) { 'spec/sample_files/image/redshift.xmp' }
let(:file_path) { 'spec/sample_files/image/redshift.xmp' }
has_most_options
its(:light_years) { should be_nil }
its(:redshift) { should == redshift }
end
context "distance in both" do
let(:file_path) { 'spec/sample_files/image/both.xmp' }
let(:file_path) { 'spec/sample_files/image/both.xmp' }
has_most_options
end
context "distance in neither" do
let(:file_path) { 'spec/sample_files/image/neither.xmp' }
its(:light_years) { should == light_years }
its(:redshift) { should == redshift }
end
end
end
describe '#to_xml' do

View File

@ -0,0 +1,43 @@
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 4.2.2-c063 53.352624, 2008/07/30-18:05:41 ">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about=""
xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:title>:
<rdf:Alt>
<rdf:li xml:lang="x-default">My title</rdf:li>
</rdf:Alt>
</dc:title>
<dc:description>
<rdf:Alt>
<rdf:li xml:lang="x-default">Description</rdf:li>
</rdf:Alt>
</dc:description>
</rdf:Description>
<rdf:Description rdf:about=""
xmlns:Iptc4xmpCore="http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/">
<Iptc4xmpCore:CreatorContactInfo rdf:parseType="Resource">
</Iptc4xmpCore:CreatorContactInfo>
</rdf:Description>
<rdf:Description rdf:about=""
xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/">
<photoshop:Headline>Headline</photoshop:Headline>
</rdf:Description>
<rdf:Description rdf:about=""
xmlns:avm="http://www.communicatingastronomy.org/avm/1.0/">
<avm:Distance.Notes>Distance Notes</avm:Distance.Notes>
<avm:ReferenceURL>Reference URL</avm:ReferenceURL>
<avm:Credit>Credit</avm:Credit>
<avm:Date>2010-01-01</avm:Date>
<avm:ID>ID</avm:ID>
<avm:Type>Observation</avm:Type>
<avm:Image.ProductQuality>Good</avm:Image.ProductQuality>
<avm:Distance>
<rdf:Seq>
<rdf:li>Light years</rdf:li>
<rdf:li>Redshift</rdf:li>
</rdf:Seq>
</avm:Distance>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>

View File

@ -32,6 +32,7 @@
<avm:ID>ID</avm:ID>
<avm:Type>Observation</avm:Type>
<avm:Image.ProductQuality>Good</avm:Image.ProductQuality>
<avm:Distance><rdf:Seq><rdf:li>Light years</rdf:li></rdf:Seq></avm:Distance>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>

View File

@ -0,0 +1,43 @@
<x:xmpmeta xmlns:x="adobe:ns:meta/" x:xmptk="Adobe XMP Core 4.2.2-c063 53.352624, 2008/07/30-18:05:41 ">
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
<rdf:Description rdf:about=""
xmlns:dc="http://purl.org/dc/elements/1.1/">
<dc:title>:
<rdf:Alt>
<rdf:li xml:lang="x-default">My title</rdf:li>
</rdf:Alt>
</dc:title>
<dc:description>
<rdf:Alt>
<rdf:li xml:lang="x-default">Description</rdf:li>
</rdf:Alt>
</dc:description>
</rdf:Description>
<rdf:Description rdf:about=""
xmlns:Iptc4xmpCore="http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/">
<Iptc4xmpCore:CreatorContactInfo rdf:parseType="Resource">
</Iptc4xmpCore:CreatorContactInfo>
</rdf:Description>
<rdf:Description rdf:about=""
xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/">
<photoshop:Headline>Headline</photoshop:Headline>
</rdf:Description>
<rdf:Description rdf:about=""
xmlns:avm="http://www.communicatingastronomy.org/avm/1.0/">
<avm:Distance.Notes>Distance Notes</avm:Distance.Notes>
<avm:ReferenceURL>Reference URL</avm:ReferenceURL>
<avm:Credit>Credit</avm:Credit>
<avm:Date>2010-01-01</avm:Date>
<avm:ID>ID</avm:ID>
<avm:Type>Observation</avm:Type>
<avm:Image.ProductQuality>Good</avm:Image.ProductQuality>
<avm:Distance>
<rdf:Seq>
<rdf:li>-</rdf:li>
<rdf:li>Redshift</rdf:li>
</rdf:Seq>
</avm:Distance>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>