onix 0.8.4 → 0.8.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 CHANGED
@@ -1,3 +1,9 @@
1
+ v0.8.5 (21st December 2010)
2
+ - switch back to the vanilla roxml gem. Ben is maintaining it again and
3
+ he has merged in my bug fixes
4
+ - update packaging - use bundler and rspec 2.x
5
+ - support normalising short tag files that include HTML tags
6
+
1
7
  v0.8.4 (18th October 2010)
2
8
  - some small fixes to xml names from Tim
3
9
  - make all code lists available via the ONIX::Lists class
@@ -10,7 +10,7 @@ module ONIX
10
10
  module Version #:nodoc:
11
11
  Major = 0
12
12
  Minor = 8
13
- Tiny = 4
13
+ Tiny = 5
14
14
 
15
15
  String = [Major, Minor, Tiny].join('.')
16
16
  end
@@ -3,7 +3,7 @@
3
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
4
4
  require 'date'
5
5
 
6
- context "ONIX::APAProduct" do
6
+ describe "ONIX::APAProduct" do
7
7
 
8
8
  before(:each) do
9
9
  @data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -12,7 +12,7 @@ context "ONIX::APAProduct" do
12
12
  @product_node = @doc.root
13
13
  end
14
14
 
15
- specify "should provide read access to attributes" do
15
+ it "should provide read access to attributes" do
16
16
  @product = ONIX::Product.from_xml(@product_node.to_s)
17
17
  @apa = ONIX::APAProduct.new(@product)
18
18
 
@@ -26,7 +26,7 @@ context "ONIX::APAProduct" do
26
26
  @apa.pack_quantity.should eql(12)
27
27
  end
28
28
 
29
- specify "should provide write access to attributes" do
29
+ it "should provide write access to attributes" do
30
30
  apa = ONIX::APAProduct.new
31
31
 
32
32
  apa.notification_type = 3
@@ -56,8 +56,8 @@ context "ONIX::APAProduct" do
56
56
 
57
57
  end
58
58
 
59
- context ONIX::APAProduct, "series method" do
60
- specify "should set the nested series value on the underlying product class" do
59
+ describe ONIX::APAProduct, "series method" do
60
+ it "should set the nested series value on the underlying product class" do
61
61
  apa = ONIX::APAProduct.new
62
62
 
63
63
  apa.series = "Harry Potter"
@@ -66,7 +66,7 @@ context ONIX::APAProduct, "series method" do
66
66
  end
67
67
  end
68
68
 
69
- context ONIX::APAProduct, "price method" do
69
+ describe ONIX::APAProduct, "price method" do
70
70
  before(:each) do
71
71
  @data_path = File.join(File.dirname(__FILE__),"..","data")
72
72
  file1 = File.join(@data_path, "usd.xml")
@@ -74,7 +74,7 @@ context ONIX::APAProduct, "price method" do
74
74
  @product_node = @doc.root
75
75
  end
76
76
 
77
- specify "should return the first price in the file, regardless of type" do
77
+ it "should return the first price in the file, regardless of type" do
78
78
  @product = ONIX::Product.from_xml(@product_node.to_s)
79
79
  @apa = ONIX::APAProduct.new(@product)
80
80
 
@@ -82,7 +82,7 @@ context ONIX::APAProduct, "price method" do
82
82
  end
83
83
  end
84
84
 
85
- context ONIX::APAProduct, "rrp_exc_sales_tax method" do
85
+ describe ONIX::APAProduct, "rrp_exc_sales_tax method" do
86
86
  before(:each) do
87
87
  @data_path = File.join(File.dirname(__FILE__),"..","data")
88
88
  file1 = File.join(@data_path, "usd.xml")
@@ -90,7 +90,7 @@ context ONIX::APAProduct, "rrp_exc_sales_tax method" do
90
90
  @product_node = @doc.root
91
91
  end
92
92
 
93
- specify "should return the first price in the file of type 1" do
93
+ it "should return the first price in the file of type 1" do
94
94
  @product = ONIX::Product.from_xml(@product_node.to_s)
95
95
  @apa = ONIX::APAProduct.new(@product)
96
96
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
4
4
 
5
- context "ONIX::AudienceRange" do
5
+ describe ONIX::AudienceRange do
6
6
 
7
7
  before(:each) do
8
8
  data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -11,12 +11,12 @@ context "ONIX::AudienceRange" do
11
11
  @root = @doc.root
12
12
  end
13
13
 
14
- specify "should correctly convert to a string" do
14
+ it "should correctly convert to a string" do
15
15
  aud = ONIX::AudienceRange.from_xml(@root.to_s)
16
16
  aud.to_xml.to_s[0,15].should eql("<AudienceRange>")
17
17
  end
18
18
 
19
- specify "should provide read access to first level attributes" do
19
+ it "should provide read access to first level attributes" do
20
20
  aud = ONIX::AudienceRange.from_xml(@root.to_s)
21
21
 
22
22
  aud.audience_range_qualifier.should eql(11)
@@ -28,7 +28,7 @@ context "ONIX::AudienceRange" do
28
28
  aud.audience_range_values[1].should eql(5)
29
29
  end
30
30
 
31
- specify "should provide write access to first level attributes" do
31
+ it "should provide write access to first level attributes" do
32
32
  aud = ONIX::AudienceRange.new
33
33
 
34
34
  aud.audience_range_qualifier = 12
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
4
4
 
5
- context "ONIX::Contributor" do
5
+ describe ONIX::Contributor do
6
6
 
7
7
  before(:each) do
8
8
  data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -11,12 +11,12 @@ context "ONIX::Contributor" do
11
11
  @root = @doc.root
12
12
  end
13
13
 
14
- specify "should correctly convert to a string" do
14
+ it "should correctly convert to a string" do
15
15
  header = ONIX::Contributor.from_xml(@root.to_s)
16
16
  header.to_xml.to_s[0,13].should eql("<Contributor>")
17
17
  end
18
18
 
19
- specify "should provide read access to first level attributes" do
19
+ it "should provide read access to first level attributes" do
20
20
  contrib = ONIX::Contributor.from_xml(@root.to_s)
21
21
 
22
22
  contrib.contributor_role.should eql("A01")
@@ -24,7 +24,7 @@ context "ONIX::Contributor" do
24
24
  contrib.sequence_number.should eql(1)
25
25
  end
26
26
 
27
- specify "should provide write access to first level attributes" do
27
+ it "should provide write access to first level attributes" do
28
28
  contrib = ONIX::Contributor.new
29
29
 
30
30
  contrib.contributor_role = "A02"
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
4
4
 
5
- context "ONIX::Header" do
5
+ describe ONIX::Header do
6
6
 
7
7
  before(:each) do
8
8
  data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -11,12 +11,12 @@ context "ONIX::Header" do
11
11
  @header_node = @doc.root
12
12
  end
13
13
 
14
- specify "should correctly convert to a string" do
14
+ it "should correctly convert to a string" do
15
15
  header = ONIX::Header.from_xml(@header_node.to_s)
16
16
  header.to_xml.to_s[0,8].should eql("<Header>")
17
17
  end
18
18
 
19
- specify "should provide read access to first level attributes" do
19
+ it "should provide read access to first level attributes" do
20
20
  header = ONIX::Header.from_xml(@header_node.to_s)
21
21
 
22
22
  header.from_ean_number.should eql("1111111111111")
@@ -42,7 +42,7 @@ context "ONIX::Header" do
42
42
  header.default_class_of_trade.should eql("f")
43
43
  end
44
44
 
45
- specify "should provide write access to first level attributes" do
45
+ it "should provide write access to first level attributes" do
46
46
  header = ONIX::Header.new
47
47
 
48
48
  header.from_ean_number = "1111111111111"
@@ -95,7 +95,7 @@ context "ONIX::Header" do
95
95
  header.to_xml.to_s.include?("<DefaultClassOfTrade>f</DefaultClassOfTrade>").should be_true
96
96
  end
97
97
 
98
- specify "should correctly handle text with & < and >" do
98
+ it "should correctly handle text with & < and >" do
99
99
  header = ONIX::Header.new
100
100
 
101
101
  header.from_company = "James & Healy"
@@ -109,9 +109,9 @@ context "ONIX::Header" do
109
109
  end
110
110
  end
111
111
 
112
- context "ONIX::Header" do
112
+ describe ONIX::Header do
113
113
 
114
- specify "should correctly handle headers with an invalid sent date" do
114
+ it "should correctly handle headers with an invalid sent date" do
115
115
  data_path = File.join(File.dirname(__FILE__),"..","data")
116
116
  file = File.join(data_path, "header_invalid_sentdate.xml")
117
117
  header = ONIX::Header.from_xml(File.read(file))
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
4
4
 
5
- context "ONIX::Imprint" do
5
+ describe ONIX::Imprint do
6
6
 
7
7
  before(:each) do
8
8
  data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -11,18 +11,18 @@ context "ONIX::Imprint" do
11
11
  @root = @doc.root
12
12
  end
13
13
 
14
- specify "should correctly convert to a string" do
14
+ it "should correctly convert to a string" do
15
15
  imp = ONIX::Imprint.from_xml(@root.to_s)
16
16
  imp.to_xml.to_s[0,9].should eql("<Imprint>")
17
17
  end
18
18
 
19
- specify "should provide read access to first level attributes" do
19
+ it "should provide read access to first level attributes" do
20
20
  imp = ONIX::Imprint.from_xml(@root.to_s)
21
21
 
22
22
  imp.imprint_name.should eql("Oxford University Press UK")
23
23
  end
24
24
 
25
- specify "should provide write access to first level attributes" do
25
+ it "should provide write access to first level attributes" do
26
26
  imp = ONIX::Imprint.new
27
27
 
28
28
  imp.imprint_name = "Paulist Press"
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
4
4
 
5
- context "ONIX::Language" do
5
+ describe ONIX::Language do
6
6
 
7
7
  before(:each) do
8
8
  data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -11,12 +11,12 @@ context "ONIX::Language" do
11
11
  @root = @doc.root
12
12
  end
13
13
 
14
- specify "should correctly convert to a string" do
14
+ it "should correctly convert to a string" do
15
15
  lan = ONIX::Language.from_xml(@root.to_s)
16
16
  lan.to_xml.to_s[0,10].should eql("<Language>")
17
17
  end
18
18
 
19
- specify "should provide read access to first level attributes" do
19
+ it "should provide read access to first level attributes" do
20
20
  lan = ONIX::Language.from_xml(@root.to_s)
21
21
 
22
22
  lan.language_role.should eql(1)
@@ -24,7 +24,7 @@ context "ONIX::Language" do
24
24
  lan.country_code.should eql("US")
25
25
  end
26
26
 
27
- specify "should provide write access to first level attributes" do
27
+ it "should provide write access to first level attributes" do
28
28
  lan = ONIX::Language.new
29
29
 
30
30
  lan.language_role = 2
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
4
4
 
5
- context ONIX::Lists, "list method" do
5
+ describe ONIX::Lists, "list method" do
6
6
 
7
7
  it "should return a hash containing the ProductForm code list" do
8
8
  forms = ONIX::Lists.list(7)
@@ -12,7 +12,7 @@ context ONIX::Lists, "list method" do
12
12
 
13
13
  end
14
14
 
15
- context ONIX::Lists, "product_form shortcut method" do
15
+ describe ONIX::Lists, "product_form shortcut method" do
16
16
 
17
17
  it "should return a hash containing the ProductForm code list" do
18
18
  forms = ONIX::Lists.product_form
@@ -22,7 +22,7 @@ context ONIX::Lists, "product_form shortcut method" do
22
22
 
23
23
  end
24
24
 
25
- context ONIX::Lists, "PRODUCT_FORM shortcut constant" do
25
+ describe ONIX::Lists, "PRODUCT_FORM shortcut constant" do
26
26
 
27
27
  it "should return a hash containing the ProductForm code list" do
28
28
  forms = ONIX::Lists::PRODUCT_FORM
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
4
4
 
5
- context "ONIX::MarketRepresentation" do
5
+ describe ONIX::MarketRepresentation do
6
6
 
7
7
  before(:each) do
8
8
  data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -11,19 +11,19 @@ context "ONIX::MarketRepresentation" do
11
11
  @root = @doc.root
12
12
  end
13
13
 
14
- specify "should correctly convert to a string" do
14
+ it "should correctly convert to a string" do
15
15
  rep = ONIX::MarketRepresentation.from_xml(@root.to_s)
16
16
  rep.to_xml.to_s[0,22].should eql("<MarketRepresentation>")
17
17
  end
18
18
 
19
- specify "should provide read access to first level attributes" do
19
+ it "should provide read access to first level attributes" do
20
20
  rep = ONIX::MarketRepresentation.from_xml(@root.to_s)
21
21
 
22
22
  rep.agent_name.should eql("Allen & Unwin")
23
23
  rep.agent_role.should eql(7)
24
24
  end
25
25
 
26
- specify "should provide write access to first level attributes" do
26
+ it "should provide write access to first level attributes" do
27
27
  rep = ONIX::MarketRepresentation.new
28
28
 
29
29
  rep.agent_name = "Rainbow Book Agencies"
@@ -35,5 +35,3 @@ context "ONIX::MarketRepresentation" do
35
35
  end
36
36
 
37
37
  end
38
-
39
-
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
4
4
 
5
- context "ONIX::Measure" do
5
+ describe ONIX::Measure do
6
6
 
7
7
  before(:each) do
8
8
  data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -11,12 +11,12 @@ context "ONIX::Measure" do
11
11
  @root = @doc.root
12
12
  end
13
13
 
14
- specify "should correctly convert to a string" do
14
+ it "should correctly convert to a string" do
15
15
  m = ONIX::Measure.from_xml(@root.to_s)
16
16
  m.to_xml.to_s[0,9].should eql("<Measure>")
17
17
  end
18
18
 
19
- specify "should provide read access to first level attributes" do
19
+ it "should provide read access to first level attributes" do
20
20
  m = ONIX::Measure.from_xml(@root.to_s)
21
21
 
22
22
  m.measure_type_code.should eql(1)
@@ -24,7 +24,7 @@ context "ONIX::Measure" do
24
24
  m.measure_unit_code.should eql("mm")
25
25
  end
26
26
 
27
- specify "should provide write access to first level attributes" do
27
+ it "should provide write access to first level attributes" do
28
28
  m = ONIX::Measure.new
29
29
 
30
30
  m.measure_type_code = 1
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
4
4
 
5
- context "ONIX::MediaFile" do
5
+ describe ONIX::MediaFile do
6
6
 
7
7
  before(:each) do
8
8
  data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -11,19 +11,19 @@ context "ONIX::MediaFile" do
11
11
  @root = @doc.root
12
12
  end
13
13
 
14
- specify "should correctly convert to a string" do
14
+ it "should correctly convert to a string" do
15
15
  mf = ONIX::MediaFile.from_xml(@root.to_s)
16
16
  mf.to_xml.to_s[0,11].should eql("<MediaFile>")
17
17
  end
18
18
 
19
- specify "should provide read access to first level attributes" do
19
+ it "should provide read access to first level attributes" do
20
20
  mf = ONIX::MediaFile.from_xml(@root.to_s)
21
21
  mf.media_file_type_code.should eql(4)
22
22
  mf.media_file_link_type_code.should eql(1)
23
23
  mf.media_file_link.should eql("http://www.allenandunwin.com/BookCovers/resized_9788888028729_224_297_FitSquare.jpg")
24
24
  end
25
25
 
26
- specify "should provide write access to first level attributes" do
26
+ it "should provide write access to first level attributes" do
27
27
  mf = ONIX::MediaFile.new
28
28
 
29
29
  mf.media_file_type_code = 2
@@ -2,7 +2,7 @@
2
2
 
3
3
  require File.dirname(__FILE__) + '/spec_helper.rb'
4
4
 
5
- context "ONIX::Normaliser", "with a simple short tag file" do
5
+ describe ONIX::Normaliser, "with a simple short tag file" do
6
6
 
7
7
  before(:each) do
8
8
  @data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -14,7 +14,7 @@ context "ONIX::Normaliser", "with a simple short tag file" do
14
14
  File.unlink(@outfile) if File.file?(@outfile)
15
15
  end
16
16
 
17
- specify "should correctly convert short tag file to reference tag" do
17
+ it "should correctly convert short tag file to reference tag" do
18
18
  ONIX::Normaliser.process(@filename, @outfile)
19
19
 
20
20
  File.file?(@outfile).should be_true
@@ -22,10 +22,33 @@ context "ONIX::Normaliser", "with a simple short tag file" do
22
22
  content.include?("<m174>").should be_false
23
23
  content.include?("<FromCompany>").should be_true
24
24
  end
25
+ end
26
+
27
+ describe ONIX::Normaliser, "with a short tag file that include HTML tags" do
28
+
29
+ before(:each) do
30
+ @data_path = File.join(File.dirname(__FILE__),"..","data")
31
+ @filename = File.join(@data_path, "short_tags_ivp.xml")
32
+ @outfile = @filename + ".new"
33
+ end
34
+
35
+ after(:each) do
36
+ File.unlink(@outfile) if File.file?(@outfile)
37
+ end
38
+
39
+ it "should correctly convert short tag file to reference tag" do
40
+ ONIX::Normaliser.process(@filename, @outfile)
41
+
42
+ File.file?(@outfile).should be_true
43
+ content = File.read(@outfile)
44
+ content.include?("<m174>").should be_false
45
+ content.include?("<FromCompany>").should be_true
46
+ content.include?("<em>Discipleship Essentials</em>").should be_true
47
+ end
25
48
 
26
49
  end
27
50
 
28
- context "ONIX::Normaliser", "with a utf8 file that has illegal control chars" do
51
+ describe ONIX::Normaliser, "with a utf8 file that has illegal control chars" do
29
52
 
30
53
  before(:each) do
31
54
  @data_path = File.join(File.dirname(__FILE__),"..","data")
@@ -37,7 +60,7 @@ context "ONIX::Normaliser", "with a utf8 file that has illegal control chars" do
37
60
  File.unlink(@outfile) if File.file?(@outfile)
38
61
  end
39
62
 
40
- specify "should remove all control chars except LF, CR and TAB" do
63
+ it "should remove all control chars except LF, CR and TAB" do
41
64
  ONIX::Normaliser.process(@filename, @outfile)
42
65
 
43
66
  File.file?(@outfile).should be_true