onix2 1.0.0

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.
Files changed (240) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +209 -0
  3. data/README.markdown +69 -0
  4. data/TODO +14 -0
  5. data/dtd/2.1r3/iso-amsa.ent +173 -0
  6. data/dtd/2.1r3/iso-amsb.ent +146 -0
  7. data/dtd/2.1r3/iso-amsc.ent +49 -0
  8. data/dtd/2.1r3/iso-amsn.ent +117 -0
  9. data/dtd/2.1r3/iso-amso.ent +77 -0
  10. data/dtd/2.1r3/iso-amsr.ent +205 -0
  11. data/dtd/2.1r3/iso-box.ent +67 -0
  12. data/dtd/2.1r3/iso-cyr1.ent +94 -0
  13. data/dtd/2.1r3/iso-cyr2.ent +53 -0
  14. data/dtd/2.1r3/iso-dia.ent +41 -0
  15. data/dtd/2.1r3/iso-grk3.ent +70 -0
  16. data/dtd/2.1r3/iso-lat1.ent +89 -0
  17. data/dtd/2.1r3/iso-lat2.ent +148 -0
  18. data/dtd/2.1r3/iso-mfrk.ent +79 -0
  19. data/dtd/2.1r3/iso-mopf.ent +53 -0
  20. data/dtd/2.1r3/iso-mscr.ent +79 -0
  21. data/dtd/2.1r3/iso-num.ent +103 -0
  22. data/dtd/2.1r3/iso-num.old.ent +103 -0
  23. data/dtd/2.1r3/iso-pub.ent +110 -0
  24. data/dtd/2.1r3/iso-tech.ent +183 -0
  25. data/dtd/2.1r3/onix-international.dtd +1012 -0
  26. data/dtd/2.1r3/onix-xhtml.elt +672 -0
  27. data/dtd/2.1r3/reference.elt +4758 -0
  28. data/dtd/2.1r3/xhtml-special.ent +79 -0
  29. data/dtd/2.1r3/xhtml-symbol.ent +242 -0
  30. data/lib/onix2.rb +85 -0
  31. data/lib/onix2/addressee_identifier.rb +29 -0
  32. data/lib/onix2/apa_product.rb +785 -0
  33. data/lib/onix2/audience_range.rb +37 -0
  34. data/lib/onix2/code_list_extractor.rb +69 -0
  35. data/lib/onix2/contributor.rb +55 -0
  36. data/lib/onix2/discount_coded.rb +29 -0
  37. data/lib/onix2/header.rb +68 -0
  38. data/lib/onix2/imprint.rb +31 -0
  39. data/lib/onix2/language.rb +29 -0
  40. data/lib/onix2/lists.rb +134 -0
  41. data/lib/onix2/market_representation.rb +38 -0
  42. data/lib/onix2/measure.rb +29 -0
  43. data/lib/onix2/media_file.rb +33 -0
  44. data/lib/onix2/other_text.rb +35 -0
  45. data/lib/onix2/price.rb +47 -0
  46. data/lib/onix2/product.rb +97 -0
  47. data/lib/onix2/product_identifier.rb +27 -0
  48. data/lib/onix2/publisher.rb +33 -0
  49. data/lib/onix2/reader.rb +157 -0
  50. data/lib/onix2/sales_restriction.rb +25 -0
  51. data/lib/onix2/sales_rights.rb +28 -0
  52. data/lib/onix2/sender_identifier.rb +29 -0
  53. data/lib/onix2/series.rb +28 -0
  54. data/lib/onix2/series_identifier.rb +27 -0
  55. data/lib/onix2/simple_product.rb +47 -0
  56. data/lib/onix2/stock.rb +29 -0
  57. data/lib/onix2/subject.rb +33 -0
  58. data/lib/onix2/supply_detail.rb +53 -0
  59. data/lib/onix2/title.rb +33 -0
  60. data/lib/onix2/version.rb +3 -0
  61. data/lib/onix2/website.rb +29 -0
  62. data/lib/onix2/writer.rb +86 -0
  63. data/spec/addressee_identifier_spec.rb +33 -0
  64. data/spec/apa_product_spec.rb +116 -0
  65. data/spec/audience_range_spec.rb +44 -0
  66. data/spec/contributor_spec.rb +38 -0
  67. data/spec/discount_coded_spec.rb +34 -0
  68. data/spec/header_spec.rb +153 -0
  69. data/spec/imprint_spec.rb +31 -0
  70. data/spec/language_spec.rb +38 -0
  71. data/spec/lists_spec.rb +33 -0
  72. data/spec/market_representation_spec.rb +33 -0
  73. data/spec/measure_spec.rb +38 -0
  74. data/spec/media_file_spec.rb +38 -0
  75. data/spec/other_text_spec.rb +33 -0
  76. data/spec/price_spec.rb +52 -0
  77. data/spec/product_identifier_spec.rb +34 -0
  78. data/spec/product_spec.rb +102 -0
  79. data/spec/publisher_spec.rb +33 -0
  80. data/spec/reader_spec.rb +155 -0
  81. data/spec/sales_restriction_spec.rb +27 -0
  82. data/spec/sender_identifier.rb +33 -0
  83. data/spec/series_identifier_spec.rb +33 -0
  84. data/spec/series_spec.rb +47 -0
  85. data/spec/spec_helper.rb +15 -0
  86. data/spec/stock_spec.rb +39 -0
  87. data/spec/subject_spec.rb +34 -0
  88. data/spec/supply_detail_spec.rb +97 -0
  89. data/spec/title_spec.rb +38 -0
  90. data/spec/website_spec.rb +33 -0
  91. data/spec/writer_spec.rb +78 -0
  92. data/support/codes/001.tsv +10 -0
  93. data/support/codes/002.tsv +5 -0
  94. data/support/codes/003.tsv +7 -0
  95. data/support/codes/005.tsv +13 -0
  96. data/support/codes/006.tsv +76 -0
  97. data/support/codes/007.tsv +123 -0
  98. data/support/codes/008.tsv +7 -0
  99. data/support/codes/009.tsv +7 -0
  100. data/support/codes/010.tsv +34 -0
  101. data/support/codes/011.tsv +11 -0
  102. data/support/codes/012.tsv +11 -0
  103. data/support/codes/013.tsv +7 -0
  104. data/support/codes/014.tsv +4 -0
  105. data/support/codes/015.tsv +13 -0
  106. data/support/codes/016.tsv +6 -0
  107. data/support/codes/017.tsv +90 -0
  108. data/support/codes/018.tsv +3 -0
  109. data/support/codes/019.tsv +7 -0
  110. data/support/codes/020.tsv +0 -0
  111. data/support/codes/021.tsv +31 -0
  112. data/support/codes/022.tsv +9 -0
  113. data/support/codes/023.tsv +9 -0
  114. data/support/codes/024.tsv +11 -0
  115. data/support/codes/025.tsv +29 -0
  116. data/support/codes/026.tsv +75 -0
  117. data/support/codes/027.tsv +75 -0
  118. data/support/codes/028.tsv +8 -0
  119. data/support/codes/029.tsv +16 -0
  120. data/support/codes/030.tsv +15 -0
  121. data/support/codes/031.tsv +3 -0
  122. data/support/codes/032.tsv +2 -0
  123. data/support/codes/033.tsv +36 -0
  124. data/support/codes/034.tsv +14 -0
  125. data/support/codes/035.tsv +6 -0
  126. data/support/codes/036.tsv +3 -0
  127. data/support/codes/037.tsv +6 -0
  128. data/support/codes/038.tsv +36 -0
  129. data/support/codes/039.tsv +8 -0
  130. data/support/codes/040.tsv +6 -0
  131. data/support/codes/041.tsv +6 -0
  132. data/support/codes/042.tsv +16 -0
  133. data/support/codes/043.tsv +4 -0
  134. data/support/codes/044.tsv +13 -0
  135. data/support/codes/045.tsv +12 -0
  136. data/support/codes/046.tsv +3 -0
  137. data/support/codes/047.tsv +4 -0
  138. data/support/codes/048.tsv +11 -0
  139. data/support/codes/049.tsv +84 -0
  140. data/support/codes/050.tsv +8 -0
  141. data/support/codes/051.tsv +27 -0
  142. data/support/codes/052.tsv +1 -0
  143. data/support/codes/053.tsv +3 -0
  144. data/support/codes/054.tsv +23 -0
  145. data/support/codes/055.tsv +13 -0
  146. data/support/codes/056.tsv +2 -0
  147. data/support/codes/057.tsv +5 -0
  148. data/support/codes/058.tsv +21 -0
  149. data/support/codes/059.tsv +4 -0
  150. data/support/codes/060.tsv +2 -0
  151. data/support/codes/061.tsv +3 -0
  152. data/support/codes/062.tsv +5 -0
  153. data/support/codes/063.tsv +0 -0
  154. data/support/codes/064.tsv +13 -0
  155. data/support/codes/065.tsv +25 -0
  156. data/support/codes/066.tsv +4 -0
  157. data/support/codes/067.tsv +2 -0
  158. data/support/codes/068.tsv +15 -0
  159. data/support/codes/069.tsv +4 -0
  160. data/support/codes/070.tsv +2 -0
  161. data/support/codes/071.tsv +9 -0
  162. data/support/codes/072.tsv +7 -0
  163. data/support/codes/073.tsv +36 -0
  164. data/support/codes/074.tsv +489 -0
  165. data/support/codes/075.tsv +2 -0
  166. data/support/codes/076.tsv +12 -0
  167. data/support/codes/077.tsv +19 -0
  168. data/support/codes/078.tsv +148 -0
  169. data/support/codes/079.tsv +17 -0
  170. data/support/codes/080.tsv +19 -0
  171. data/support/codes/081.tsv +11 -0
  172. data/support/codes/082.tsv +17 -0
  173. data/support/codes/083.tsv +68 -0
  174. data/support/codes/084.tsv +10 -0
  175. data/support/codes/085.tsv +23 -0
  176. data/support/codes/086.tsv +5 -0
  177. data/support/codes/087.tsv +6 -0
  178. data/support/codes/088.tsv +0 -0
  179. data/support/codes/089.tsv +1 -0
  180. data/support/codes/090.tsv +11 -0
  181. data/support/codes/091.tsv +248 -0
  182. data/support/codes/092.tsv +7 -0
  183. data/support/codes/093.tsv +13 -0
  184. data/support/codes/094.tsv +3 -0
  185. data/support/codes/095.tsv +3 -0
  186. data/support/codes/096.tsv +185 -0
  187. data/support/codes/097.tsv +1 -0
  188. data/support/codes/098.tsv +21 -0
  189. data/support/codes/099.tsv +24 -0
  190. data/support/codes/100.tsv +4 -0
  191. data/support/codes/101.tsv +2 -0
  192. data/support/codes/102.tsv +3 -0
  193. data/support/codes/121.tsv +127 -0
  194. data/support/codes/138.tsv +6 -0
  195. data/support/codes/139.tsv +70 -0
  196. data/support/codes/140.tsv +7 -0
  197. data/support/codes/141.tsv +10 -0
  198. data/support/codes/142.tsv +12 -0
  199. data/support/codes/143.tsv +7 -0
  200. data/support/codes/144.tsv +4 -0
  201. data/support/codes/145.tsv +5 -0
  202. data/support/codes/146.tsv +3 -0
  203. data/support/codes/147.tsv +7 -0
  204. data/support/codes/148.tsv +3 -0
  205. data/support/codes/149.tsv +4 -0
  206. data/support/codes/150.tsv +124 -0
  207. data/support/codes/151.tsv +7 -0
  208. data/support/codes/152.tsv +2 -0
  209. data/support/codes/153.tsv +14 -0
  210. data/support/codes/154.tsv +9 -0
  211. data/support/codes/155.tsv +5 -0
  212. data/support/codes/156.tsv +4 -0
  213. data/support/codes/157.tsv +4 -0
  214. data/support/codes/158.tsv +24 -0
  215. data/support/codes/159.tsv +6 -0
  216. data/support/codes/160.tsv +0 -0
  217. data/support/codes/161.tsv +3 -0
  218. data/support/codes/162.tsv +3 -0
  219. data/support/codes/163.tsv +7 -0
  220. data/support/codes/164.tsv +2 -0
  221. data/support/codes/165.tsv +2 -0
  222. data/support/codes/166.tsv +2 -0
  223. data/support/codes/167.tsv +3 -0
  224. data/support/codes/168.tsv +2 -0
  225. data/support/codes/169.tsv +3 -0
  226. data/support/codes/170.tsv +0 -0
  227. data/support/codes/171.tsv +2 -0
  228. data/support/codes/172.tsv +1 -0
  229. data/support/codes/173.tsv +2 -0
  230. data/support/codes/174.tsv +2 -0
  231. data/support/codes/175.tsv +175 -0
  232. data/support/codes/176.tsv +12 -0
  233. data/support/codes/177.tsv +2 -0
  234. data/support/codes/178.tsv +17 -0
  235. data/support/entities.txt +1499 -0
  236. data/support/extract.rb +25 -0
  237. data/support/switch-onix-2.1-short-to-reference.xsl +24 -0
  238. data/support/switch-onix-tagnames-1.1.xsl +25 -0
  239. data/support/switch-onix-tagnames-2.0.xsl +37 -0
  240. metadata +440 -0
@@ -0,0 +1,79 @@
1
+ <!-- Special characters for HTML -->
2
+
3
+ <!-- Character entity set. Typical invocation:
4
+ <!ENTITY % HTMLspecial PUBLIC
5
+ "-//W3C//ENTITIES Special for XHTML//EN"
6
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml-special.ent">
7
+ %HTMLspecial;
8
+ -->
9
+
10
+ <!-- Portions (C) International Organization for Standardization 1986:
11
+ Permission to copy in any form is granted for use with
12
+ conforming SGML systems and applications as defined in
13
+ ISO 8879, provided this notice is included in all copies.
14
+ -->
15
+
16
+ <!-- Relevant ISO entity set is given unless names are newly introduced.
17
+ New names (i.e., not in ISO 8879 list) do not clash with any
18
+ existing ISO 8879 entity names. ISO 10646 character numbers
19
+ are given for each character, in hex. values are decimal
20
+ conversions of the ISO 10646 values and refer to the document
21
+ character set. Names are Unicode names.
22
+ -->
23
+
24
+ <!-- C0 Controls and Basic Latin -->
25
+ <!ENTITY quot "&#34;"> <!-- quotation mark = APL quote,
26
+ U+0022 ISOnum -->
27
+ <!ENTITY amp "&#38;#38;"> <!-- ampersand, U+0026 ISOnum -->
28
+ <!ENTITY lt "&#38;#60;"> <!-- less-than sign, U+003C ISOnum -->
29
+ <!ENTITY gt "&#62;"> <!-- greater-than sign, U+003E ISOnum -->
30
+ <!ENTITY apos "&#39;"> <!-- apostrophe mark, U+0027 ISOnum -->
31
+
32
+ <!-- Latin Extended-A -->
33
+ <!ENTITY OElig "&#338;"> <!-- latin capital ligature OE,
34
+ U+0152 ISOlat2 -->
35
+ <!ENTITY oelig "&#339;"> <!-- latin small ligature oe, U+0153 ISOlat2 -->
36
+ <!-- ligature is a misnomer, this is a separate character in some languages -->
37
+ <!ENTITY Scaron "&#352;"> <!-- latin capital letter S with caron,
38
+ U+0160 ISOlat2 -->
39
+ <!ENTITY scaron "&#353;"> <!-- latin small letter s with caron,
40
+ U+0161 ISOlat2 -->
41
+ <!ENTITY Yuml "&#376;"> <!-- latin capital letter Y with diaeresis,
42
+ U+0178 ISOlat2 -->
43
+
44
+ <!-- Spacing Modifier Letters -->
45
+ <!ENTITY circ "&#710;"> <!-- modifier letter circumflex accent,
46
+ U+02C6 ISOpub -->
47
+ <!ENTITY tilde "&#732;"> <!-- small tilde, U+02DC ISOdia -->
48
+
49
+ <!-- General Punctuation -->
50
+ <!ENTITY ensp "&#8194;"> <!-- en space, U+2002 ISOpub -->
51
+ <!ENTITY emsp "&#8195;"> <!-- em space, U+2003 ISOpub -->
52
+ <!ENTITY thinsp "&#8201;"> <!-- thin space, U+2009 ISOpub -->
53
+ <!ENTITY zwnj "&#8204;"> <!-- zero width non-joiner,
54
+ U+200C NEW RFC 2070 -->
55
+ <!ENTITY zwj "&#8205;"> <!-- zero width joiner, U+200D NEW RFC 2070 -->
56
+ <!ENTITY lrm "&#8206;"> <!-- left-to-right mark, U+200E NEW RFC 2070 -->
57
+ <!ENTITY rlm "&#8207;"> <!-- right-to-left mark, U+200F NEW RFC 2070 -->
58
+ <!ENTITY ndash "&#8211;"> <!-- en dash, U+2013 ISOpub -->
59
+ <!ENTITY mdash "&#8212;"> <!-- em dash, U+2014 ISOpub -->
60
+ <!ENTITY lsquo "&#8216;"> <!-- left single quotation mark,
61
+ U+2018 ISOnum -->
62
+ <!ENTITY rsquo "&#8217;"> <!-- right single quotation mark,
63
+ U+2019 ISOnum -->
64
+ <!ENTITY sbquo "&#8218;"> <!-- single low-9 quotation mark, U+201A NEW -->
65
+ <!ENTITY ldquo "&#8220;"> <!-- left double quotation mark,
66
+ U+201C ISOnum -->
67
+ <!ENTITY rdquo "&#8221;"> <!-- right double quotation mark,
68
+ U+201D ISOnum -->
69
+ <!ENTITY bdquo "&#8222;"> <!-- double low-9 quotation mark, U+201E NEW -->
70
+ <!ENTITY dagger "&#8224;"> <!-- dagger, U+2020 ISOpub -->
71
+ <!ENTITY Dagger "&#8225;"> <!-- double dagger, U+2021 ISOpub -->
72
+ <!ENTITY permil "&#8240;"> <!-- per mille sign, U+2030 ISOtech -->
73
+ <!ENTITY lsaquo "&#8249;"> <!-- single left-pointing angle quotation mark,
74
+ U+2039 ISO proposed -->
75
+ <!-- lsaquo is proposed but not yet ISO standardized -->
76
+ <!ENTITY rsaquo "&#8250;"> <!-- single right-pointing angle quotation mark,
77
+ U+203A ISO proposed -->
78
+ <!-- rsaquo is proposed but not yet ISO standardized -->
79
+ <!ENTITY euro "&#8364;"> <!-- euro sign, U+20AC NEW -->
@@ -0,0 +1,242 @@
1
+ <!-- Mathematical, Greek and Symbolic characters for HTML -->
2
+
3
+ <!-- Character entity set. Typical invocation:
4
+ <!ENTITY % HTMLsymbol PUBLIC
5
+ "-//W3C//ENTITIES Symbols for XHTML//EN"
6
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml-symbol.ent">
7
+ %HTMLsymbol;
8
+ -->
9
+
10
+ <!-- Portions (C) International Organization for Standardization 1986:
11
+ Permission to copy in any form is granted for use with
12
+ conforming SGML systems and applications as defined in
13
+ ISO 8879, provided this notice is included in all copies.
14
+ -->
15
+
16
+ <!-- Relevant ISO entity set is given unless names are newly introduced.
17
+ New names (i.e., not in ISO 8879 list) do not clash with any
18
+ existing ISO 8879 entity names. ISO 10646 character numbers
19
+ are given for each character, in hex. values are decimal
20
+ conversions of the ISO 10646 values and refer to the document
21
+ character set. Names are Unicode names.
22
+ -->
23
+
24
+ <!-- Latin Extended-B -->
25
+ <!ENTITY fnof "&#402;"> <!-- latin small f with hook = function
26
+ = florin, U+0192 ISOtech -->
27
+
28
+ <!-- Greek -->
29
+ <!ENTITY Alpha "&#913;"> <!-- greek capital letter alpha, U+0391 -->
30
+ <!ENTITY Beta "&#914;"> <!-- greek capital letter beta, U+0392 -->
31
+ <!ENTITY Gamma "&#915;"> <!-- greek capital letter gamma,
32
+ U+0393 ISOgrk3 -->
33
+ <!ENTITY Delta "&#916;"> <!-- greek capital letter delta,
34
+ U+0394 ISOgrk3 -->
35
+ <!ENTITY Epsilon "&#917;"> <!-- greek capital letter epsilon, U+0395 -->
36
+ <!ENTITY Zeta "&#918;"> <!-- greek capital letter zeta, U+0396 -->
37
+ <!ENTITY Eta "&#919;"> <!-- greek capital letter eta, U+0397 -->
38
+ <!ENTITY Theta "&#920;"> <!-- greek capital letter theta,
39
+ U+0398 ISOgrk3 -->
40
+ <!ENTITY Iota "&#921;"> <!-- greek capital letter iota, U+0399 -->
41
+ <!ENTITY Kappa "&#922;"> <!-- greek capital letter kappa, U+039A -->
42
+ <!ENTITY Lambda "&#923;"> <!-- greek capital letter lambda,
43
+ U+039B ISOgrk3 -->
44
+ <!ENTITY Mu "&#924;"> <!-- greek capital letter mu, U+039C -->
45
+ <!ENTITY Nu "&#925;"> <!-- greek capital letter nu, U+039D -->
46
+ <!ENTITY Xi "&#926;"> <!-- greek capital letter xi, U+039E ISOgrk3 -->
47
+ <!ENTITY Omicron "&#927;"> <!-- greek capital letter omicron, U+039F -->
48
+ <!ENTITY Pi "&#928;"> <!-- greek capital letter pi, U+03A0 ISOgrk3 -->
49
+ <!ENTITY Rho "&#929;"> <!-- greek capital letter rho, U+03A1 -->
50
+ <!-- there is no Sigmaf, and no U+03A2 character either -->
51
+ <!ENTITY Sigma "&#931;"> <!-- greek capital letter sigma,
52
+ U+03A3 ISOgrk3 -->
53
+ <!ENTITY Tau "&#932;"> <!-- greek capital letter tau, U+03A4 -->
54
+ <!ENTITY Upsilon "&#933;"> <!-- greek capital letter upsilon,
55
+ U+03A5 ISOgrk3 -->
56
+ <!ENTITY Phi "&#934;"> <!-- greek capital letter phi,
57
+ U+03A6 ISOgrk3 -->
58
+ <!ENTITY Chi "&#935;"> <!-- greek capital letter chi, U+03A7 -->
59
+ <!ENTITY Psi "&#936;"> <!-- greek capital letter psi,
60
+ U+03A8 ISOgrk3 -->
61
+ <!ENTITY Omega "&#937;"> <!-- greek capital letter omega,
62
+ U+03A9 ISOgrk3 -->
63
+
64
+ <!ENTITY alpha "&#945;"> <!-- greek small letter alpha,
65
+ U+03B1 ISOgrk3 -->
66
+ <!ENTITY beta "&#946;"> <!-- greek small letter beta, U+03B2 ISOgrk3 -->
67
+ <!ENTITY gamma "&#947;"> <!-- greek small letter gamma,
68
+ U+03B3 ISOgrk3 -->
69
+ <!ENTITY delta "&#948;"> <!-- greek small letter delta,
70
+ U+03B4 ISOgrk3 -->
71
+ <!ENTITY epsilon "&#949;"> <!-- greek small letter epsilon,
72
+ U+03B5 ISOgrk3 -->
73
+ <!ENTITY zeta "&#950;"> <!-- greek small letter zeta, U+03B6 ISOgrk3 -->
74
+ <!ENTITY eta "&#951;"> <!-- greek small letter eta, U+03B7 ISOgrk3 -->
75
+ <!ENTITY theta "&#952;"> <!-- greek small letter theta,
76
+ U+03B8 ISOgrk3 -->
77
+ <!ENTITY iota "&#953;"> <!-- greek small letter iota, U+03B9 ISOgrk3 -->
78
+ <!ENTITY kappa "&#954;"> <!-- greek small letter kappa,
79
+ U+03BA ISOgrk3 -->
80
+ <!ENTITY lambda "&#955;"> <!-- greek small letter lambda,
81
+ U+03BB ISOgrk3 -->
82
+ <!ENTITY mu "&#956;"> <!-- greek small letter mu, U+03BC ISOgrk3 -->
83
+ <!ENTITY nu "&#957;"> <!-- greek small letter nu, U+03BD ISOgrk3 -->
84
+ <!ENTITY xi "&#958;"> <!-- greek small letter xi, U+03BE ISOgrk3 -->
85
+ <!ENTITY omicron "&#959;"> <!-- greek small letter omicron, U+03BF NEW -->
86
+ <!ENTITY pi "&#960;"> <!-- greek small letter pi, U+03C0 ISOgrk3 -->
87
+ <!ENTITY rho "&#961;"> <!-- greek small letter rho, U+03C1 ISOgrk3 -->
88
+ <!ENTITY sigmaf "&#962;"> <!-- greek small letter final sigma,
89
+ U+03C2 ISOgrk3 -->
90
+ <!ENTITY sigma "&#963;"> <!-- greek small letter sigma,
91
+ U+03C3 ISOgrk3 -->
92
+ <!ENTITY tau "&#964;"> <!-- greek small letter tau, U+03C4 ISOgrk3 -->
93
+ <!ENTITY upsilon "&#965;"> <!-- greek small letter upsilon,
94
+ U+03C5 ISOgrk3 -->
95
+ <!ENTITY phi "&#966;"> <!-- greek small letter phi, U+03C6 ISOgrk3 -->
96
+ <!ENTITY chi "&#967;"> <!-- greek small letter chi, U+03C7 ISOgrk3 -->
97
+ <!ENTITY psi "&#968;"> <!-- greek small letter psi, U+03C8 ISOgrk3 -->
98
+ <!ENTITY omega "&#969;"> <!-- greek small letter omega,
99
+ U+03C9 ISOgrk3 -->
100
+ <!ENTITY thetasym "&#977;"> <!-- greek small letter theta symbol,
101
+ U+03D1 NEW -->
102
+ <!ENTITY upsih "&#978;"> <!-- greek upsilon with hook symbol,
103
+ U+03D2 NEW -->
104
+ <!ENTITY piv "&#982;"> <!-- greek pi symbol, U+03D6 ISOgrk3 -->
105
+
106
+ <!-- General Punctuation -->
107
+ <!ENTITY bull "&#8226;"> <!-- bullet = black small circle,
108
+ U+2022 ISOpub -->
109
+ <!-- bullet is NOT the same as bullet operator, U+2219 -->
110
+ <!ENTITY hellip "&#8230;"> <!-- horizontal ellipsis = three dot leader,
111
+ U+2026 ISOpub -->
112
+ <!ENTITY prime "&#8242;"> <!-- prime = minutes = feet, U+2032 ISOtech -->
113
+ <!ENTITY Prime "&#8243;"> <!-- double prime = seconds = inches,
114
+ U+2033 ISOtech -->
115
+ <!ENTITY oline "&#8254;"> <!-- overline = spacing overscore,
116
+ U+203E NEW -->
117
+ <!ENTITY frasl "&#8260;"> <!-- fraction slash, U+2044 NEW -->
118
+
119
+ <!-- Letterlike Symbols -->
120
+ <!ENTITY weierp "&#8472;"> <!-- script capital P = power set
121
+ = Weierstrass p, U+2118 ISOamso -->
122
+ <!ENTITY image "&#8465;"> <!-- blackletter capital I = imaginary part,
123
+ U+2111 ISOamso -->
124
+ <!ENTITY real "&#8476;"> <!-- blackletter capital R = real part symbol,
125
+ U+211C ISOamso -->
126
+ <!ENTITY trade "&#8482;"> <!-- trade mark sign, U+2122 ISOnum -->
127
+ <!ENTITY alefsym "&#8501;"> <!-- alef symbol = first transfinite cardinal,
128
+ U+2135 NEW -->
129
+ <!-- alef symbol is NOT the same as hebrew letter alef,
130
+ U+05D0 although the same glyph could be used to depict both characters -->
131
+
132
+ <!-- Arrows -->
133
+ <!ENTITY larr "&#8592;"> <!-- leftwards arrow, U+2190 ISOnum -->
134
+ <!ENTITY uarr "&#8593;"> <!-- upwards arrow, U+2191 ISOnum-->
135
+ <!ENTITY rarr "&#8594;"> <!-- rightwards arrow, U+2192 ISOnum -->
136
+ <!ENTITY darr "&#8595;"> <!-- downwards arrow, U+2193 ISOnum -->
137
+ <!ENTITY harr "&#8596;"> <!-- left right arrow, U+2194 ISOamsa -->
138
+ <!ENTITY crarr "&#8629;"> <!-- downwards arrow with corner leftwards
139
+ = carriage return, U+21B5 NEW -->
140
+ <!ENTITY lArr "&#8656;"> <!-- leftwards double arrow, U+21D0 ISOtech -->
141
+ <!-- Unicode does not say that lArr is the same as the 'is implied by' arrow
142
+ but also does not have any other character for that function. So ? lArr can
143
+ be used for 'is implied by' as ISOtech suggests -->
144
+ <!ENTITY uArr "&#8657;"> <!-- upwards double arrow, U+21D1 ISOamsa -->
145
+ <!ENTITY rArr "&#8658;"> <!-- rightwards double arrow,
146
+ U+21D2 ISOtech -->
147
+ <!-- Unicode does not say this is the 'implies' character but does not have
148
+ another character with this function so ?
149
+ rArr can be used for 'implies' as ISOtech suggests -->
150
+ <!ENTITY dArr "&#8659;"> <!-- downwards double arrow, U+21D3 ISOamsa -->
151
+ <!ENTITY hArr "&#8660;"> <!-- left right double arrow,
152
+ U+21D4 ISOamsa -->
153
+
154
+ <!-- Mathematical Operators -->
155
+ <!ENTITY forall "&#8704;"> <!-- for all, U+2200 ISOtech -->
156
+ <!ENTITY part "&#8706;"> <!-- partial differential, U+2202 ISOtech -->
157
+ <!ENTITY exist "&#8707;"> <!-- there exists, U+2203 ISOtech -->
158
+ <!ENTITY empty "&#8709;"> <!-- empty set = null set = diameter,
159
+ U+2205 ISOamso -->
160
+ <!ENTITY nabla "&#8711;"> <!-- nabla = backward difference,
161
+ U+2207 ISOtech -->
162
+ <!ENTITY isin "&#8712;"> <!-- element of, U+2208 ISOtech -->
163
+ <!ENTITY notin "&#8713;"> <!-- not an element of, U+2209 ISOtech -->
164
+ <!ENTITY ni "&#8715;"> <!-- contains as member, U+220B ISOtech -->
165
+ <!-- should there be a more memorable name than 'ni'? -->
166
+ <!ENTITY prod "&#8719;"> <!-- n-ary product = product sign,
167
+ U+220F ISOamsb -->
168
+ <!-- prod is NOT the same character as U+03A0 'greek capital letter pi' though
169
+ the same glyph might be used for both -->
170
+ <!ENTITY sum "&#8721;"> <!-- n-ary sumation, U+2211 ISOamsb -->
171
+ <!-- sum is NOT the same character as U+03A3 'greek capital letter sigma'
172
+ though the same glyph might be used for both -->
173
+ <!ENTITY minus "&#8722;"> <!-- minus sign, U+2212 ISOtech -->
174
+ <!ENTITY lowast "&#8727;"> <!-- asterisk operator, U+2217 ISOtech -->
175
+ <!ENTITY radic "&#8730;"> <!-- square root = radical sign,
176
+ U+221A ISOtech -->
177
+ <!ENTITY prop "&#8733;"> <!-- proportional to, U+221D ISOtech -->
178
+ <!ENTITY infin "&#8734;"> <!-- infinity, U+221E ISOtech -->
179
+ <!ENTITY ang "&#8736;"> <!-- angle, U+2220 ISOamso -->
180
+ <!ENTITY and "&#8743;"> <!-- logical and = wedge, U+2227 ISOtech -->
181
+ <!ENTITY or "&#8744;"> <!-- logical or = vee, U+2228 ISOtech -->
182
+ <!ENTITY cap "&#8745;"> <!-- intersection = cap, U+2229 ISOtech -->
183
+ <!ENTITY cup "&#8746;"> <!-- union = cup, U+222A ISOtech -->
184
+ <!ENTITY int "&#8747;"> <!-- integral, U+222B ISOtech -->
185
+ <!ENTITY there4 "&#8756;"> <!-- therefore, U+2234 ISOtech -->
186
+ <!ENTITY sim "&#8764;"> <!-- tilde operator = varies with = similar to,
187
+ U+223C ISOtech -->
188
+ <!-- tilde operator is NOT the same character as the tilde, U+007E,
189
+ although the same glyph might be used to represent both -->
190
+ <!ENTITY cong "&#8773;"> <!-- approximately equal to, U+2245 ISOtech -->
191
+ <!ENTITY asymp "&#8776;"> <!-- almost equal to = asymptotic to,
192
+ U+2248 ISOamsr -->
193
+ <!ENTITY ne "&#8800;"> <!-- not equal to, U+2260 ISOtech -->
194
+ <!ENTITY equiv "&#8801;"> <!-- identical to, U+2261 ISOtech -->
195
+ <!ENTITY le "&#8804;"> <!-- less-than or equal to, U+2264 ISOtech -->
196
+ <!ENTITY ge "&#8805;"> <!-- greater-than or equal to,
197
+ U+2265 ISOtech -->
198
+ <!ENTITY sub "&#8834;"> <!-- subset of, U+2282 ISOtech -->
199
+ <!ENTITY sup "&#8835;"> <!-- superset of, U+2283 ISOtech -->
200
+ <!-- note that nsup, 'not a superset of, U+2283' is not covered by the Symbol
201
+ font encoding and is not included. Should it be, for symmetry?
202
+ It is in ISOamsn -->
203
+ <!ENTITY nsub "&#8836;"> <!-- not a subset of, U+2284 ISOamsn -->
204
+ <!ENTITY sube "&#8838;"> <!-- subset of or equal to, U+2286 ISOtech -->
205
+ <!ENTITY supe "&#8839;"> <!-- superset of or equal to,
206
+ U+2287 ISOtech -->
207
+ <!ENTITY oplus "&#8853;"> <!-- circled plus = direct sum,
208
+ U+2295 ISOamsb -->
209
+ <!ENTITY otimes "&#8855;"> <!-- circled times = vector product,
210
+ U+2297 ISOamsb -->
211
+ <!ENTITY perp "&#8869;"> <!-- up tack = orthogonal to = perpendicular,
212
+ U+22A5 ISOtech -->
213
+ <!ENTITY sdot "&#8901;"> <!-- dot operator, U+22C5 ISOamsb -->
214
+ <!-- dot operator is NOT the same character as U+00B7 middle dot -->
215
+
216
+ <!-- Miscellaneous Technical -->
217
+ <!ENTITY lceil "&#8968;"> <!-- left ceiling = apl upstile,
218
+ U+2308 ISOamsc -->
219
+ <!ENTITY rceil "&#8969;"> <!-- right ceiling, U+2309 ISOamsc -->
220
+ <!ENTITY lfloor "&#8970;"> <!-- left floor = apl downstile,
221
+ U+230A ISOamsc -->
222
+ <!ENTITY rfloor "&#8971;"> <!-- right floor, U+230B ISOamsc -->
223
+ <!ENTITY lang "&#9001;"> <!-- left-pointing angle bracket = bra,
224
+ U+2329 ISOtech -->
225
+ <!-- lang is NOT the same character as U+003C 'less than'
226
+ or U+2039 'single left-pointing angle quotation mark' -->
227
+ <!ENTITY rang "&#9002;"> <!-- right-pointing angle bracket = ket,
228
+ U+232A ISOtech -->
229
+ <!-- rang is NOT the same character as U+003E 'greater than'
230
+ or U+203A 'single right-pointing angle quotation mark' -->
231
+
232
+ <!-- Geometric Shapes -->
233
+ <!ENTITY loz "&#9674;"> <!-- lozenge, U+25CA ISOpub -->
234
+
235
+ <!-- Miscellaneous Symbols -->
236
+ <!ENTITY spades "&#9824;"> <!-- black spade suit, U+2660 ISOpub -->
237
+ <!-- black here seems to mean filled as opposed to hollow -->
238
+ <!ENTITY clubs "&#9827;"> <!-- black club suit = shamrock,
239
+ U+2663 ISOpub -->
240
+ <!ENTITY hearts "&#9829;"> <!-- black heart suit = valentine,
241
+ U+2665 ISOpub -->
242
+ <!ENTITY diams "&#9830;"> <!-- black diamond suit, U+2666 ISOpub -->
@@ -0,0 +1,85 @@
1
+ # coding: utf-8
2
+
3
+ require 'active_support'
4
+ require 'bigdecimal'
5
+ require 'cgi'
6
+ require 'singleton'
7
+ require 'representable/xml'
8
+ require 'virtus'
9
+
10
+ module ONIX2
11
+ class Formatters
12
+
13
+ TWO_DIGITS = ->(value, *context) {
14
+ if value.is_a?(Array)
15
+ value.each_with_index do |val, index|
16
+ value[index] = ONIX2::Formatters::two_digits_format(val)
17
+ end
18
+ else
19
+ ONIX2::Formatters::two_digits_format(value)
20
+ end
21
+ }
22
+
23
+ def self.two_digits_format(value)
24
+ if value.nil?
25
+ nil
26
+ elsif value.to_i < 10
27
+ "%02i" % value
28
+ elsif value.to_i > 99
29
+ value.to_s[-2,2]
30
+ else
31
+ value.to_s
32
+ end
33
+ end
34
+
35
+ YYYYMMDD = ->(value, *context) { value.strftime("%Y%m%d") if value.respond_to? :strftime }
36
+ DECIMAL = ->(value, *context) {
37
+ case value
38
+ when nil then nil
39
+ when BigDecimal then value.to_s("F")
40
+ else value.to_s
41
+ end
42
+ }
43
+
44
+ end
45
+
46
+ # core files
47
+ # - ordering is important, classes need to be defined before any
48
+ # other class can use them
49
+ autoload :SenderIdentifier, "onix2/sender_identifier"
50
+ autoload :AddresseeIdentifier, "onix2/addressee_identifier"
51
+ autoload :Header, "onix2/header"
52
+ autoload :ProductIdentifier, "onix2/product_identifier"
53
+ autoload :SeriesIdentifier, "onix2/series_identifier"
54
+ autoload :Series, "onix2/series"
55
+ autoload :Title, "onix2/title"
56
+ autoload :Website, "onix2/website"
57
+ autoload :Contributor, "onix2/contributor"
58
+ autoload :Language, "onix2/language"
59
+ autoload :Subject, "onix2/subject"
60
+ autoload :AudienceRange, "onix2/audience_range"
61
+ autoload :Imprint, "onix2/imprint"
62
+ autoload :Publisher, "onix2/publisher"
63
+ autoload :OtherText, "onix2/other_text"
64
+ autoload :MediaFile, "onix2/media_file"
65
+ autoload :SalesRestriction, "onix2/sales_restriction"
66
+ autoload :Stock, "onix2/stock"
67
+ autoload :DiscountCoded, "onix2/discount_coded"
68
+ autoload :Price, "onix2/price"
69
+ autoload :SupplyDetail, "onix2/supply_detail"
70
+ autoload :MarketRepresentation, "onix2/market_representation"
71
+ autoload :Measure, "onix2/measure"
72
+ autoload :Product, "onix2/product"
73
+ autoload :Reader, "onix2/reader"
74
+ autoload :Writer, "onix2/writer"
75
+ autoload :SalesRights, "onix2/sales_rights"
76
+
77
+ # product wrappers
78
+ autoload :SimpleProduct, "onix2/simple_product"
79
+ autoload :APAProduct, "onix2/apa_product"
80
+
81
+ # misc
82
+ autoload :Lists, "onix2/lists"
83
+ autoload :CodeListExtractor, "onix2/code_list_extractor"
84
+
85
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+
3
+ module ONIX2
4
+ class AddresseeIdentifier
5
+ include Virtus.model
6
+
7
+ attribute :addressee_id_type, Integer
8
+ attribute :id_type_name
9
+ attribute :id_value
10
+
11
+ def to_xml
12
+ AddresseeIdentifierRepresenter.new(self).to_xml
13
+ end
14
+
15
+ def self.from_xml(data)
16
+ AddresseeIdentifierRepresenter.new(self.new).from_xml(data)
17
+ end
18
+ end
19
+
20
+ class AddresseeIdentifierRepresenter < Representable::Decorator
21
+ include Representable::XML
22
+
23
+ self.representation_wrap = :AddresseeIdentifier
24
+
25
+ property :addressee_id_type, as: "AddresseeIDType", render_filter: ::ONIX2::Formatters::TWO_DIGITS
26
+ property :id_type_name, as: "IDTypeName"
27
+ property :id_value, as: "IDValue"
28
+ end
29
+ end
@@ -0,0 +1,785 @@
1
+ # coding: utf-8
2
+
3
+ module ONIX2
4
+ class APAProduct < SimpleProduct
5
+
6
+ delegate :record_reference, :record_reference=
7
+ delegate :notification_type, :notification_type=
8
+ delegate :product_form, :product_form=
9
+ delegate :edition, :edition=
10
+ delegate :number_of_pages, :number_of_pages=
11
+ delegate :bic_main_subject, :bic_main_subject=
12
+ delegate :publishing_status, :publishing_status=
13
+ delegate :publication_date, :publication_date=
14
+
15
+ def measurement_system
16
+ @measurement_system ||= :metric
17
+ end
18
+
19
+ def measurement_system=(value)
20
+ if value == :metric || value == :imperial
21
+ @measurement_system = value
22
+ else
23
+ raise ArgumentError, "#{value} is not a recognised measurement system"
24
+ end
25
+ end
26
+
27
+ # retrieve the current EAN
28
+ def ean
29
+ identifier(3).try(:id_value)
30
+ end
31
+
32
+ # set a new EAN
33
+ def ean=(isbn)
34
+ identifier_set(3, isbn)
35
+ end
36
+
37
+ # retrieve the proprietary ID
38
+ def proprietary_id
39
+ identifier(1).try(:id_value)
40
+ end
41
+
42
+ # set a new proprietary ID
43
+ def proprietary_id=(isbn)
44
+ identifier_set(1, isbn)
45
+ end
46
+
47
+ # retrieve the current ISBN 10
48
+ def isbn10
49
+ identifier(2).try(:id_value)
50
+ end
51
+
52
+ # set a new ISBN 10
53
+ def isbn10=(isbn)
54
+ identifier_set(2, isbn)
55
+ end
56
+
57
+ # retrieve the current ISBN 13
58
+ def isbn13
59
+ identifier(15).try(:id_value)
60
+ end
61
+
62
+ # set a new ISBN 13
63
+ def isbn13=(isbn)
64
+ identifier_set(15, isbn)
65
+ end
66
+
67
+ # retrieve the current title
68
+ def title
69
+ composite = product.titles.first
70
+ if composite.nil?
71
+ nil
72
+ else
73
+ composite.title_text || composite.title_without_prefix
74
+ end
75
+ end
76
+
77
+ # set a new title
78
+ def title=(str)
79
+ composite = product.titles.first
80
+ if composite.nil?
81
+ composite = ONIX2::Title.new
82
+ composite.title_type = 1
83
+ product.titles << composite
84
+ end
85
+ composite.title_text = str
86
+ end
87
+
88
+ # retrieve the current subtitle
89
+ def subtitle
90
+ composite = product.titles.first
91
+ if composite.nil?
92
+ nil
93
+ else
94
+ composite.subtitle
95
+ end
96
+ end
97
+
98
+ # set a new subtitle
99
+ def subtitle=(str)
100
+ composite = product.titles.first
101
+ if composite.nil?
102
+ composite = ONIX2::Title.new
103
+ composite.title_type = 1
104
+ product.titles << composite
105
+ end
106
+ composite.subtitle = str
107
+ end
108
+
109
+ def series
110
+ composite = product.series.first
111
+ composite.try(:title_of_series)
112
+ end
113
+
114
+ def series=(val)
115
+ composite = product.series.first
116
+ if composite.nil?
117
+ composite = ONIX2::Series.new
118
+ product.series << composite
119
+ end
120
+ composite.title_of_series = val.to_s
121
+ end
122
+
123
+ # retrieve the current publisher website for this particular product
124
+ def publisher_website
125
+ website(2).try(:website_link)
126
+ end
127
+
128
+ # set a new publisher website for this particular product
129
+ def publisher_website=(str)
130
+ website_set(2, str)
131
+ end
132
+
133
+ # retrieve the current supplier website for this particular product
134
+ def supplier_website
135
+ website(12).try(:website_link)
136
+ end
137
+
138
+ # set a new supplier website for this particular product
139
+ def supplier_website=(str)
140
+ website_set(12, str)
141
+ end
142
+
143
+ # retrieve an array of all contributors
144
+ def contributors
145
+ product.contributors.collect { |contrib| contrib.person_name_inverted || contrib.person_name}
146
+ end
147
+
148
+ # set a new contributor to this product
149
+ # str should be the contributors name inverted (Healy, James)
150
+ def add_contributor(str, role = "A01")
151
+ contrib = ::ONIX2::Contributor.new
152
+ contrib.sequence_number = product.contributors.size + 1
153
+ contrib.contributor_role = role
154
+ contrib.person_name_inverted = str
155
+ product.contributors << contrib
156
+ end
157
+
158
+ # return an array of BIC subjects for this title
159
+ # could be version 1 or version 2, most ONIX files don't
160
+ # specifiy
161
+ def bic_subjects
162
+ subjects = product.subjects.select { |sub| sub.subject_scheme_id.to_i == 12 }
163
+ subjects.collect { |sub| sub.subject_code}
164
+ end
165
+
166
+ # add a BIC subject code to the product
167
+ def add_bic_subject(code)
168
+ add_subject code, "12"
169
+ end
170
+
171
+ # return an array of BISAC subjects for this title
172
+ def bisac_subjects
173
+ subjects = product.subjects.select { |sub| sub.subject_scheme_id.to_i == 10 }
174
+ subjects.collect { |sub| sub.subject_code}
175
+ end
176
+
177
+ # add a BISAC subject code to the product
178
+ def add_bisac_subject(code)
179
+ add_subject code, "10"
180
+ end
181
+
182
+ # retrieve the url to the product cover image
183
+ def cover_url
184
+ media_file(4).try(:media_file_link)
185
+ end
186
+
187
+ # set the url to the product cover image
188
+ def cover_url=(url)
189
+ # 4 - cover image
190
+ # 1 - URI
191
+ media_file_set(4,1,url)
192
+ end
193
+
194
+ # retrieve the url to the high quality product cover image
195
+ def cover_url_hq
196
+ media_file(6).try(:media_file_link)
197
+ end
198
+
199
+ # set the url to the high quality product cover image
200
+ def cover_url_hq=(url)
201
+ # 6 - hq cover image
202
+ # 1 - URI
203
+ media_file_set(6,1,url)
204
+ end
205
+
206
+ # retrieve the url to the product thumbnail
207
+ def thumbnail_url
208
+ media_file(7).try(:media_file_link)
209
+ end
210
+
211
+ # set the url to the product cover image
212
+ def thumbnail_url=(url)
213
+ # 7 - thumbnail image
214
+ # 1 - URI
215
+ media_file_set(7,1,url)
216
+ end
217
+
218
+ # retrieve the main description
219
+ def main_description
220
+ other_text(1).try(:text)
221
+ end
222
+
223
+ # set the main description
224
+ def main_description=(t)
225
+ other_text_set(1,t)
226
+ end
227
+
228
+ # retrieve the short description
229
+ def short_description
230
+ other_text(2).try(:text)
231
+ end
232
+
233
+ # set the short description
234
+ def short_description=(t)
235
+ other_text_set(2,t)
236
+ end
237
+
238
+ # retrieve the long description
239
+ def long_description
240
+ other_text(3).try(:text)
241
+ end
242
+
243
+ # set the long description
244
+ def long_description=(t)
245
+ other_text_set(3,t)
246
+ end
247
+
248
+ # retrieve the imprint
249
+ def imprint
250
+ composite = product.imprints.first
251
+ composite ? composite.imprint_name : nil
252
+ end
253
+
254
+ # set a new imprint
255
+ def imprint=(str)
256
+ composite = product.imprints.first
257
+ if composite.nil?
258
+ composite = ONIX2::Imprint.new
259
+ product.imprints << composite
260
+ end
261
+ composite.imprint_name = str
262
+ end
263
+
264
+ # retrieve the publisher
265
+ def publisher
266
+ publisher_get(1).try(:publisher_name)
267
+ end
268
+
269
+ # set a new publisher
270
+ def publisher=(str)
271
+ publisher_set(1, str)
272
+ end
273
+
274
+ # retrieve the sales restriction type
275
+ def sales_restriction_type
276
+ composite = product.sales_restrictions.first
277
+ composite.nil? ? nil : composite.imprint_name
278
+ end
279
+
280
+ # set a new sales restriction type
281
+ def sales_restriction_type=(type)
282
+ composite = product.sales_restrictions.first
283
+ if composite.nil?
284
+ composite = ONIX2::SalesRestriction.new
285
+ product.sales_restrictions << composite
286
+ end
287
+ composite.sales_restriction_type = type
288
+ end
289
+
290
+ # retrieve the supplier name
291
+ def supplier_name
292
+ composite = product.supply_details.first
293
+ composite.nil? ? nil : composite.supplier_name
294
+ end
295
+
296
+ # set a new supplier name
297
+ def supplier_name=(str)
298
+ composite = find_or_create_supply_detail
299
+ composite.supplier_name = str
300
+ end
301
+
302
+ # retrieve the supplier phone number
303
+ def supplier_phone
304
+ composite = product.supply_details.first
305
+ composite.nil? ? nil : composite.telephone_number
306
+ end
307
+
308
+ # set a new supplier phone number
309
+ def supplier_phone=(str)
310
+ composite = find_or_create_supply_detail
311
+ composite.telephone_number = str
312
+ end
313
+
314
+ # retrieve the supplier fax number
315
+ def supplier_fax
316
+ composite = product.supply_details.first
317
+ composite.nil? ? nil : composite.fax_number
318
+ end
319
+
320
+ # set a new supplier fax number
321
+ def supplier_fax=(str)
322
+ composite = find_or_create_supply_detail
323
+ composite.fax_number = str
324
+ end
325
+
326
+ # retrieve the supplier email address
327
+ def supplier_email
328
+ composite = product.supply_details.first
329
+ composite.nil? ? nil : composite.email_address
330
+ end
331
+
332
+ # set a new supplier email address
333
+ def supplier_email=(str)
334
+ composite = find_or_create_supply_detail
335
+ composite.email_address = str
336
+ end
337
+
338
+ # retrieve the supply country code
339
+ def supply_country
340
+ composite = product.supply_details.first
341
+ composite.nil? ? nil : composite.supply_to_country
342
+ end
343
+
344
+ # set a new supply country code
345
+ def supply_country=(str)
346
+ composite = find_or_create_supply_detail
347
+ composite.supply_to_country = str
348
+ end
349
+
350
+ # retrieve the product availability code
351
+ def product_availability
352
+ composite = product.supply_details.first
353
+ composite.nil? ? nil : composite.product_availability
354
+ end
355
+
356
+ # set a new product availability
357
+ def product_availability=(num)
358
+ composite = find_or_create_supply_detail
359
+ composite.product_availability = num
360
+ end
361
+
362
+ # retrieve the number in stock
363
+ def on_hand
364
+ supply = find_or_create_supply_detail
365
+ composite = supply.stock.first
366
+ if composite.nil?
367
+ composite = ONIX2::Stock.new
368
+ supply.stock << composite
369
+ end
370
+ composite.on_hand
371
+ end
372
+
373
+ # set a new in stock quantity
374
+ def on_hand=(num)
375
+ supply = find_or_create_supply_detail
376
+ composite = supply.stock.first
377
+ if composite.nil?
378
+ composite = ONIX2::Stock.new
379
+ supply.stock << composite
380
+ end
381
+ composite.on_hand = num
382
+ end
383
+
384
+ # retrieve the number on order
385
+ def on_order
386
+ supply = find_or_create_supply_detail
387
+ composite = supply.stock.first
388
+ if composite.nil?
389
+ composite = ONIX2::Stock.new
390
+ supply.stock << composite
391
+ end
392
+ composite.on_order
393
+ end
394
+
395
+ # set a new on order quantity
396
+ def on_order=(num)
397
+ supply = find_or_create_supply_detail
398
+ composite = supply.stock.first
399
+ if composite.nil?
400
+ composite = ONIX2::Stock.new
401
+ supply.stock << composite
402
+ end
403
+ composite.on_order = num
404
+ end
405
+
406
+ # retrieve the supplier phone number
407
+ def pack_quantity
408
+ composite = product.supply_details.first
409
+ composite.nil? ? nil : composite.pack_quantity
410
+ end
411
+
412
+ # set a new supplier phone number
413
+ def pack_quantity=(val)
414
+ composite = find_or_create_supply_detail
415
+ composite.pack_quantity = val.to_i
416
+ end
417
+
418
+ # retrieve the rrp excluding any sales tax
419
+ def rrp_exc_sales_tax
420
+ price_get(1).try(:price_amount)
421
+ end
422
+
423
+ # set the rrp excluding any sales tax
424
+ def rrp_exc_sales_tax=(num)
425
+ price_set(1, num)
426
+ end
427
+
428
+ # retrieve the rrp including any sales tax
429
+ def rrp_inc_sales_tax
430
+ price_get(2).try(:price_amount)
431
+ end
432
+
433
+ # set the rrp including any sales tax
434
+ def rrp_inc_sales_tax=(num)
435
+ price_set(2, num)
436
+ end
437
+
438
+ # retrieve the nett price including any sales tax
439
+ def nett_inc_sales_tax
440
+ price_get(7).try(:price_amount)
441
+ end
442
+
443
+ # set the rrp including any sales tax
444
+ def nett_inc_sales_tax=(num)
445
+ price_set(7, num)
446
+ end
447
+
448
+ # retrieve the discount code that describes the rrp in this file
449
+ def proprietry_discount_code_for_rrp
450
+ price = price_get(2)
451
+ return nil if price.nil?
452
+
453
+ discount = price.discounts_coded.find { |disc| disc.discount_code_type == 2 }
454
+ discount.try(:discount_code)
455
+ end
456
+
457
+ # set the discount code that describes the rrp in this file
458
+ def proprietry_discount_code_for_rrp=(code)
459
+ price = price_get(2)
460
+ if price.nil?
461
+ self.rrp_inc_sales_tax = 0
462
+ price = price_get(2)
463
+ end
464
+
465
+ discount = price.discounts_coded.find { |disc| disc.discount_code_type == 2 }
466
+
467
+ if discount.nil?
468
+ discount = ONIX2::DiscountCoded.new
469
+ discount.discount_code_type = 2
470
+ price.discounts_coded << discount
471
+ end
472
+ discount.discount_code = code
473
+ end
474
+
475
+ # just get the first price we can find, regardless of the type.
476
+ # useful as a backup for reading files from that don't contain a type
477
+ def price
478
+ price_get(nil).try(:price_amount)
479
+ end
480
+
481
+ # retrieve the height of the product
482
+ #
483
+ # If APAProduct#measurement_system is metric, these will be in mm, otherwise they
484
+ # will be in inches.
485
+ #
486
+ def height
487
+ # TODO: auto unit conversion
488
+ measurement(1).try(:measurement)
489
+ end
490
+
491
+ # set the height of the book
492
+ #
493
+ # If APAProduct#measurement_system is metric, this should be in mm, otherwise it
494
+ # will be in inches.
495
+ #
496
+ def height=(value)
497
+ if measurement_system == :metric
498
+ measurement_set(1,value, "mm")
499
+ elsif measurement_system == :imperial
500
+ measurement_set(1,value, "in")
501
+ end
502
+ end
503
+
504
+ # retrieve the width of the product
505
+ #
506
+ # If APAProduct#measurement_system is metric, these will be in mm, otherwise they
507
+ # will be in inches.
508
+ #
509
+ def width
510
+ # TODO: auto unit conversion
511
+ measurement(2).try(:measurement)
512
+ end
513
+
514
+ # set the width of the product
515
+ #
516
+ # If APAProduct#measurement_system is metric, this should be in mm, otherwise it
517
+ # will be in inches.
518
+ #
519
+ def width=(value)
520
+ if measurement_system == :metric
521
+ measurement_set(2,value, "mm")
522
+ elsif measurement_system == :imperial
523
+ measurement_set(2,value, "in")
524
+ end
525
+ end
526
+
527
+ # retrieve the weight of the product
528
+ #
529
+ # If APAProduct#measurement_system is metric, these will be in grams, otherwise they
530
+ # will be in ounces.
531
+ #
532
+ def weight
533
+ # TODO: auto unit conversion
534
+ measurement(8).try(:measurement)
535
+ end
536
+
537
+ # set the weight of the product
538
+ #
539
+ # If APAProduct#measurement_system is metric, this should be in grams, otherwise it
540
+ # will be in ounces.
541
+ #
542
+ def weight=(value)
543
+ if measurement_system == :metric
544
+ measurement_set(8,value, "gr")
545
+ elsif measurement_system == :imperial
546
+ measurement_set(8,value, "oz")
547
+ end
548
+ end
549
+
550
+ # retrieve the thickness of the product
551
+ #
552
+ # If APAProduct#measurement_system is metric, these will be in mm, otherwise they
553
+ # will be in inches.
554
+ #
555
+ def thickness
556
+ # TODO: auto unit conversion
557
+ measurement(3).try(:measurement)
558
+ end
559
+
560
+ # set the thickness of the product
561
+ #
562
+ # If APAProduct#measurement_system is metric, this should be in mm, otherwise it
563
+ # will be in inches.
564
+ #
565
+ def thickness=(value)
566
+ if measurement_system == :metric
567
+ measurement_set(3,value, "mm")
568
+ elsif measurement_system == :imperial
569
+ measurement_set(3,value, "in")
570
+ end
571
+ end
572
+
573
+ def agent_name
574
+ reps = product.market_representations.first
575
+ return nil if reps.nil?
576
+ reps.agent_name
577
+ end
578
+
579
+ def agent_name=(value)
580
+ reps = product.market_representations.first
581
+ if reps.nil?
582
+ reps = ONIX2::MarketRepresentation.new
583
+ product.market_representations << reps
584
+ end
585
+ reps.agent_name = value.to_s
586
+ end
587
+
588
+ def market_country
589
+ reps = product.market_representations.first
590
+ return nil if reps.nil?
591
+ reps.market_country
592
+ end
593
+
594
+ def market_country=(value)
595
+ reps = product.market_representations.first
596
+ if reps.nil?
597
+ reps = ONIX2::MarketRepresentation.new
598
+ product.market_representations << reps
599
+ end
600
+ reps.market_country = value.to_s
601
+ end
602
+
603
+ def market_publishing_status
604
+ reps = product.market_representations.first
605
+ return nil if reps.nil?
606
+ reps.market_publishing_status
607
+ end
608
+
609
+ def market_publishing_status=(value)
610
+ reps = product.market_representations.first
611
+ if reps.nil?
612
+ reps = ONIX2::MarketRepresentation.new
613
+ product.market_representations << reps
614
+ end
615
+ reps.market_publishing_status = value.to_i
616
+ end
617
+
618
+ private
619
+
620
+ # add a new subject to this product
621
+ # str should be the subject code
622
+ # type should be the code for the subject scheme you're using. See ONIX codelist 27.
623
+ # 12 is BIC
624
+ def add_subject(str, type = "12")
625
+ subject = ::ONIX2::Subject.new
626
+ subject.subject_scheme_id = type.to_i
627
+ subject.subject_code = str
628
+ product.subjects << subject
629
+ end
630
+
631
+ def find_or_create_supply_detail
632
+ composite = product.supply_details.first
633
+ if composite.nil?
634
+ composite = ONIX2::SupplyDetail.new
635
+ product.supply_details << composite
636
+ end
637
+ composite
638
+ end
639
+
640
+ # retrieve the value of a particular ID
641
+ def identifier(type)
642
+ product.product_identifiers.find { |id| id.product_id_type == type }
643
+ end
644
+
645
+ # set the value of a particular ID
646
+ def identifier_set(type, value)
647
+ isbn_id = identifier(type)
648
+
649
+ # create a new isbn record if we need to
650
+ if isbn_id.nil?
651
+ isbn_id = ONIX2::ProductIdentifier.new
652
+ isbn_id.product_id_type = type
653
+ product.product_identifiers << isbn_id
654
+ end
655
+
656
+ isbn_id.id_value = value
657
+ end
658
+
659
+ # retrieve the value of a particular measurement
660
+ def measurement(type)
661
+ product.measurements.find { |m| m.measure_type_code == type }
662
+ end
663
+
664
+ # set the value of a particular measurement
665
+ def measurement_set(type, value, unit)
666
+ measure = measurement(type)
667
+
668
+ # create a new isbn record if we need to
669
+ if measure.nil?
670
+ measure = ONIX2::Measure.new
671
+ measure.measure_type_code = type
672
+ product.measurements << measure
673
+ end
674
+
675
+ # store the new value
676
+ measure.measurement = value
677
+ measure.measure_unit_code = unit.to_s
678
+ end
679
+
680
+ # retrieve the value of a particular media file
681
+ def media_file(type)
682
+ product.media_files.find { |m| m.media_file_type_code == type }
683
+ end
684
+
685
+ # set the value of a particular ID
686
+ def media_file_set(type, link_type, value)
687
+ media = media_file(type)
688
+
689
+ # create a new isbn record if we need to
690
+ if media.nil?
691
+ media = ONIX2::MediaFile.new
692
+ media.media_file_type_code = type
693
+ media.media_file_link_type_code = link_type
694
+ product.media_files << media
695
+ end
696
+
697
+ # store the new value
698
+ media.media_file_link = value.to_s
699
+ end
700
+
701
+ # retrieve the value of a particular price
702
+ def price_get(type)
703
+ supply = find_or_create_supply_detail
704
+ if type.nil?
705
+ supply.prices.first
706
+ else
707
+ supply.prices.find { |p| p.price_type_code == type }
708
+ end
709
+ end
710
+
711
+ # set the value of a particular price
712
+ def price_set(type, num)
713
+ p = price_get(type)
714
+
715
+ # create a new isbn record if we need to
716
+ if p.nil?
717
+ supply = find_or_create_supply_detail
718
+ p = ONIX2::Price.new
719
+ p.price_type_code = type
720
+ supply.prices << p
721
+ end
722
+
723
+ # store the new value
724
+ p.price_amount = num
725
+ end
726
+
727
+ # retrieve the value of a particular publisher
728
+ def publisher_get(type)
729
+ product.publishers.find { |pub| pub.publishing_role == type }
730
+ end
731
+
732
+ # set the value of a particular ID
733
+ def publisher_set(type, value)
734
+ pub = publisher_get(type)
735
+
736
+ # create a new isbn record if we need to
737
+ if pub.nil?
738
+ pub = ONIX2::Publisher.new
739
+ pub.publishing_role = type
740
+ product.publishers << pub
741
+ end
742
+
743
+ # store the new value
744
+ pub.publisher_name = value.to_s
745
+ end
746
+
747
+ # retrieve the value of a particular other text value
748
+ def other_text(type)
749
+ product.text.find { |t| t.text_type_code == type }
750
+ end
751
+
752
+ # set the value of a particular other text value
753
+ def other_text_set(type, value)
754
+ text = other_text(type)
755
+
756
+ if text.nil?
757
+ text = ONIX2::OtherText.new
758
+ text.text_type_code = type
759
+ product.text << text
760
+ end
761
+
762
+ # store the new value
763
+ text.text = value.to_s
764
+ end
765
+
766
+ # retrieve the value of a particular website
767
+ def website(type)
768
+ product.websites.find { |site| site.website_role == type }
769
+ end
770
+
771
+ # set the value of a particular website
772
+ def website_set(type, value)
773
+ site = website(type)
774
+
775
+ # create a new website record if we need to
776
+ if site.nil?
777
+ site = ONIX2::Website.new
778
+ site.website_role = type
779
+ product.websites << site
780
+ end
781
+
782
+ site.website_link = value.to_s
783
+ end
784
+ end
785
+ end