add proposal id and better serialization

This commit is contained in:
John Bintz 2011-03-30 10:09:35 -04:00
parent b703ee1a55
commit 864b3c2417
11 changed files with 46 additions and 48 deletions

3
.gitignore vendored
View File

@ -2,4 +2,5 @@
.bundle
Gemfile.lock
pkg/*
.quickfix.txt
.quickfix-out

6
.rspec
View File

@ -1,5 +1,5 @@
-c
--require ./spec/quick_fix_formatter.rb
--format progress
--format RSpec::Core::Formatters::QuickFixFormatter
--out .quickfix.txt
--require rspec/quickfix-formatter
--format RSpec::QuickFixFormatter
--out .quickfix-out

View File

@ -3,6 +3,8 @@ source "http://rubygems.org"
# Specify your gem's dependencies in ruby-avm-library.gemspec
gemspec
gem 'rspec-quickfix-formatter', :git => 'git://github.com/johnbintz/rspec-quickfix-formatter.git'
group :test do
gem 'autotest'
end

View File

@ -61,6 +61,7 @@ module AVM
'MetadataDate',
'MetadataVersion',
'Subject.Category',
'ProposalID'
]
AVM_SINGLE_METHODS = [
@ -90,7 +91,8 @@ module AVM
:related_resources,
:metadata_date,
:metadata_version,
:categories
:categories,
:proposal_id
]
AVM_SINGLE_MESSAGES = [
@ -120,7 +122,8 @@ module AVM
:related_resources,
:string_metadata_date,
:metadata_version,
:categories
:categories,
:proposal_id
]
AVM_SINGLES = AVM_SINGLE_FIELDS.zip(AVM_SINGLE_METHODS)
@ -135,6 +138,9 @@ module AVM
:reference_value
]
SEMICOLON_AVM_FIELDS = [ :categories, :proposal_id ]
:wa
HASH_FIELDS = [ :title, :headline, :description, :distance_notes,
:spectral_notes, :reference_url, :credit, :date,
:id, :image_type, :image_quality, :coordinate_frame,
@ -142,7 +148,8 @@ module AVM
:spatial_scale, :spatial_rotation, :coordinate_system_projection, :spatial_quality,
:spatial_notes, :fits_header, :spatial_cd_matrix, :distance,
:publisher, :publisher_id, :resource_id, :resource_url,
:related_resources, :metadata_date, :metadata_version, :subject_names, :categories
:related_resources, :metadata_date, :metadata_version, :subject_names, :categories,
:proposal_id
]
attr_reader :creator, :observations
@ -191,6 +198,9 @@ module AVM
AVM_SINGLES_FOR_MESSAGES.each do |tag, message|
if value = send(message)
if SEMICOLON_AVM_FIELDS.include?(message)
value = value.join(';')
else
case value
when Array
container_tag = (message == :related_resources) ? 'Bag' : 'Seq'
@ -198,6 +208,7 @@ module AVM
else
value = value.to_s
end
end
refs[:avm].add_child(%{<avm:#{tag}>#{value}</avm:#{tag}>})
end
@ -280,7 +291,7 @@ module AVM
AVM_SINGLES.each do |tag, field|
if node = refs[:avm].at_xpath("./avm:#{tag}")
if field == :categories
if SEMICOLON_AVM_FIELDS.include?(field)
options[field] = node.text.split(";").collect(&:strip)
else
if !(list_items = node.search('.//rdf:li')).empty?

View File

@ -1,7 +1,7 @@
module Ruby
module Avm
module Library
VERSION = "0.0.1"
VERSION = "0.0.2"
end
end
end

View File

@ -44,6 +44,7 @@ describe AVM::Image do
let(:related_resources) { [ 'Resource 1', 'Resource 2' ] }
let(:metadata_date) { '2010-01-05' }
let(:metadata_version) { '1.2' }
let(:proposal_id) { [ 'one', 'two', 'three' ] }
def self.with_all_options
let(:options) { {
@ -80,7 +81,8 @@ describe AVM::Image do
:metadata_date => metadata_date,
:metadata_version => metadata_version,
:subject_names => subject_names,
:categories => categories
:categories => categories,
:proposal_id => proposal_id
} }
end
@ -124,6 +126,7 @@ describe AVM::Image do
its(:related_resources) { should == related_resources }
its(:metadata_date) { should == Time.parse(metadata_date) }
its(:metadata_version) { should == metadata_version }
its(:proposal_id) { should == proposal_id }
its(:subject_names) { should == subject_names }
its(:categories) { should == categories }
@ -152,16 +155,16 @@ describe AVM::Image do
:image_quality => avm_image_quality.new,
:coordinate_frame => avm_coordinate_frame.new,
:equinox => equinox,
:reference_value => reference_value,
:reference_dimension => reference_dimension,
:reference_pixel => reference_pixel,
:spatial_scale => spatial_scale,
:reference_value => reference_value.collect(&:to_f),
:reference_dimension => reference_dimension.collect(&:to_f),
:reference_pixel => reference_pixel.collect(&:to_f),
:spatial_scale => spatial_scale.collect(&:to_f),
:spatial_rotation => spatial_rotation,
:coordinate_system_projection => avm_coordinate_system_projection.new,
:spatial_quality => avm_spatial_quality.new,
:spatial_notes => spatial_notes,
:fits_header => fits_header,
:spatial_cd_matrix => spatial_cd_matrix,
:spatial_cd_matrix => spatial_cd_matrix.collect(&:to_f),
:distance => [ light_years, redshift ],
:creator => [],
:publisher => publisher,
@ -173,7 +176,8 @@ describe AVM::Image do
:metadata_version => metadata_version,
:subject_names => subject_names,
:categories => categories,
:observations => []
:observations => [],
:proposal_id => proposal_id
} }
its(:distance) { should == [ light_years, redshift ] }
@ -199,7 +203,7 @@ describe AVM::Image do
:light_years, :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, :subject_names, :categories
:fits_header, :spatial_cd_matrix, :subject_names, :categories, :proposal_id
].each do |field|
its(field) { should be_nil }
end
@ -285,6 +289,8 @@ describe AVM::Image do
xpath_text(avm, './avm:ID').should == id
xpath_text(avm, './avm:Type').should == type
xpath_text(avm, './avm:Image.ProductQuality').should == image_quality
xpath_text(avm, './avm:Subject.Category').should == categories.join(';')
xpath_text(avm, './avm:ProposalID').should == proposal_id.join(';')
end
it "should have the spatial tags" do

View File

@ -1,26 +0,0 @@
require 'rspec/core/formatters/base_text_formatter'
module RSpec
module Core
module Formatters
class QuickFixFormatter < BaseTextFormatter
def dump_summary(duration, example_count, failure_count, pending_count)
end
def dump_profile
end
def dump_pending
end
def dump_failures
failed_examples.each do |example|
output.puts "%s:%s:%s" % [ example.file_path, example.metadata[:line_number], example.metadata[:execution_result][:exception].message ]
end
end
end
end
end
end

View File

@ -96,6 +96,7 @@
</avm:RelatedResources>
<avm:MetadataDate>2010-01-05</avm:MetadataDate>
<avm:MetadataVersion>1.2</avm:MetadataVersion>
<avm:ProposalID>one;two;three</avm:ProposalID>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>

View File

@ -91,6 +91,7 @@
</avm:RelatedResources>
<avm:MetadataDate>2010-01-05</avm:MetadataDate>
<avm:MetadataVersion>1.2</avm:MetadataVersion>
<avm:ProposalID>one;two;three</avm:ProposalID>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>

View File

@ -96,6 +96,7 @@
</avm:RelatedResources>
<avm:MetadataDate>2010-01-05</avm:MetadataDate>
<avm:MetadataVersion>1.2</avm:MetadataVersion>
<avm:ProposalID>one;two;three</avm:ProposalID>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>

View File

@ -91,6 +91,7 @@
</avm:RelatedResources>
<avm:MetadataDate>2010-01-05</avm:MetadataDate>
<avm:MetadataVersion>1.2</avm:MetadataVersion>
<avm:ProposalID>one;two;three</avm:ProposalID>
</rdf:Description>
</rdf:RDF>
</x:xmpmeta>