onix 0.7.7 → 0.7.8
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.
- data/lib/onix/audience_range.rb +26 -0
- data/lib/onix/language.rb +14 -0
- data/lib/onix/lists/audience_code.rb +17 -0
- data/lib/onix/lists/country_code.rb +257 -0
- data/lib/onix/lists/language_code.rb +498 -0
- data/lib/onix/lists/language_role.rb +18 -0
- data/lib/onix/lists/notification_type.rb +19 -0
- data/lib/onix/lists/product_form_detail.rb +157 -0
- data/lib/onix/product.rb +10 -2
- data/lib/onix/series.rb +18 -0
- data/lib/onix/series_identifier.rb +13 -0
- data/lib/onix.rb +12 -3
- data/spec/audience_range_spec.rb +46 -0
- data/spec/language_spec.rb +42 -0
- data/spec/series_identifier_spec.rb +38 -0
- data/spec/series_spec.rb +34 -0
- metadata +20 -2
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
module ONIX
|
|
4
|
+
module Lists
|
|
5
|
+
# Code list 78
|
|
6
|
+
PRODUCT_FORM_DETAIL = {
|
|
7
|
+
"A101" => "CD standard audio format",
|
|
8
|
+
"A102" => "SACD super audio format",
|
|
9
|
+
"A103" => "MP3 format",
|
|
10
|
+
"A104" => "WAV format",
|
|
11
|
+
"A105" => "Real Audio format",
|
|
12
|
+
"A106" => "WMA",
|
|
13
|
+
"A107" => "AAC",
|
|
14
|
+
"A108" => "Ogg/Vorbis",
|
|
15
|
+
"A109" => "Audible",
|
|
16
|
+
"A110" => "FLAC",
|
|
17
|
+
"A111" => "AIFF",
|
|
18
|
+
"A112" => "ALAC",
|
|
19
|
+
"A201" => "DAISY 2: full audio with title only (no navigation)",
|
|
20
|
+
"A202" => "DAISY 2: full audio with navigation",
|
|
21
|
+
"A203" => "DAISY 2: full audio with navigation and partial text",
|
|
22
|
+
"A204" => "DAISY 2: full audio and full text",
|
|
23
|
+
"A205" => "DAISY 2: full text and some audio",
|
|
24
|
+
"A206" => "DAISY 2: full text and no audio",
|
|
25
|
+
"A207" => "DAISY 3: full audio with title only (no navigation)",
|
|
26
|
+
"A208" => "DAISY 3: full audio with navigation",
|
|
27
|
+
"A209" => "DAISY 3: full audio with navigation and partial text",
|
|
28
|
+
"A210" => "DAISY 3: full audio and full text",
|
|
29
|
+
"A211" => "DAISY 3: full text and some audio",
|
|
30
|
+
"A212" => "DAISY 3: full text and no audio",
|
|
31
|
+
"B101" => "Mass market (rack) paperback",
|
|
32
|
+
"B102" => "Trade paperback (US)",
|
|
33
|
+
"B103" => "Digest format paperback",
|
|
34
|
+
"B104" => "A-format paperback",
|
|
35
|
+
"B105" => "B-format paperback",
|
|
36
|
+
"B106" => "Trade paperback (UK)",
|
|
37
|
+
"B107" => "Tall rack paperback (US)",
|
|
38
|
+
"B108" => "A5: Tankobon",
|
|
39
|
+
"B109" => "B5: Tankobon",
|
|
40
|
+
"B110" => "B6: Tankobon",
|
|
41
|
+
"B111" => "A6: Bunko",
|
|
42
|
+
"B112" => "B40-dori: Shinsho",
|
|
43
|
+
"B113" => "Pocket (Sweden)",
|
|
44
|
+
"B114" => "Storpocket (Sweden)",
|
|
45
|
+
"B115" => "Kartonnage (Sweden)",
|
|
46
|
+
"B116" => "Flexband (Sweden)",
|
|
47
|
+
"B201" => "Coloring / join-the-dot book",
|
|
48
|
+
"B202" => "Lift-the-flap book",
|
|
49
|
+
"B203" => "Fuzzy book",
|
|
50
|
+
"B204" => "Miniature book",
|
|
51
|
+
"B205" => "Moving picture / flicker book",
|
|
52
|
+
"B206" => "Pop-up book",
|
|
53
|
+
"B207" => "Scented / 'smelly' book",
|
|
54
|
+
"B208" => "Sound story / 'noisy' book",
|
|
55
|
+
"B209" => "Sticker book",
|
|
56
|
+
"B210" => "Touch-and-feel book",
|
|
57
|
+
"B211" => "Toy / die-cut book",
|
|
58
|
+
"B212" => "Die-cut book",
|
|
59
|
+
"B213" => "Book-as-toy",
|
|
60
|
+
"B214" => "Soft-to-touch book",
|
|
61
|
+
"B215" => "Fuzzy-felt book",
|
|
62
|
+
"B221" => "Picture book",
|
|
63
|
+
"B301" => "Loose leaf - sheets & binder",
|
|
64
|
+
"B302" => "Loose leaf - binder only",
|
|
65
|
+
"B303" => "Loose leaf - sheets only",
|
|
66
|
+
"B304" => "Sewn",
|
|
67
|
+
"B305" => "Unsewn / adhesive bound",
|
|
68
|
+
"B306" => "Library binding",
|
|
69
|
+
"B307" => "Reinforced binding",
|
|
70
|
+
"B308" => "Half bound",
|
|
71
|
+
"B309" => "Quarter bound",
|
|
72
|
+
"B310" => "Saddle-sewn",
|
|
73
|
+
"B311" => "Comb bound",
|
|
74
|
+
"B312" => "Wire-O",
|
|
75
|
+
"B313" => "Concealed wire",
|
|
76
|
+
"B401" => "Cloth over boards",
|
|
77
|
+
"B402" => "Paper over boards",
|
|
78
|
+
"B403" => "Leather, real",
|
|
79
|
+
"B404" => "Leather, imitation",
|
|
80
|
+
"B405" => "Leather, bonded",
|
|
81
|
+
"B406" => "Vellum",
|
|
82
|
+
"B407" => "Plastic",
|
|
83
|
+
"B408" => "Vinyl",
|
|
84
|
+
"B409" => "Cloth",
|
|
85
|
+
"B410" => "Imitation cloth",
|
|
86
|
+
"B411" => "Velvet",
|
|
87
|
+
"B412" => "Flexible plastic/vinyl cover",
|
|
88
|
+
"B413" => "Plastic-covered",
|
|
89
|
+
"B414" => "Vinyl-covered",
|
|
90
|
+
"B415" => "Laminated cover",
|
|
91
|
+
"B501" => "With dust jacket",
|
|
92
|
+
"B502" => "With printed dust jacket",
|
|
93
|
+
"B503" => "With translucent dust cover",
|
|
94
|
+
"B504" => "With flaps",
|
|
95
|
+
"B505" => "With thumb index",
|
|
96
|
+
"B506" => "With ribbon marker(s)",
|
|
97
|
+
"B507" => "With zip fastener",
|
|
98
|
+
"B508" => "With button snap fastener",
|
|
99
|
+
"B509" => "With leather edge lining",
|
|
100
|
+
"B601" => "Turn-around book",
|
|
101
|
+
"B602" => "Unflipped manga format",
|
|
102
|
+
"B701" => "UK Braille Grade 1",
|
|
103
|
+
"B702" => "UK Braille Grade 2",
|
|
104
|
+
"B703" => "US Braille",
|
|
105
|
+
"D101" => "Real Video format",
|
|
106
|
+
"D102" => "Quicktime format",
|
|
107
|
+
"D103" => "AVI format",
|
|
108
|
+
"D104" => "Windows Media Video format",
|
|
109
|
+
"D105" => "MPEG-4",
|
|
110
|
+
"D201" => "MS-DOS",
|
|
111
|
+
"D202" => "Windows",
|
|
112
|
+
"D203" => "Macintosh",
|
|
113
|
+
"D204" => "UNIX / LINUX",
|
|
114
|
+
"D205" => "Other operating system(s)",
|
|
115
|
+
"D206" => "Palm OS",
|
|
116
|
+
"D207" => "Windows Mobile",
|
|
117
|
+
"D301" => "Microsoft XBox",
|
|
118
|
+
"D302" => "Nintendo Gameboy Color",
|
|
119
|
+
"D303" => "Nintendo Gameboy Advanced",
|
|
120
|
+
"D304" => "Nintendo Gameboy",
|
|
121
|
+
"D305" => "Nintendo Gamecube",
|
|
122
|
+
"D306" => "Nintendo 64",
|
|
123
|
+
"D307" => "Sega Dreamcast",
|
|
124
|
+
"D308" => "Sega Genesis/Megadrive",
|
|
125
|
+
"D309" => "Sega Saturn",
|
|
126
|
+
"D310" => "Sony PlayStation 1",
|
|
127
|
+
"D311" => "Sony PlayStation 2",
|
|
128
|
+
"D312" => "Nintendo Dual Screen",
|
|
129
|
+
"D313" => "Sony PlayStation 3",
|
|
130
|
+
"D314" => "Xbox 360",
|
|
131
|
+
"D315" => "Nintendo Wii",
|
|
132
|
+
"D316" => "Sony PlayStation Portable (PSP)",
|
|
133
|
+
"L101" => "Laminated",
|
|
134
|
+
"P101" => "Desk calendar",
|
|
135
|
+
"P102" => "Mini calendar",
|
|
136
|
+
"P103" => "Engagement calendar",
|
|
137
|
+
"P104" => "Day by day calendar",
|
|
138
|
+
"P105" => "Poster calendar",
|
|
139
|
+
"P106" => "Wall calendar",
|
|
140
|
+
"P107" => "Perpetual calendar",
|
|
141
|
+
"P108" => "Advent calendar",
|
|
142
|
+
"P109" => "Bookmark calendar",
|
|
143
|
+
"P110" => "Student calendar",
|
|
144
|
+
"P111" => "Project calendar",
|
|
145
|
+
"P112" => "Almanac calendar",
|
|
146
|
+
"P113" => "Other calendar",
|
|
147
|
+
"P114" => "Other calendar or organiser product",
|
|
148
|
+
"P201" => "Hardback (stationery)",
|
|
149
|
+
"P202" => "Paperback / softback (stationery)",
|
|
150
|
+
"P203" => "Spiral bound (stationery)",
|
|
151
|
+
"P204" => "Leather / fine binding (stationery)",
|
|
152
|
+
"V201" => "PAL",
|
|
153
|
+
"V202" => "NTSC",
|
|
154
|
+
"V203" => "SECAM",
|
|
155
|
+
}
|
|
156
|
+
end
|
|
157
|
+
end
|
data/lib/onix/product.rb
CHANGED
|
@@ -11,14 +11,18 @@ module ONIX
|
|
|
11
11
|
xml_accessor :notification_type, :from => "NotificationType", :as => Fixnum, :to_xml => ONIX::Formatters.two_digit
|
|
12
12
|
xml_accessor :product_identifiers, :from => "ProductIdentifier", :as => [ONIX::ProductIdentifier]
|
|
13
13
|
xml_accessor :product_form, :from => "ProductForm"
|
|
14
|
-
xml_accessor :
|
|
15
|
-
xml_accessor :
|
|
14
|
+
xml_accessor :product_form_detail, :from => "ProductFormDetail"
|
|
15
|
+
xml_accessor :series, :from => "Series", :as => [ONIX::Series]
|
|
16
16
|
xml_accessor :titles, :from => "Title", :as => [ONIX::Title]
|
|
17
17
|
xml_accessor :websites, :from => "Website", :as => [ONIX::Website]
|
|
18
18
|
xml_accessor :contributors, :from => "Contributor", :as => [ONIX::Contributor]
|
|
19
|
+
xml_accessor :edition_number, :from => "EditionNumber", :as => Fixnum
|
|
20
|
+
xml_accessor :languages, :from => "Language", :as => [ONIX::Language]
|
|
19
21
|
xml_accessor :number_of_pages, :from => "NumberOfPages", :as => Fixnum
|
|
20
22
|
xml_accessor :bic_main_subject, :from => "BICMainSubject"
|
|
21
23
|
xml_accessor :subjects, :from => "Subject", :as => [ONIX::Subject]
|
|
24
|
+
xml_accessor :audience_code, :from => "AudienceCode", :to_xml => ONIX::Formatters.two_digit
|
|
25
|
+
xml_accessor :audience_ranges, :from => "AudienceRange", :as => [ONIX::AudienceRange]
|
|
22
26
|
xml_accessor :text, :from => "OtherText", :as => [ONIX::OtherText]
|
|
23
27
|
xml_accessor :media_files, :from => "MediaFile", :as => [ONIX::MediaFile]
|
|
24
28
|
xml_accessor :imprints, :from => "Imprint", :as => [ONIX::Imprint]
|
|
@@ -31,6 +35,7 @@ module ONIX
|
|
|
31
35
|
nil
|
|
32
36
|
end
|
|
33
37
|
end
|
|
38
|
+
xml_accessor :copyright_year, :from => "CopyrightYear", :as => Integer
|
|
34
39
|
xml_accessor :year_first_published, :from => "YearFirstPublished", :as => Fixnum
|
|
35
40
|
xml_accessor :sales_restrictions, :from => "SalesRestriction", :as => [ONIX::SalesRestriction]
|
|
36
41
|
xml_accessor :measurements, :from => "Measure", :as => [ONIX::Measure]
|
|
@@ -48,11 +53,14 @@ module ONIX
|
|
|
48
53
|
|
|
49
54
|
def initialize
|
|
50
55
|
self.product_identifiers = []
|
|
56
|
+
self.series = []
|
|
51
57
|
self.titles = []
|
|
52
58
|
self.contributors = []
|
|
53
59
|
self.websites = []
|
|
54
60
|
self.subjects = []
|
|
61
|
+
self.audience_ranges = []
|
|
55
62
|
self.text = []
|
|
63
|
+
self.languages = []
|
|
56
64
|
self.media_files = []
|
|
57
65
|
self.imprints = []
|
|
58
66
|
self.publishers = []
|
data/lib/onix/series.rb
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
module ONIX
|
|
4
|
+
class Series
|
|
5
|
+
include ROXML
|
|
6
|
+
include ONIX::Common
|
|
7
|
+
|
|
8
|
+
xml_name "Series"
|
|
9
|
+
|
|
10
|
+
xml_accessor :series_identifiers, :from => "SeriesIdentifier", :as => [ONIX::SeriesIdentifier]
|
|
11
|
+
xml_accessor :title_of_series, :from => "TitleOfSeries"
|
|
12
|
+
|
|
13
|
+
def initialize
|
|
14
|
+
self.series_identifiers = []
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
module ONIX
|
|
4
|
+
class SeriesIdentifier
|
|
5
|
+
include ROXML
|
|
6
|
+
include ONIX::Common
|
|
7
|
+
|
|
8
|
+
xml_name "SeriesIdentifier"
|
|
9
|
+
|
|
10
|
+
xml_accessor :series_id_type, :from => "SeriesIDType", :as => Fixnum, :to_xml => ONIX::Formatters.two_digit
|
|
11
|
+
xml_accessor :id_value, :from => "IDValue"
|
|
12
|
+
end
|
|
13
|
+
end
|
data/lib/onix.rb
CHANGED
|
@@ -16,7 +16,7 @@ module ONIX
|
|
|
16
16
|
module Version #:nodoc:
|
|
17
17
|
Major = 0
|
|
18
18
|
Minor = 7
|
|
19
|
-
Tiny =
|
|
19
|
+
Tiny = 8
|
|
20
20
|
|
|
21
21
|
String = [Major, Minor, Tiny].join('.')
|
|
22
22
|
end
|
|
@@ -74,14 +74,18 @@ require File.join(File.dirname(__FILE__), "onix", "sender_identifier")
|
|
|
74
74
|
require File.join(File.dirname(__FILE__), "onix", "addressee_identifier")
|
|
75
75
|
require File.join(File.dirname(__FILE__), "onix", "header")
|
|
76
76
|
require File.join(File.dirname(__FILE__), "onix", "product_identifier")
|
|
77
|
+
require File.join(File.dirname(__FILE__), "onix", "series_identifier")
|
|
78
|
+
require File.join(File.dirname(__FILE__), "onix", "series")
|
|
77
79
|
require File.join(File.dirname(__FILE__), "onix", "title")
|
|
78
80
|
require File.join(File.dirname(__FILE__), "onix", "website")
|
|
79
81
|
require File.join(File.dirname(__FILE__), "onix", "contributor")
|
|
82
|
+
require File.join(File.dirname(__FILE__), "onix", "language")
|
|
80
83
|
require File.join(File.dirname(__FILE__), "onix", "subject")
|
|
81
|
-
require File.join(File.dirname(__FILE__), "onix", "
|
|
82
|
-
require File.join(File.dirname(__FILE__), "onix", "media_file")
|
|
84
|
+
require File.join(File.dirname(__FILE__), "onix", "audience_range")
|
|
83
85
|
require File.join(File.dirname(__FILE__), "onix", "imprint")
|
|
84
86
|
require File.join(File.dirname(__FILE__), "onix", "publisher")
|
|
87
|
+
require File.join(File.dirname(__FILE__), "onix", "other_text")
|
|
88
|
+
require File.join(File.dirname(__FILE__), "onix", "media_file")
|
|
85
89
|
require File.join(File.dirname(__FILE__), "onix", "sales_restriction")
|
|
86
90
|
require File.join(File.dirname(__FILE__), "onix", "stock")
|
|
87
91
|
require File.join(File.dirname(__FILE__), "onix", "price")
|
|
@@ -95,6 +99,11 @@ require File.join(File.dirname(__FILE__), "onix", "writer")
|
|
|
95
99
|
# lists
|
|
96
100
|
require File.join(File.dirname(__FILE__), "onix", "lists", "product_form")
|
|
97
101
|
require File.join(File.dirname(__FILE__), "onix", "lists", "product_availability")
|
|
102
|
+
require File.join(File.dirname(__FILE__), "onix", "lists", "country_code")
|
|
103
|
+
require File.join(File.dirname(__FILE__), "onix", "lists", "language_code")
|
|
104
|
+
require File.join(File.dirname(__FILE__), "onix", "lists", "language_role")
|
|
105
|
+
require File.join(File.dirname(__FILE__), "onix", "lists", "notification_type")
|
|
106
|
+
require File.join(File.dirname(__FILE__), "onix", "lists", "product_form_detail")
|
|
98
107
|
|
|
99
108
|
# product wrappers
|
|
100
109
|
require File.join(File.dirname(__FILE__), "onix", "simple_product")
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
|
|
4
|
+
|
|
5
|
+
require 'onix'
|
|
6
|
+
|
|
7
|
+
context "ONIX::AudienceRange" do
|
|
8
|
+
|
|
9
|
+
before(:each) do
|
|
10
|
+
data_path = File.join(File.dirname(__FILE__),"..","data")
|
|
11
|
+
file1 = File.join(data_path, "audience_range.xml")
|
|
12
|
+
@doc = LibXML::XML::Document.file(file1)
|
|
13
|
+
@root = @doc.root
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
specify "should correctly convert to a string" do
|
|
17
|
+
aud = ONIX::AudienceRange.from_xml(@root.to_s)
|
|
18
|
+
aud.to_xml.to_s[0,15].should eql("<AudienceRange>")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
specify "should provide read access to first level attibutes" do
|
|
22
|
+
aud = ONIX::AudienceRange.from_xml(@root.to_s)
|
|
23
|
+
|
|
24
|
+
aud.audience_range_qualifier.should eql(11)
|
|
25
|
+
aud.audience_range_precisions.size.should eql(2)
|
|
26
|
+
aud.audience_range_precisions[0].should eql(3)
|
|
27
|
+
aud.audience_range_precisions[1].should eql(4)
|
|
28
|
+
aud.audience_range_values.size.should eql(2)
|
|
29
|
+
aud.audience_range_values[0].should eql(3)
|
|
30
|
+
aud.audience_range_values[1].should eql(5)
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
specify "should provide write access to first level attibutes" do
|
|
34
|
+
aud = ONIX::AudienceRange.new
|
|
35
|
+
|
|
36
|
+
aud.audience_range_qualifier = 12
|
|
37
|
+
aud.to_xml.to_s.include?("<AudienceRangeQualifier>12</AudienceRangeQualifier>").should be_true
|
|
38
|
+
|
|
39
|
+
aud.audience_range_precisions[0] = 888
|
|
40
|
+
aud.to_xml.to_s.include?("<AudienceRangePrecision>888</AudienceRangePrecision>").should be_true
|
|
41
|
+
|
|
42
|
+
aud.audience_range_values[0] = 999
|
|
43
|
+
aud.to_xml.to_s.include?("<AudienceRangeValue>999</AudienceRangeValue>").should be_true
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
|
|
4
|
+
|
|
5
|
+
require 'onix'
|
|
6
|
+
|
|
7
|
+
context "ONIX::Language" do
|
|
8
|
+
|
|
9
|
+
before(:each) do
|
|
10
|
+
data_path = File.join(File.dirname(__FILE__),"..","data")
|
|
11
|
+
file1 = File.join(data_path, "language.xml")
|
|
12
|
+
@doc = LibXML::XML::Document.file(file1)
|
|
13
|
+
@root = @doc.root
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
specify "should correctly convert to a string" do
|
|
17
|
+
lan = ONIX::Language.from_xml(@root.to_s)
|
|
18
|
+
lan.to_xml.to_s[0,10].should eql("<Language>")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
specify "should provide read access to first level attibutes" do
|
|
22
|
+
lan = ONIX::Language.from_xml(@root.to_s)
|
|
23
|
+
|
|
24
|
+
lan.language_role.should eql(1)
|
|
25
|
+
lan.language_code.should eql("eng")
|
|
26
|
+
lan.country_code.should eql("US")
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
specify "should provide write access to first level attibutes" do
|
|
30
|
+
lan = ONIX::Language.new
|
|
31
|
+
|
|
32
|
+
lan.language_role = 2
|
|
33
|
+
lan.to_xml.to_s.include?("<LanguageRole>02</LanguageRole>").should be_true
|
|
34
|
+
|
|
35
|
+
lan.language_code = "aar"
|
|
36
|
+
lan.to_xml.to_s.include?("<LanguageCode>aar</LanguageCode>").should be_true
|
|
37
|
+
|
|
38
|
+
lan.country_code = "AD"
|
|
39
|
+
lan.to_xml.to_s.include?("<CountryCode>AD</CountryCode>").should be_true
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
|
|
4
|
+
|
|
5
|
+
require 'onix'
|
|
6
|
+
|
|
7
|
+
context "ONIX::SeriesIdentifier" do
|
|
8
|
+
|
|
9
|
+
before(:each) do
|
|
10
|
+
data_path = File.join(File.dirname(__FILE__),"..","data")
|
|
11
|
+
file1 = File.join(data_path, "series_identifier.xml")
|
|
12
|
+
@doc = LibXML::XML::Document.file(file1)
|
|
13
|
+
@root = @doc.root
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
specify "should correctly convert to a string" do
|
|
17
|
+
series = ONIX::SeriesIdentifier.from_xml(@root.to_s)
|
|
18
|
+
series.to_xml.to_s[0,18].should eql("<SeriesIdentifier>")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
specify "should provide read access to first level attibutes" do
|
|
22
|
+
series = ONIX::SeriesIdentifier.from_xml(@root.to_s)
|
|
23
|
+
|
|
24
|
+
series.series_id_type.should eql(1)
|
|
25
|
+
series.id_value.should eql("10001")
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
specify "should provide write access to first level attibutes" do
|
|
29
|
+
series = ONIX::SeriesIdentifier.new
|
|
30
|
+
|
|
31
|
+
series.series_id_type = 9
|
|
32
|
+
series.to_xml.to_s.include?("<SeriesIDType>09</SeriesIDType>").should be_true
|
|
33
|
+
|
|
34
|
+
series.id_value = 999
|
|
35
|
+
series.to_xml.to_s.include?("<IDValue>999</IDValue>").should be_true
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
data/spec/series_spec.rb
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# coding: utf-8
|
|
2
|
+
|
|
3
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
|
|
4
|
+
|
|
5
|
+
require 'onix'
|
|
6
|
+
|
|
7
|
+
context "ONIX::Series" do
|
|
8
|
+
|
|
9
|
+
before(:each) do
|
|
10
|
+
data_path = File.join(File.dirname(__FILE__),"..","data")
|
|
11
|
+
file1 = File.join(data_path, "series.xml")
|
|
12
|
+
@doc = LibXML::XML::Document.file(file1)
|
|
13
|
+
@root = @doc.root
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
specify "should correctly convert to a string" do
|
|
17
|
+
series = ONIX::Series.from_xml(@root.to_s)
|
|
18
|
+
series.to_xml.to_s[0,8].should eql("<Series>")
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
specify "should provide read access to first level attibutes" do
|
|
22
|
+
series = ONIX::Series.from_xml(@root.to_s)
|
|
23
|
+
|
|
24
|
+
series.title_of_series.should eql("Citizens and Their Governments")
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
specify "should provide write access to first level attibutes" do
|
|
28
|
+
series = ONIX::Series.new
|
|
29
|
+
|
|
30
|
+
series.title_of_series = "Cool Science Careers"
|
|
31
|
+
series.to_xml.to_s.include?("<TitleOfSeries>Cool Science Careers</TitleOfSeries>").should be_true
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: onix
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.7.
|
|
4
|
+
version: 0.7.8
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- James Healy
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
11
|
|
|
12
|
-
date: 2009-10-
|
|
12
|
+
date: 2009-10-19 00:00:00 +11:00
|
|
13
13
|
default_executable:
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
@@ -57,6 +57,12 @@ files:
|
|
|
57
57
|
- lib/onix/reader.rb
|
|
58
58
|
- lib/onix/lists/product_form.rb
|
|
59
59
|
- lib/onix/lists/product_availability.rb
|
|
60
|
+
- lib/onix/lists/audience_code.rb
|
|
61
|
+
- lib/onix/lists/country_code.rb
|
|
62
|
+
- lib/onix/lists/language_code.rb
|
|
63
|
+
- lib/onix/lists/language_role.rb
|
|
64
|
+
- lib/onix/lists/notification_type.rb
|
|
65
|
+
- lib/onix/lists/product_form_detail.rb
|
|
60
66
|
- lib/onix/addressee_identifier.rb
|
|
61
67
|
- lib/onix/apa_product.rb
|
|
62
68
|
- lib/onix/contributor.rb
|
|
@@ -78,6 +84,10 @@ files:
|
|
|
78
84
|
- lib/onix/writer.rb
|
|
79
85
|
- lib/onix/common.rb
|
|
80
86
|
- lib/onix/normaliser.rb
|
|
87
|
+
- lib/onix/audience_range.rb
|
|
88
|
+
- lib/onix/language.rb
|
|
89
|
+
- lib/onix/series.rb
|
|
90
|
+
- lib/onix/series_identifier.rb
|
|
81
91
|
- lib/onix.rb
|
|
82
92
|
- README.markdown
|
|
83
93
|
- TODO
|
|
@@ -134,6 +144,10 @@ files:
|
|
|
134
144
|
- spec/title_spec.rb
|
|
135
145
|
- spec/normaliser_spec.rb
|
|
136
146
|
- spec/apa_product_spec.rb
|
|
147
|
+
- spec/audience_range_spec.rb
|
|
148
|
+
- spec/language_spec.rb
|
|
149
|
+
- spec/series_identifier_spec.rb
|
|
150
|
+
- spec/series_spec.rb
|
|
137
151
|
has_rdoc: true
|
|
138
152
|
homepage: http://github.com/yob/onix/tree/master
|
|
139
153
|
licenses: []
|
|
@@ -187,3 +201,7 @@ test_files:
|
|
|
187
201
|
- spec/title_spec.rb
|
|
188
202
|
- spec/normaliser_spec.rb
|
|
189
203
|
- spec/apa_product_spec.rb
|
|
204
|
+
- spec/audience_range_spec.rb
|
|
205
|
+
- spec/language_spec.rb
|
|
206
|
+
- spec/series_identifier_spec.rb
|
|
207
|
+
- spec/series_spec.rb
|