onix 0.7.4 → 0.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +3 -0
- data/lib/onix.rb +1 -1
- data/lib/onix/header.rb +7 -1
- data/lib/onix/product.rb +7 -1
- data/spec/header_spec.rb +11 -0
- data/spec/product_spec.rb +4 -6
- metadata +3 -3
data/CHANGELOG
CHANGED
data/lib/onix.rb
CHANGED
data/lib/onix/header.rb
CHANGED
@@ -20,7 +20,13 @@ module ONIX
|
|
20
20
|
xml_accessor :to_person, :from => "ToPerson"
|
21
21
|
xml_accessor :message_number, :from => "MessageNumber"
|
22
22
|
xml_accessor :message_repeat, :from => "MessageRepeat", :as => Fixnum
|
23
|
-
xml_accessor
|
23
|
+
xml_accessor(:sent_date, :from => "SentDate", :to_xml => ONIX::Formatters.yyyymmdd) do |val|
|
24
|
+
begin
|
25
|
+
Date.parse(val)
|
26
|
+
rescue
|
27
|
+
nil
|
28
|
+
end
|
29
|
+
end
|
24
30
|
xml_accessor :message_note, :from => "MessageNote"
|
25
31
|
|
26
32
|
# defaults
|
data/lib/onix/product.rb
CHANGED
@@ -24,7 +24,13 @@ module ONIX
|
|
24
24
|
xml_accessor :imprints, :from => "Imprint", :as => [ONIX::Imprint]
|
25
25
|
xml_accessor :publishers, :from => "Publisher", :as => [ONIX::Publisher]
|
26
26
|
xml_accessor :publishing_status, :from => "PublishingStatus", :as => Fixnum, :to_xml => ONIX::Formatters.two_digit
|
27
|
-
xml_accessor
|
27
|
+
xml_accessor(:publication_date, :from => "PublicationDate", :to_xml => ONIX::Formatters.yyyymmdd) do |val|
|
28
|
+
begin
|
29
|
+
Date.parse(val)
|
30
|
+
rescue
|
31
|
+
nil
|
32
|
+
end
|
33
|
+
end
|
28
34
|
xml_accessor :year_first_published, :from => "YearFirstPublished", :as => Fixnum
|
29
35
|
xml_accessor :sales_restrictions, :from => "SalesRestriction", :as => [ONIX::SalesRestriction]
|
30
36
|
xml_accessor :measurements, :from => "Measure", :as => [ONIX::Measure]
|
data/spec/header_spec.rb
CHANGED
@@ -110,3 +110,14 @@ context "ONIX::Header" do
|
|
110
110
|
header.to_xml.to_s.include?("James > Healy").should be_true
|
111
111
|
end
|
112
112
|
end
|
113
|
+
|
114
|
+
context "ONIX::Header" do
|
115
|
+
|
116
|
+
specify "should correctly handle headers with an invalid sent date" do
|
117
|
+
data_path = File.join(File.dirname(__FILE__),"..","data")
|
118
|
+
file = File.join(data_path, "header_invalid_sentdate.xml")
|
119
|
+
header = ONIX::Header.from_xml(File.read(file))
|
120
|
+
|
121
|
+
header.sent_date.should be_nil
|
122
|
+
end
|
123
|
+
end
|
data/spec/product_spec.rb
CHANGED
@@ -86,13 +86,11 @@ context "ONIX::Product" do
|
|
86
86
|
product.to_xml.to_s.include?("<YearFirstPublished>1998</YearFirstPublished>").should be_true
|
87
87
|
end
|
88
88
|
|
89
|
-
specify "should correctly from_xml files that have
|
90
|
-
=
|
91
|
-
do
|
92
|
-
file = File.join(@data_path, "extra_entities.xml")
|
89
|
+
specify "should correctly from_xml files that have an invalid publication date" do
|
90
|
+
file = File.join(@data_path, "product_invalid_pubdate.xml")
|
93
91
|
product = ONIX::Product.from_xml(File.read(file))
|
94
92
|
|
95
|
-
product.
|
93
|
+
product.bic_main_subject.should eql("VXFC1")
|
94
|
+
product.publication_date.should be_nil
|
96
95
|
end
|
97
|
-
=end
|
98
96
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: onix
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Healy
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-09-
|
12
|
+
date: 2009-09-08 00:00:00 +10:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -159,7 +159,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
159
159
|
requirements: []
|
160
160
|
|
161
161
|
rubyforge_project: rbook
|
162
|
-
rubygems_version: 1.3.
|
162
|
+
rubygems_version: 1.3.5
|
163
163
|
signing_key:
|
164
164
|
specification_version: 3
|
165
165
|
summary: A convient mapping between ruby objects and the ONIX XML specification
|