multiple contacts

This commit is contained in:
John Bintz 2011-03-11 13:37:23 -05:00
parent efff98eb32
commit b11d2813cd
5 changed files with 82 additions and 19 deletions

View File

@ -24,5 +24,9 @@ module AVM
def to_creator_list_element def to_creator_list_element
%{<rdf:li>#{self.name}</rdf:li>} %{<rdf:li>#{self.name}</rdf:li>}
end end
def primary?
@primary
end
end end
end end

View File

@ -85,12 +85,14 @@ module AVM
IPTC_CORE_FIELDS_AND_NAMES.each do |key, element_name| IPTC_CORE_FIELDS_AND_NAMES.each do |key, element_name|
if node = refs[:iptc].at_xpath("//Iptc4xmpCore:#{element_name}") if node = refs[:iptc].at_xpath("//Iptc4xmpCore:#{element_name}")
contacts.first[key] = node.text.strip contacts.each { |contact| contact[key] = node.text.strip }
end end
end end
end end
@contacts = contacts.collect { |contact| Contact.new(contact) } if !(@contacts = contacts.collect { |contact| Contact.new(contact) }).empty?
@contacts.first.primary = true
end
end end
def primary_contact def primary_contact

View File

@ -108,18 +108,7 @@ describe AVM::Creator do
its('creator.length') { should == 1 } its('creator.length') { should == 1 }
context 'creator one' do def self.field_checks
subject { image.creator[0] }
let(:name) { 'John Bintz' }
let(:email) { 'bintz@stsci.edu' }
let(:telephone) { '800-555-1234' }
let(:address) { '3700 San Martin Drive' }
let(:city) { 'Baltimore' }
let(:state) { 'Maryland' }
let(:zip) { '21218' }
let(:country) { 'USA' }
its(:name) { should == name } its(:name) { should == name }
its(:address) { should == address } its(:address) { should == address }
its(:city) { should == city } its(:city) { should == city }
@ -129,10 +118,54 @@ describe AVM::Creator do
its(:email) { should == email } its(:email) { should == email }
its(:telephone) { should == telephone } its(:telephone) { should == telephone }
end end
end
context 'two creators' do let(:name) { 'John Bintz' }
let(:file_path) { 'spec/sample_files/creator/two_creators.xmp' } let(:email) { 'bintz@stsci.edu' }
let(:telephone) { '800-555-1234' }
let(:address) { '3700 San Martin Drive' }
let(:city) { 'Baltimore' }
let(:state) { 'Maryland' }
let(:zip) { '21218' }
let(:country) { 'USA' }
context 'creator one' do
subject { image.creator[0] }
field_checks
it { should be_primary }
end
context 'two creators' do
let(:file_path) { 'spec/sample_files/creator/two_creators.xmp' }
its('creator.length') { should == 2 }
context 'first creator' do
subject { image.creator[0] }
field_checks
it { should be_primary }
end
context 'second creator' do
subject { image.creator[1] }
field_checks
it { should_not be_primary }
let(:name) { 'Aohn Bintz' }
let(:email) { 'aohn@stsci.edu' }
let(:telephone) { '800-555-2345' }
let(:address) { '3700 San Martin Drive' }
let(:city) { 'Baltimore' }
let(:state) { 'Maryland' }
let(:zip) { '21218' }
let(:country) { 'USA' }
end
end
end end
end end

View File

@ -21,5 +21,3 @@
</rdf:Description> </rdf:Description>
</rdf:RDF> </rdf:RDF>
</x:xmpmeta> </x:xmpmeta>

View File

@ -0,0 +1,26 @@
<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:creator>
<rdf:Seq>
<rdf:li>John Bintz</rdf:li>
<rdf:li>Aohn Bintz</rdf:li>
</rdf:Seq>
</dc:creator>
</rdf:Description>
<rdf:Description rdf:about=""
xmlns:Iptc4xmpCore="http://iptc.org/std/Iptc4xmpCore/1.0/xmlns/">
<Iptc4xmpCore:CreatorContactInfo rdf:parseType="Resource">
<Iptc4xmpCore:CiAdrExtadr>3700 San Martin Drive</Iptc4xmpCore:CiAdrExtadr>
<Iptc4xmpCore:CiAdrCity>Baltimore</Iptc4xmpCore:CiAdrCity>
<Iptc4xmpCore:CiAdrRegion>Maryland</Iptc4xmpCore:CiAdrRegion>
<Iptc4xmpCore:CiAdrPcode>21218</Iptc4xmpCore:CiAdrPcode>
<Iptc4xmpCore:CiAdrCtry>USA</Iptc4xmpCore:CiAdrCtry>
<Iptc4xmpCore:CiTelWork>800-555-1234,800-555-2345</Iptc4xmpCore:CiTelWork>
<Iptc4xmpCore:CiEmailWork>bintz@stsci.edu,aohn@stsci.edu</Iptc4xmpCore:CiEmailWork>
<Iptc4xmpCore:CiUrlWork>http://hubblesite.org</Iptc4xmpCore:CiUrlWork>
</Iptc4xmpCore:CreatorContactInfo>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>