onix 0.8.3 → 0.8.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. data/CHANGELOG +4 -0
  2. data/README.markdown +1 -0
  3. data/lib/onix/code_list_extractor.rb +69 -0
  4. data/lib/onix/lists.rb +134 -0
  5. data/lib/onix/price.rb +1 -1
  6. data/lib/onix/product.rb +1 -0
  7. data/lib/onix.rb +4 -10
  8. data/spec/apa_product_spec.rb +2 -2
  9. data/spec/audience_range_spec.rb +2 -2
  10. data/spec/contributor_spec.rb +2 -2
  11. data/spec/header_spec.rb +2 -2
  12. data/spec/imprint_spec.rb +2 -2
  13. data/spec/language_spec.rb +2 -2
  14. data/spec/lists_spec.rb +33 -0
  15. data/spec/market_representation_spec.rb +2 -2
  16. data/spec/measure_spec.rb +2 -2
  17. data/spec/media_file_spec.rb +2 -2
  18. data/spec/other_text_spec.rb +2 -2
  19. data/spec/price_spec.rb +2 -2
  20. data/spec/product_identifier_spec.rb +2 -2
  21. data/spec/product_spec.rb +2 -2
  22. data/spec/publisher_spec.rb +2 -2
  23. data/spec/sales_restriction_spec.rb +2 -2
  24. data/spec/sender_identifier.rb +2 -2
  25. data/spec/series_identifier_spec.rb +2 -2
  26. data/spec/series_spec.rb +2 -2
  27. data/spec/stock_spec.rb +2 -2
  28. data/spec/subject_spec.rb +2 -2
  29. data/spec/supply_detail_spec.rb +2 -2
  30. data/spec/title_spec.rb +2 -2
  31. data/spec/website_spec.rb +2 -2
  32. data/support/codes/001.tsv +10 -0
  33. data/support/codes/002.tsv +5 -0
  34. data/support/codes/003.tsv +7 -0
  35. data/support/codes/005.tsv +13 -0
  36. data/support/codes/006.tsv +76 -0
  37. data/support/codes/007.tsv +123 -0
  38. data/support/codes/008.tsv +7 -0
  39. data/support/codes/009.tsv +7 -0
  40. data/support/codes/010.tsv +34 -0
  41. data/support/codes/011.tsv +11 -0
  42. data/support/codes/012.tsv +11 -0
  43. data/support/codes/013.tsv +7 -0
  44. data/support/codes/014.tsv +4 -0
  45. data/support/codes/015.tsv +13 -0
  46. data/support/codes/016.tsv +6 -0
  47. data/support/codes/017.tsv +90 -0
  48. data/support/codes/018.tsv +3 -0
  49. data/support/codes/019.tsv +7 -0
  50. data/support/codes/020.tsv +0 -0
  51. data/support/codes/021.tsv +31 -0
  52. data/support/codes/022.tsv +9 -0
  53. data/support/codes/023.tsv +9 -0
  54. data/support/codes/024.tsv +11 -0
  55. data/support/codes/025.tsv +29 -0
  56. data/support/codes/026.tsv +75 -0
  57. data/support/codes/027.tsv +75 -0
  58. data/support/codes/028.tsv +8 -0
  59. data/support/codes/029.tsv +16 -0
  60. data/support/codes/030.tsv +15 -0
  61. data/support/codes/031.tsv +3 -0
  62. data/support/codes/032.tsv +2 -0
  63. data/support/codes/033.tsv +36 -0
  64. data/support/codes/034.tsv +14 -0
  65. data/support/codes/035.tsv +6 -0
  66. data/support/codes/036.tsv +3 -0
  67. data/support/codes/037.tsv +6 -0
  68. data/support/codes/038.tsv +36 -0
  69. data/support/codes/039.tsv +8 -0
  70. data/support/codes/040.tsv +6 -0
  71. data/support/codes/041.tsv +6 -0
  72. data/support/codes/042.tsv +16 -0
  73. data/support/codes/043.tsv +4 -0
  74. data/support/codes/044.tsv +13 -0
  75. data/support/codes/045.tsv +12 -0
  76. data/support/codes/046.tsv +3 -0
  77. data/support/codes/047.tsv +4 -0
  78. data/support/codes/048.tsv +11 -0
  79. data/support/codes/049.tsv +84 -0
  80. data/support/codes/050.tsv +8 -0
  81. data/support/codes/051.tsv +27 -0
  82. data/support/codes/052.tsv +1 -0
  83. data/support/codes/053.tsv +3 -0
  84. data/support/codes/054.tsv +23 -0
  85. data/support/codes/055.tsv +13 -0
  86. data/support/codes/056.tsv +2 -0
  87. data/support/codes/057.tsv +5 -0
  88. data/support/codes/058.tsv +21 -0
  89. data/support/codes/059.tsv +4 -0
  90. data/support/codes/060.tsv +2 -0
  91. data/support/codes/061.tsv +3 -0
  92. data/support/codes/062.tsv +5 -0
  93. data/support/codes/063.tsv +0 -0
  94. data/support/codes/064.tsv +13 -0
  95. data/support/codes/065.tsv +25 -0
  96. data/support/codes/066.tsv +4 -0
  97. data/support/codes/067.tsv +2 -0
  98. data/support/codes/068.tsv +15 -0
  99. data/support/codes/069.tsv +4 -0
  100. data/support/codes/070.tsv +2 -0
  101. data/support/codes/071.tsv +9 -0
  102. data/support/codes/072.tsv +7 -0
  103. data/support/codes/073.tsv +36 -0
  104. data/support/codes/074.tsv +489 -0
  105. data/support/codes/075.tsv +2 -0
  106. data/support/codes/076.tsv +12 -0
  107. data/support/codes/077.tsv +19 -0
  108. data/support/codes/078.tsv +148 -0
  109. data/support/codes/079.tsv +17 -0
  110. data/support/codes/080.tsv +19 -0
  111. data/support/codes/081.tsv +11 -0
  112. data/support/codes/082.tsv +17 -0
  113. data/support/codes/083.tsv +68 -0
  114. data/support/codes/084.tsv +10 -0
  115. data/support/codes/085.tsv +23 -0
  116. data/support/codes/086.tsv +5 -0
  117. data/support/codes/087.tsv +6 -0
  118. data/support/codes/088.tsv +0 -0
  119. data/support/codes/089.tsv +1 -0
  120. data/support/codes/090.tsv +11 -0
  121. data/support/codes/091.tsv +248 -0
  122. data/support/codes/092.tsv +7 -0
  123. data/support/codes/093.tsv +13 -0
  124. data/support/codes/094.tsv +3 -0
  125. data/support/codes/095.tsv +3 -0
  126. data/support/codes/096.tsv +185 -0
  127. data/support/codes/097.tsv +1 -0
  128. data/support/codes/098.tsv +21 -0
  129. data/support/codes/099.tsv +24 -0
  130. data/support/codes/100.tsv +4 -0
  131. data/support/codes/101.tsv +2 -0
  132. data/support/codes/102.tsv +3 -0
  133. data/support/codes/121.tsv +127 -0
  134. data/support/codes/138.tsv +6 -0
  135. data/support/codes/139.tsv +70 -0
  136. data/support/codes/140.tsv +7 -0
  137. data/support/codes/141.tsv +10 -0
  138. data/support/codes/142.tsv +12 -0
  139. data/support/codes/143.tsv +7 -0
  140. data/support/codes/144.tsv +4 -0
  141. data/support/codes/145.tsv +5 -0
  142. data/support/codes/146.tsv +3 -0
  143. data/support/codes/147.tsv +7 -0
  144. data/support/codes/148.tsv +3 -0
  145. data/support/codes/149.tsv +4 -0
  146. data/support/codes/150.tsv +124 -0
  147. data/support/codes/151.tsv +7 -0
  148. data/support/codes/152.tsv +2 -0
  149. data/support/codes/153.tsv +14 -0
  150. data/support/codes/154.tsv +9 -0
  151. data/support/codes/155.tsv +5 -0
  152. data/support/codes/156.tsv +4 -0
  153. data/support/codes/157.tsv +4 -0
  154. data/support/codes/158.tsv +24 -0
  155. data/support/codes/159.tsv +6 -0
  156. data/support/codes/160.tsv +0 -0
  157. data/support/codes/161.tsv +3 -0
  158. data/support/codes/162.tsv +3 -0
  159. data/support/codes/163.tsv +7 -0
  160. data/support/codes/164.tsv +2 -0
  161. data/support/codes/165.tsv +2 -0
  162. data/support/codes/166.tsv +2 -0
  163. data/support/codes/167.tsv +3 -0
  164. data/support/codes/168.tsv +2 -0
  165. data/support/codes/169.tsv +3 -0
  166. data/support/codes/170.tsv +0 -0
  167. data/support/codes/171.tsv +2 -0
  168. data/support/codes/172.tsv +1 -0
  169. data/support/codes/173.tsv +2 -0
  170. data/support/codes/174.tsv +2 -0
  171. data/support/codes/175.tsv +175 -0
  172. data/support/codes/176.tsv +12 -0
  173. data/support/codes/177.tsv +2 -0
  174. data/support/codes/178.tsv +17 -0
  175. metadata +151 -13
  176. data/lib/onix/lists/audience_code.rb +0 -17
  177. data/lib/onix/lists/contributor_role.rb +0 -99
  178. data/lib/onix/lists/country_code.rb +0 -257
  179. data/lib/onix/lists/language_code.rb +0 -498
  180. data/lib/onix/lists/language_role.rb +0 -18
  181. data/lib/onix/lists/notification_type.rb +0 -19
  182. data/lib/onix/lists/product_availability.rb +0 -32
  183. data/lib/onix/lists/product_form.rb +0 -99
  184. data/lib/onix/lists/product_form_detail.rb +0 -157
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ v0.8.4 (18th October 2010)
2
+ - some small fixes to xml names from Tim
3
+ - make all code lists available via the ONIX::Lists class
4
+
1
5
  v0.8.3 (9th September 2010)
2
6
  - Fix for race condition in ONIX::Normaliser
3
7
  - thanks to pixelvixen for reporting
data/README.markdown CHANGED
@@ -45,6 +45,7 @@ view the comments to the following classes:
45
45
  * ONIX::Reader - For reading ONIX files
46
46
  * ONIX::Writer - For writing ONIX files
47
47
  * ONIX::Normaliser - For normalising ONIX files before reading them. Fixes encoding issues, etc
48
+ * ONIX::Lists - For building hashes of code lists from the ONIX spec
48
49
 
49
50
  ## Licensing
50
51
 
@@ -0,0 +1,69 @@
1
+ # coding: utf-8
2
+
3
+ module ONIX
4
+
5
+ # A utility class that processes the code list XSD from the ONIX spec and
6
+ # creates a set of TSV files. The generated files are used by this library
7
+ # to make hashes of the code lists available to users.
8
+ #
9
+ class CodeListExtractor
10
+
11
+ # Creates a new extractor. Expects the path to a copy of the code lists
12
+ # file from the spec (called ONIX_BookProduct_CodeLists.xsd on my system).
13
+ #
14
+ def initialize(filename)
15
+ raise ArgumentError, "#{filename} not found" unless File.file?(filename)
16
+
17
+ @filename = filename
18
+ end
19
+
20
+ # generate a set of TSV files in the given directory. Creates the directory
21
+ # if it doesn't exist and will overwrite existing files.
22
+ #
23
+ def run(dir)
24
+ FileUtils.mkdir_p(dir) unless File.directory?(dir)
25
+
26
+ each_list do |number, data|
27
+ #puts number
28
+ file = number.to_s.rjust(3, "0") + ".tsv"
29
+ path = File.join(dir, file)
30
+ File.open(path, "w") { |f| f.write data}
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ def data
37
+ @data ||= File.open(@filename) { |f| f.read }
38
+ end
39
+
40
+ def document
41
+ @document ||= Nokogiri::XML(data)
42
+ @document.remove_namespaces! if @document.namespaces.size > 0
43
+ @document
44
+ end
45
+
46
+ def each_list(&block)
47
+ document.xpath("//simpleType").each do |node|
48
+ list_name = node.xpath("./@name").first.value
49
+ list_number = list_name[/List(\d+)/,1].to_i
50
+ if list_number > 0
51
+ yield list_number, list_data(list_number)
52
+ end
53
+ end
54
+ end
55
+
56
+ def list_data(num)
57
+ str = ""
58
+ nodes = document.xpath("//simpleType[@name='List#{num}']/restriction/enumeration")
59
+ nodes.each do |node|
60
+ code = node.xpath("./@value").first.value
61
+ desc = node.xpath("./annotation/documentation").first.text
62
+ ldesc = node.xpath("./annotation/documentation").last.text
63
+ str += "#{code}\t#{desc}\t#{ldesc}\n"
64
+ end
65
+ str
66
+ end
67
+
68
+ end
69
+ end
data/lib/onix/lists.rb ADDED
@@ -0,0 +1,134 @@
1
+ # coding: utf-8
2
+
3
+ module ONIX
4
+
5
+ # Builds hashes for all code lists in the ONIX spec.
6
+ #
7
+ # Use like so:
8
+ #
9
+ # ONIX::Lists.list(7)
10
+ # => { "BB" => "Hardback", ... }
11
+ #
12
+ # There are also some constants for commonly used lists:
13
+ #
14
+ # ONIX::Lists::PRODUCT_FORM
15
+ # => { "BB" => "Hardback", ... }
16
+ #
17
+ class Lists
18
+ include Singleton
19
+
20
+ # retrieve a hash with the specified code list
21
+ #
22
+ # ONIX::Lists.list(7)
23
+ # => { "BB" => "Hardback", ... }
24
+ #
25
+ def self.list(number)
26
+ self.instance.list(number)
27
+ end
28
+
29
+ # Shortcut to retrieve a common code list
30
+ #
31
+ def self.audience_code
32
+ self.instance.list(28)
33
+ end
34
+
35
+ # Shortcut to retrieve a common code list
36
+ #
37
+ def self.contributor_role
38
+ self.instance.list(17)
39
+ end
40
+
41
+ # Shortcut to retrieve a common code list
42
+ #
43
+ def self.country_code
44
+ self.instance.list(91)
45
+ end
46
+
47
+ # Shortcut to retrieve a common code list
48
+ #
49
+ def self.language_code
50
+ self.instance.list(74)
51
+ end
52
+
53
+ # Shortcut to retrieve a common code list
54
+ #
55
+ def self.language_role
56
+ self.instance.list(22)
57
+ end
58
+
59
+ # Shortcut to retrieve a common code list
60
+ #
61
+ def self.notification_type
62
+ self.instance.list(1)
63
+ end
64
+
65
+ # Shortcut to retrieve a common code list
66
+ #
67
+ def self.product_availability
68
+ self.instance.list(65)
69
+ end
70
+
71
+ # Shortcut to retrieve a common code list
72
+ #
73
+ def self.product_form
74
+ self.instance.list(7)
75
+ end
76
+
77
+ # Shortcut to retrieve a common code list
78
+ #
79
+ def self.product_form_detail
80
+ self.instance.list(78)
81
+ end
82
+
83
+ # return a hash with the data for a single code list.
84
+ #
85
+ # number should be a fixnum specifying the list to retrieve
86
+ #
87
+ # ONIX::Lists.instance.list(7)
88
+ # => { "BB" => "Hardback", ... }
89
+ #
90
+ def list(number)
91
+ cache[number] ||= build_hash(number)
92
+ end
93
+
94
+ private
95
+
96
+ def build_hash(number)
97
+ val = {}
98
+ data(number).each_line do |line|
99
+ code, desc, ldesc = *line.split("\t")
100
+ code = code.to_i if code.to_s.match(/\d+/)
101
+ val[code] = desc
102
+ end
103
+ val
104
+ end
105
+
106
+ def cache
107
+ @cache ||= {}
108
+ end
109
+
110
+ def path(number)
111
+ code_dir = File.dirname(__FILE__) + "/../../support/codes"
112
+ filename = number.to_s.rjust(3, "0") + ".tsv"
113
+ File.join(code_dir, filename)
114
+ end
115
+
116
+ def data(number)
117
+ File.open(path(number)) { |f| f.read }
118
+ end
119
+
120
+ public
121
+
122
+ # These are here for backwards compatability with the onix gem <= 0.8.3
123
+ AUDIENCE_CODE = ONIX::Lists.audience_code
124
+ CONTRIBUTOR_ROLE = ONIX::Lists.contributor_role
125
+ COUNTRY_CODE = ONIX::Lists.country_code
126
+ LANGUAGE_CODE = ONIX::Lists.language_code
127
+ LANGUAGE_ROLE = ONIX::Lists.language_role
128
+ NOTIFICATION_TYPE = ONIX::Lists.notification_type
129
+ PRODUCT_AVAILABILITY = ONIX::Lists.product_availability
130
+ PRODUCT_FORM = ONIX::Lists.product_form
131
+ PRODUCT_FORM_DETAIL = ONIX::Lists.product_form_detail
132
+
133
+ end
134
+ end
data/lib/onix/price.rb CHANGED
@@ -7,7 +7,7 @@ module ONIX
7
7
  xml_name "Price"
8
8
 
9
9
  xml_accessor :price_type_code, :from => "PriceTypeCode", :as => Fixnum, :to_xml => ONIX::Formatters.two_digit
10
- xml_accessor :price_type_qualifier, :from => "PriceTypeQualifier", :as => Fixnum, :to_xml => ONIX::Formatters.two_digit
10
+ xml_accessor :price_type_qualifier, :from => "PriceQualifier", :as => Fixnum, :to_xml => ONIX::Formatters.two_digit
11
11
  xml_accessor :price_type_description, :from => "PriceTypeDescription"
12
12
  xml_accessor :price_per, :from => "PricePer", :as => Fixnum, :to_xml => ONIX::Formatters.two_digit
13
13
  xml_accessor :minimum_order_qty, :from => "MinimumOrderQuantity", :as => Fixnum
data/lib/onix/product.rb CHANGED
@@ -18,6 +18,7 @@ module ONIX
18
18
  xml_accessor :edition_number, :from => "EditionNumber", :as => Fixnum
19
19
  xml_accessor :languages, :from => "Language", :as => [ONIX::Language]
20
20
  xml_accessor :number_of_pages, :from => "NumberOfPages", :as => Fixnum
21
+ xml_accessor :basic_main_subject, :from => "BASICMainSubject"
21
22
  xml_accessor :bic_main_subject, :from => "BICMainSubject"
22
23
  xml_accessor :subjects, :from => "Subject", :as => [ONIX::Subject]
23
24
  xml_accessor :audience_code, :from => "AudienceCode", :to_xml => ONIX::Formatters.two_digit
data/lib/onix.rb CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  require 'bigdecimal'
4
4
  require 'cgi'
5
+ require 'singleton'
5
6
  require 'roxml'
6
7
  require 'andand'
7
8
 
@@ -9,7 +10,7 @@ module ONIX
9
10
  module Version #:nodoc:
10
11
  Major = 0
11
12
  Minor = 8
12
- Tiny = 3
13
+ Tiny = 4
13
14
 
14
15
  String = [Major, Minor, Tiny].join('.')
15
16
  end
@@ -82,18 +83,11 @@ require File.join(File.dirname(__FILE__), "onix", "product")
82
83
  require File.join(File.dirname(__FILE__), "onix", "reader")
83
84
  require File.join(File.dirname(__FILE__), "onix", "writer")
84
85
 
85
- # lists
86
- require File.join(File.dirname(__FILE__), "onix", "lists", "product_form")
87
- require File.join(File.dirname(__FILE__), "onix", "lists", "product_availability")
88
- require File.join(File.dirname(__FILE__), "onix", "lists", "country_code")
89
- require File.join(File.dirname(__FILE__), "onix", "lists", "language_code")
90
- require File.join(File.dirname(__FILE__), "onix", "lists", "language_role")
91
- require File.join(File.dirname(__FILE__), "onix", "lists", "notification_type")
92
- require File.join(File.dirname(__FILE__), "onix", "lists", "product_form_detail")
93
-
94
86
  # product wrappers
95
87
  require File.join(File.dirname(__FILE__), "onix", "simple_product")
96
88
  require File.join(File.dirname(__FILE__), "onix", "apa_product")
97
89
 
98
90
  # misc
91
+ require File.join(File.dirname(__FILE__), "onix", "lists")
99
92
  require File.join(File.dirname(__FILE__), "onix", "normaliser")
93
+ require File.join(File.dirname(__FILE__), "onix", "code_list_extractor")
@@ -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 attibutes" do
15
+ specify "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 attibutes" do
29
+ specify "should provide write access to attributes" do
30
30
  apa = ONIX::APAProduct.new
31
31
 
32
32
  apa.notification_type = 3
@@ -16,7 +16,7 @@ context "ONIX::AudienceRange" do
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 attibutes" do
19
+ specify "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 attibutes" do
31
+ specify "should provide write access to first level attributes" do
32
32
  aud = ONIX::AudienceRange.new
33
33
 
34
34
  aud.audience_range_qualifier = 12
@@ -16,7 +16,7 @@ context "ONIX::Contributor" do
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 attibutes" do
19
+ specify "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 attibutes" do
27
+ specify "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
@@ -16,7 +16,7 @@ context "ONIX::Header" do
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 attibutes" do
19
+ specify "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 attibutes" do
45
+ specify "should provide write access to first level attributes" do
46
46
  header = ONIX::Header.new
47
47
 
48
48
  header.from_ean_number = "1111111111111"
data/spec/imprint_spec.rb CHANGED
@@ -16,13 +16,13 @@ context "ONIX::Imprint" do
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 attibutes" do
19
+ specify "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 attibutes" do
25
+ specify "should provide write access to first level attributes" do
26
26
  imp = ONIX::Imprint.new
27
27
 
28
28
  imp.imprint_name = "Paulist Press"
@@ -16,7 +16,7 @@ context "ONIX::Language" do
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 attibutes" do
19
+ specify "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 attibutes" do
27
+ specify "should provide write access to first level attributes" do
28
28
  lan = ONIX::Language.new
29
29
 
30
30
  lan.language_role = 2
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+
3
+ require File.dirname(__FILE__) + '/spec_helper.rb'
4
+
5
+ context 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
+ context 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
+ context 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
@@ -16,14 +16,14 @@ context "ONIX::MarketRepresentation" do
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 attibutes" do
19
+ specify "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 attibutes" do
26
+ specify "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"
data/spec/measure_spec.rb CHANGED
@@ -16,7 +16,7 @@ context "ONIX::Measure" do
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 attibutes" do
19
+ specify "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 attibutes" do
27
+ specify "should provide write access to first level attributes" do
28
28
  m = ONIX::Measure.new
29
29
 
30
30
  m.measure_type_code = 1
@@ -16,14 +16,14 @@ context "ONIX::MediaFile" do
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 attibutes" do
19
+ specify "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 attibutes" do
26
+ specify "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
@@ -16,14 +16,14 @@ context "ONIX::OtherText" do
16
16
  ot.to_xml.to_s[0,11].should eql("<OtherText>")
17
17
  end
18
18
 
19
- specify "should provide read access to first level attibutes" do
19
+ specify "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
- specify "should provide write access to first level attibutes" do
26
+ specify "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
@@ -16,14 +16,14 @@ context "ONIX::Price" do
16
16
  p.to_xml.to_s[0,7].should eql("<Price>")
17
17
  end
18
18
 
19
- specify "should provide read access to first level attibutes" do
19
+ specify "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
- specify "should provide write access to first level attibutes" do
26
+ specify "should provide write access to first level attributes" do
27
27
  p = ONIX::Price.new
28
28
 
29
29
  p.price_type_code = 1
@@ -16,14 +16,14 @@ context "ONIX::ProductIdentifier" do
16
16
  id.to_xml.to_s[0,19].should eql("<ProductIdentifier>")
17
17
  end
18
18
 
19
- specify "should provide read access to first level attibutes" do
19
+ specify "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
- specify "should provide write access to first level attibutes" do
26
+ specify "should provide write access to first level attributes" do
27
27
  id = ONIX::ProductIdentifier.new
28
28
 
29
29
  id.product_id_type = 2
data/spec/product_spec.rb CHANGED
@@ -11,7 +11,7 @@ context "ONIX::Product" do
11
11
  @product_node = @doc.root
12
12
  end
13
13
 
14
- specify "should provide read access to first level attibutes" do
14
+ specify "should provide read access to first level attributes" do
15
15
  product = ONIX::Product.from_xml(@product_node.to_s)
16
16
 
17
17
  product.record_reference.should eql("365-9780194351898")
@@ -52,7 +52,7 @@ context "ONIX::Product" do
52
52
  product.measurements.size.should eql(1)
53
53
  end
54
54
 
55
- specify "should provide write access to first level attibutes" do
55
+ specify "should provide write access to first level attributes" do
56
56
  product = ONIX::Product.new
57
57
 
58
58
  product.notification_type = 3
@@ -16,13 +16,13 @@ context "ONIX::Publisher" do
16
16
  pub.to_xml.to_s[0,11].should eql("<Publisher>")
17
17
  end
18
18
 
19
- specify "should provide read access to first level attibutes" do
19
+ specify "should provide read access to first level attributes" do
20
20
  pub = ONIX::Publisher.from_xml(@root.to_s)
21
21
  pub.publishing_role.should eql(1)
22
22
  pub.publisher_name.should eql("Desbooks Publishing")
23
23
  end
24
24
 
25
- specify "should provide write access to first level attibutes" do
25
+ specify "should provide write access to first level attributes" do
26
26
  pub = ONIX::Publisher.new
27
27
 
28
28
  pub.publisher_name = "Paulist Press"
@@ -16,13 +16,13 @@ context "ONIX::SalesRestriction" do
16
16
  sr.to_xml.to_s[0,18].should eql("<SalesRestriction>")
17
17
  end
18
18
 
19
- specify "should provide read access to first level attibutes" do
19
+ specify "should provide read access to first level attributes" do
20
20
  sr = ONIX::SalesRestriction.from_xml(@root.to_s)
21
21
 
22
22
  sr.sales_restriction_type.should eql(0)
23
23
  end
24
24
 
25
- specify "should provide write access to first level attibutes" do
25
+ specify "should provide write access to first level attributes" do
26
26
  sr = ONIX::SalesRestriction.new
27
27
 
28
28
  sr.sales_restriction_type = 1
@@ -16,14 +16,14 @@ context "ONIX::SenderIdentifier" do
16
16
  id.to_xml.to_s[0,18].should eql("<SenderIdentifier>")
17
17
  end
18
18
 
19
- specify "should provide read access to first level attibutes" do
19
+ specify "should provide read access to first level attributes" do
20
20
  id = ONIX::SenderIdentifier.from_xml(@root.to_s)
21
21
 
22
22
  id.sender_id_type.should eql(1)
23
23
  id.id_value.should eql("123456")
24
24
  end
25
25
 
26
- specify "should provide write access to first level attibutes" do
26
+ specify "should provide write access to first level attributes" do
27
27
  id = ONIX::SenderIdentifier.new
28
28
 
29
29
  id.sender_id_type = 1
@@ -16,14 +16,14 @@ context "ONIX::SeriesIdentifier" do
16
16
  series.to_xml.to_s[0,18].should eql("<SeriesIdentifier>")
17
17
  end
18
18
 
19
- specify "should provide read access to first level attibutes" do
19
+ specify "should provide read access to first level attributes" do
20
20
  series = ONIX::SeriesIdentifier.from_xml(@root.to_s)
21
21
 
22
22
  series.series_id_type.should eql(1)
23
23
  series.id_value.should eql("10001")
24
24
  end
25
25
 
26
- specify "should provide write access to first level attibutes" do
26
+ specify "should provide write access to first level attributes" do
27
27
  series = ONIX::SeriesIdentifier.new
28
28
 
29
29
  series.series_id_type = 9
data/spec/series_spec.rb CHANGED
@@ -16,13 +16,13 @@ context "ONIX::Series" do
16
16
  series.to_xml.to_s[0,8].should eql("<Series>")
17
17
  end
18
18
 
19
- specify "should provide read access to first level attibutes" do
19
+ specify "should provide read access to first level attributes" do
20
20
  series = ONIX::Series.from_xml(@root.to_s)
21
21
 
22
22
  series.title_of_series.should eql("Citizens and Their Governments")
23
23
  end
24
24
 
25
- specify "should provide write access to first level attibutes" do
25
+ specify "should provide write access to first level attributes" do
26
26
  series = ONIX::Series.new
27
27
 
28
28
  series.title_of_series = "Cool Science Careers"
data/spec/stock_spec.rb CHANGED
@@ -16,7 +16,7 @@ context "ONIX::Stock" do
16
16
  s.to_xml.to_s[0,7].should eql("<Stock>")
17
17
  end
18
18
 
19
- specify "should provide read access to first level attibutes" do
19
+ specify "should provide read access to first level attributes" do
20
20
  s = ONIX::Stock.from_xml(@root.to_s)
21
21
 
22
22
  # note that these fields *should* be numeric according to the ONIX spec,
@@ -25,7 +25,7 @@ context "ONIX::Stock" do
25
25
  s.on_order.should eql("0")
26
26
  end
27
27
 
28
- specify "should provide write access to first level attibutes" do
28
+ specify "should provide write access to first level attributes" do
29
29
  s = ONIX::Stock.new
30
30
 
31
31
  s.on_hand = "123"