Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Create SLProduct class.

  • Loading branch information...
commit f25b03907fe46d0a773913ec871d1786508e3b5b 1 parent a1d1027
tim authored
View
9 data/audience_range.xml
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="utf-8"?>
+<AudienceRange>
+ <AudienceRangeQualifier>11</AudienceRangeQualifier>
+ <AudienceRangePrecision>03</AudienceRangePrecision>
+ <AudienceRangePrecision>04</AudienceRangePrecision>
+ <AudienceRangeValue>3</AudienceRangeValue>
+ <AudienceRangeValue>5</AudienceRangeValue>
+</AudienceRange>
+
View
7 data/language.xml
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Language>
+ <LanguageRole>01</LanguageRole>
+ <LanguageCode>eng</LanguageCode>
+ <CountryCode>US</CountryCode>
+</Language>
+
View
5 data/series.xml
@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Series>
+ <TitleOfSeries>Citizens and Their Governments</TitleOfSeries>
+</Series>
+
View
6 data/series_identifier.xml
@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<SeriesIdentifier>
+ <SeriesIDType>01</SeriesIDType>
+ <IDValue>10001</IDValue>
+</SeriesIdentifier>
+
View
81 data/sl_product.xml
@@ -0,0 +1,81 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!DOCTYPE ONIXMessage SYSTEM "http://www.editeur.org/onix/2.1/03/reference/onix-international.dtd">
+<Product>
+ <RecordReference>10001</RecordReference>
+ <NotificationType>02</NotificationType>
+ <ProductIdentifier>
+ <ProductIDType>01</ProductIDType>
+ <IDValue>10001</IDValue>
+ </ProductIdentifier>
+ <ProductIdentifier>
+ <ProductIDType>02</ProductIDType>
+ <IDValue>1602791082</IDValue>
+ </ProductIdentifier>
+ <ProductIdentifier>
+ <ProductIDType>15</ProductIDType>
+ <IDValue>9781602791084</IDValue>
+ </ProductIdentifier>
+ <Title>
+ <TitleType>01</TitleType>
+ <TitleText>Citizens and Their Governments</TitleText>
+ </Title>
+ <CopyrightYear>2008</CopyrightYear>
+ <AudienceRange>
+ <AudienceRangeQualifier>11</AudienceRangeQualifier>
+ <AudienceRangePrecision>03</AudienceRangePrecision>
+ <AudienceRangePrecision>04</AudienceRangePrecision>
+ <AudienceRangeValue>3</AudienceRangeValue>
+ <AudienceRangeValue>5</AudienceRangeValue>
+ </AudienceRange>
+ <Language>
+ <LanguageRole>01</LanguageRole>
+ <LanguageCode>eng</LanguageCode>
+ </Language>
+ <Website>
+ <WebsiteRole>12</WebsiteRole>
+ <WebsiteLink>http://www.cherrylakepublishing.com/shop/show/10001</WebsiteLink>
+ </Website>
+ <NumberOfPages>32</NumberOfPages>
+ <OtherText>
+ <TextTypeCode>01</TextTypeCode>
+ <Text>This series focuses on teaching civic literacy from a global perspective. Why is voting important? How do elections differ around the world? What is the impact of immigration? How does the government work?</Text>
+ </OtherText>
+ <MediaFile>
+ <MediaFileTypeCode>04</MediaFileTypeCode>
+ <MediaFileLinkTypeCode>01</MediaFileLinkTypeCode>
+ <MediaFileLink>http://www.cherrylakepublishing.com/images/covers/l/9781602791084</MediaFileLink>
+ </MediaFile>
+ <MediaFile>
+ <MediaFileTypeCode>07</MediaFileTypeCode>
+ <MediaFileLinkTypeCode>01</MediaFileLinkTypeCode>
+ <MediaFileLink>http://www.cherrylakepublishing.com/images/covers/m/9781602791084</MediaFileLink>
+ </MediaFile>
+ <Publisher>
+ <PublishingRole>01</PublishingRole>
+ <PublisherName>Cherry Lake</PublisherName>
+ </Publisher>
+ <PublishingStatus>02</PublishingStatus>
+ <PublicationDate>20091201</PublicationDate>
+ <Measure>
+ <MeasureTypeCode>01</MeasureTypeCode>
+ <Measurement>9.5</Measurement>
+ <MeasureUnitCode>in</MeasureUnitCode>
+ </Measure>
+ <Measure>
+ <MeasureTypeCode>02</MeasureTypeCode>
+ <Measurement>7.5</Measurement>
+ <MeasureUnitCode>in</MeasureUnitCode>
+ </Measure>
+ <SupplyDetail>
+ <SupplierName>Cherry Lake Publishing</SupplierName>
+ <TelephoneNumber>1-866-918-3956</TelephoneNumber>
+ <FaxNumber>1-866-489-6490</FaxNumber>
+ <EmailAddress>sales@cherrylakepublishing.com</EmailAddress>
+ <SupplyToCountry>US</SupplyToCountry>
+ <ProductAvailability>10</ProductAvailability>
+ <Price>
+ <PriceTypeCode>01</PriceTypeCode>
+ <PriceAmount>232.65</PriceAmount>
+ </Price>
+ </SupplyDetail>
+</Product>
View
10 lib/onix.rb
@@ -70,6 +70,10 @@ def self.two_digit
# core files
# - ordering is important, classes need to be defined before any
# other class can use them
+require File.join(File.dirname(__FILE__), "onix", "language") # milkfarm
+require File.join(File.dirname(__FILE__), "onix", "series_identifier") # milkfarm
+require File.join(File.dirname(__FILE__), "onix", "series") # milkfarm
+require File.join(File.dirname(__FILE__), "onix", "audience_range") # milkfarm
require File.join(File.dirname(__FILE__), "onix", "sender_identifier")
require File.join(File.dirname(__FILE__), "onix", "addressee_identifier")
require File.join(File.dirname(__FILE__), "onix", "header")
@@ -95,10 +99,16 @@ def self.two_digit
# lists
require File.join(File.dirname(__FILE__), "onix", "lists", "product_form")
require File.join(File.dirname(__FILE__), "onix", "lists", "product_availability")
+require File.join(File.dirname(__FILE__), "onix", "lists", "country_code") # milkfarm
+require File.join(File.dirname(__FILE__), "onix", "lists", "language_code") # milkfarm
+require File.join(File.dirname(__FILE__), "onix", "lists", "language_role") # milkfarm
+require File.join(File.dirname(__FILE__), "onix", "lists", "notification_type") # milkfarm
+require File.join(File.dirname(__FILE__), "onix", "lists", "product_form_detail") # milkfarm
# product wrappers
require File.join(File.dirname(__FILE__), "onix", "simple_product")
require File.join(File.dirname(__FILE__), "onix", "apa_product")
+require File.join(File.dirname(__FILE__), "onix", "sl_product") # milkfarm
# misc
require File.join(File.dirname(__FILE__), "onix", "normaliser")
View
19 lib/onix/audience_range.rb
@@ -0,0 +1,19 @@
+# coding: utf-8
+
+module ONIX
+ class AudienceRange
+ include ROXML
+ include ONIX::Common
+
+ xml_name "AudienceRange"
+
+ xml_accessor :audience_range_qualifier, :from => "AudienceRangeQualifier", :as => Fixnum, :to_xml => ONIX::Formatters.two_digit
+ xml_accessor :audience_range_precisions, :from => "AudienceRangePrecision", :as => [Fixnum], :to_xml => [ONIX::Formatters.two_digit] # TODO: two_digit isn't working on the array items
+ xml_accessor :audience_range_values, :from => "AudienceRangeValue", :as => [Integer]
+
+ def initialize
+ self.audience_range_precisions = []
+ self.audience_range_values = []
+ end
+ end
+end
View
14 lib/onix/language.rb
@@ -0,0 +1,14 @@
+# coding: utf-8
+
+module ONIX
+ class Language
+ include ROXML
+ include ONIX::Common
+
+ xml_name "Language"
+
+ xml_accessor :language_role, :from => "LanguageRole", :as => Fixnum, :to_xml => ONIX::Formatters.two_digit
+ xml_accessor :language_code, :from => "LanguageCode"
+ xml_accessor :country_code, :from => "CountryCode"
+ end
+end
View
257 lib/onix/lists/country_code.rb
@@ -0,0 +1,257 @@
+# coding: utf-8
+# milkfarm
+module ONIX
+ module Lists
+ # Code list 91
+ COUNTRY_CODE = {
+ "AD" => "Andorra",
+ "AE" => "United Arab Emirates",
+ "AF" => "Afghanistan",
+ "AG" => "Antigua and Barbuda",
+ "AI" => "Anguilla",
+ "AL" => "Albania",
+ "AM" => "Armenia",
+ "AN" => "Netherlands Antilles",
+ "AO" => "Angola",
+ "AQ" => "Antarctica",
+ "AR" => "Argentina",
+ "AS" => "American Samoa",
+ "AT" => "Austria",
+ "AU" => "Australia",
+ "AW" => "Aruba",
+ "AX" => "Aland Islands",
+ "AZ" => "Azerbaijan",
+ "BA" => "Bosnia and Herzegovina",
+ "BB" => "Barbados",
+ "BD" => "Bangladesh",
+ "BE" => "Belgium",
+ "BF" => "Burkina Faso",
+ "BG" => "Bulgaria",
+ "BH" => "Bahrain",
+ "BI" => "Burundi",
+ "BJ" => "Benin",
+ "BL" => "Saint Barthelemy",
+ "BM" => "Bermuda",
+ "BN" => "Brunei Darussalam",
+ "BO" => "Bolivia",
+ "BR" => "Brazil",
+ "BS" => "Bahamas",
+ "BT" => "Bhutan",
+ "BV" => "Bouvet Island",
+ "BW" => "Botswana",
+ "BY" => "Belarus",
+ "BZ" => "Belize",
+ "CA" => "Canada",
+ "CC" => "Cocos (Keeling) Islands",
+ "CD" => "Congo, Democratic Republic of the",
+ "CF" => "Central African Republic",
+ "CG" => "Congo",
+ "CH" => "Switzerland",
+ "CI" => "Cote D'Ivoire",
+ "CK" => "Cook Islands",
+ "CL" => "Chile",
+ "CM" => "Cameroon",
+ "CN" => "China",
+ "CO" => "Colombia",
+ "CR" => "Costa Rica",
+ "CS" => "Serbia and Montenegro",
+ "CU" => "Cuba",
+ "CV" => "Cape Verde",
+ "CX" => "Christmas Island",
+ "CY" => "Cyprus",
+ "CZ" => "Czech Republic",
+ "DE" => "Germany",
+ "DJ" => "Djibouti",
+ "DK" => "Denmark",
+ "DM" => "Dominica",
+ "DO" => "Dominican Republic",
+ "DZ" => "Algeria",
+ "EC" => "Ecuador",
+ "EE" => "Estonia",
+ "EG" => "Egypt",
+ "EH" => "Western Sahara",
+ "ER" => "Eritrea",
+ "ES" => "Spain",
+ "ET" => "Ethiopia",
+ "FI" => "Finland",
+ "FJ" => "Fiji",
+ "FK" => "Falkland Islands (Malvinas)",
+ "FM" => "Micronesia, Federated States of",
+ "FO" => "Faroe Islands",
+ "FR" => "France",
+ "GA" => "Gabon",
+ "GB" => "United Kingdom",
+ "GD" => "Grenada",
+ "GE" => "Georgia",
+ "GF" => "French Guiana",
+ "GG" => "Guernsey",
+ "GH" => "Ghana",
+ "GI" => "Gibraltar",
+ "GL" => "Greenland",
+ "GM" => "Gambia",
+ "GN" => "Guinea",
+ "GP" => "Guadeloupe",
+ "GQ" => "Equatorial Guinea",
+ "GR" => "Greece",
+ "GS" => "South Georgia and the South Sandwich Islands",
+ "GT" => "Guatemala",
+ "GU" => "Guam",
+ "GW" => "Guinea-Bissau",
+ "GY" => "Guyana",
+ "HK" => "Hong Kong",
+ "HM" => "Heard Island and McDonald Islands",
+ "HN" => "Honduras",
+ "HR" => "Croatia",
+ "HT" => "Haiti",
+ "HU" => "Hungary",
+ "ID" => "Indonesia",
+ "IE" => "Ireland",
+ "IL" => "Israel",
+ "IM" => "Isle of Man",
+ "IN" => "India",
+ "IO" => "British Indian Ocean Territory",
+ "IQ" => "Iraq",
+ "IR" => "Iran, Islamic Republic of",
+ "IS" => "Iceland",
+ "IT" => "Italy",
+ "JE" => "Jersey",
+ "JM" => "Jamaica",
+ "JO" => "Jordan",
+ "JP" => "Japan",
+ "KE" => "Kenya",
+ "KG" => "Kyrgyzstan",
+ "KH" => "Cambodia",
+ "KI" => "Kiribati",
+ "KM" => "Comoros",
+ "KN" => "Saint Kitts and Nevis",
+ "KP" => "Korea, Democratic People's Republic of",
+ "KR" => "Korea, Republic of",
+ "KW" => "Kuwait",
+ "KY" => "Cayman Islands",
+ "KZ" => "Kazakhstan",
+ "LA" => "Lao People's Democratic Republic",
+ "LB" => "Lebanon",
+ "LC" => "Saint Lucia",
+ "LI" => "Liechtenstein",
+ "LK" => "Sri Lanka",
+ "LR" => "Liberia",
+ "LS" => "Lesotho",
+ "LT" => "Lithuania",
+ "LU" => "Luxembourg",
+ "LV" => "Latvia",
+ "LY" => "Libyan Arab Jamahiriya",
+ "MA" => "Morocco",
+ "MC" => "Monaco",
+ "MD" => "Moldova, Republic of",
+ "ME" => "Montenegro",
+ "MF" => "Saint Martin, French part",
+ "MG" => "Madagascar",
+ "MH" => "Marshall Islands",
+ "MK" => "Macedonia, the former Yugoslav Republic of",
+ "ML" => "Mali",
+ "MM" => "Myanmar",
+ "MN" => "Mongolia",
+ "MO" => "Macao",
+ "MP" => "Northern Mariana Islands",
+ "MQ" => "Martinique",
+ "MR" => "Mauritania",
+ "MS" => "Montserrat",
+ "MT" => "Malta",
+ "MU" => "Mauritius",
+ "MV" => "Maldives",
+ "MW" => "Malawi",
+ "MX" => "Mexico",
+ "MY" => "Malaysia",
+ "MZ" => "Mozambique",
+ "NA" => "Namibia",
+ "NC" => "New Caledonia",
+ "NE" => "Niger",
+ "NF" => "Norfolk Island",
+ "NG" => "Nigeria",
+ "NI" => "Nicaragua",
+ "NL" => "Netherlands",
+ "NO" => "Norway",
+ "NP" => "Nepal",
+ "NR" => "Nauru",
+ "NU" => "Niue",
+ "NZ" => "New Zealand",
+ "OM" => "Oman",
+ "PA" => "Panama",
+ "PE" => "Peru",
+ "PF" => "French Polynesia",
+ "PG" => "Papua New Guinea",
+ "PH" => "Philippines",
+ "PK" => "Pakistan",
+ "PL" => "Poland",
+ "PM" => "Saint Pierre and Miquelon",
+ "PN" => "Pitcairn",
+ "PR" => "Puerto Rico",
+ "PS" => "Palestinian Territory, Occupied",
+ "PT" => "Portugal",
+ "PW" => "Palau",
+ "PY" => "Paraguay",
+ "QA" => "Qatar",
+ "RE" => "Reunion",
+ "RO" => "Romania",
+ "RS" => "Serbia",
+ "RU" => "Russian Federation",
+ "RW" => "Rwanda",
+ "SA" => "Saudi Arabia",
+ "SB" => "Solomon Islands",
+ "SC" => "Seychelles",
+ "SD" => "Sudan",
+ "SE" => "Sweden",
+ "SG" => "Singapore",
+ "SH" => "Saint Helena",
+ "SI" => "Slovenia",
+ "SJ" => "Svalbard and Jan Mayen",
+ "SK" => "Slovakia",
+ "SL" => "Sierra Leone",
+ "SM" => "San Marino",
+ "SN" => "Senegal",
+ "SO" => "Somalia",
+ "SR" => "Suriname",
+ "ST" => "Sao Tome and Principe",
+ "SV" => "El Salvador",
+ "SY" => "Syrian Arab Republic",
+ "SZ" => "Swaziland",
+ "TC" => "Turks and Caicos Islands",
+ "TD" => "Chad",
+ "TF" => "French Southern Territories",
+ "TG" => "Togo",
+ "TH" => "Thailand",
+ "TJ" => "Tajikistan",
+ "TK" => "Tokelau",
+ "TL" => "Timor-Leste",
+ "TM" => "Turkmenistan",
+ "TN" => "Tunisia",
+ "TO" => "Tonga",
+ "TR" => "Turkey",
+ "TT" => "Trinidad and Tobago",
+ "TV" => "Tuvalu",
+ "TW" => "Taiwan, Province of China",
+ "TZ" => "Tanzania, United Republic of",
+ "UA" => "Ukraine",
+ "UG" => "Uganda",
+ "UM" => "United States Minor Outlying Islands",
+ "US" => "United States",
+ "UY" => "Uruguay",
+ "UZ" => "Uzbekistan",
+ "VA" => "Holy See (Vatican City State)",
+ "VC" => "Saint Vincent and the Grenadines",
+ "VE" => "Venezuela, Bolivarian Republic of",
+ "VG" => "Virgin Islands, British",
+ "VI" => "Virgin Islands, US",
+ "VN" => "Viet Nam",
+ "VU" => "Vanuatu",
+ "WF" => "Wallis and Futuna",
+ "WS" => "Samoa",
+ "YE" => "Yemen",
+ "YT" => "Mayotte",
+ "YU" => "Yugoslavia",
+ "ZA" => "South Africa",
+ "ZM" => "Zambia",
+ "ZW" => "Zimbabwe",
+ }
+ end
+end
View
498 lib/onix/lists/language_code.rb
@@ -0,0 +1,498 @@
+# coding: utf-8
+# milkfarm
+module ONIX
+ module Lists
+ # Code list 74
+ LANGUAGE_CODE = {
+ "aar" => "Afar",
+ "abk" => "Abkhaz",
+ "ace" => "Achinese",
+ "ach" => "Acoli",
+ "ada" => "Adangme",
+ "ady" => "Adygei",
+ "afa" => "Afroasiatic languages",
+ "afh" => "Afrihili (Artificial language)",
+ "afr" => "Afrikaans",
+ "ain" => "Ainu",
+ "aka" => "Akan",
+ "akk" => "Akkadian",
+ "alb" => "Albanian",
+ "ale" => "Aleut",
+ "alg" => "Algonquian languages",
+ "alt" => "Southern Altai",
+ "amh" => "Amharic",
+ "ang" => "English, Old (ca. 450-1100)",
+ "anp" => "Angika",
+ "apa" => "Apache languages",
+ "ara" => "Arabic",
+ "arc" => "Official Aramaic; Imperial Aramaic (700-300 BCE)",
+ "arg" => "Aragonese Spanish",
+ "arm" => "Armenian",
+ "arn" => "Mapudungun; Mapuche",
+ "arp" => "Arapaho",
+ "art" => "Artificial languages",
+ "arw" => "Arawak",
+ "asm" => "Assamese",
+ "ast" => "Asturian; Bable; Leonese; Asturleonese",
+ "ath" => "Athapascan languages",
+ "aus" => "Australian languages",
+ "ava" => "Avaric",
+ "ave" => "Avestan",
+ "awa" => "Awadhi",
+ "aym" => "Aymara",
+ "aze" => "Azerbaijani",
+ "bad" => "Banda languages",
+ "bai" => "Bamileke languages",
+ "bak" => "Bashkir",
+ "bal" => "Baluchi",
+ "bam" => "Bambara",
+ "ban" => "Balinese",
+ "baq" => "Basque",
+ "bas" => "Basa",
+ "bat" => "Baltic languages",
+ "bej" => "Beja; Bedawiyet",
+ "bel" => "Belarusian",
+ "bem" => "Bemba",
+ "ben" => "Bengali",
+ "ber" => "Berber languages",
+ "bho" => "Bhojpuri",
+ "bih" => "Bihari",
+ "bik" => "Bikol",
+ "bin" => "Bini; Edo",
+ "bis" => "Bislama",
+ "bla" => "Siksika",
+ "bnt" => "Bantu languages",
+ "bos" => "Bosnian",
+ "bra" => "Braj",
+ "bre" => "Breton",
+ "btk" => "Batak languages",
+ "bua" => "Buriat",
+ "bug" => "Bugis",
+ "bul" => "Bulgarian",
+ "bur" => "Burmese",
+ "byn" => "Blin; Bilin",
+ "cad" => "Caddo",
+ "cai" => "Central American Indian languages",
+ "car" => "Galibi Carib",
+ "cat" => "Catalan",
+ "cau" => "Caucasian languages",
+ "ceb" => "Cebuano",
+ "cel" => "Celtic languages",
+ "cha" => "Chamorro",
+ "chb" => "Chibcha",
+ "che" => "Chechen",
+ "chg" => "Chagatai",
+ "chi" => "Chinese",
+ "chk" => "Truk",
+ "chm" => "Mari",
+ "chn" => "Chinook jargon",
+ "cho" => "Choctaw",
+ "chp" => "Chipewyan; Dene Suline",
+ "chr" => "Cherokee",
+ "chu" => "Church Slavic; Old Slavonic; Church Slavonic; Old Bulgarian; Old Church Slavonic",
+ "chv" => "Chuvash",
+ "chy" => "Cheyenne",
+ "cmc" => "Chamic languages",
+ "cop" => "Coptic",
+ "cor" => "Cornish",
+ "cos" => "Corsican",
+ "cpe" => "Creoles and pidgins, English-based",
+ "cpf" => "Creoles and pidgins, French-based",
+ "cpp" => "Creoles and pidgins, Portuguese-based",
+ "cre" => "Cree",
+ "crh" => "Crimean Turkish; Crimean Tatar",
+ "crp" => "Creoles and pidgins",
+ "csb" => "Kashubian",
+ "cus" => "Cushitic languages",
+ "cze" => "Czech",
+ "dak" => "Dakota",
+ "dan" => "Danish",
+ "dar" => "Dargwa",
+ "day" => "Land Dayak languages",
+ "del" => "Delaware",
+ "den" => "Slave",
+ "dgr" => "Dogrib",
+ "din" => "Dinka",
+ "div" => "Divehi; Dhivehi; Maldivian",
+ "doi" => "Dogri",
+ "dra" => "Dravidian languages",
+ "dsb" => "Lower Sorbian",
+ "dua" => "Duala",
+ "dum" => "Dutch, Middle (ca. 1050-1350)",
+ "dut" => "Dutch; Flemish",
+ "dyu" => "Dyula",
+ "dzo" => "Dzongkha",
+ "efi" => "Efik",
+ "egy" => "Egyptian",
+ "eka" => "Ekajuk",
+ "elx" => "Elamite",
+ "eng" => "English",
+ "enm" => "English, Middle (1100-1500)",
+ "epo" => "Esperanto",
+ "est" => "Estonian",
+ "ewe" => "Ewe",
+ "ewo" => "Ewondo",
+ "fan" => "Fang",
+ "fao" => "Faroese",
+ "fat" => "Fanti",
+ "fij" => "Fijian",
+ "fil" => "Filipino; Pilipino",
+ "fin" => "Finnish",
+ "fiu" => "Finno-Ugrian languages",
+ "fon" => "Fon",
+ "fre" => "French",
+ "frm" => "French, Middle (ca. 1400-1600)",
+ "fro" => "French, Old (ca. 842-1400)",
+ "frr" => "Northern Frisian",
+ "frs" => "Eastern Frisian",
+ "fry" => "Western Frisian",
+ "ful" => "Fula",
+ "fur" => "Friulian",
+ "gaa" => "",
+ "gay" => "Gayo",
+ "gba" => "Gbaya",
+ "gem" => "Germanic languages",
+ "geo" => "Georgian",
+ "ger" => "German",
+ "gez" => "Ethiopic",
+ "gil" => "Gilbertese",
+ "gla" => "Scottish Gaelic",
+ "gle" => "Irish",
+ "glg" => "Galician",
+ "glv" => "Manx",
+ "gmh" => "German, Middle High (ca. 1050-1500)",
+ "goh" => "German, Old High (ca. 750-1050)",
+ "gon" => "Gondi",
+ "gor" => "Gorontalo",
+ "got" => "Gothic",
+ "grb" => "Grebo",
+ "grc" => "Greek, Ancient (to 1453)",
+ "gre" => "Greek, Modern (1453-)",
+ "grn" => "Guarani",
+ "gsw" => "Swiss German; Alemannic",
+ "guj" => "Gujarati",
+ "gwi" => "Gwich'in",
+ "hai" => "Haida",
+ "hat" => "Haitian French Creole",
+ "hau" => "Hausa",
+ "haw" => "Hawaiian",
+ "heb" => "Hebrew",
+ "her" => "Herero",
+ "hil" => "Hiligaynon",
+ "him" => "Himachali",
+ "hin" => "Hindi",
+ "hit" => "Hittite",
+ "hmn" => "Hmong",
+ "hmo" => "Hiri Motu",
+ "hrv" => "Croatian",
+ "hsb" => "Upper Sorbian",
+ "hun" => "Hungarian",
+ "hup" => "Hupa",
+ "iba" => "Iban",
+ "ibo" => "Igbo",
+ "ice" => "Icelandic",
+ "ido" => "Ido",
+ "iii" => "Sichuan Yi; Nuosu",
+ "ijo" => "Ijo languages",
+ "iku" => "Inuktitut",
+ "ile" => "Interlingue; Occidental",
+ "ilo" => "Iloko",
+ "ina" => "Interlingua (International Auxiliary Language Association)",
+ "inc" => "Indic languages",
+ "ind" => "Indonesian",
+ "ine" => "Indo-European languages",
+ "inh" => "Ingush",
+ "ipk" => "Inupiaq",
+ "ira" => "Iranian languages",
+ "iro" => "Iroquoian languages",
+ "ita" => "Italian",
+ "jav" => "Javanese",
+ "jbo" => "Lojban",
+ "jpn" => "Japanese",
+ "jpr" => "Judeo-Persian",
+ "jrb" => "Judeo-Arabic",
+ "kaa" => "Kara-Kalpak",
+ "kab" => "Kabyle",
+ "kac" => "Kachin; Jingpho",
+ "kal" => "Kalâtdlisut",
+ "kam" => "Kamba",
+ "kan" => "Kannada",
+ "kar" => "Karen languages",
+ "kas" => "Kashmiri",
+ "kau" => "Kanuri",
+ "kaw" => "Kawi",
+ "kaz" => "Kazakh",
+ "kbd" => "Kabardian",
+ "kha" => "Khasi",
+ "khi" => "Khoisan languages",
+ "khm" => "Central Khmer",
+ "kho" => "Khotanese; Sakan",
+ "kik" => "Kikuyu; Gikuyu",
+ "kin" => "Kinyarwanda",
+ "kir" => "Kirghiz; Kyrgyz",
+ "kmb" => "Kimbundu",
+ "kok" => "Konkani",
+ "kom" => "Komi",
+ "kon" => "Kongo",
+ "kor" => "Korean",
+ "kos" => "Kusaie",
+ "kpe" => "Kpelle",
+ "krc" => "Karachay-Balkar",
+ "krl" => "Karelian",
+ "kro" => "Kru languages",
+ "kru" => "Kurukh",
+ "kua" => "Kuanyama",
+ "kum" => "Kumyk",
+ "kur" => "Kurdish",
+ "kut" => "Kutenai",
+ "lad" => "Ladino",
+ "lah" => "Lahnda",
+ "lam" => "Lamba",
+ "lao" => "Lao",
+ "lat" => "Latin",
+ "lav" => "Latvian",
+ "lez" => "Lezgian",
+ "lim" => "Limburgish",
+ "lin" => "Lingala",
+ "lit" => "Lithuanian",
+ "lol" => "Mongo-Nkundu",
+ "loz" => "Lozi",
+ "ltz" => "Luxembourgish; Letzeburgesch",
+ "lua" => "Luba-Lulua",
+ "lub" => "Luba-Katanga",
+ "lug" => "Ganda",
+ "lui" => "Luiseño",
+ "lun" => "Lunda",
+ "luo" => "Luo (Kenya and Tanzania)",
+ "lus" => "Lushai",
+ "mac" => "Macedonian",
+ "mad" => "Madurese",
+ "mag" => "Magahi",
+ "mah" => "Marshall",
+ "mai" => "Maithili",
+ "mak" => "Makasar",
+ "mal" => "Malayalam",
+ "man" => "Mandingo",
+ "mao" => "Maori",
+ "map" => "Austronesian languages",
+ "mar" => "Marathi",
+ "mas" => "Masai",
+ "may" => "Malay",
+ "mdf" => "Moksha",
+ "mdr" => "Mandar",
+ "men" => "Mende",
+ "mga" => "Irish, Middle (ca. 1100-1550)",
+ "mic" => "Mi'kmaq; Micmac",
+ "min" => "Minangkabau",
+ "mis" => "Uncoded languages",
+ "mkh" => "Mon-Khmer languages",
+ "mlg" => "Malagasy",
+ "mlt" => "Maltese",
+ "mnc" => "Manchu",
+ "mni" => "Manipuri",
+ "mno" => "Manobo languages",
+ "moh" => "Mohawk",
+ "mol" => "Moldavian; Moldovan",
+ "mon" => "Mongolian",
+ "mos" => "Mooré",
+ "mul" => "Multiple languages",
+ "mun" => "Munda languages",
+ "mus" => "Creek",
+ "mwl" => "Mirandese",
+ "mwr" => "Marwari",
+ "myn" => "Mayan languages",
+ "myv" => "Erzya",
+ "nah" => "Nahuatl languages",
+ "nai" => "North American Indian languages",
+ "nap" => "Neapolitan",
+ "nau" => "Nauru",
+ "nav" => "Navajo",
+ "nbl" => "Ndebele, South",
+ "nde" => "Ndebele, North",
+ "ndo" => "Ndonga",
+ "nds" => "Low German; Low Saxon",
+ "nep" => "Nepali",
+ "new" => "Newari",
+ "nia" => "Nias",
+ "nic" => "Niger-Kordofanian languages",
+ "niu" => "Niuean",
+ "nno" => "Norwegian Nynorsk",
+ "nob" => "Norwegian Bokmål",
+ "nog" => "Nogai",
+ "non" => "Old Norse",
+ "nor" => "Norwegian",
+ "nqo" => "N'Ko",
+ "nso" => "Pedi; Sepedi; Northern Sotho",
+ "nub" => "Nubian languages",
+ "nwc" => "Classical Newari; Old Newari; Classical Nepal Bhasa",
+ "nya" => "Chichewa; Chewa; Nyanja",
+ "nym" => "Nyamwezi",
+ "nyn" => "Nyankole",
+ "nyo" => "Nyoro",
+ "nzi" => "Nzima",
+ "oci" => "Occitan (post 1500)",
+ "oji" => "Ojibwa",
+ "ori" => "Oriya",
+ "orm" => "Oromo",
+ "osa" => "Osage",
+ "oss" => "Ossetian; Ossetic",
+ "ota" => "Turkish, Ottoman",
+ "oto" => "Otomian languages",
+ "paa" => "Papuan languages",
+ "pag" => "Pangasinan",
+ "pal" => "Pahlavi",
+ "pam" => "Pampanga; Kapampangan",
+ "pan" => "Panjabi",
+ "pap" => "Papiamento",
+ "pau" => "Palauan",
+ "peo" => "Old Persian (ca. 600-400 B.C.)",
+ "per" => "Persian",
+ "phi" => "Philippine languages",
+ "phn" => "Phoenician",
+ "pli" => "Pali",
+ "pol" => "Polish",
+ "pon" => "Ponape",
+ "por" => "Portuguese",
+ "pra" => "Prakrit languages",
+ "pro" => "Provençal (to 1500);Occitan, Old (to 1500)",
+ "pus" => "Pushto; Pashto",
+ "qar" => "Aranés",
+ "qav" => "Valencian",
+ "que" => "Quechua",
+ "raj" => "Rajasthani",
+ "rap" => "Rapanui",
+ "rar" => "Rarotongan; Cook Islands Maori",
+ "roa" => "Romance languages",
+ "roh" => "Romansh",
+ "rom" => "Romany",
+ "rum" => "Romanian",
+ "run" => "Rundi",
+ "rup" => "Aromanian; Arumanian; Macedo-Romanian",
+ "rus" => "Russian",
+ "sad" => "Sandawe",
+ "sag" => "Sango",
+ "sah" => "Yakut",
+ "sai" => "South American Indian languages",
+ "sal" => "Salishan languages",
+ "sam" => "Samaritan Aramaic",
+ "san" => "Sanskrit",
+ "sas" => "Sasak",
+ "sat" => "Santali",
+ "scc" => "Serbian",
+ "scn" => "Sicilian",
+ "sco" => "Scots",
+ "scr" => "Croatian",
+ "sel" => "Selkup",
+ "sem" => "Semitic languages",
+ "sga" => "Irish, Old (to 1100)",
+ "sgn" => "Sign languages",
+ "shn" => "Shan",
+ "sid" => "Sidamo",
+ "sin" => "Sinhala; Sinhalese",
+ "sio" => "Siouan languages",
+ "sit" => "Sino-Tibetan languages",
+ "sla" => "Slavic languages",
+ "slo" => "Slovak",
+ "slv" => "Slovenian",
+ "sma" => "Southern Sami",
+ "sme" => "Northern Sami",
+ "smi" => "Sami languages",
+ "smj" => "Lule Sami",
+ "smn" => "Inari Sami",
+ "smo" => "Samoan",
+ "sms" => "Skolt Sami",
+ "sna" => "Shona",
+ "snd" => "Sindhi",
+ "snk" => "Soninke",
+ "sog" => "Sogdian",
+ "som" => "Somali",
+ "son" => "Songhai languages",
+ "sot" => "Sotho",
+ "spa" => "Spanish",
+ "srd" => "Sardinian",
+ "srn" => "Sranan Tongo",
+ "srp" => "Serbian",
+ "srr" => "Serer",
+ "ssa" => "Nilo-Saharan languages",
+ "ssw" => "Swazi",
+ "suk" => "Sukuma",
+ "sun" => "Sundanese",
+ "sus" => "Susu",
+ "sux" => "Sumerian",
+ "swa" => "Swahili",
+ "swe" => "Swedish",
+ "syc" => "Classical Syriac",
+ "syr" => "Syriac",
+ "tah" => "Tahitian",
+ "tai" => "Tai languages",
+ "tam" => "Tamil",
+ "tat" => "Tatar",
+ "tel" => "Telugu",
+ "tem" => "Temne",
+ "ter" => "Terena",
+ "tet" => "Tetum",
+ "tgk" => "Tajik",
+ "tgl" => "Tagalog",
+ "tha" => "Thai",
+ "tib" => "Tibetan",
+ "tig" => "Tigré",
+ "tir" => "Tigrinya",
+ "tiv" => "Tiv",
+ "tkl" => "Tokelauan",
+ "tlh" => "Klingon; tlhIngan-Hol",
+ "tli" => "Tlingit",
+ "tmh" => "Tamashek",
+ "tog" => "Tonga (Nyasa)",
+ "ton" => "Tongan",
+ "tpi" => "Tok Pisin",
+ "tsi" => "Tsimshian",
+ "tsn" => "Tswana",
+ "tso" => "Tsonga",
+ "tuk" => "Turkmen",
+ "tum" => "Tumbuka",
+ "tup" => "Tupi languages",
+ "tur" => "Turkish",
+ "tut" => "Altaic languages",
+ "tvl" => "Tuvaluan",
+ "twi" => "Twi",
+ "tyv" => "Tuvinian",
+ "udm" => "Udmurt",
+ "uga" => "Ugaritic",
+ "uig" => "Uighur; Uyghur",
+ "ukr" => "Ukrainian",
+ "umb" => "Umbundu",
+ "und" => "Undetermined",
+ "urd" => "Urdu",
+ "uzb" => "Uzbek",
+ "vai" => "Vai",
+ "ven" => "Venda",
+ "vie" => "Vietnamese",
+ "vol" => "Volapük",
+ "vot" => "Votic",
+ "wak" => "Wakashan languages",
+ "wal" => "Wolaitta; Wolaytta",
+ "war" => "Waray",
+ "was" => "Washo",
+ "wel" => "Welsh",
+ "wen" => "Sorbian languages",
+ "wln" => "Walloon",
+ "wol" => "Wolof",
+ "xal" => "Kalmyk",
+ "xho" => "Xhosa",
+ "yao" => "Yao",
+ "yap" => "Yapese",
+ "yid" => "Yiddish",
+ "yor" => "Yoruba",
+ "ypk" => "Yupik languages",
+ "zap" => "Zapotec",
+ "zbl" => "Blissymbols; Blissymbolics; Bliss",
+ "zen" => "Zenaga",
+ "zha" => "Zhuang; Chuang",
+ "znd" => "Zande languages",
+ "zul" => "Zulu",
+ "zun" => "Zuni",
+ "zxx" => "No linguistic content",
+ "zza" => "Zaza; Dimili; Dimli; Kirdki; Kirmanjki; Zazaki",
+ }
+ end
+end
View
18 lib/onix/lists/language_role.rb
@@ -0,0 +1,18 @@
+# coding: utf-8
+# milkfarm
+module ONIX
+ module Lists
+ # Code list 22
+ LANGUAGE_ROLE = {
+ "01" => "Language of text",
+ "02" => "Original language of a translated text",
+ "03" => "Language of abstracts",
+ "04" => "Rights language",
+ "05" => "Rights-excluded language",
+ "06" => "Original language in a multilingual edition",
+ "07" => "Translated language in a multilingual edition",
+ "08" => "Language of audio track",
+ "09" => "Language of subtitles",
+ }
+ end
+end
View
19 lib/onix/lists/notification_type.rb
@@ -0,0 +1,19 @@
+# coding: utf-8
+# milkfarm
+module ONIX
+ module Lists
+ # Code list 1
+ NOTIFICATION_TYPE = {
+ 1 => "Early notification",
+ 2 => "Advance notification (confirmed)",
+ 3 => "Notification confirmed from book-in-hand",
+ 4 => "Update (partial)",
+ 5 => "Delete",
+ 8 => "Notice of sale",
+ 9 => "Notice of acquisition",
+ 12 => "Update - SupplyDetail only",
+ 13 => "Update - MarketRepresentation only",
+ 14 => "Update - SupplyDetail and MarketRepresentation",
+ }
+ end
+end
View
157 lib/onix/lists/product_form_detail.rb
@@ -0,0 +1,157 @@
+# coding: utf-8
+# milkfarm
+module ONIX
+ module Lists
+ # Code list 78
+ PRODUCT_FORM_DETAIL = {
+ "A101" => "CD standard audio format",
+ "A102" => "SACD super audio format",
+ "A103" => "MP3 format",
+ "A104" => "WAV format",
+ "A105" => "Real Audio format",
+ "A106" => "WMA",
+ "A107" => "AAC",
+ "A108" => "Ogg/Vorbis",
+ "A109" => "Audible",
+ "A110" => "FLAC",
+ "A111" => "AIFF",
+ "A112" => "ALAC",
+ "A201" => "DAISY 2: full audio with title only (no navigation)",
+ "A202" => "DAISY 2: full audio with navigation",
+ "A203" => "DAISY 2: full audio with navigation and partial text",
+ "A204" => "DAISY 2: full audio and full text",
+ "A205" => "DAISY 2: full text and some audio",
+ "A206" => "DAISY 2: full text and no audio",
+ "A207" => "DAISY 3: full audio with title only (no navigation)",
+ "A208" => "DAISY 3: full audio with navigation",
+ "A209" => "DAISY 3: full audio with navigation and partial text",
+ "A210" => "DAISY 3: full audio and full text",
+ "A211" => "DAISY 3: full text and some audio",
+ "A212" => "DAISY 3: full text and no audio",
+ "B101" => "Mass market (rack) paperback",
+ "B102" => "Trade paperback (US)",
+ "B103" => "Digest format paperback",
+ "B104" => "A-format paperback",
+ "B105" => "B-format paperback",
+ "B106" => "Trade paperback (UK)",
+ "B107" => "Tall rack paperback (US)",
+ "B108" => "A5: Tankobon",
+ "B109" => "B5: Tankobon",
+ "B110" => "B6: Tankobon",
+ "B111" => "A6: Bunko",
+ "B112" => "B40-dori: Shinsho",
+ "B113" => "Pocket (Sweden)",
+ "B114" => "Storpocket (Sweden)",
+ "B115" => "Kartonnage (Sweden)",
+ "B116" => "Flexband (Sweden)",
+ "B201" => "Coloring / join-the-dot book",
+ "B202" => "Lift-the-flap book",
+ "B203" => "Fuzzy book",
+ "B204" => "Miniature book",
+ "B205" => "Moving picture / flicker book",
+ "B206" => "Pop-up book",
+ "B207" => "Scented / 'smelly' book",
+ "B208" => "Sound story / 'noisy' book",
+ "B209" => "Sticker book",
+ "B210" => "Touch-and-feel book",
+ "B211" => "Toy / die-cut book",
+ "B212" => "Die-cut book",
+ "B213" => "Book-as-toy",
+ "B214" => "Soft-to-touch book",
+ "B215" => "Fuzzy-felt book",
+ "B221" => "Picture book",
+ "B301" => "Loose leaf - sheets &amp; binder",
+ "B302" => "Loose leaf - binder only",
+ "B303" => "Loose leaf - sheets only",
+ "B304" => "Sewn",
+ "B305" => "Unsewn / adhesive bound",
+ "B306" => "Library binding",
+ "B307" => "Reinforced binding",
+ "B308" => "Half bound",
+ "B309" => "Quarter bound",
+ "B310" => "Saddle-sewn",
+ "B311" => "Comb bound",
+ "B312" => "Wire-O",
+ "B313" => "Concealed wire",
+ "B401" => "Cloth over boards",
+ "B402" => "Paper over boards",
+ "B403" => "Leather, real",
+ "B404" => "Leather, imitation",
+ "B405" => "Leather, bonded",
+ "B406" => "Vellum",
+ "B407" => "Plastic",
+ "B408" => "Vinyl",
+ "B409" => "Cloth",
+ "B410" => "Imitation cloth",
+ "B411" => "Velvet",
+ "B412" => "Flexible plastic/vinyl cover",
+ "B413" => "Plastic-covered",
+ "B414" => "Vinyl-covered",
+ "B415" => "Laminated cover",
+ "B501" => "With dust jacket",
+ "B502" => "With printed dust jacket",
+ "B503" => "With translucent dust cover",
+ "B504" => "With flaps",
+ "B505" => "With thumb index",
+ "B506" => "With ribbon marker(s)",
+ "B507" => "With zip fastener",
+ "B508" => "With button snap fastener",
+ "B509" => "With leather edge lining",
+ "B601" => "Turn-around book",
+ "B602" => "Unflipped manga format",
+ "B701" => "UK Braille Grade 1",
+ "B702" => "UK Braille Grade 2",
+ "B703" => "US Braille",
+ "D101" => "Real Video format",
+ "D102" => "Quicktime format",
+ "D103" => "AVI format",
+ "D104" => "Windows Media Video format",
+ "D105" => "MPEG-4",
+ "D201" => "MS-DOS",
+ "D202" => "Windows",
+ "D203" => "Macintosh",
+ "D204" => "UNIX / LINUX",
+ "D205" => "Other operating system(s)",
+ "D206" => "Palm OS",
+ "D207" => "Windows Mobile",
+ "D301" => "Microsoft XBox",
+ "D302" => "Nintendo Gameboy Color",
+ "D303" => "Nintendo Gameboy Advanced",
+ "D304" => "Nintendo Gameboy",
+ "D305" => "Nintendo Gamecube",
+ "D306" => "Nintendo 64",
+ "D307" => "Sega Dreamcast",
+ "D308" => "Sega Genesis/Megadrive",
+ "D309" => "Sega Saturn",
+ "D310" => "Sony PlayStation 1",
+ "D311" => "Sony PlayStation 2",
+ "D312" => "Nintendo Dual Screen",
+ "D313" => "Sony PlayStation 3",
+ "D314" => "Xbox 360",
+ "D315" => "Nintendo Wii",
+ "D316" => "Sony PlayStation Portable (PSP)",
+ "L101" => "Laminated",
+ "P101" => "Desk calendar",
+ "P102" => "Mini calendar",
+ "P103" => "Engagement calendar",
+ "P104" => "Day by day calendar",
+ "P105" => "Poster calendar",
+ "P106" => "Wall calendar",
+ "P107" => "Perpetual calendar",
+ "P108" => "Advent calendar",
+ "P109" => "Bookmark calendar",
+ "P110" => "Student calendar",
+ "P111" => "Project calendar",
+ "P112" => "Almanac calendar",
+ "P113" => "Other calendar",
+ "P114" => "Other calendar or organiser product",
+ "P201" => "Hardback (stationery)",
+ "P202" => "Paperback / softback (stationery)",
+ "P203" => "Spiral bound (stationery)",
+ "P204" => "Leather / fine binding (stationery)",
+ "V201" => "PAL",
+ "V202" => "NTSC",
+ "V203" => "SECAM",
+ }
+ end
+end
View
13 lib/onix/product.rb
@@ -10,10 +10,15 @@ class Product
xml_accessor :record_reference, :from => "RecordReference"
xml_accessor :notification_type, :from => "NotificationType", :as => Fixnum, :to_xml => ONIX::Formatters.two_digit
xml_accessor :product_identifiers, :from => "ProductIdentifier", :as => [ONIX::ProductIdentifier]
+ xml_accessor :titles, :from => "Title", :as => [ONIX::Title]
+ xml_accessor :series_identifiers, :from => "SeriesIdentifier", :as => [ONIX::SeriesIdentifier] # milkfarm
+ xml_accessor :series, :from => "Series", :as => [ONIX::Series] # milkfarm
xml_accessor :product_form, :from => "ProductForm"
- xml_accessor :series, :from => "Series"
+ xml_accessor :product_form_detail, :from => "ProductFormDetail" # milkfarm
+ xml_accessor :copyright_year, :from => "CopyrightYear", :as => Integer # milkfarm
xml_accessor :edition_number, :from => "EditionNumber", :as => Fixnum
- xml_accessor :titles, :from => "Title", :as => [ONIX::Title]
+ xml_accessor :audience_ranges, :from => "AudienceRange", :as => [ONIX::AudienceRange] # milkfarm
+ xml_accessor :languages, :from => "Language", :as => [ONIX::Language] # milkfarm
xml_accessor :websites, :from => "Website", :as => [ONIX::Website]
xml_accessor :contributors, :from => "Contributor", :as => [ONIX::Contributor]
xml_accessor :number_of_pages, :from => "NumberOfPages", :as => Fixnum
@@ -47,7 +52,11 @@ class Product
xml_reader :dimensions, :from => "Dimensions"
def initialize
+ self.series = [] # milkfarm
+ self.audience_ranges = [] # milkfarm
+ self.languages = [] # milkfarm
self.product_identifiers = []
+ self.series_identifiers = [] # milkfarm
self.titles = []
self.contributors = []
self.websites = []
View
12 lib/onix/series.rb
@@ -0,0 +1,12 @@
+# coding: utf-8
+# milkfarm
+module ONIX
+ class Series
+ include ROXML
+ include ONIX::Common
+
+ xml_name "Series"
+
+ xml_accessor :title_of_series, :from => "TitleOfSeries"
+ end
+end
View
13 lib/onix/series_identifier.rb
@@ -0,0 +1,13 @@
+# coding: utf-8
+# milkfarm
+module ONIX
+ class SeriesIdentifier
+ include ROXML
+ include ONIX::Common
+
+ xml_name "SeriesIdentifier"
+
+ xml_accessor :series_id_type, :from => "SeriesIDType", :as => Fixnum, :to_xml => ONIX::Formatters.two_digit
+ xml_accessor :id_value, :from => "IDValue"
+ end
+end
View
157 lib/onix/sl_product.rb
@@ -0,0 +1,157 @@
+# coding: utf-8
+# milkfarm
+module ONIX
+ class SLProduct < APAProduct
+
+ delegate :copyright_year, :copyright_year=
+ delegate :product_form_detail, :product_form_detail=
+
+ # retrieve the proprietary series ID
+ def proprietary_series_id
+ series_identifier(1).andand.id_value
+ end
+
+ # set a new proprietary series ID
+ def proprietary_series_id=(id)
+ series_identifier_set(1, id)
+ end
+
+ # retrieve the issn
+ def issn
+ series_identifier(2).andand.id_value
+ end
+
+ # set a new issn
+ def issn=(id)
+ series_identifier_set(2, id)
+ end
+
+ # retrieve the value of a particular ID
+ def series_identifier(type)
+ product.series_identifiers.find { |id| id.series_id_type == type }
+ end
+
+ # set the value of a particular ID
+ def series_identifier_set(type, value)
+ series_id = series_identifier(type)
+
+ # create a new series identifier record if we need to
+ if series_id.nil?
+ series_id = ONIX::SeriesIdentifier.new
+ series_id.series_id_type = type
+ product.series_identifiers << series_id
+ end
+
+ series_id.id_value = value
+ end
+
+ # retrieve the value of a particular ID
+ def series(str)
+ product.series.find { |id| id.title_of_series == series }
+ end
+
+ # set the value of a particular ID
+ def series=(value)
+ series_id = series(value)
+
+ # create a new series record if we need to
+ if series_id.nil?
+ series_id = ONIX::Series.new
+ series_id.title_of_series = value
+ product.series << series_id
+ end
+ end
+
+ # retrieve the "language of text" (role=1) language code for this particular product
+ def language_code
+ language(1).andand.language_code
+ end
+
+ # set a new "language of text" (role=1) language code for this particular product
+ def language_code=(str)
+ language_set(1, str)
+ end
+
+ # retrieve the "language of text" (role=1) country code for this particular product
+ def country_code
+ language(1).andand.country_code
+ end
+
+ # set a new "language of text" (role=1) country code for this particular product
+ def country_code=(str)
+ language_set(1, language_code, str)
+ end
+
+ # retrieve the value of a particular language
+ def language(type)
+ product.languages.find { |l| l.language_role == type }
+ end
+
+ # set the value of a particular language
+ def language_set(type, value, value2=nil)
+ l = language(type)
+
+ # create a new language record if we need to
+ if l.nil?
+ l = ONIX::Language.new
+ l.language_role = type
+ product.languages << l
+ end
+
+ # cannot set country_code without language_code
+ unless value.nil?
+ l.language_code = value.to_s # mandatory
+ l.country_code = value2.to_s if value2 # optional
+ end
+ end
+
+ # retrieve the dewey for this title
+ def dewey
+ product.subjects.find { |sub| sub.subject_scheme_id.to_i == 1 } # dewey = 1, abridged dewey = 2
+ end
+
+ # add a dewey to the product
+ def dewey=(code)
+ add_subject code, "1" # dewey = 1, abridged dewey = 2
+ end
+
+ # audience_range_qualifier: 11 = US school grades
+ # audience_range_precision: 1 = exact, 3 = from, 4 = to
+ def us_grade_range
+ audience_range(11)
+ end
+
+ # set a new "audience of text" (role=1) country code for this particular product
+ def us_grade_range=(range=[])
+ audience_range_set(11, range[0], range[1])
+ end
+
+ # retrieve the value of a particular audience range
+ def audience_range(type)
+ product.audience_ranges.find { |a| a.audience_range_qualifier == type }
+ end
+
+ # set the value of a particular audience_range
+ def audience_range_set(type, min=nil, max=nil)
+ a = audience_range(type)
+
+ # create a new audience_range record if we need to
+ if a.nil?
+ a = ONIX::AudienceRange.new
+ a.audience_range_qualifier = type
+ product.audience_ranges << a
+ end
+
+ unless min.nil?
+ a.audience_range_precisions << "03"
+ a.audience_range_values << min
+ end
+ unless max.nil?
+ a.audience_range_precisions << "04"
+ a.audience_range_values << max
+ end
+ a.audience_range_precisions = ["01"] if min.nil? || max.nil?
+ end
+
+ end
+end
View
46 spec/audience_range_spec.rb
@@ -0,0 +1,46 @@
+# coding: utf-8
+
+$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
+
+require 'onix'
+
+context "ONIX::AudienceRange" do
+
+ before(:each) do
+ data_path = File.join(File.dirname(__FILE__),"..","data")
+ file1 = File.join(data_path, "audience_range.xml")
+ @doc = LibXML::XML::Document.file(file1)
+ @root = @doc.root
+ end
+
+ specify "should correctly convert to a string" do
+ aud = ONIX::AudienceRange.from_xml(@root.to_s)
+ aud.to_xml.to_s[0,15].should eql("<AudienceRange>")
+ end
+
+ specify "should provide read access to first level attibutes" do
+ aud = ONIX::AudienceRange.from_xml(@root.to_s)
+
+ aud.audience_range_qualifier.should eql(11)
+ aud.audience_range_precisions.size.should eql(2)
+ aud.audience_range_precisions[0].should eql(3)
+ aud.audience_range_precisions[1].should eql(4)
+ aud.audience_range_values.size.should eql(2)
+ aud.audience_range_values[0].should eql(3)
+ aud.audience_range_values[1].should eql(5)
+ end
+
+ specify "should provide write access to first level attibutes" do
+ aud = ONIX::AudienceRange.new
+
+ aud.audience_range_qualifier = 12
+ aud.to_xml.to_s.include?("<AudienceRangeQualifier>12</AudienceRangeQualifier>").should be_true
+
+ aud.audience_range_precisions[0] = 888
+ aud.to_xml.to_s.include?("<AudienceRangePrecision>888</AudienceRangePrecision>").should be_true
+
+ aud.audience_range_values[0] = 999
+ aud.to_xml.to_s.include?("<AudienceRangeValue>999</AudienceRangeValue>").should be_true
+ end
+
+end
View
42 spec/language_spec.rb
@@ -0,0 +1,42 @@
+# coding: utf-8
+
+$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
+
+require 'onix'
+
+context "ONIX::Language" do
+
+ before(:each) do
+ data_path = File.join(File.dirname(__FILE__),"..","data")
+ file1 = File.join(data_path, "language.xml")
+ @doc = LibXML::XML::Document.file(file1)
+ @root = @doc.root
+ end
+
+ specify "should correctly convert to a string" do
+ lan = ONIX::Language.from_xml(@root.to_s)
+ lan.to_xml.to_s[0,10].should eql("<Language>")
+ end
+
+ specify "should provide read access to first level attibutes" do
+ lan = ONIX::Language.from_xml(@root.to_s)
+
+ lan.language_role.should eql(1)
+ lan.language_code.should eql("eng")
+ lan.country_code.should eql("US")
+ end
+
+ specify "should provide write access to first level attibutes" do
+ lan = ONIX::Language.new
+
+ lan.language_role = 2
+ lan.to_xml.to_s.include?("<LanguageRole>02</LanguageRole>").should be_true
+
+ lan.language_code = "aar"
+ lan.to_xml.to_s.include?("<LanguageCode>aar</LanguageCode>").should be_true
+
+ lan.country_code = "AD"
+ lan.to_xml.to_s.include?("<CountryCode>AD</CountryCode>").should be_true
+ end
+
+end
View
38 spec/series_identifier_spec.rb
@@ -0,0 +1,38 @@
+# coding: utf-8
+
+$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
+
+require 'onix'
+
+context "ONIX::SeriesIdentifier" do
+
+ before(:each) do
+ data_path = File.join(File.dirname(__FILE__),"..","data")
+ file1 = File.join(data_path, "series_identifier.xml")
+ @doc = LibXML::XML::Document.file(file1)
+ @root = @doc.root
+ end
+
+ specify "should correctly convert to a string" do
+ series = ONIX::SeriesIdentifier.from_xml(@root.to_s)
+ series.to_xml.to_s[0,18].should eql("<SeriesIdentifier>")
+ end
+
+ specify "should provide read access to first level attibutes" do
+ series = ONIX::SeriesIdentifier.from_xml(@root.to_s)
+
+ series.series_id_type.should eql(1)
+ series.id_value.should eql("10001")
+ end
+
+ specify "should provide write access to first level attibutes" do
+ series = ONIX::SeriesIdentifier.new
+
+ series.series_id_type = 9
+ series.to_xml.to_s.include?("<SeriesIDType>09</SeriesIDType>").should be_true
+
+ series.id_value = 999
+ series.to_xml.to_s.include?("<IDValue>999</IDValue>").should be_true
+ end
+
+end
View
34 spec/series_spec.rb
@@ -0,0 +1,34 @@
+# coding: utf-8
+
+$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
+
+require 'onix'
+
+context "ONIX::Series" do
+
+ before(:each) do
+ data_path = File.join(File.dirname(__FILE__),"..","data")
+ file1 = File.join(data_path, "series.xml")
+ @doc = LibXML::XML::Document.file(file1)
+ @root = @doc.root
+ end
+
+ specify "should correctly convert to a string" do
+ series = ONIX::Series.from_xml(@root.to_s)
+ series.to_xml.to_s[0,8].should eql("<Series>")
+ end
+
+ specify "should provide read access to first level attibutes" do
+ series = ONIX::Series.from_xml(@root.to_s)
+
+ series.title_of_series.should eql("Citizens and Their Governments")
+ end
+
+ specify "should provide write access to first level attibutes" do
+ series = ONIX::Series.new
+
+ series.title_of_series = "Cool Science Careers"
+ series.to_xml.to_s.include?("<TitleOfSeries>Cool Science Careers</TitleOfSeries>").should be_true
+ end
+
+end
View
48 spec/sl_product_spec.rb
@@ -0,0 +1,48 @@
+# coding: utf-8
+
+$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
+
+require 'onix'
+require 'date'
+
+context "ONIX::SLProduct" do
+
+ before(:each) do
+ @data_path = File.join(File.dirname(__FILE__),"..","data")
+ file1 = File.join(@data_path, "sl_product.xml")
+ @doc = LibXML::XML::Document.file(file1)
+ @product_node = @doc.root
+ end
+
+ specify "should provide read access to attibrutes" do
+ @product = ONIX::Product.from_xml(@product_node.to_s)
+ @sl = ONIX::SLProduct.new(@product)
+
+ @sl.record_reference.should eql("10001")
+ @sl.notification_type.should eql(2)
+ @sl.number_of_pages.should eql(32)
+ @sl.publishing_status.should eql(2)
+ @sl.publication_date.should eql(Date.civil(2009,12,1))
+ @sl.copyright_year.should eql(2008)
+ end
+
+ specify "should provide write access to attibutes" do
+ apa = ONIX::SLProduct.new
+
+ apa.notification_type = 3
+ apa.to_xml.to_s.include?("<NotificationType>03</NotificationType>").should be_true
+
+ apa.record_reference = "999"
+ apa.to_xml.to_s.include?("<RecordReference>999</RecordReference>").should be_true
+
+ apa.number_of_pages = 100
+ apa.to_xml.to_s.include?("<NumberOfPages>100</NumberOfPages>").should be_true
+
+ apa.publishing_status = 4
+ apa.to_xml.to_s.include?("<PublishingStatus>04</PublishingStatus>").should be_true
+
+ apa.publication_date = Date.civil(1998,9,1)
+ apa.to_xml.to_s.include?("<PublicationDate>19980901</PublicationDate>").should be_true
+ end
+
+end
Please sign in to comment.
Something went wrong with that request. Please try again.