onix 0.7.4 → 0.7.5

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,6 @@
1
+ v0.7.5 (8th September 2009)
2
+ - Don't raise an exception on malformed dates when reading files
3
+
1
4
  v0.7.4 (2nd September 2009)
2
5
  - Expand ONIX::Normaliser
3
6
  - strip control chars
@@ -16,7 +16,7 @@ module ONIX
16
16
  module Version #:nodoc:
17
17
  Major = 0
18
18
  Minor = 7
19
- Tiny = 4
19
+ Tiny = 5
20
20
 
21
21
  String = [Major, Minor, Tiny].join('.')
22
22
  end
@@ -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 :sent_date, :from => "SentDate", :as => Date, :to_xml => ONIX::Formatters.yyyymmdd
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
@@ -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 :publication_date, :from => "PublicationDate", :as => Date, :to_xml => ONIX::Formatters.yyyymmdd
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]
@@ -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
@@ -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 non-standard entties"
90
- =begin
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.titles.first.title_text.should eql("Ipod® & Itunes® for Dummies®, 4th Edition")
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
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-02 00:00:00 +10:00
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.4
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