starting work on image fields
This commit is contained in:
parent
b11d2813cd
commit
d3113968a9
|
@ -5,8 +5,9 @@ module AVM
|
|||
class Image
|
||||
attr_reader :creator
|
||||
|
||||
def initialize
|
||||
def initialize(options = {})
|
||||
@creator = AVM::Creator.new(self)
|
||||
@options = options
|
||||
end
|
||||
|
||||
def to_xml
|
||||
|
@ -17,6 +18,18 @@ module AVM
|
|||
document.doc
|
||||
end
|
||||
|
||||
def id
|
||||
@options[:id]
|
||||
end
|
||||
|
||||
def image_type
|
||||
@options[:type]
|
||||
end
|
||||
|
||||
def date
|
||||
Time.parse(@options[:date])
|
||||
end
|
||||
|
||||
def self.from_xml(string)
|
||||
document = AVM::XMP.from_string(string)
|
||||
|
||||
|
@ -24,6 +37,10 @@ module AVM
|
|||
image.creator.from_xml(self, document)
|
||||
image
|
||||
end
|
||||
|
||||
def method_missing(method)
|
||||
@options[method]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -2,14 +2,49 @@ require 'spec_helper'
|
|||
require 'avm/image'
|
||||
|
||||
describe AVM::Image do
|
||||
let(:image) { self.class.describes.new }
|
||||
let(:image) { self.class.describes.new(options) }
|
||||
let(:options) { {} }
|
||||
|
||||
subject { image }
|
||||
|
||||
describe '#initialize' do
|
||||
it { should be_a_kind_of(AVM::Image) }
|
||||
|
||||
let(:options) { {
|
||||
:title => title,
|
||||
:headline => headline,
|
||||
:description => description,
|
||||
:distance_notes => distance_notes,
|
||||
:reference_url => reference_url,
|
||||
:credit => credit,
|
||||
:date => date,
|
||||
:id => id,
|
||||
:type => type,
|
||||
:image_quality => image_quality
|
||||
} }
|
||||
|
||||
let(:title) { 'My title' }
|
||||
let(:headline) { 'Headline' }
|
||||
let(:description) { 'Description' }
|
||||
let(:distance_notes) { 'Distance Notes' }
|
||||
let(:reference_url) { 'Reference URL' }
|
||||
let(:credit) { 'Credit' }
|
||||
let(:date) { '2010-01-01' }
|
||||
let(:id) { 'ID' }
|
||||
let(:type) { 'Obvservation' }
|
||||
let(:image_quality) { 'Good' }
|
||||
|
||||
its(:creator) { should be_a_kind_of(AVM::Creator) }
|
||||
its(:title) { should == title }
|
||||
its(:headline) { should == headline }
|
||||
its(:description) { should == description }
|
||||
its(:distance_notes) { should == distance_notes }
|
||||
its(:reference_url) { should == reference_url }
|
||||
its(:credit) { should == credit }
|
||||
its(:date) { should == Time.parse(date) }
|
||||
its(:id) { should == id }
|
||||
its(:image_type) { should == type }
|
||||
its(:image_quality) { should == image_quality }
|
||||
end
|
||||
|
||||
describe '#to_xml' do
|
||||
|
|
Loading…
Reference in New Issue