publisher tags
This commit is contained in:
parent
8f9141bece
commit
50965072a9
|
@ -11,16 +11,31 @@ module AVM
|
|||
class Image
|
||||
DUBLIN_CORE_FIELDS = [ :title, :description ]
|
||||
|
||||
PHOTOSHOP_SINGLES = {
|
||||
'Headline' => :headline,
|
||||
'DateCreated' => :date
|
||||
}
|
||||
PHOTOSHOP_SINGLE_FIELDS = [
|
||||
'Headline',
|
||||
'DateCreated',
|
||||
'Credit'
|
||||
]
|
||||
|
||||
PHOTOSHOP_SINGLE_METHODS = [
|
||||
:headline,
|
||||
:date,
|
||||
:credit
|
||||
]
|
||||
|
||||
PHOTOSHOP_SINGLES_MESSAGES = [
|
||||
:headline,
|
||||
:string_date,
|
||||
:credit
|
||||
]
|
||||
|
||||
PHOTOSHOP_SINGLES_FOR_METHODS = PHOTOSHOP_SINGLE_FIELDS.zip(PHOTOSHOP_SINGLE_METHODS)
|
||||
PHOTOSHOP_SINGLES_FOR_MESSAGES = PHOTOSHOP_SINGLE_FIELDS.zip(PHOTOSHOP_SINGLES_MESSAGES)
|
||||
|
||||
AVM_SINGLE_FIELDS = [
|
||||
'Distance.Notes',
|
||||
'Spectral.Notes',
|
||||
'ReferenceURL',
|
||||
'Credit',
|
||||
'ID',
|
||||
'Type',
|
||||
'Image.ProductQuality',
|
||||
|
@ -36,14 +51,20 @@ module AVM
|
|||
'Spatial.ReferenceDimension',
|
||||
'Spatial.ReferenceValue',
|
||||
'Spatial.Equinox',
|
||||
'Spatial.CoordinateFrame'
|
||||
'Spatial.CoordinateFrame',
|
||||
'Publisher',
|
||||
'PublisherID',
|
||||
'ResourceID',
|
||||
'ResourceURL',
|
||||
'RelatedResources',
|
||||
'MetadataDate',
|
||||
'MetadataVersion',
|
||||
]
|
||||
|
||||
AVM_SINGLE_METHODS = [
|
||||
:distance_notes,
|
||||
:spectral_notes,
|
||||
:reference_url,
|
||||
:credit,
|
||||
:id,
|
||||
:type,
|
||||
:quality,
|
||||
|
@ -59,14 +80,20 @@ module AVM
|
|||
:reference_dimension,
|
||||
:reference_value,
|
||||
:equinox,
|
||||
:coordinate_frame
|
||||
:coordinate_frame,
|
||||
:publisher,
|
||||
:publisher_id,
|
||||
:resource_id,
|
||||
:resource_url,
|
||||
:related_resources,
|
||||
:metadata_date,
|
||||
:metadata_version,
|
||||
]
|
||||
|
||||
AVM_SINGLE_MESSAGES = [
|
||||
:distance_notes,
|
||||
:spectral_notes,
|
||||
:reference_url,
|
||||
:credit,
|
||||
:id,
|
||||
:image_type,
|
||||
:image_quality,
|
||||
|
@ -82,7 +109,14 @@ module AVM
|
|||
:reference_dimension,
|
||||
:reference_value,
|
||||
:equinox,
|
||||
:coordinate_frame
|
||||
:coordinate_frame,
|
||||
:publisher,
|
||||
:publisher_id,
|
||||
:resource_id,
|
||||
:resource_url,
|
||||
:related_resources,
|
||||
:string_metadata_date,
|
||||
:metadata_version,
|
||||
]
|
||||
|
||||
AVM_SINGLES = AVM_SINGLE_FIELDS.zip(AVM_SINGLE_METHODS)
|
||||
|
@ -102,7 +136,9 @@ module AVM
|
|||
:id, :image_type, :image_quality, :coordinate_frame,
|
||||
:equinox, :reference_value, :reference_dimension, :reference_pixel,
|
||||
:spatial_scale, :spatial_rotation, :coordinate_system_projection, :spatial_quality,
|
||||
:spatial_notes, :fits_header, :spatial_cd_matrix, :distance
|
||||
:spatial_notes, :fits_header, :spatial_cd_matrix, :distance,
|
||||
:publisher, :publisher_id, :resource_id, :resource_url,
|
||||
:related_resources, :metadata_date, :metadata_version
|
||||
]
|
||||
|
||||
attr_reader :creator, :observations
|
||||
|
@ -142,14 +178,16 @@ module AVM
|
|||
refs[:dublin_core].add_child(%{<dc:#{field}>#{alt_li_tag(send(field))}</dc:#{field}>})
|
||||
end
|
||||
|
||||
refs[:photoshop].add_child(%{<photoshop:Headline>#{headline}</photoshop:Headline>})
|
||||
refs[:photoshop].add_child(%{<photoshop:DateCreated>#{string_date}</photoshop:DateCreated>})
|
||||
PHOTOSHOP_SINGLES_FOR_MESSAGES.each do |tag, message|
|
||||
refs[:photoshop].add_child(%{<photoshop:#{tag}>#{send(message)}</photoshop:#{tag}>})
|
||||
end
|
||||
|
||||
AVM_SINGLES_FOR_MESSAGES.each do |tag, message|
|
||||
if value = send(message)
|
||||
case value
|
||||
when Array
|
||||
value = '<rdf:Seq>' + value.collect { |v| "<rdf:li>#{v.to_s}</rdf:li>" }.join + '</rdf:Seq>'
|
||||
container_tag = (message == :related_resources) ? 'Bag' : 'Seq'
|
||||
value = "<rdf:#{container_tag}>" + value.collect { |v| "<rdf:li>#{v.to_s}</rdf:li>" }.join + "</rdf:#{container_tag}>"
|
||||
else
|
||||
value = value.to_s
|
||||
end
|
||||
|
@ -198,12 +236,19 @@ module AVM
|
|||
end
|
||||
|
||||
def date
|
||||
(Time.parse(@options[:date]) rescue nil)
|
||||
date_or_nil(:date)
|
||||
end
|
||||
|
||||
def metadata_date
|
||||
date_or_nil(:metadata_date)
|
||||
end
|
||||
|
||||
def string_date
|
||||
return nil if !date
|
||||
date.strftime('%Y-%m-%d')
|
||||
string_date_or_nil(:date)
|
||||
end
|
||||
|
||||
def string_metadata_date
|
||||
string_date_or_nil(:metadata_date)
|
||||
end
|
||||
|
||||
def distance
|
||||
|
@ -232,7 +277,7 @@ module AVM
|
|||
end
|
||||
end
|
||||
|
||||
PHOTOSHOP_SINGLES.each do |tag, field|
|
||||
PHOTOSHOP_SINGLES_FOR_METHODS.each do |tag, field|
|
||||
if node = refs[:photoshop].at_xpath("./photoshop:#{tag}")
|
||||
options[field] = node.text
|
||||
end
|
||||
|
@ -270,6 +315,16 @@ module AVM
|
|||
end
|
||||
|
||||
private
|
||||
def date_or_nil(field)
|
||||
(Time.parse(@options[field]) rescue nil)
|
||||
end
|
||||
|
||||
def string_date_or_nil(field)
|
||||
return nil if !send(field)
|
||||
send(field).strftime('%Y-%m-%d')
|
||||
end
|
||||
|
||||
|
||||
def alt_li_tag(text)
|
||||
%{<rdf:Alt><rdf:li xml:lang="x-default">#{text}</rdf:li></rdf:Alt>}
|
||||
end
|
||||
|
|
|
@ -34,6 +34,14 @@ describe AVM::Image do
|
|||
let(:fits_header) { 'FITS header' }
|
||||
let(:spatial_cd_matrix) { [ 1, 2, 3, 4 ] }
|
||||
|
||||
let(:publisher) { 'Publisher' }
|
||||
let(:publisher_id) { 'Publisher ID' }
|
||||
let(:resource_id) { 'Resource ID' }
|
||||
let(:resource_url) { 'Resource URL' }
|
||||
let(:related_resources) { [ 'Resource 1', 'Resource 2' ] }
|
||||
let(:metadata_date) { '2010-01-05' }
|
||||
let(:metadata_version) { '1.2' }
|
||||
|
||||
def self.with_all_options
|
||||
let(:options) { {
|
||||
:title => title,
|
||||
|
@ -61,6 +69,13 @@ describe AVM::Image do
|
|||
:spatial_notes => spatial_notes,
|
||||
:fits_header => fits_header,
|
||||
:spatial_cd_matrix => spatial_cd_matrix,
|
||||
:publisher => publisher,
|
||||
:publisher_id => publisher_id,
|
||||
:resource_id => resource_id,
|
||||
:resource_url => resource_url,
|
||||
:related_resources => related_resources,
|
||||
:metadata_date => metadata_date,
|
||||
:metadata_version => metadata_version,
|
||||
} }
|
||||
end
|
||||
|
||||
|
@ -96,6 +111,14 @@ describe AVM::Image do
|
|||
its(:spatial_notes) { should == spatial_notes }
|
||||
its(:fits_header) { should == fits_header }
|
||||
its(:spatial_cd_matrix) { should == spatial_cd_matrix }
|
||||
|
||||
its(:publisher) { should == publisher }
|
||||
its(:publisher_id) { should == publisher_id }
|
||||
its(:resource_id) { should == resource_id }
|
||||
its(:resource_url) { should == resource_url }
|
||||
its(:related_resources) { should == related_resources }
|
||||
its(:metadata_date) { should == Time.parse(metadata_date) }
|
||||
its(:metadata_version) { should == metadata_version }
|
||||
end
|
||||
|
||||
describe '#initialize' do
|
||||
|
@ -130,7 +153,14 @@ describe AVM::Image do
|
|||
:fits_header => fits_header,
|
||||
:spatial_cd_matrix => spatial_cd_matrix,
|
||||
:distance => [ light_years, redshift ],
|
||||
:creator => []
|
||||
:creator => [],
|
||||
:publisher => publisher,
|
||||
:publisher_id => publisher_id,
|
||||
:resource_id => resource_id,
|
||||
:resource_url => resource_url,
|
||||
:related_resources => related_resources,
|
||||
:metadata_date => Time.parse(metadata_date),
|
||||
:metadata_version => metadata_version,
|
||||
} }
|
||||
|
||||
its(:distance) { should == [ light_years, redshift ] }
|
||||
|
@ -217,8 +247,8 @@ describe AVM::Image do
|
|||
which.at_xpath(xpath).text
|
||||
end
|
||||
|
||||
def xpath_list(which, xpath)
|
||||
which.at_xpath(xpath).search('.//rdf:li').collect(&:text)
|
||||
def xpath_list(which, xpath, search = './/rdf:li')
|
||||
which.at_xpath(xpath).search(search).collect(&:text)
|
||||
end
|
||||
|
||||
it "should have the image info tags" do
|
||||
|
@ -229,7 +259,7 @@ describe AVM::Image do
|
|||
xpath_text(avm, './avm:Distance.Notes').should == distance_notes
|
||||
xpath_text(avm, './avm:Spectral.Notes').should == spectral_notes
|
||||
xpath_text(avm, './avm:ReferenceURL').should == reference_url
|
||||
xpath_text(avm, './avm:Credit').should == credit
|
||||
xpath_text(photoshop, './photoshop:Credit').should == credit
|
||||
xpath_text(photoshop, './photoshop:DateCreated').should == date
|
||||
xpath_text(avm, './avm:ID').should == id
|
||||
xpath_text(avm, './avm:Type').should == type
|
||||
|
@ -250,6 +280,16 @@ describe AVM::Image do
|
|||
xpath_list(avm, './avm:Spatial.CDMatrix').should == spatial_cd_matrix.collect(&:to_s)
|
||||
end
|
||||
|
||||
it "should have the publisher tags" do
|
||||
xpath_text(avm, './avm:Publisher').should == publisher
|
||||
xpath_text(avm, './avm:PublisherID').should == publisher_id
|
||||
xpath_text(avm, './avm:ResourceID').should == resource_id
|
||||
xpath_text(avm, './avm:ResourceURL').should == resource_url
|
||||
xpath_list(avm, './avm:RelatedResources', './rdf:Bag/rdf:li').should == related_resources
|
||||
xpath_text(avm, './avm:MetadataDate').should == metadata_date
|
||||
xpath_text(avm, './avm:MetadataVersion').should == metadata_version
|
||||
end
|
||||
|
||||
context "distance" do
|
||||
context "no distances" do
|
||||
let(:redshift) { nil }
|
||||
|
|
|
@ -12,7 +12,6 @@
|
|||
<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/">
|
||||
|
@ -22,6 +21,7 @@
|
|||
<rdf:Description rdf:about=""
|
||||
xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/">
|
||||
<photoshop:Headline>Headline</photoshop:Headline>
|
||||
<photoshop:Credit>Credit</photoshop:Credit>
|
||||
<photoshop:DateCreated>2010-01-01</photoshop:DateCreated>
|
||||
</rdf:Description>
|
||||
<rdf:Description rdf:about=""
|
||||
|
@ -29,7 +29,6 @@
|
|||
<avm:Spectral.Notes>Spectral Notes</avm:Spectral.Notes>
|
||||
<avm:Distance.Notes>Distance Notes</avm:Distance.Notes>
|
||||
<avm:ReferenceURL>Reference URL</avm:ReferenceURL>
|
||||
<avm:Credit>Credit</avm:Credit>
|
||||
<avm:ID>ID</avm:ID>
|
||||
<avm:Type>Observation</avm:Type>
|
||||
<avm:Image.ProductQuality>Good</avm:Image.ProductQuality>
|
||||
|
@ -78,6 +77,18 @@
|
|||
<rdf:li>4</rdf:li>
|
||||
</rdf:Seq>
|
||||
</avm:Spatial.CDMatrix>
|
||||
<avm:Publisher>Publisher</avm:Publisher>
|
||||
<avm:PublisherID>Publisher ID</avm:PublisherID>
|
||||
<avm:ResourceID>Resource ID</avm:ResourceID>
|
||||
<avm:ResourceURL>Resource URL</avm:ResourceURL>
|
||||
<avm:RelatedResources>
|
||||
<rdf:Bag>
|
||||
<rdf:li>Resource 1</rdf:li>
|
||||
<rdf:li>Resource 2</rdf:li>
|
||||
</rdf:Bag>
|
||||
</avm:RelatedResources>
|
||||
<avm:MetadataDate>2010-01-05</avm:MetadataDate>
|
||||
<avm:MetadataVersion>1.2</avm:MetadataVersion>
|
||||
</rdf:Description>
|
||||
</rdf:RDF>
|
||||
</x:xmpmeta>
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
<rdf:Description rdf:about=""
|
||||
xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/">
|
||||
<photoshop:Headline>Headline</photoshop:Headline>
|
||||
<photoshop:Credit>Credit</photoshop:Credit>
|
||||
<photoshop:DateCreated>2010-01-01</photoshop:DateCreated>
|
||||
</rdf:Description>
|
||||
<rdf:Description rdf:about=""
|
||||
|
@ -28,7 +29,6 @@
|
|||
<avm:Spectral.Notes>Spectral Notes</avm:Spectral.Notes>
|
||||
<avm:Distance.Notes>Distance Notes</avm:Distance.Notes>
|
||||
<avm:ReferenceURL>Reference URL</avm:ReferenceURL>
|
||||
<avm:Credit>Credit</avm:Credit>
|
||||
<avm:ID>ID</avm:ID>
|
||||
<avm:Type>Observation</avm:Type>
|
||||
<avm:Image.ProductQuality>Good</avm:Image.ProductQuality>
|
||||
|
@ -72,6 +72,18 @@
|
|||
<rdf:li>4</rdf:li>
|
||||
</rdf:Seq>
|
||||
</avm:Spatial.CDMatrix>
|
||||
<avm:Publisher>Publisher</avm:Publisher>
|
||||
<avm:PublisherID>Publisher ID</avm:PublisherID>
|
||||
<avm:ResourceID>Resource ID</avm:ResourceID>
|
||||
<avm:ResourceURL>Resource URL</avm:ResourceURL>
|
||||
<avm:RelatedResources>
|
||||
<rdf:Bag>
|
||||
<rdf:li>Resource 1</rdf:li>
|
||||
<rdf:li>Resource 2</rdf:li>
|
||||
</rdf:Bag>
|
||||
</avm:RelatedResources>
|
||||
<avm:MetadataDate>2010-01-05</avm:MetadataDate>
|
||||
<avm:MetadataVersion>1.2</avm:MetadataVersion>
|
||||
</rdf:Description>
|
||||
</rdf:RDF>
|
||||
</x:xmpmeta>
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
<rdf:Description rdf:about=""
|
||||
xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/">
|
||||
<photoshop:Headline>Headline</photoshop:Headline>
|
||||
<photoshop:Credit>Credit</photoshop:Credit>
|
||||
<photoshop:DateCreated>2010-01-01</photoshop:DateCreated>
|
||||
</rdf:Description>
|
||||
<rdf:Description rdf:about=""
|
||||
|
@ -29,7 +30,6 @@
|
|||
<avm:Spectral.Notes>Spectral Notes</avm:Spectral.Notes>
|
||||
<avm:Distance.Notes>Distance Notes</avm:Distance.Notes>
|
||||
<avm:ReferenceURL>Reference URL</avm:ReferenceURL>
|
||||
<avm:Credit>Credit</avm:Credit>
|
||||
<avm:ID>ID</avm:ID>
|
||||
<avm:Type>Observation</avm:Type>
|
||||
<avm:Image.ProductQuality>Good</avm:Image.ProductQuality>
|
||||
|
@ -78,6 +78,18 @@
|
|||
<rdf:li>4</rdf:li>
|
||||
</rdf:Seq>
|
||||
</avm:Spatial.CDMatrix>
|
||||
<avm:Publisher>Publisher</avm:Publisher>
|
||||
<avm:PublisherID>Publisher ID</avm:PublisherID>
|
||||
<avm:ResourceID>Resource ID</avm:ResourceID>
|
||||
<avm:ResourceURL>Resource URL</avm:ResourceURL>
|
||||
<avm:RelatedResources>
|
||||
<rdf:Bag>
|
||||
<rdf:li>Resource 1</rdf:li>
|
||||
<rdf:li>Resource 2</rdf:li>
|
||||
</rdf:Bag>
|
||||
</avm:RelatedResources>
|
||||
<avm:MetadataDate>2010-01-05</avm:MetadataDate>
|
||||
<avm:MetadataVersion>1.2</avm:MetadataVersion>
|
||||
</rdf:Description>
|
||||
</rdf:RDF>
|
||||
</x:xmpmeta>
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
<rdf:Description rdf:about=""
|
||||
xmlns:photoshop="http://ns.adobe.com/photoshop/1.0/">
|
||||
<photoshop:Headline>Headline</photoshop:Headline>
|
||||
<photoshop:Credit>Credit</photoshop:Credit>
|
||||
<photoshop:DateCreated>2010-01-01</photoshop:DateCreated>
|
||||
</rdf:Description>
|
||||
<rdf:Description rdf:about=""
|
||||
|
@ -28,7 +29,6 @@
|
|||
<avm:Spectral.Notes>Spectral Notes</avm:Spectral.Notes>
|
||||
<avm:Distance.Notes>Distance Notes</avm:Distance.Notes>
|
||||
<avm:ReferenceURL>Reference URL</avm:ReferenceURL>
|
||||
<avm:Credit>Credit</avm:Credit>
|
||||
<avm:ID>ID</avm:ID>
|
||||
<avm:Type>Observation</avm:Type>
|
||||
<avm:Image.ProductQuality>Good</avm:Image.ProductQuality>
|
||||
|
@ -72,6 +72,18 @@
|
|||
<rdf:li>4</rdf:li>
|
||||
</rdf:Seq>
|
||||
</avm:Spatial.CDMatrix>
|
||||
<avm:Publisher>Publisher</avm:Publisher>
|
||||
<avm:PublisherID>Publisher ID</avm:PublisherID>
|
||||
<avm:ResourceID>Resource ID</avm:ResourceID>
|
||||
<avm:ResourceURL>Resource URL</avm:ResourceURL>
|
||||
<avm:RelatedResources>
|
||||
<rdf:Bag>
|
||||
<rdf:li>Resource 1</rdf:li>
|
||||
<rdf:li>Resource 2</rdf:li>
|
||||
</rdf:Bag>
|
||||
</avm:RelatedResources>
|
||||
<avm:MetadataDate>2010-01-05</avm:MetadataDate>
|
||||
<avm:MetadataVersion>1.2</avm:MetadataVersion>
|
||||
</rdf:Description>
|
||||
</rdf:RDF>
|
||||
</x:xmpmeta>
|
||||
|
|
Loading…
Reference in New Issue