cacofonix 0.10.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.
- checksums.yaml +7 -0
- data/.gitignore +2 -0
- data/.rvmrc +1 -0
- data/.travis.yml +10 -0
- data/CHANGELOG.md +205 -0
- data/CODE_OF_CONDUCT.md +74 -0
- data/Gemfile +5 -0
- data/LICENSE.txt +22 -0
- data/README.md +76 -0
- data/Rakefile +6 -0
- data/TODO +14 -0
- data/bin/onix_extract_codelists +41 -0
- data/cacofonix.gemspec +39 -0
- data/data/9780194351898.xml +74 -0
- data/data/Ashgate Other.xml +382679 -0
- data/data/Bookwise_July_2008.xml +21611 -0
- data/data/Peribo Onix 0408.xml +17051 -0
- data/data/aau.xml +96 -0
- data/data/audience_range.xml +9 -0
- data/data/contributor.xml +6 -0
- data/data/control_chars.xml +74 -0
- data/data/entities.xml +78 -0
- data/data/extra_entities.xml +65 -0
- data/data/header.xml +21 -0
- data/data/header_invalid_sentdate.xml +21 -0
- data/data/hlasep08.xml +24519 -0
- data/data/imprint.xml +5 -0
- data/data/iso_8859_1.xml +58 -0
- data/data/jul.xml +24783 -0
- data/data/language.xml +7 -0
- data/data/market_representation.xml +11 -0
- data/data/measure.xml +6 -0
- data/data/media_file.xml +6 -0
- data/data/no_encoding.xml +78 -0
- data/data/no_xml_declaration.xml +95 -0
- data/data/other_text.xml +5 -0
- data/data/price.xml +5 -0
- data/data/product.xml +79 -0
- data/data/product_identifier.xml +5 -0
- data/data/product_invalid_pubdate.xml +42 -0
- data/data/publisher.xml +5 -0
- data/data/rba_FANT.xml +23 -0
- data/data/reference_with_release_attrib.xml +74 -0
- data/data/sales_restriction.xml +4 -0
- data/data/sales_rights.xml +35 -0
- data/data/sender_identifier.xml +5 -0
- data/data/series.xml +5 -0
- data/data/series_identifier.xml +6 -0
- data/data/short_tags.xml +191 -0
- data/data/short_tags_ivp.xml +231 -0
- data/data/sl_product.xml +81 -0
- data/data/stock.xml +5 -0
- data/data/subject.xml +6 -0
- data/data/supply_detail.xml +18 -0
- data/data/title.xml +6 -0
- data/data/two_products.xml +114 -0
- data/data/usd.xml +175 -0
- data/data/utf_16.xml +0 -0
- data/data/website.xml +6 -0
- data/examples/reader.rb +25 -0
- data/examples/reader_apa.rb +22 -0
- data/examples/writer.rb +13 -0
- data/examples/writer_apa.rb +38 -0
- data/lib/cacofonix.rb +151 -0
- data/lib/cacofonix/codelists/001.rb +16 -0
- data/lib/cacofonix/codelists/002.rb +11 -0
- data/lib/cacofonix/codelists/003.rb +13 -0
- data/lib/cacofonix/codelists/005.rb +20 -0
- data/lib/cacofonix/codelists/006.rb +82 -0
- data/lib/cacofonix/codelists/007.rb +129 -0
- data/lib/cacofonix/codelists/008.rb +13 -0
- data/lib/cacofonix/codelists/009.rb +13 -0
- data/lib/cacofonix/codelists/010.rb +52 -0
- data/lib/cacofonix/codelists/011.rb +17 -0
- data/lib/cacofonix/codelists/012.rb +17 -0
- data/lib/cacofonix/codelists/013.rb +13 -0
- data/lib/cacofonix/codelists/014.rb +10 -0
- data/lib/cacofonix/codelists/015.rb +19 -0
- data/lib/cacofonix/codelists/016.rb +12 -0
- data/lib/cacofonix/codelists/017.rb +96 -0
- data/lib/cacofonix/codelists/018.rb +11 -0
- data/lib/cacofonix/codelists/019.rb +13 -0
- data/lib/cacofonix/codelists/020.rb +7 -0
- data/lib/cacofonix/codelists/021.rb +39 -0
- data/lib/cacofonix/codelists/022.rb +15 -0
- data/lib/cacofonix/codelists/023.rb +19 -0
- data/lib/cacofonix/codelists/024.rb +17 -0
- data/lib/cacofonix/codelists/025.rb +35 -0
- data/lib/cacofonix/codelists/026.rb +86 -0
- data/lib/cacofonix/codelists/027.rb +90 -0
- data/lib/cacofonix/codelists/028.rb +14 -0
- data/lib/cacofonix/codelists/029.rb +25 -0
- data/lib/cacofonix/codelists/030.rb +22 -0
- data/lib/cacofonix/codelists/031.rb +9 -0
- data/lib/cacofonix/codelists/032.rb +8 -0
- data/lib/cacofonix/codelists/033.rb +43 -0
- data/lib/cacofonix/codelists/034.rb +21 -0
- data/lib/cacofonix/codelists/035.rb +12 -0
- data/lib/cacofonix/codelists/036.rb +9 -0
- data/lib/cacofonix/codelists/037.rb +12 -0
- data/lib/cacofonix/codelists/038.rb +43 -0
- data/lib/cacofonix/codelists/039.rb +14 -0
- data/lib/cacofonix/codelists/040.rb +12 -0
- data/lib/cacofonix/codelists/041.rb +12 -0
- data/lib/cacofonix/codelists/042.rb +22 -0
- data/lib/cacofonix/codelists/043.rb +12 -0
- data/lib/cacofonix/codelists/044.rb +22 -0
- data/lib/cacofonix/codelists/045.rb +19 -0
- data/lib/cacofonix/codelists/046.rb +15 -0
- data/lib/cacofonix/codelists/047.rb +10 -0
- data/lib/cacofonix/codelists/048.rb +17 -0
- data/lib/cacofonix/codelists/049.rb +91 -0
- data/lib/cacofonix/codelists/050.rb +14 -0
- data/lib/cacofonix/codelists/051.rb +36 -0
- data/lib/cacofonix/codelists/052.rb +7 -0
- data/lib/cacofonix/codelists/053.rb +10 -0
- data/lib/cacofonix/codelists/054.rb +29 -0
- data/lib/cacofonix/codelists/055.rb +23 -0
- data/lib/cacofonix/codelists/056.rb +8 -0
- data/lib/cacofonix/codelists/057.rb +11 -0
- data/lib/cacofonix/codelists/058.rb +29 -0
- data/lib/cacofonix/codelists/059.rb +13 -0
- data/lib/cacofonix/codelists/060.rb +8 -0
- data/lib/cacofonix/codelists/061.rb +9 -0
- data/lib/cacofonix/codelists/062.rb +11 -0
- data/lib/cacofonix/codelists/063.rb +7 -0
- data/lib/cacofonix/codelists/064.rb +19 -0
- data/lib/cacofonix/codelists/065.rb +34 -0
- data/lib/cacofonix/codelists/066.rb +10 -0
- data/lib/cacofonix/codelists/067.rb +8 -0
- data/lib/cacofonix/codelists/068.rb +22 -0
- data/lib/cacofonix/codelists/069.rb +10 -0
- data/lib/cacofonix/codelists/070.rb +8 -0
- data/lib/cacofonix/codelists/071.rb +16 -0
- data/lib/cacofonix/codelists/072.rb +13 -0
- data/lib/cacofonix/codelists/073.rb +42 -0
- data/lib/cacofonix/codelists/074.rb +495 -0
- data/lib/cacofonix/codelists/075.rb +8 -0
- data/lib/cacofonix/codelists/076.rb +18 -0
- data/lib/cacofonix/codelists/077.rb +25 -0
- data/lib/cacofonix/codelists/078.rb +173 -0
- data/lib/cacofonix/codelists/079.rb +25 -0
- data/lib/cacofonix/codelists/080.rb +26 -0
- data/lib/cacofonix/codelists/081.rb +45 -0
- data/lib/cacofonix/codelists/082.rb +23 -0
- data/lib/cacofonix/codelists/083.rb +74 -0
- data/lib/cacofonix/codelists/084.rb +16 -0
- data/lib/cacofonix/codelists/085.rb +29 -0
- data/lib/cacofonix/codelists/086.rb +11 -0
- data/lib/cacofonix/codelists/087.rb +12 -0
- data/lib/cacofonix/codelists/088.rb +7 -0
- data/lib/cacofonix/codelists/089.rb +7 -0
- data/lib/cacofonix/codelists/090.rb +17 -0
- data/lib/cacofonix/codelists/091.rb +257 -0
- data/lib/cacofonix/codelists/092.rb +14 -0
- data/lib/cacofonix/codelists/093.rb +19 -0
- data/lib/cacofonix/codelists/094.rb +9 -0
- data/lib/cacofonix/codelists/095.rb +9 -0
- data/lib/cacofonix/codelists/096.rb +191 -0
- data/lib/cacofonix/codelists/097.rb +7 -0
- data/lib/cacofonix/codelists/098.rb +27 -0
- data/lib/cacofonix/codelists/099.rb +30 -0
- data/lib/cacofonix/codelists/100.rb +12 -0
- data/lib/cacofonix/codelists/101.rb +8 -0
- data/lib/cacofonix/codelists/102.rb +9 -0
- data/lib/cacofonix/codelists/121.rb +164 -0
- data/lib/cacofonix/codelists/138.rb +12 -0
- data/lib/cacofonix/codelists/139.rb +76 -0
- data/lib/cacofonix/codelists/140.rb +13 -0
- data/lib/cacofonix/codelists/141.rb +16 -0
- data/lib/cacofonix/codelists/142.rb +18 -0
- data/lib/cacofonix/codelists/143.rb +13 -0
- data/lib/cacofonix/codelists/144.rb +12 -0
- data/lib/cacofonix/codelists/145.rb +13 -0
- data/lib/cacofonix/codelists/146.rb +9 -0
- data/lib/cacofonix/codelists/147.rb +16 -0
- data/lib/cacofonix/codelists/148.rb +9 -0
- data/lib/cacofonix/codelists/149.rb +10 -0
- data/lib/cacofonix/codelists/150.rb +130 -0
- data/lib/cacofonix/codelists/151.rb +13 -0
- data/lib/cacofonix/codelists/152.rb +8 -0
- data/lib/cacofonix/codelists/153.rb +20 -0
- data/lib/cacofonix/codelists/154.rb +15 -0
- data/lib/cacofonix/codelists/155.rb +11 -0
- data/lib/cacofonix/codelists/156.rb +10 -0
- data/lib/cacofonix/codelists/157.rb +10 -0
- data/lib/cacofonix/codelists/158.rb +32 -0
- data/lib/cacofonix/codelists/159.rb +12 -0
- data/lib/cacofonix/codelists/160.rb +10 -0
- data/lib/cacofonix/codelists/161.rb +9 -0
- data/lib/cacofonix/codelists/162.rb +12 -0
- data/lib/cacofonix/codelists/163.rb +17 -0
- data/lib/cacofonix/codelists/164.rb +11 -0
- data/lib/cacofonix/codelists/165.rb +9 -0
- data/lib/cacofonix/codelists/166.rb +9 -0
- data/lib/cacofonix/codelists/167.rb +9 -0
- data/lib/cacofonix/codelists/168.rb +8 -0
- data/lib/cacofonix/codelists/169.rb +9 -0
- data/lib/cacofonix/codelists/170.rb +7 -0
- data/lib/cacofonix/codelists/171.rb +8 -0
- data/lib/cacofonix/codelists/172.rb +7 -0
- data/lib/cacofonix/codelists/173.rb +8 -0
- data/lib/cacofonix/codelists/174.rb +8 -0
- data/lib/cacofonix/codelists/175.rb +206 -0
- data/lib/cacofonix/codelists/176.rb +20 -0
- data/lib/cacofonix/codelists/177.rb +8 -0
- data/lib/cacofonix/codelists/178.rb +24 -0
- data/lib/cacofonix/codelists/179.rb +7 -0
- data/lib/cacofonix/codelists/184.rb +11 -0
- data/lib/cacofonix/core/code.rb +106 -0
- data/lib/cacofonix/core/element.rb +275 -0
- data/lib/cacofonix/core/header.rb +45 -0
- data/lib/cacofonix/core/lists.rb +108 -0
- data/lib/cacofonix/core/reader.rb +166 -0
- data/lib/cacofonix/core/writer.rb +123 -0
- data/lib/cacofonix/elements/addressee_identifier.rb +6 -0
- data/lib/cacofonix/elements/agent_identifier.rb +6 -0
- data/lib/cacofonix/elements/audience.rb +8 -0
- data/lib/cacofonix/elements/audience_range.rb +15 -0
- data/lib/cacofonix/elements/batch_bonus.rb +7 -0
- data/lib/cacofonix/elements/bible.rb +12 -0
- data/lib/cacofonix/elements/complexity.rb +7 -0
- data/lib/cacofonix/elements/conference.rb +14 -0
- data/lib/cacofonix/elements/conference_sponsor.rb +8 -0
- data/lib/cacofonix/elements/conference_sponsor_identifier.rb +6 -0
- data/lib/cacofonix/elements/contained_item.rb +6 -0
- data/lib/cacofonix/elements/content_item.rb +21 -0
- data/lib/cacofonix/elements/contributor.rb +19 -0
- data/lib/cacofonix/elements/copyright_owner.rb +8 -0
- data/lib/cacofonix/elements/copyright_owner_identifier.rb +6 -0
- data/lib/cacofonix/elements/copyright_statement.rb +7 -0
- data/lib/cacofonix/elements/discount_coded.rb +8 -0
- data/lib/cacofonix/elements/extent.rb +8 -0
- data/lib/cacofonix/elements/identifier.rb +7 -0
- data/lib/cacofonix/elements/illustrations.rb +8 -0
- data/lib/cacofonix/elements/imprint.rb +9 -0
- data/lib/cacofonix/elements/language.rb +8 -0
- data/lib/cacofonix/elements/location_identifier.rb +8 -0
- data/lib/cacofonix/elements/main_subject.rb +9 -0
- data/lib/cacofonix/elements/market_date.rb +8 -0
- data/lib/cacofonix/elements/market_representation.rb +18 -0
- data/lib/cacofonix/elements/measure.rb +8 -0
- data/lib/cacofonix/elements/media_file.rb +16 -0
- data/lib/cacofonix/elements/name.rb +6 -0
- data/lib/cacofonix/elements/name_base.rb +17 -0
- data/lib/cacofonix/elements/new_supplier.rb +12 -0
- data/lib/cacofonix/elements/not_for_sale.rb +13 -0
- data/lib/cacofonix/elements/on_order_detail.rb +7 -0
- data/lib/cacofonix/elements/other_text.rb +17 -0
- data/lib/cacofonix/elements/page_run.rb +7 -0
- data/lib/cacofonix/elements/person_date.rb +8 -0
- data/lib/cacofonix/elements/person_name_identifier.rb +6 -0
- data/lib/cacofonix/elements/price.rb +46 -0
- data/lib/cacofonix/elements/prize.rb +10 -0
- data/lib/cacofonix/elements/product.rb +155 -0
- data/lib/cacofonix/elements/product_base.rb +61 -0
- data/lib/cacofonix/elements/product_classification.rb +8 -0
- data/lib/cacofonix/elements/product_form_feature.rb +8 -0
- data/lib/cacofonix/elements/product_identifier.rb +6 -0
- data/lib/cacofonix/elements/professional_affiliation.rb +7 -0
- data/lib/cacofonix/elements/publisher.rb +11 -0
- data/lib/cacofonix/elements/reissue.rb +9 -0
- data/lib/cacofonix/elements/related_product.rb +6 -0
- data/lib/cacofonix/elements/religious_text.rb +8 -0
- data/lib/cacofonix/elements/religious_text_feature.rb +8 -0
- data/lib/cacofonix/elements/sales_outlet.rb +7 -0
- data/lib/cacofonix/elements/sales_outlet_identifier.rb +6 -0
- data/lib/cacofonix/elements/sales_restriction.rb +7 -0
- data/lib/cacofonix/elements/sales_rights.rb +13 -0
- data/lib/cacofonix/elements/sender_identifier.rb +6 -0
- data/lib/cacofonix/elements/series.rb +11 -0
- data/lib/cacofonix/elements/series_identifier.rb +6 -0
- data/lib/cacofonix/elements/set.rb +13 -0
- data/lib/cacofonix/elements/stock.rb +16 -0
- data/lib/cacofonix/elements/stock_quantity_coded.rb +8 -0
- data/lib/cacofonix/elements/subject.rb +13 -0
- data/lib/cacofonix/elements/supplier_identifier.rb +6 -0
- data/lib/cacofonix/elements/supply_detail.rb +37 -0
- data/lib/cacofonix/elements/text_item.rb +11 -0
- data/lib/cacofonix/elements/text_item_identifier.rb +6 -0
- data/lib/cacofonix/elements/title.rb +11 -0
- data/lib/cacofonix/elements/website.rb +8 -0
- data/lib/cacofonix/elements/work_identifier.rb +6 -0
- data/lib/cacofonix/utils/code_list_extractor.rb +112 -0
- data/lib/cacofonix/utils/normaliser.rb +125 -0
- data/lib/cacofonix/version.rb +5 -0
- data/lib/cacofonix/wrappers/apa_product.rb +748 -0
- data/lib/cacofonix/wrappers/simple_product.rb +49 -0
- data/support/entities.txt +1499 -0
- data/support/extract.rb +25 -0
- data/support/switch-onix-2.1-short-to-reference.xsl +24 -0
- data/support/switch-onix-tagnames-1.1.xsl +25 -0
- data/support/switch-onix-tagnames-2.0.xsl +37 -0
- metadata +438 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
module Cacofonix; module CodeLists
|
|
4
|
+
LIST_175 = {
|
|
5
|
+
"A101" => "CD standard audio format",
|
|
6
|
+
"A102" => "SACD super audio format",
|
|
7
|
+
"A103" => "MP3 format",
|
|
8
|
+
"A104" => "WAV format",
|
|
9
|
+
"A105" => "Real Audio format",
|
|
10
|
+
"A106" => "WMA",
|
|
11
|
+
"A107" => "AAC",
|
|
12
|
+
"A108" => "Ogg/Vorbis",
|
|
13
|
+
"A109" => "Audible",
|
|
14
|
+
"A110" => "FLAC",
|
|
15
|
+
"A111" => "AIFF",
|
|
16
|
+
"A112" => "ALAC",
|
|
17
|
+
"A201" => "DAISY 2: full audio with title only (no navigation)",
|
|
18
|
+
"A202" => "DAISY 2: full audio with navigation (no text)",
|
|
19
|
+
"A203" => "DAISY 2: full audio with navigation and partial text",
|
|
20
|
+
"A204" => "DAISY 2: full audio with navigation and full text",
|
|
21
|
+
"A205" => "DAISY 2: full text with navigatino and partial audio",
|
|
22
|
+
"A206" => "DAISY 2: full text with navigation and no audio",
|
|
23
|
+
"A207" => "DAISY 3: full audio with title only (no navigation)",
|
|
24
|
+
"A208" => "DAISY 3: full audio with navigation (no text)",
|
|
25
|
+
"A209" => "DAISY 3: full audio with navigation and partial text",
|
|
26
|
+
"A210" => "DAISY 3: full audio with navigation and full text",
|
|
27
|
+
"A211" => "DAISY 3: full textwith navigation and partial audio",
|
|
28
|
+
"A212" => "DAISY 3: full text with navigation and no audio",
|
|
29
|
+
"B101" => "Mass market (rack) paperback",
|
|
30
|
+
"B102" => "Trade paperback (US)",
|
|
31
|
+
"B103" => "Digest format paperback",
|
|
32
|
+
"B104" => "A-format paperback",
|
|
33
|
+
"B105" => "B-format paperback",
|
|
34
|
+
"B106" => "Trade paperback (UK)",
|
|
35
|
+
"B107" => "Tall rack paperback (US)",
|
|
36
|
+
"B108" => "A5: Tankobon",
|
|
37
|
+
"B109" => "B5: Tankobon",
|
|
38
|
+
"B110" => "B6: Tankobon",
|
|
39
|
+
"B111" => "A6: Bunko",
|
|
40
|
+
"B112" => "B40-dori: Shinsho",
|
|
41
|
+
"B113" => "Pocket (Sweden)",
|
|
42
|
+
"B114" => "Storpocket (Sweden)",
|
|
43
|
+
"B115" => "Kartonnage (Sweden)",
|
|
44
|
+
"B116" => "Flexband (Sweden)",
|
|
45
|
+
"B117" => "Mook",
|
|
46
|
+
"B118" => "Dwarsligger",
|
|
47
|
+
"B119" => "46 size",
|
|
48
|
+
"B120" => "46-Henkei size",
|
|
49
|
+
"B121" => "A4",
|
|
50
|
+
"B122" => "A4-Henkei size",
|
|
51
|
+
"B123" => "A5-Henkei size",
|
|
52
|
+
"B124" => "B5-Henkei size",
|
|
53
|
+
"B125" => "B6-Henkei size",
|
|
54
|
+
"B126" => "AB size",
|
|
55
|
+
"B127" => "B7 size",
|
|
56
|
+
"B128" => "Kiku size",
|
|
57
|
+
"B129" => "Kiku-Henkei size",
|
|
58
|
+
"B201" => "Coloring / join-the-dot book",
|
|
59
|
+
"B202" => "Lift-the-flap book",
|
|
60
|
+
"B204" => "Miniature book",
|
|
61
|
+
"B205" => "Moving picture / flicker book",
|
|
62
|
+
"B206" => "Pop-up book",
|
|
63
|
+
"B207" => "Scented / 'smelly' book",
|
|
64
|
+
"B208" => "Sound story / 'noisy' book",
|
|
65
|
+
"B209" => "Sticker book",
|
|
66
|
+
"B210" => "Touch-and-feel book",
|
|
67
|
+
"B212" => "Die-cut book",
|
|
68
|
+
"B213" => "Book-as-toy",
|
|
69
|
+
"B214" => "Soft-to-touch book",
|
|
70
|
+
"B215" => "Fuzzy-felt book",
|
|
71
|
+
"B221" => "Picture book",
|
|
72
|
+
"B222" => "'Carousel' Book",
|
|
73
|
+
"B301" => "Loose leaf - sheets and binder",
|
|
74
|
+
"B302" => "Loose leaf - binder only",
|
|
75
|
+
"B303" => "Loose leaf - sheets only",
|
|
76
|
+
"B304" => "Sewn",
|
|
77
|
+
"B305" => "Unsewn / adhesive bound",
|
|
78
|
+
"B306" => "Library binding",
|
|
79
|
+
"B307" => "Reinforced binding",
|
|
80
|
+
"B308" => "Half bound",
|
|
81
|
+
"B309" => "Quarter bound",
|
|
82
|
+
"B310" => "Saddle-sewn",
|
|
83
|
+
"B311" => "Comb bound",
|
|
84
|
+
"B312" => "Wire-O",
|
|
85
|
+
"B313" => "Concealed wire",
|
|
86
|
+
"B401" => "Cloth over boards",
|
|
87
|
+
"B402" => "Paper over boards",
|
|
88
|
+
"B403" => "Leather, real",
|
|
89
|
+
"B404" => "Leather, imitation",
|
|
90
|
+
"B405" => "Leather, bonded",
|
|
91
|
+
"B406" => "Vellum",
|
|
92
|
+
"B409" => "Cloth",
|
|
93
|
+
"B410" => "Imitation cloth",
|
|
94
|
+
"B411" => "Velvet",
|
|
95
|
+
"B412" => "Flexible plastic/vinyl cover",
|
|
96
|
+
"B413" => "Plastic-covered",
|
|
97
|
+
"B414" => "Vinyl-covered",
|
|
98
|
+
"B415" => "Laminated cover",
|
|
99
|
+
"B501" => "With dust jacket",
|
|
100
|
+
"B502" => "With printed dust jacket",
|
|
101
|
+
"B503" => "With translucent dust cover",
|
|
102
|
+
"B504" => "With flaps",
|
|
103
|
+
"B505" => "With thumb index",
|
|
104
|
+
"B506" => "With ribbon marker(s)",
|
|
105
|
+
"B507" => "With zip fastener",
|
|
106
|
+
"B508" => "With button snap fastener",
|
|
107
|
+
"B509" => "With leather edge lining",
|
|
108
|
+
"B510" => "Rough front",
|
|
109
|
+
"B601" => "Turn-around book",
|
|
110
|
+
"B602" => "Unflipped manga format",
|
|
111
|
+
"B701" => "UK Uncontracted Braille",
|
|
112
|
+
"B702" => "UK Contracted Braille",
|
|
113
|
+
"B703" => "US Braille",
|
|
114
|
+
"B704" => "US Uncontracted Braille",
|
|
115
|
+
"B705" => "US Contracted Braille",
|
|
116
|
+
"B706" => "Unified English Braille",
|
|
117
|
+
"B707" => "Moon",
|
|
118
|
+
"D101" => "Real Video format",
|
|
119
|
+
"D102" => "Quicktime format",
|
|
120
|
+
"D103" => "AVI format",
|
|
121
|
+
"D104" => "Windows Media Video format",
|
|
122
|
+
"D105" => "MPEG-4",
|
|
123
|
+
"D201" => "MS-DOS",
|
|
124
|
+
"D202" => "Windows",
|
|
125
|
+
"D203" => "Macintosh",
|
|
126
|
+
"D204" => "UNIX / LINUX",
|
|
127
|
+
"D205" => "Other operating system(s)",
|
|
128
|
+
"D206" => "Palm OS",
|
|
129
|
+
"D207" => "Windows Mobile",
|
|
130
|
+
"D301" => "Microsoft XBox",
|
|
131
|
+
"D302" => "Nintendo Gameboy Color",
|
|
132
|
+
"D303" => "Nintendo Gameboy Advanced",
|
|
133
|
+
"D304" => "Nintendo Gameboy",
|
|
134
|
+
"D305" => "Nintendo Gamecube",
|
|
135
|
+
"D306" => "Nintendo 64",
|
|
136
|
+
"D307" => "Sega Dreamcast",
|
|
137
|
+
"D308" => "Sega Genesis/Megadrive",
|
|
138
|
+
"D309" => "Sega Saturn",
|
|
139
|
+
"D310" => "Sony PlayStation 1",
|
|
140
|
+
"D311" => "Sony PlayStation 2",
|
|
141
|
+
"D312" => "Nintendo Dual Screen",
|
|
142
|
+
"D313" => "Sony PlayStation 3",
|
|
143
|
+
"D314" => "Xbox 360",
|
|
144
|
+
"D315" => "Nintendo Wii",
|
|
145
|
+
"D316" => "Sony PlayStation Portable (PSP)",
|
|
146
|
+
"E100" => "Other",
|
|
147
|
+
"E101" => "EPUB",
|
|
148
|
+
"E102" => "OEB",
|
|
149
|
+
"E103" => "DOC",
|
|
150
|
+
"E104" => "DOCX",
|
|
151
|
+
"E105" => "HTML",
|
|
152
|
+
"E106" => "ODF",
|
|
153
|
+
"E107" => "PDF",
|
|
154
|
+
"E108" => "PDF/A",
|
|
155
|
+
"E109" => "RTF",
|
|
156
|
+
"E110" => "SGML",
|
|
157
|
+
"E111" => "TCR",
|
|
158
|
+
"E112" => "TXT",
|
|
159
|
+
"E113" => "XHTML",
|
|
160
|
+
"E114" => "zTXT",
|
|
161
|
+
"E115" => "XPS",
|
|
162
|
+
"E116" => "Amazon Kindle",
|
|
163
|
+
"E117" => "BBeB",
|
|
164
|
+
"E118" => "DXReader",
|
|
165
|
+
"E119" => "EBL",
|
|
166
|
+
"E120" => "Ebrary",
|
|
167
|
+
"E121" => "eReader",
|
|
168
|
+
"E122" => "Exebook",
|
|
169
|
+
"E123" => "Franklin eBookman",
|
|
170
|
+
"E124" => "Gemstar Rocketbook",
|
|
171
|
+
"E125" => "iSilo",
|
|
172
|
+
"E126" => "Microsoft Reader",
|
|
173
|
+
"E127" => "Mobipocket",
|
|
174
|
+
"E128" => "MyiLibrary",
|
|
175
|
+
"E129" => "NetLibrary",
|
|
176
|
+
"E130" => "Plucker",
|
|
177
|
+
"E131" => "VitalBook",
|
|
178
|
+
"E132" => "Vook",
|
|
179
|
+
"E133" => "Google Edition",
|
|
180
|
+
"E134" => "Book 'app' for iOS",
|
|
181
|
+
"E135" => "Book 'app' for Android",
|
|
182
|
+
"E136" => "Book 'app' for other operating system",
|
|
183
|
+
"L101" => "Laminated",
|
|
184
|
+
"P101" => "Desk calendar",
|
|
185
|
+
"P102" => "Mini calendar",
|
|
186
|
+
"P103" => "Engagement calendar",
|
|
187
|
+
"P104" => "Day by day calendar",
|
|
188
|
+
"P105" => "Poster calendar",
|
|
189
|
+
"P106" => "Wall calendar",
|
|
190
|
+
"P107" => "Perpetual calendar",
|
|
191
|
+
"P108" => "Advent calendar",
|
|
192
|
+
"P109" => "Bookmark calendar",
|
|
193
|
+
"P110" => "Student calendar",
|
|
194
|
+
"P111" => "Project calendar",
|
|
195
|
+
"P112" => "Almanac calendar",
|
|
196
|
+
"P113" => "Other calendar",
|
|
197
|
+
"P114" => "Other calendar or organiser product",
|
|
198
|
+
"P201" => "Hardback (stationery)",
|
|
199
|
+
"P202" => "Paperback / softback (stationery)",
|
|
200
|
+
"P203" => "Spiral bound (stationery)",
|
|
201
|
+
"P204" => "Leather / fine binding (stationery)",
|
|
202
|
+
"V201" => "PAL",
|
|
203
|
+
"V202" => "NTSC",
|
|
204
|
+
"V203" => "SECAM"
|
|
205
|
+
}
|
|
206
|
+
end; end
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
module Cacofonix; module CodeLists
|
|
4
|
+
LIST_176 = {
|
|
5
|
+
"01" => "Android",
|
|
6
|
+
"02" => "BlackBerry OS",
|
|
7
|
+
"03" => "iOS",
|
|
8
|
+
"04" => "Linux",
|
|
9
|
+
"05" => "Mac OS",
|
|
10
|
+
"06" => "Mac OS X",
|
|
11
|
+
"07" => "Palm OS",
|
|
12
|
+
"08" => "webOS",
|
|
13
|
+
"09" => "Symbian",
|
|
14
|
+
"10" => "Windows",
|
|
15
|
+
"11" => "Windows CE",
|
|
16
|
+
"12" => "Windows Mobile",
|
|
17
|
+
"13" => "Mac OS",
|
|
18
|
+
"14" => "Windows Phone 7"
|
|
19
|
+
}
|
|
20
|
+
end; end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
module Cacofonix; module CodeLists
|
|
4
|
+
LIST_178 = {
|
|
5
|
+
"A103" => "MP3",
|
|
6
|
+
"A104" => "WAV",
|
|
7
|
+
"A105" => "Real Audio",
|
|
8
|
+
"A106" => "WMA",
|
|
9
|
+
"A107" => "AAC",
|
|
10
|
+
"D101" => "Real Video",
|
|
11
|
+
"D102" => "QuickTime",
|
|
12
|
+
"D103" => "AVI",
|
|
13
|
+
"D104" => "WMV",
|
|
14
|
+
"D105" => "MPEG-4",
|
|
15
|
+
"D106" => "FLV",
|
|
16
|
+
"D107" => "SWF",
|
|
17
|
+
"D401" => "PDF",
|
|
18
|
+
"D501" => "GIF",
|
|
19
|
+
"D502" => "JPEG",
|
|
20
|
+
"D503" => "PNG",
|
|
21
|
+
"D504" => "TIFF",
|
|
22
|
+
"E101" => "EPUB"
|
|
23
|
+
}
|
|
24
|
+
end; end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
module Cacofonix; module CodeLists
|
|
4
|
+
LIST_184 = {
|
|
5
|
+
"00" => "No warning",
|
|
6
|
+
"01" => "Carries 'CE' logo",
|
|
7
|
+
"02" => "Carries minimum age warning",
|
|
8
|
+
"03" => "Carries EU Toy Safety Directive 'Unsuitable for children ages 0-3' warning logo",
|
|
9
|
+
"04" => "Carries EU Toy Safety Directive hazard warning"
|
|
10
|
+
}
|
|
11
|
+
end; end
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
module Cacofonix
|
|
5
|
+
|
|
6
|
+
class Code
|
|
7
|
+
|
|
8
|
+
attr_reader :key, :value, :list, :list_number
|
|
9
|
+
|
|
10
|
+
# Note re: key type. For backwards compatibility, code keys that are
|
|
11
|
+
# all-digits are passed around in this gem as Integers.
|
|
12
|
+
#
|
|
13
|
+
# The actual code list hashes have string-based keys for consistency. If
|
|
14
|
+
# you want the integer-or-string key, use Code#key. If you want the real
|
|
15
|
+
# string key, use Code#to_s.
|
|
16
|
+
#
|
|
17
|
+
# If the key is not found in the list, the behaviour depends on the
|
|
18
|
+
# :enforce option. By default, it returns a code with key and value set to
|
|
19
|
+
# nil. If :enforce is true, an exception is raised. If :enforce is false,
|
|
20
|
+
# the key and value is the data given in the tag.
|
|
21
|
+
#
|
|
22
|
+
def initialize(list_number, data, options = {})
|
|
23
|
+
@list_number = list_number
|
|
24
|
+
unless @list = Cacofonix::Lists.list(@list_number)
|
|
25
|
+
raise Cacofonix::CodeListNotFound.new(@list_number)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
@key = @value = nil
|
|
29
|
+
return if data.nil? || data == ""
|
|
30
|
+
|
|
31
|
+
if data.kind_of?(Integer)
|
|
32
|
+
@key = data
|
|
33
|
+
pad_length = options[:length] || ["#{@list.size}".size, 2].max
|
|
34
|
+
@real_key = pad(data, pad_length)
|
|
35
|
+
elsif data.match(/^\d+$/) && @list.keys.include?(data)
|
|
36
|
+
@key = data.to_i
|
|
37
|
+
@real_key = data
|
|
38
|
+
elsif @list.keys.include?(data)
|
|
39
|
+
@key = @real_key = data
|
|
40
|
+
else
|
|
41
|
+
@list.each_pair { |k, v|
|
|
42
|
+
next unless v == data
|
|
43
|
+
@real_key = k
|
|
44
|
+
@key = @real_key.match(/^\d+$/) ? @real_key.to_i : @real_key
|
|
45
|
+
break
|
|
46
|
+
}
|
|
47
|
+
end
|
|
48
|
+
if @real_key
|
|
49
|
+
@value = @list[@real_key]
|
|
50
|
+
elsif options[:enforce] == true
|
|
51
|
+
raise Cacofonix::CodeNotFoundInList.new(@list_number, data)
|
|
52
|
+
elsif options[:enforce] == false
|
|
53
|
+
@value = @key = @real_key = data
|
|
54
|
+
else
|
|
55
|
+
@value = @key = @real_key = nil
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
# Returns true if the given key has a value in the codelist.
|
|
61
|
+
#
|
|
62
|
+
def valid?
|
|
63
|
+
@value ? true : false
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
# Returns the string representation of the key. eg, "BB".
|
|
68
|
+
#
|
|
69
|
+
def to_s
|
|
70
|
+
@real_key
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
# Returns the string representation of the value. eg, "Hardback".
|
|
75
|
+
#
|
|
76
|
+
def to_str
|
|
77
|
+
@value.to_s
|
|
78
|
+
end
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
private
|
|
82
|
+
|
|
83
|
+
# Converts a Integer key into a String key.
|
|
84
|
+
#
|
|
85
|
+
def pad(key, len)
|
|
86
|
+
key ? key.to_s.rjust(len, '0') : nil
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
class CodeListNotFound < ArgumentError
|
|
93
|
+
def initialize(list_number)
|
|
94
|
+
@list_number = list_number
|
|
95
|
+
end
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class CodeNotFoundInList < RuntimeError
|
|
100
|
+
def initialize(list_number, code)
|
|
101
|
+
@list_number = list_number
|
|
102
|
+
@code = code
|
|
103
|
+
end
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
end
|
|
@@ -0,0 +1,275 @@
|
|
|
1
|
+
require "dry/core/class_attributes"
|
|
2
|
+
|
|
3
|
+
module Cacofonix
|
|
4
|
+
|
|
5
|
+
class Element
|
|
6
|
+
extend Dry::Core::ClassAttributes
|
|
7
|
+
include ROXML
|
|
8
|
+
|
|
9
|
+
defines :xml_array_accessors
|
|
10
|
+
|
|
11
|
+
# An accessor to an array of element instances.
|
|
12
|
+
#
|
|
13
|
+
# Options:
|
|
14
|
+
#
|
|
15
|
+
# :from - defaults to the class name, but you can override this.
|
|
16
|
+
# :singular - accessor is not an array, just a single object.
|
|
17
|
+
#
|
|
18
|
+
def self.onix_composite(name, klass, options = {})
|
|
19
|
+
options[:as] = options.delete(:singular) ? klass : [klass]
|
|
20
|
+
options[:from] ||= klass.to_s.split("::").last
|
|
21
|
+
xml_accessor(name, options)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# An accessor that treats the input/output as a date.
|
|
25
|
+
#
|
|
26
|
+
# Options: none yet.
|
|
27
|
+
#
|
|
28
|
+
def self.onix_date_accessor(name, tag_name, options = {})
|
|
29
|
+
options = options.merge(
|
|
30
|
+
:from => tag_name,
|
|
31
|
+
:to_xml => Cacofonix::Formatters.yyyymmdd
|
|
32
|
+
)
|
|
33
|
+
if options[:as].kind_of?(Array)
|
|
34
|
+
prep = lambda { |vs|
|
|
35
|
+
[vs].flatten.collect { |v| Date.parse(v) rescue nil }
|
|
36
|
+
}
|
|
37
|
+
else
|
|
38
|
+
prep = lambda { |v| Date.parse(v) rescue nil }
|
|
39
|
+
end
|
|
40
|
+
xml_accessor(name, options, &prep)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# An accessor that treats the input as a space-separated list, and
|
|
44
|
+
# creates an array for it.
|
|
45
|
+
#
|
|
46
|
+
def self.onix_space_separated_list(name, tag_name, options = {})
|
|
47
|
+
options = options.merge(
|
|
48
|
+
:from => tag_name,
|
|
49
|
+
:to_xml => Cacofonix::Formatters.space_separated
|
|
50
|
+
)
|
|
51
|
+
prep = lambda { |v| v ? v.split : [] }
|
|
52
|
+
xml_accessor(name, options, &prep)
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
# An accessor that treats an empty string as a true value -- so that
|
|
57
|
+
# something like <NoContributor /> is recognised as
|
|
58
|
+
# "there is no contributor".
|
|
59
|
+
#
|
|
60
|
+
def self.onix_boolean_flag(name, tag_name, options = {})
|
|
61
|
+
options = options.merge(
|
|
62
|
+
:from => tag_name,
|
|
63
|
+
:to_xml => Cacofonix::Formatters.boolean
|
|
64
|
+
)
|
|
65
|
+
prep = lambda { |v| v ? true : false }
|
|
66
|
+
xml_accessor(name, options, &prep)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
# An accessor that maps a "code" string into an Cacofonix::Code object.
|
|
71
|
+
# A Code object can return the simple code (or "key"), or the value that
|
|
72
|
+
# is associated with it in ONIX code lists, and so on.
|
|
73
|
+
#
|
|
74
|
+
# Required:
|
|
75
|
+
#
|
|
76
|
+
# :list - integer referring to an ONIX Code List
|
|
77
|
+
#
|
|
78
|
+
# Special options for Code instantiation are:
|
|
79
|
+
#
|
|
80
|
+
# :length - how many digits to pad (default is taken from total list size)
|
|
81
|
+
#
|
|
82
|
+
# As well as the normal accessor (x/x=), this will create a
|
|
83
|
+
# special accessor for the richer Code object (#x_code/#x_code=).
|
|
84
|
+
# For example:
|
|
85
|
+
#
|
|
86
|
+
# class Foo < Cacofonix::Element
|
|
87
|
+
# onix_code_from_list(:message_type, "MessageType", :list => 1)
|
|
88
|
+
# end
|
|
89
|
+
#
|
|
90
|
+
# foo = Foo.new
|
|
91
|
+
#
|
|
92
|
+
# foo.message_type = 1
|
|
93
|
+
#
|
|
94
|
+
# foo.message_type
|
|
95
|
+
# >> 1
|
|
96
|
+
#
|
|
97
|
+
# foo.message_type_code
|
|
98
|
+
# >> #<Cacofonix::Code:.......>
|
|
99
|
+
#
|
|
100
|
+
# foo.message_type_code.key
|
|
101
|
+
# >> 1
|
|
102
|
+
#
|
|
103
|
+
# foo.message_type_code.to_s
|
|
104
|
+
# >> "01"
|
|
105
|
+
#
|
|
106
|
+
# foo.message_type_code.value
|
|
107
|
+
# >> "Early notification"
|
|
108
|
+
#
|
|
109
|
+
#
|
|
110
|
+
def self.onix_code_from_list(name, tag_name, options = {})
|
|
111
|
+
unless list_number = options.delete(:list)
|
|
112
|
+
raise Cacofonix::CodeListNotSpecified
|
|
113
|
+
end
|
|
114
|
+
code_opts = options.slice(:length, :enforce)
|
|
115
|
+
options.delete(:enforce)
|
|
116
|
+
prep = lambda { |value|
|
|
117
|
+
Cacofonix::Code.new(list_number, value, code_opts)
|
|
118
|
+
}
|
|
119
|
+
options = options.merge(:from => tag_name)
|
|
120
|
+
xml_accessor("#{name}_code", options, &prep)
|
|
121
|
+
|
|
122
|
+
define_method(name) do
|
|
123
|
+
send("#{name}_code").key
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
define_method("#{name}=") do |val|
|
|
127
|
+
val = prep.call(val) unless val.kind_of?(Cacofonix::Code)
|
|
128
|
+
send("#{name}_code=", val)
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
# Like onix_code_from_list, but for an array of codes.
|
|
133
|
+
#
|
|
134
|
+
# Required:
|
|
135
|
+
#
|
|
136
|
+
# :list - integer referring to an ONIX Code List
|
|
137
|
+
#
|
|
138
|
+
# One important caveat: when assigning to this accessor, you must
|
|
139
|
+
# pass in the complete array -- if you assign an array that you later
|
|
140
|
+
# push or shift items into, you might get unexpected results.
|
|
141
|
+
#
|
|
142
|
+
# Similar to onix_code_from_list, this creates a special accessor for the
|
|
143
|
+
# Code objects at (#x_codes/#x_codes=). For example:
|
|
144
|
+
#
|
|
145
|
+
# class Bar < Cacofonix::Element
|
|
146
|
+
# onix_codes_from_list(:identifiers, "Identifier", :list => 5)
|
|
147
|
+
# end
|
|
148
|
+
#
|
|
149
|
+
# bar = Bar.new
|
|
150
|
+
#
|
|
151
|
+
# bar.identifiers = [1, 5, 13]
|
|
152
|
+
#
|
|
153
|
+
# bar.identifiers_codes.collect { |ids| ids.value }
|
|
154
|
+
# >> ["Proprietary", "ISMN-10", "LLCN"]
|
|
155
|
+
#
|
|
156
|
+
# If a block is given, each value is passed into it first - return
|
|
157
|
+
# an array of the actual values.
|
|
158
|
+
#
|
|
159
|
+
def self.onix_codes_from_list(name, tag_name, options = {}, &blk)
|
|
160
|
+
unless list_number = options.delete(:list)
|
|
161
|
+
raise Cacofonix::CodeListNotSpecified
|
|
162
|
+
end
|
|
163
|
+
code_opts = options.slice(:length, :enforce)
|
|
164
|
+
options.delete(:enforce)
|
|
165
|
+
prep = lambda { |values|
|
|
166
|
+
if block_given?
|
|
167
|
+
values = [values].flatten.collect { |v| blk.call(v) }
|
|
168
|
+
end
|
|
169
|
+
[values].flatten.collect do |data|
|
|
170
|
+
Cacofonix::Code.new(list_number, data, code_opts)
|
|
171
|
+
end
|
|
172
|
+
}
|
|
173
|
+
options = options.merge(:from => tag_name, :as => [])
|
|
174
|
+
xml_accessor("#{name}_codes", options, &prep)
|
|
175
|
+
|
|
176
|
+
define_method(name) do
|
|
177
|
+
codes = send("#{name}_codes")
|
|
178
|
+
codes ? codes.collect { |cd| cd.key } : nil
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
# FIXME: Hmm, adding to array? what happens with push, etc?
|
|
182
|
+
define_method("#{name}=") do |vals|
|
|
183
|
+
vals = [vals].flatten.collect { |v|
|
|
184
|
+
v.kind_of?(Cacofonix::Code) ? v : prep.call(v)
|
|
185
|
+
}.flatten
|
|
186
|
+
send("#{name}_codes=", vals)
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
# Sugar for a common case -- country or territory codes.
|
|
192
|
+
#
|
|
193
|
+
def self.onix_spaced_codes_from_list(name, tag_name, options)
|
|
194
|
+
options[:to_xml] ||= Cacofonix::Formatters.space_separated
|
|
195
|
+
onix_codes_from_list(name, tag_name, options) { |v| v ? v.split : [] }
|
|
196
|
+
end
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
# Query a composite array within this element, looking for an attribute
|
|
200
|
+
# ('mthd') that has a value equal to 'query'.
|
|
201
|
+
#
|
|
202
|
+
# The idea is that you can shorten this:
|
|
203
|
+
#
|
|
204
|
+
# product.websites.detect { |ws| ws.website_role == 1 }
|
|
205
|
+
#
|
|
206
|
+
# To this:
|
|
207
|
+
#
|
|
208
|
+
# product.fetch(:websites, :website_role, 1)
|
|
209
|
+
#
|
|
210
|
+
# Note: query may be an array of values, will return the first
|
|
211
|
+
# composite that matches one of them. So this:
|
|
212
|
+
#
|
|
213
|
+
# product.websites.detect { |ws| ws.website_role == 1 } ||
|
|
214
|
+
# product.websites.detect { |ws| ws.website_role == 2 }
|
|
215
|
+
#
|
|
216
|
+
# becomes this:
|
|
217
|
+
#
|
|
218
|
+
# product.fetch(:websites, :website_role, [1, 2])
|
|
219
|
+
#
|
|
220
|
+
def fetch(composite_symbol, mthd, query)
|
|
221
|
+
result = nil
|
|
222
|
+
[query].flatten.each do |matcher|
|
|
223
|
+
break if result = send(composite_symbol).detect do |comp|
|
|
224
|
+
comp.send(mthd) == matcher
|
|
225
|
+
end
|
|
226
|
+
end
|
|
227
|
+
result
|
|
228
|
+
end
|
|
229
|
+
|
|
230
|
+
# Queries a composite array like #fetch, but returns *all* composites
|
|
231
|
+
# that have a match.
|
|
232
|
+
#
|
|
233
|
+
def fetch_all(composite_symbol, mthd, query)
|
|
234
|
+
[query].flatten.inject([]) do |acc, matcher|
|
|
235
|
+
comps = send(composite_symbol).select do |comp|
|
|
236
|
+
comp.send(mthd) == matcher
|
|
237
|
+
end
|
|
238
|
+
acc += comps if comps.any?
|
|
239
|
+
acc
|
|
240
|
+
end
|
|
241
|
+
end
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
def self.alias_accessor(new_accessor, old_accessor)
|
|
245
|
+
alias_method(new_accessor, old_accessor)
|
|
246
|
+
alias_method("#{new_accessor}=", "#{old_accessor}=")
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
|
|
250
|
+
def self.xml_accessor(attr, *args, **options)
|
|
251
|
+
if options[:as] && options[:as].kind_of?(Array)
|
|
252
|
+
xml_array_accessors(Array(xml_array_accessors) + [attr])
|
|
253
|
+
end
|
|
254
|
+
|
|
255
|
+
super
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
def initialize(*)
|
|
260
|
+
if self.class.xml_array_accessors
|
|
261
|
+
self.class.xml_array_accessors.each do |attr|
|
|
262
|
+
send :"#{attr}=", []
|
|
263
|
+
end
|
|
264
|
+
end
|
|
265
|
+
|
|
266
|
+
super
|
|
267
|
+
end
|
|
268
|
+
|
|
269
|
+
end
|
|
270
|
+
|
|
271
|
+
|
|
272
|
+
class CodeListNotSpecified < ArgumentError
|
|
273
|
+
end
|
|
274
|
+
|
|
275
|
+
end
|