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
%{<rdf:li>#{self.name}</rdf:li>}
end
def primary?
@primary
end
end
end

View File

@ -85,12 +85,14 @@ module AVM
IPTC_CORE_FIELDS_AND_NAMES.each do |key, 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
@contacts = contacts.collect { |contact| Contact.new(contact) }
if !(@contacts = contacts.collect { |contact| Contact.new(contact) }).empty?
@contacts.first.primary = true
end
end
def primary_contact

View File

@ -108,8 +108,16 @@ describe AVM::Creator do
its('creator.length') { should == 1 }
context 'creator one' do
subject { image.creator[0] }
def self.field_checks
its(:name) { should == name }
its(:address) { should == address }
its(:city) { should == city }
its(:state) { should == state }
its(:zip) { should == zip }
its(:country) { should == country }
its(:email) { should == email }
its(:telephone) { should == telephone }
end
let(:name) { 'John Bintz' }
let(:email) { 'bintz@stsci.edu' }
@ -120,19 +128,44 @@ describe AVM::Creator do
let(:zip) { '21218' }
let(:country) { 'USA' }
its(:name) { should == name }
its(:address) { should == address }
its(:city) { should == city }
its(:state) { should == state }
its(:zip) { should == zip }
its(:country) { should == country }
its(:email) { should == email }
its(:telephone) { should == telephone }
end
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

View File

@ -21,5 +21,3 @@
</rdf:Description>
</rdf:RDF>
</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>