add proposal id and better serialization
This commit is contained in:
parent
b703ee1a55
commit
864b3c2417
|
@ -2,4 +2,5 @@
|
||||||
.bundle
|
.bundle
|
||||||
Gemfile.lock
|
Gemfile.lock
|
||||||
pkg/*
|
pkg/*
|
||||||
.quickfix.txt
|
.quickfix-out
|
||||||
|
|
||||||
|
|
6
.rspec
6
.rspec
|
@ -1,5 +1,5 @@
|
||||||
-c
|
-c
|
||||||
--require ./spec/quick_fix_formatter.rb
|
|
||||||
--format progress
|
--format progress
|
||||||
--format RSpec::Core::Formatters::QuickFixFormatter
|
--require rspec/quickfix-formatter
|
||||||
--out .quickfix.txt
|
--format RSpec::QuickFixFormatter
|
||||||
|
--out .quickfix-out
|
||||||
|
|
2
Gemfile
2
Gemfile
|
@ -3,6 +3,8 @@ source "http://rubygems.org"
|
||||||
# Specify your gem's dependencies in ruby-avm-library.gemspec
|
# Specify your gem's dependencies in ruby-avm-library.gemspec
|
||||||
gemspec
|
gemspec
|
||||||
|
|
||||||
|
gem 'rspec-quickfix-formatter', :git => 'git://github.com/johnbintz/rspec-quickfix-formatter.git'
|
||||||
|
|
||||||
group :test do
|
group :test do
|
||||||
gem 'autotest'
|
gem 'autotest'
|
||||||
end
|
end
|
||||||
|
|
|
@ -61,6 +61,7 @@ module AVM
|
||||||
'MetadataDate',
|
'MetadataDate',
|
||||||
'MetadataVersion',
|
'MetadataVersion',
|
||||||
'Subject.Category',
|
'Subject.Category',
|
||||||
|
'ProposalID'
|
||||||
]
|
]
|
||||||
|
|
||||||
AVM_SINGLE_METHODS = [
|
AVM_SINGLE_METHODS = [
|
||||||
|
@ -90,7 +91,8 @@ module AVM
|
||||||
:related_resources,
|
:related_resources,
|
||||||
:metadata_date,
|
:metadata_date,
|
||||||
:metadata_version,
|
:metadata_version,
|
||||||
:categories
|
:categories,
|
||||||
|
:proposal_id
|
||||||
]
|
]
|
||||||
|
|
||||||
AVM_SINGLE_MESSAGES = [
|
AVM_SINGLE_MESSAGES = [
|
||||||
|
@ -120,7 +122,8 @@ module AVM
|
||||||
:related_resources,
|
:related_resources,
|
||||||
:string_metadata_date,
|
:string_metadata_date,
|
||||||
:metadata_version,
|
:metadata_version,
|
||||||
:categories
|
:categories,
|
||||||
|
:proposal_id
|
||||||
]
|
]
|
||||||
|
|
||||||
AVM_SINGLES = AVM_SINGLE_FIELDS.zip(AVM_SINGLE_METHODS)
|
AVM_SINGLES = AVM_SINGLE_FIELDS.zip(AVM_SINGLE_METHODS)
|
||||||
|
@ -135,6 +138,9 @@ module AVM
|
||||||
:reference_value
|
:reference_value
|
||||||
]
|
]
|
||||||
|
|
||||||
|
SEMICOLON_AVM_FIELDS = [ :categories, :proposal_id ]
|
||||||
|
:wa
|
||||||
|
|
||||||
HASH_FIELDS = [ :title, :headline, :description, :distance_notes,
|
HASH_FIELDS = [ :title, :headline, :description, :distance_notes,
|
||||||
:spectral_notes, :reference_url, :credit, :date,
|
:spectral_notes, :reference_url, :credit, :date,
|
||||||
:id, :image_type, :image_quality, :coordinate_frame,
|
:id, :image_type, :image_quality, :coordinate_frame,
|
||||||
|
@ -142,7 +148,8 @@ module AVM
|
||||||
:spatial_scale, :spatial_rotation, :coordinate_system_projection, :spatial_quality,
|
: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,
|
: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
|
attr_reader :creator, :observations
|
||||||
|
@ -191,6 +198,9 @@ module AVM
|
||||||
|
|
||||||
AVM_SINGLES_FOR_MESSAGES.each do |tag, message|
|
AVM_SINGLES_FOR_MESSAGES.each do |tag, message|
|
||||||
if value = send(message)
|
if value = send(message)
|
||||||
|
if SEMICOLON_AVM_FIELDS.include?(message)
|
||||||
|
value = value.join(';')
|
||||||
|
else
|
||||||
case value
|
case value
|
||||||
when Array
|
when Array
|
||||||
container_tag = (message == :related_resources) ? 'Bag' : 'Seq'
|
container_tag = (message == :related_resources) ? 'Bag' : 'Seq'
|
||||||
|
@ -198,6 +208,7 @@ module AVM
|
||||||
else
|
else
|
||||||
value = value.to_s
|
value = value.to_s
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
refs[:avm].add_child(%{<avm:#{tag}>#{value}</avm:#{tag}>})
|
refs[:avm].add_child(%{<avm:#{tag}>#{value}</avm:#{tag}>})
|
||||||
end
|
end
|
||||||
|
@ -280,7 +291,7 @@ module AVM
|
||||||
|
|
||||||
AVM_SINGLES.each do |tag, field|
|
AVM_SINGLES.each do |tag, field|
|
||||||
if node = refs[:avm].at_xpath("./avm:#{tag}")
|
if node = refs[:avm].at_xpath("./avm:#{tag}")
|
||||||
if field == :categories
|
if SEMICOLON_AVM_FIELDS.include?(field)
|
||||||
options[field] = node.text.split(";").collect(&:strip)
|
options[field] = node.text.split(";").collect(&:strip)
|
||||||
else
|
else
|
||||||
if !(list_items = node.search('.//rdf:li')).empty?
|
if !(list_items = node.search('.//rdf:li')).empty?
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
module Ruby
|
module Ruby
|
||||||
module Avm
|
module Avm
|
||||||
module Library
|
module Library
|
||||||
VERSION = "0.0.1"
|
VERSION = "0.0.2"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -44,6 +44,7 @@ describe AVM::Image do
|
||||||
let(:related_resources) { [ 'Resource 1', 'Resource 2' ] }
|
let(:related_resources) { [ 'Resource 1', 'Resource 2' ] }
|
||||||
let(:metadata_date) { '2010-01-05' }
|
let(:metadata_date) { '2010-01-05' }
|
||||||
let(:metadata_version) { '1.2' }
|
let(:metadata_version) { '1.2' }
|
||||||
|
let(:proposal_id) { [ 'one', 'two', 'three' ] }
|
||||||
|
|
||||||
def self.with_all_options
|
def self.with_all_options
|
||||||
let(:options) { {
|
let(:options) { {
|
||||||
|
@ -80,7 +81,8 @@ describe AVM::Image do
|
||||||
:metadata_date => metadata_date,
|
:metadata_date => metadata_date,
|
||||||
:metadata_version => metadata_version,
|
:metadata_version => metadata_version,
|
||||||
:subject_names => subject_names,
|
:subject_names => subject_names,
|
||||||
:categories => categories
|
:categories => categories,
|
||||||
|
:proposal_id => proposal_id
|
||||||
} }
|
} }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -124,6 +126,7 @@ describe AVM::Image do
|
||||||
its(:related_resources) { should == related_resources }
|
its(:related_resources) { should == related_resources }
|
||||||
its(:metadata_date) { should == Time.parse(metadata_date) }
|
its(:metadata_date) { should == Time.parse(metadata_date) }
|
||||||
its(:metadata_version) { should == metadata_version }
|
its(:metadata_version) { should == metadata_version }
|
||||||
|
its(:proposal_id) { should == proposal_id }
|
||||||
|
|
||||||
its(:subject_names) { should == subject_names }
|
its(:subject_names) { should == subject_names }
|
||||||
its(:categories) { should == categories }
|
its(:categories) { should == categories }
|
||||||
|
@ -152,16 +155,16 @@ describe AVM::Image do
|
||||||
:image_quality => avm_image_quality.new,
|
:image_quality => avm_image_quality.new,
|
||||||
:coordinate_frame => avm_coordinate_frame.new,
|
:coordinate_frame => avm_coordinate_frame.new,
|
||||||
:equinox => equinox,
|
:equinox => equinox,
|
||||||
:reference_value => reference_value,
|
:reference_value => reference_value.collect(&:to_f),
|
||||||
:reference_dimension => reference_dimension,
|
:reference_dimension => reference_dimension.collect(&:to_f),
|
||||||
:reference_pixel => reference_pixel,
|
:reference_pixel => reference_pixel.collect(&:to_f),
|
||||||
:spatial_scale => spatial_scale,
|
:spatial_scale => spatial_scale.collect(&:to_f),
|
||||||
:spatial_rotation => spatial_rotation,
|
:spatial_rotation => spatial_rotation,
|
||||||
:coordinate_system_projection => avm_coordinate_system_projection.new,
|
:coordinate_system_projection => avm_coordinate_system_projection.new,
|
||||||
:spatial_quality => avm_spatial_quality.new,
|
:spatial_quality => avm_spatial_quality.new,
|
||||||
:spatial_notes => spatial_notes,
|
:spatial_notes => spatial_notes,
|
||||||
:fits_header => fits_header,
|
:fits_header => fits_header,
|
||||||
:spatial_cd_matrix => spatial_cd_matrix,
|
:spatial_cd_matrix => spatial_cd_matrix.collect(&:to_f),
|
||||||
:distance => [ light_years, redshift ],
|
:distance => [ light_years, redshift ],
|
||||||
:creator => [],
|
:creator => [],
|
||||||
:publisher => publisher,
|
:publisher => publisher,
|
||||||
|
@ -173,7 +176,8 @@ describe AVM::Image do
|
||||||
:metadata_version => metadata_version,
|
:metadata_version => metadata_version,
|
||||||
:subject_names => subject_names,
|
:subject_names => subject_names,
|
||||||
:categories => categories,
|
:categories => categories,
|
||||||
:observations => []
|
:observations => [],
|
||||||
|
:proposal_id => proposal_id
|
||||||
} }
|
} }
|
||||||
|
|
||||||
its(:distance) { should == [ light_years, redshift ] }
|
its(:distance) { should == [ light_years, redshift ] }
|
||||||
|
@ -199,7 +203,7 @@ describe AVM::Image do
|
||||||
:light_years, :coordinate_frame, :equinox, :reference_value,
|
:light_years, :coordinate_frame, :equinox, :reference_value,
|
||||||
:reference_dimension, :reference_pixel, :spatial_scale,
|
:reference_dimension, :reference_pixel, :spatial_scale,
|
||||||
:spatial_rotation, :coordinate_system_projection, :spatial_quality, :spatial_notes,
|
: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|
|
].each do |field|
|
||||||
its(field) { should be_nil }
|
its(field) { should be_nil }
|
||||||
end
|
end
|
||||||
|
@ -285,6 +289,8 @@ describe AVM::Image do
|
||||||
xpath_text(avm, './avm:ID').should == id
|
xpath_text(avm, './avm:ID').should == id
|
||||||
xpath_text(avm, './avm:Type').should == type
|
xpath_text(avm, './avm:Type').should == type
|
||||||
xpath_text(avm, './avm:Image.ProductQuality').should == image_quality
|
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
|
end
|
||||||
|
|
||||||
it "should have the spatial tags" do
|
it "should have the spatial tags" do
|
||||||
|
|
|
@ -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
|
|
||||||
|
|
||||||
|
|
|
@ -96,6 +96,7 @@
|
||||||
</avm:RelatedResources>
|
</avm:RelatedResources>
|
||||||
<avm:MetadataDate>2010-01-05</avm:MetadataDate>
|
<avm:MetadataDate>2010-01-05</avm:MetadataDate>
|
||||||
<avm:MetadataVersion>1.2</avm:MetadataVersion>
|
<avm:MetadataVersion>1.2</avm:MetadataVersion>
|
||||||
|
<avm:ProposalID>one;two;three</avm:ProposalID>
|
||||||
</rdf:Description>
|
</rdf:Description>
|
||||||
</rdf:RDF>
|
</rdf:RDF>
|
||||||
</x:xmpmeta>
|
</x:xmpmeta>
|
||||||
|
|
|
@ -91,6 +91,7 @@
|
||||||
</avm:RelatedResources>
|
</avm:RelatedResources>
|
||||||
<avm:MetadataDate>2010-01-05</avm:MetadataDate>
|
<avm:MetadataDate>2010-01-05</avm:MetadataDate>
|
||||||
<avm:MetadataVersion>1.2</avm:MetadataVersion>
|
<avm:MetadataVersion>1.2</avm:MetadataVersion>
|
||||||
|
<avm:ProposalID>one;two;three</avm:ProposalID>
|
||||||
</rdf:Description>
|
</rdf:Description>
|
||||||
</rdf:RDF>
|
</rdf:RDF>
|
||||||
</x:xmpmeta>
|
</x:xmpmeta>
|
||||||
|
|
|
@ -96,6 +96,7 @@
|
||||||
</avm:RelatedResources>
|
</avm:RelatedResources>
|
||||||
<avm:MetadataDate>2010-01-05</avm:MetadataDate>
|
<avm:MetadataDate>2010-01-05</avm:MetadataDate>
|
||||||
<avm:MetadataVersion>1.2</avm:MetadataVersion>
|
<avm:MetadataVersion>1.2</avm:MetadataVersion>
|
||||||
|
<avm:ProposalID>one;two;three</avm:ProposalID>
|
||||||
</rdf:Description>
|
</rdf:Description>
|
||||||
</rdf:RDF>
|
</rdf:RDF>
|
||||||
</x:xmpmeta>
|
</x:xmpmeta>
|
||||||
|
|
|
@ -91,6 +91,7 @@
|
||||||
</avm:RelatedResources>
|
</avm:RelatedResources>
|
||||||
<avm:MetadataDate>2010-01-05</avm:MetadataDate>
|
<avm:MetadataDate>2010-01-05</avm:MetadataDate>
|
||||||
<avm:MetadataVersion>1.2</avm:MetadataVersion>
|
<avm:MetadataVersion>1.2</avm:MetadataVersion>
|
||||||
|
<avm:ProposalID>one;two;three</avm:ProposalID>
|
||||||
</rdf:Description>
|
</rdf:Description>
|
||||||
</rdf:RDF>
|
</rdf:RDF>
|
||||||
</x:xmpmeta>
|
</x:xmpmeta>
|
||||||
|
|
Loading…
Reference in New Issue