milkfarm-onix 0.8.6 → 0.8.7
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +21 -0
- data/README.markdown +1 -0
- data/lib/onix.rb +4 -17
- data/lib/onix/code_list_extractor.rb +69 -0
- data/lib/onix/lists.rb +134 -0
- data/lib/onix/product.rb +14 -0
- data/lib/onix/sl_product.rb +24 -1
- data/lib/onix/version.rb +3 -0
- data/lib/onix/work_identifier.rb +28 -0
- data/spec/apa_product_spec.rb +9 -9
- data/spec/audience_range_spec.rb +4 -4
- data/spec/contributor_spec.rb +4 -4
- data/spec/header_spec.rb +7 -7
- data/spec/imprint_spec.rb +4 -4
- data/spec/language_spec.rb +4 -4
- data/spec/lists_spec.rb +33 -0
- data/spec/market_representation_spec.rb +4 -6
- data/spec/measure_spec.rb +4 -4
- data/spec/media_file_spec.rb +4 -4
- data/spec/normaliser_spec.rb +28 -4
- data/spec/other_text_spec.rb +4 -4
- data/spec/price_spec.rb +4 -4
- data/spec/product_identifier_spec.rb +4 -4
- data/spec/product_spec.rb +8 -8
- data/spec/publisher_spec.rb +4 -4
- data/spec/reader_spec.rb +11 -11
- data/spec/sales_restriction_spec.rb +4 -5
- data/spec/sender_identifier.rb +4 -4
- data/spec/series_identifier_spec.rb +4 -4
- data/spec/series_spec.rb +4 -4
- data/spec/spec_helper.rb +4 -1
- data/spec/stock_spec.rb +4 -4
- data/spec/subject_spec.rb +4 -5
- data/spec/supply_detail_spec.rb +4 -4
- data/spec/title_spec.rb +4 -4
- data/spec/website_spec.rb +4 -4
- data/spec/work_identifier_spec.rb +39 -0
- data/spec/writer_spec.rb +7 -7
- data/support/codes/001.tsv +10 -0
- data/support/codes/002.tsv +5 -0
- data/support/codes/003.tsv +7 -0
- data/support/codes/005.tsv +13 -0
- data/support/codes/006.tsv +76 -0
- data/support/codes/007.tsv +123 -0
- data/support/codes/008.tsv +7 -0
- data/support/codes/009.tsv +7 -0
- data/support/codes/010.tsv +34 -0
- data/support/codes/011.tsv +11 -0
- data/support/codes/012.tsv +11 -0
- data/support/codes/013.tsv +7 -0
- data/support/codes/014.tsv +4 -0
- data/support/codes/015.tsv +13 -0
- data/support/codes/016.tsv +6 -0
- data/support/codes/017.tsv +90 -0
- data/support/codes/018.tsv +3 -0
- data/support/codes/019.tsv +7 -0
- data/support/codes/020.tsv +0 -0
- data/support/codes/021.tsv +31 -0
- data/support/codes/022.tsv +9 -0
- data/support/codes/023.tsv +9 -0
- data/support/codes/024.tsv +11 -0
- data/support/codes/025.tsv +29 -0
- data/support/codes/026.tsv +75 -0
- data/support/codes/027.tsv +75 -0
- data/support/codes/028.tsv +8 -0
- data/support/codes/029.tsv +16 -0
- data/support/codes/030.tsv +15 -0
- data/support/codes/031.tsv +3 -0
- data/support/codes/032.tsv +2 -0
- data/support/codes/033.tsv +36 -0
- data/support/codes/034.tsv +14 -0
- data/support/codes/035.tsv +6 -0
- data/support/codes/036.tsv +3 -0
- data/support/codes/037.tsv +6 -0
- data/support/codes/038.tsv +36 -0
- data/support/codes/039.tsv +8 -0
- data/support/codes/040.tsv +6 -0
- data/support/codes/041.tsv +6 -0
- data/support/codes/042.tsv +16 -0
- data/support/codes/043.tsv +4 -0
- data/support/codes/044.tsv +13 -0
- data/support/codes/045.tsv +12 -0
- data/support/codes/046.tsv +3 -0
- data/support/codes/047.tsv +4 -0
- data/support/codes/048.tsv +11 -0
- data/support/codes/049.tsv +84 -0
- data/support/codes/050.tsv +8 -0
- data/support/codes/051.tsv +27 -0
- data/support/codes/052.tsv +1 -0
- data/support/codes/053.tsv +3 -0
- data/support/codes/054.tsv +23 -0
- data/support/codes/055.tsv +13 -0
- data/support/codes/056.tsv +2 -0
- data/support/codes/057.tsv +5 -0
- data/support/codes/058.tsv +21 -0
- data/support/codes/059.tsv +4 -0
- data/support/codes/060.tsv +2 -0
- data/support/codes/061.tsv +3 -0
- data/support/codes/062.tsv +5 -0
- data/support/codes/063.tsv +0 -0
- data/support/codes/064.tsv +13 -0
- data/support/codes/065.tsv +25 -0
- data/support/codes/066.tsv +4 -0
- data/support/codes/067.tsv +2 -0
- data/support/codes/068.tsv +15 -0
- data/support/codes/069.tsv +4 -0
- data/support/codes/070.tsv +2 -0
- data/support/codes/071.tsv +9 -0
- data/support/codes/072.tsv +7 -0
- data/support/codes/073.tsv +36 -0
- data/support/codes/074.tsv +489 -0
- data/support/codes/075.tsv +2 -0
- data/support/codes/076.tsv +12 -0
- data/support/codes/077.tsv +19 -0
- data/support/codes/078.tsv +148 -0
- data/support/codes/079.tsv +17 -0
- data/support/codes/080.tsv +19 -0
- data/support/codes/081.tsv +11 -0
- data/support/codes/082.tsv +17 -0
- data/support/codes/083.tsv +68 -0
- data/support/codes/084.tsv +10 -0
- data/support/codes/085.tsv +23 -0
- data/support/codes/086.tsv +5 -0
- data/support/codes/087.tsv +6 -0
- data/support/codes/088.tsv +0 -0
- data/support/codes/089.tsv +1 -0
- data/support/codes/090.tsv +11 -0
- data/support/codes/091.tsv +248 -0
- data/support/codes/092.tsv +7 -0
- data/support/codes/093.tsv +13 -0
- data/support/codes/094.tsv +3 -0
- data/support/codes/095.tsv +3 -0
- data/support/codes/096.tsv +185 -0
- data/support/codes/097.tsv +1 -0
- data/support/codes/098.tsv +21 -0
- data/support/codes/099.tsv +24 -0
- data/support/codes/100.tsv +4 -0
- data/support/codes/101.tsv +2 -0
- data/support/codes/102.tsv +3 -0
- data/support/codes/121.tsv +127 -0
- data/support/codes/138.tsv +6 -0
- data/support/codes/139.tsv +70 -0
- data/support/codes/140.tsv +7 -0
- data/support/codes/141.tsv +10 -0
- data/support/codes/142.tsv +12 -0
- data/support/codes/143.tsv +7 -0
- data/support/codes/144.tsv +4 -0
- data/support/codes/145.tsv +5 -0
- data/support/codes/146.tsv +3 -0
- data/support/codes/147.tsv +7 -0
- data/support/codes/148.tsv +3 -0
- data/support/codes/149.tsv +4 -0
- data/support/codes/150.tsv +124 -0
- data/support/codes/151.tsv +7 -0
- data/support/codes/152.tsv +2 -0
- data/support/codes/153.tsv +14 -0
- data/support/codes/154.tsv +9 -0
- data/support/codes/155.tsv +5 -0
- data/support/codes/156.tsv +4 -0
- data/support/codes/157.tsv +4 -0
- data/support/codes/158.tsv +24 -0
- data/support/codes/159.tsv +6 -0
- data/support/codes/160.tsv +0 -0
- data/support/codes/161.tsv +3 -0
- data/support/codes/162.tsv +3 -0
- data/support/codes/163.tsv +7 -0
- data/support/codes/164.tsv +2 -0
- data/support/codes/165.tsv +2 -0
- data/support/codes/166.tsv +2 -0
- data/support/codes/167.tsv +3 -0
- data/support/codes/168.tsv +2 -0
- data/support/codes/169.tsv +3 -0
- data/support/codes/170.tsv +0 -0
- data/support/codes/171.tsv +2 -0
- data/support/codes/172.tsv +1 -0
- data/support/codes/173.tsv +2 -0
- data/support/codes/174.tsv +2 -0
- data/support/codes/175.tsv +175 -0
- data/support/codes/176.tsv +12 -0
- data/support/codes/177.tsv +2 -0
- data/support/codes/178.tsv +17 -0
- data/support/switch-onix-2.1-short-to-reference.xsl +3 -2
- metadata +226 -38
- data/lib/onix/lists/audience_code.rb +0 -17
- data/lib/onix/lists/contributor_role.rb +0 -99
- data/lib/onix/lists/country_code.rb +0 -257
- data/lib/onix/lists/language_code.rb +0 -498
- data/lib/onix/lists/language_role.rb +0 -18
- data/lib/onix/lists/notification_type.rb +0 -19
- data/lib/onix/lists/product_availability.rb +0 -32
- data/lib/onix/lists/product_form.rb +0 -99
- data/lib/onix/lists/product_form_detail.rb +0 -157
data/spec/audience_range_spec.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
4
4
|
|
5
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
data/spec/contributor_spec.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
4
4
|
|
5
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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"
|
data/spec/header_spec.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
4
4
|
|
5
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
112
|
+
describe ONIX::Header do
|
113
113
|
|
114
|
-
|
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))
|
data/spec/imprint_spec.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
4
4
|
|
5
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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"
|
data/spec/language_spec.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
4
4
|
|
5
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
data/spec/lists_spec.rb
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
|
3
|
+
require File.dirname(__FILE__) + '/spec_helper.rb'
|
4
|
+
|
5
|
+
describe ONIX::Lists, "list method" do
|
6
|
+
|
7
|
+
it "should return a hash containing the ProductForm code list" do
|
8
|
+
forms = ONIX::Lists.list(7)
|
9
|
+
forms.should be_a(Hash)
|
10
|
+
forms["BB"].should eql("Hardback")
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
describe ONIX::Lists, "product_form shortcut method" do
|
16
|
+
|
17
|
+
it "should return a hash containing the ProductForm code list" do
|
18
|
+
forms = ONIX::Lists.product_form
|
19
|
+
forms.should be_a(Hash)
|
20
|
+
forms["BB"].should eql("Hardback")
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
|
25
|
+
describe ONIX::Lists, "PRODUCT_FORM shortcut constant" do
|
26
|
+
|
27
|
+
it "should return a hash containing the ProductForm code list" do
|
28
|
+
forms = ONIX::Lists::PRODUCT_FORM
|
29
|
+
forms.should be_a(Hash)
|
30
|
+
forms["BB"].should eql("Hardback")
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
4
4
|
|
5
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
data/spec/measure_spec.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
4
4
|
|
5
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
data/spec/media_file_spec.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
4
4
|
|
5
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
data/spec/normaliser_spec.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
4
4
|
|
5
|
-
|
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
|
-
|
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
|
@@ -25,7 +25,31 @@ context "ONIX::Normaliser", "with a simple short tag file" do
|
|
25
25
|
|
26
26
|
end
|
27
27
|
|
28
|
-
|
28
|
+
describe ONIX::Normaliser, "with a short tag file that include HTML tags" do
|
29
|
+
|
30
|
+
before(:each) do
|
31
|
+
@data_path = File.join(File.dirname(__FILE__),"..","data")
|
32
|
+
@filename = File.join(@data_path, "short_tags_ivp.xml")
|
33
|
+
@outfile = @filename + ".new"
|
34
|
+
end
|
35
|
+
|
36
|
+
after(:each) do
|
37
|
+
File.unlink(@outfile) if File.file?(@outfile)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should correctly convert short tag file to reference tag" do
|
41
|
+
ONIX::Normaliser.process(@filename, @outfile)
|
42
|
+
|
43
|
+
File.file?(@outfile).should be_true
|
44
|
+
content = File.read(@outfile)
|
45
|
+
content.include?("<m174>").should be_false
|
46
|
+
content.include?("<FromCompany>").should be_true
|
47
|
+
content.include?("<em>Discipleship Essentials</em>").should be_true
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
describe ONIX::Normaliser, "with a utf8 file that has illegal control chars" do
|
29
53
|
|
30
54
|
before(:each) do
|
31
55
|
@data_path = File.join(File.dirname(__FILE__),"..","data")
|
@@ -37,7 +61,7 @@ context "ONIX::Normaliser", "with a utf8 file that has illegal control chars" do
|
|
37
61
|
File.unlink(@outfile) if File.file?(@outfile)
|
38
62
|
end
|
39
63
|
|
40
|
-
|
64
|
+
it "should remove all control chars except LF, CR and TAB" do
|
41
65
|
ONIX::Normaliser.process(@filename, @outfile)
|
42
66
|
|
43
67
|
File.file?(@outfile).should be_true
|
data/spec/other_text_spec.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
4
4
|
|
5
|
-
|
5
|
+
describe ONIX::OtherText do
|
6
6
|
|
7
7
|
before(:each) do
|
8
8
|
data_path = File.join(File.dirname(__FILE__),"..","data")
|
@@ -11,19 +11,19 @@ context "ONIX::OtherText" do
|
|
11
11
|
@root = @doc.root
|
12
12
|
end
|
13
13
|
|
14
|
-
|
14
|
+
it "should correctly convert to a string" do
|
15
15
|
ot = ONIX::OtherText.from_xml(@root.to_s)
|
16
16
|
ot.to_xml.to_s[0,11].should eql("<OtherText>")
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
it "should provide read access to first level attributes" do
|
20
20
|
ot = ONIX::OtherText.from_xml(@root.to_s)
|
21
21
|
|
22
22
|
ot.text_type_code.should eql(2)
|
23
23
|
ot.text[0,7].should eql("A woman")
|
24
24
|
end
|
25
25
|
|
26
|
-
|
26
|
+
it "should provide write access to first level attributes" do
|
27
27
|
ot = ONIX::OtherText.new
|
28
28
|
|
29
29
|
ot.text_type_code = 2
|
data/spec/price_spec.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
4
4
|
|
5
|
-
|
5
|
+
describe ONIX::Price do
|
6
6
|
|
7
7
|
before(:each) do
|
8
8
|
data_path = File.join(File.dirname(__FILE__),"..","data")
|
@@ -11,19 +11,19 @@ context "ONIX::Price" do
|
|
11
11
|
@root = @doc.root
|
12
12
|
end
|
13
13
|
|
14
|
-
|
14
|
+
it "should correctly convert to a string" do
|
15
15
|
p = ONIX::Price.from_xml(@root.to_s)
|
16
16
|
p.to_xml.to_s[0,7].should eql("<Price>")
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
it "should provide read access to first level attributes" do
|
20
20
|
p = ONIX::Price.from_xml(@root.to_s)
|
21
21
|
|
22
22
|
p.price_type_code.should eql(2)
|
23
23
|
p.price_amount.should eql(BigDecimal.new("7.5"))
|
24
24
|
end
|
25
25
|
|
26
|
-
|
26
|
+
it "should provide write access to first level attributes" do
|
27
27
|
p = ONIX::Price.new
|
28
28
|
|
29
29
|
p.price_type_code = 1
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
require File.dirname(__FILE__) + '/spec_helper.rb'
|
4
4
|
|
5
|
-
|
5
|
+
describe ONIX::ProductIdentifier do
|
6
6
|
|
7
7
|
before(:each) do
|
8
8
|
data_path = File.join(File.dirname(__FILE__),"..","data")
|
@@ -11,19 +11,19 @@ context "ONIX::ProductIdentifier" do
|
|
11
11
|
@root = @doc.root
|
12
12
|
end
|
13
13
|
|
14
|
-
|
14
|
+
it "should correctly convert to a string" do
|
15
15
|
id = ONIX::ProductIdentifier.from_xml(@root.to_s)
|
16
16
|
id.to_xml.to_s[0,19].should eql("<ProductIdentifier>")
|
17
17
|
end
|
18
18
|
|
19
|
-
|
19
|
+
it "should provide read access to first level attributes" do
|
20
20
|
id = ONIX::ProductIdentifier.from_xml(@root.to_s)
|
21
21
|
|
22
22
|
id.product_id_type.should eql(2)
|
23
23
|
id.id_value.should eql("0858198363")
|
24
24
|
end
|
25
25
|
|
26
|
-
|
26
|
+
it "should provide write access to first level attributes" do
|
27
27
|
id = ONIX::ProductIdentifier.new
|
28
28
|
|
29
29
|
id.product_id_type = 2
|