diff --git a/lib/avm/image.rb b/lib/avm/image.rb index c3eea5f..d2190d2 100644 --- a/lib/avm/image.rb +++ b/lib/avm/image.rb @@ -2,11 +2,14 @@ require 'avm/creator' require 'avm/xmp' require 'avm/image_type' require 'avm/image_quality' +require 'avm/observation' module AVM class Image DUBLIN_CORE_FIELDS = [ :title, :description ] - AVM_SINGLE_FIELDS = [ 'Distance.Notes', 'ReferenceURL', 'Credit', 'Date', 'ID', 'Type', 'Image.ProductQuality' ] + AVM_SINGLE_FIELDS = [ 'Distance.Notes', 'Spectral.Notes', 'ReferenceURL', 'Credit', 'Date', 'ID', 'Type', 'Image.ProductQuality' ] + AVM_SINGLE_METHODS = [ :distance_notes, :spectral_notes, :reference_url, :credit, :date, :id, :type, :quality ] + AVM_SINGLES = AVM_SINGLE_FIELDS.zip(AVM_SINGLE_METHODS) attr_reader :creator, :observations @@ -35,7 +38,7 @@ module AVM refs[:photoshop].add_child(%{#{headline}}) - AVM_SINGLE_FIELDS.zip([distance_notes, reference_url, credit, string_date, id, image_type, image_quality]).each do |tag, value| + AVM_SINGLE_FIELDS.zip([distance_notes, spectral_notes, reference_url, credit, string_date, id, image_type, image_quality]).each do |tag, value| refs[:avm].add_child(%{#{value.to_s}}) if value end @@ -91,7 +94,7 @@ module AVM end end - AVM_SINGLE_FIELDS.zip([ :distance_notes, :reference_url, :credit, :date, :id, :type, :quality ]).each do |tag, field| + AVM_SINGLES.each do |tag, field| if node = refs[:avm].at_xpath("./avm:#{tag}") options[field] = node.text end diff --git a/spec/avm/image_spec.rb b/spec/avm/image_spec.rb index 1d900a7..45ad06a 100644 --- a/spec/avm/image_spec.rb +++ b/spec/avm/image_spec.rb @@ -11,6 +11,7 @@ describe AVM::Image do let(:headline) { 'Headline' } let(:description) { 'Description' } let(:distance_notes) { 'Distance Notes' } + let(:spectral_notes) { 'Spectral Notes' } let(:reference_url) { 'Reference URL' } let(:credit) { 'Credit' } let(:date) { '2010-01-01' } @@ -20,14 +21,13 @@ describe AVM::Image do let(:redshift) { 'Redshift' } let(:light_years) { 'Light years' } - it "should have spectral notes" - def self.with_all_options let(:options) { { :title => title, :headline => headline, :description => description, :distance_notes => distance_notes, + :spectral_notes => spectral_notes, :reference_url => reference_url, :credit => credit, :date => date, @@ -45,6 +45,7 @@ describe AVM::Image do its(:headline) { should == headline } its(:description) { should == description } its(:distance_notes) { should == distance_notes } + its(:spectral_notes) { should == spectral_notes } its(:reference_url) { should == reference_url } its(:credit) { should == credit } its(:date) { should == Time.parse(date) } @@ -75,6 +76,7 @@ describe AVM::Image do its(:headline) { should be_nil } its(:description) { should be_nil } its(:distance_notes) { should be_nil } + its(:spectral_notes) { should be_nil } its(:reference_url) { should be_nil } its(:credit) { should be_nil } its(:date) { should be_nil } @@ -139,6 +141,7 @@ describe AVM::Image do dublin_core.at_xpath('./dc:description/rdf:Alt/rdf:li').text.should == description avm.at_xpath('./avm:Distance.Notes').text.should == distance_notes + avm.at_xpath('./avm:Spectral.Notes').text.should == spectral_notes avm.at_xpath('./avm:ReferenceURL').text.should == reference_url avm.at_xpath('./avm:Credit').text.should == credit avm.at_xpath('./avm:Date').text.should == date diff --git a/spec/sample_files/image/both.xmp b/spec/sample_files/image/both.xmp index 6f62e8e..cdcddd8 100644 --- a/spec/sample_files/image/both.xmp +++ b/spec/sample_files/image/both.xmp @@ -25,6 +25,7 @@ + Spectral Notes Distance Notes Reference URL Credit diff --git a/spec/sample_files/image/light_years.xmp b/spec/sample_files/image/light_years.xmp index becc7b8..aa7781d 100644 --- a/spec/sample_files/image/light_years.xmp +++ b/spec/sample_files/image/light_years.xmp @@ -25,6 +25,7 @@ + Spectral Notes Distance Notes Reference URL Credit diff --git a/spec/sample_files/image/redshift.xmp b/spec/sample_files/image/redshift.xmp index e86c9b4..a48395c 100644 --- a/spec/sample_files/image/redshift.xmp +++ b/spec/sample_files/image/redshift.xmp @@ -25,6 +25,7 @@ + Spectral Notes Distance Notes Reference URL Credit