stanford-mods 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,3 +2,5 @@ source 'https://rubygems.org'
2
2
 
3
3
  # See stanford-mods.gemspec for this gem's dependencies
4
4
  gemspec
5
+
6
+ #gem 'mods', :path => '../mods'
data/README.rdoc CHANGED
@@ -60,7 +60,8 @@ Example Using SearchWorks Mixins:
60
60
 
61
61
  == Releases
62
62
 
63
- 0.0.4 KolbRecord started
64
- 0.0.3 began SearchWorks mixins with sw_access_facet and sw_language_facet
65
- 0.0.2 add usage instructions to readme
66
- 0.0.1 Initial commit - grab name
63
+ * <b>0.0.5</b> main_author_w_date, additional_authors_w_dates added to Stanford::Mods::Record; various author methods added to searchworks mixin
64
+ * <b>0.0.4</b> KolbRecord started
65
+ * <b>0.0.3</b> began SearchWorks mixins with sw_access_facet and sw_language_facet
66
+ * <b>0.0.2</b> add usage instructions to readme
67
+ * <b>0.0.1</b> Initial commit - grab name
data/Rakefile CHANGED
@@ -24,12 +24,12 @@ task :ci => [:rspec, :doc]
24
24
  task :spec => :rspec
25
25
 
26
26
  RSpec::Core::RakeTask.new(:rspec) do |spec|
27
- spec.rspec_opts = ["-c", "-f progress", "-r ./spec/spec_helper.rb"]
27
+ spec.rspec_opts = ["-c", "--tty", "-f progress", "-r ./spec/spec_helper.rb"]
28
28
  end
29
29
 
30
30
  # Use yard to build docs
31
31
  begin
32
- project_root = File.expand_path(File.dirname(__FILE__) + "/../..")
32
+ project_root = File.expand_path(File.dirname(__FILE__))
33
33
  doc_dest_dir = File.join(project_root, 'doc')
34
34
 
35
35
  YARD::Rake::YardocTask.new(:doc) do |yt|
data/lib/stanford-mods.rb CHANGED
@@ -7,7 +7,44 @@ module Stanford
7
7
  module Mods
8
8
 
9
9
  class Record < ::Mods::Record
10
+
11
+ # the first encountered <mods><name> element with marcrelator flavor role of 'Creator' or 'Author'.
12
+ # if no marcrelator 'Creator' or 'Author', the first name without a role.
13
+ # if no name without a role, then nil
14
+ # @return [String] a name in the display_value_w_date form
15
+ # see Mods::Record.name in nom_terminology for details on the display_value algorithm
16
+ def main_author_w_date
17
+ result = nil
18
+ first_wo_role = nil
19
+ @mods_ng_xml.plain_name.each { |n|
20
+ if n.role.size == 0
21
+ first_wo_role ||= n
22
+ end
23
+ n.role.each { |r|
24
+ if r.authority.include?('marcrelator') &&
25
+ (r.value.include?('Creator') || r.value.include?('Author'))
26
+ result ||= n.display_value_w_date
27
+ end
28
+ }
29
+ }
30
+ if !result && first_wo_role
31
+ result = first_wo_role.display_value_w_date
32
+ end
33
+ result
34
+ end # main_author
35
+
36
+ # all names, in display form, except the main_author
37
+ # names will be the display_value_w_date form
38
+ # see Mods::Record.name in nom_terminology for details on the display_value algorithm
39
+ def additional_authors_w_dates
40
+ results = []
41
+ @mods_ng_xml.plain_name.each { |n|
42
+ results << n.display_value_w_date
43
+ }
44
+ results.delete(main_author_w_date)
45
+ results
46
+ end
10
47
 
11
- end
12
- end
13
- end
48
+ end # Record class
49
+ end # Mods module
50
+ end # Stanford module
@@ -1,6 +1,7 @@
1
+ # encoding: UTF-8
1
2
  require 'stanford-mods/searchworks_languages'
2
3
 
3
- # # SearchWorks specific wranglings of MODS metadata as an extension of the Mods::Record object
4
+ # SearchWorks specific wranglings of MODS metadata as a mixin to the Stanford::Mods::Record object
4
5
  module Stanford
5
6
  module Mods
6
7
 
@@ -50,6 +51,51 @@ module Stanford
50
51
  result.uniq
51
52
  end # language_facet
52
53
 
54
+
55
+ # ---- AUTHOR ----
56
+
57
+ # @return [String] value for author_1xx_search field
58
+ def sw_main_author
59
+ main_author_w_date
60
+ end
61
+
62
+ # @return [Array<String>] values for author_7xx_search field
63
+ def sw_addl_authors
64
+ additional_authors_w_dates
65
+ end
66
+
67
+ # @return [Array<String>] values for author_person_facet, author_person_display
68
+ def sw_person_authors
69
+ personal_names_w_dates
70
+ end
71
+
72
+ # return the display_value_w_date for all <mods><name> elements that do not have type='personal'
73
+ # @return [Array<String>] values for author_other_facet
74
+ def sw_impersonal_authors
75
+ @mods_ng_xml.plain_name.select {|n| n.type_at != 'personal'}.map { |n| n.display_value_w_date }
76
+ end
77
+
78
+ # @return [Array<String>] values for author_corp_display
79
+ def sw_corporate_authors
80
+ @mods_ng_xml.plain_name.select {|n| n.type_at == 'corporate'}.map { |n| n.display_value_w_date }
81
+ end
82
+
83
+ # @return [Array<String>] values for author_meeting_display
84
+ def sw_meeting_authors
85
+ @mods_ng_xml.plain_name.select {|n| n.type_at == 'conference'}.map { |n| n.display_value_w_date }
86
+ end
87
+
88
+ # Returns a sortable version of the main_author:
89
+ # main_author + sorting title
90
+ # which is the mods approximation of the value created for a marc record
91
+ # @return [String] value for author_sort field
92
+ def sw_sort_author
93
+ # substitute java Character.MAX_CODE_POINT for nil main_author so missing main authors sort last
94
+ val = '' + (main_author_w_date ? main_author_w_date : "\u{FFFF} ") + ( sort_title ? sort_title : '')
95
+ val.gsub(/[[:punct:]]*/, '')
96
+ end
97
+
98
+
53
99
  end # class Record
54
100
  end # Module Mods
55
101
  end # Module Stanford
@@ -1,5 +1,5 @@
1
1
  module Stanford
2
2
  module Mods
3
- VERSION = "0.0.4"
3
+ VERSION = "0.0.5"
4
4
  end
5
5
  end
data/spec/name_spec.rb ADDED
@@ -0,0 +1,242 @@
1
+ require 'spec_helper'
2
+
3
+ describe "name/author concepts" do
4
+ before(:all) do
5
+ @smods_rec = Stanford::Mods::Record.new
6
+ @ns_decl = "xmlns='#{Mods::MODS_NS}'"
7
+ end
8
+ context "main_author_w_date" do
9
+ before(:all) do
10
+ @mods_start = "<mods #{@ns_decl}>"
11
+ @mods_end = "</mods>"
12
+ @plain_no_role = "<name><namePart>plain_no_role</namePart></name>"
13
+ @plain_creator_code = "<name>
14
+ <namePart>plain_creator_code</namePart>
15
+ <role><roleTerm type='code' authority='marcrelator'>cre</roleTerm></role>
16
+ </name>"
17
+ @plain_creator_text = "<name>
18
+ <namePart>plain_creator_text</namePart>
19
+ <role><roleTerm type='text' authority='marcrelator'>Creator</roleTerm></role>
20
+ </name>"
21
+ @plain_creator_non_mr = "<name>
22
+ <namePart>plain_creator_non_mr</namePart>
23
+ <role><roleTerm type='text'>Creator</roleTerm></role>
24
+ </name>"
25
+ @plain_author_code = "<name>
26
+ <namePart>plain_author_code</namePart>
27
+ <role><roleTerm type='code' authority='marcrelator'>aut</roleTerm></role>
28
+ </name>"
29
+ @plain_author_text = "<name>
30
+ <namePart>plain_author_text</namePart>
31
+ <role><roleTerm type='text' authority='marcrelator'>Author</roleTerm></role>
32
+ </name>"
33
+ @plain_author_non_mr = "<name>
34
+ <namePart>plain_author_non_mr</namePart>
35
+ <role><roleTerm type='text'>Author</roleTerm></role>
36
+ </name>"
37
+ @plain_other_role_mr = "<name>
38
+ <namePart>plain_other_role_mr</namePart>
39
+ <role><roleTerm type='text' authority='marcrelator'>Actor</roleTerm></role>
40
+ </name>"
41
+
42
+ @personal_no_role = "<name><namePart type='personal'>personal_no_role</namePart></name>"
43
+ @personal_creator_code = "<name>
44
+ <namePart type='personal'>personal_creator_code</namePart>
45
+ <role><roleTerm type='code' authority='marcrelator'>cre</roleTerm></role>
46
+ </name>"
47
+ @personal_author_text = "<name>
48
+ <namePart type='personal'>personal_author_text</namePart>
49
+ <role><roleTerm type='text' authority='marcrelator'>Author</roleTerm></role>
50
+ </name>"
51
+ @personal_other_role = "<name>
52
+ <namePart type='personal'>personal_author_text</namePart>
53
+ <role><roleTerm type='text' authority='marcrelator'>Auctioneer</roleTerm></role>
54
+ </name>"
55
+ @corp_no_role = "<name><namePart type='corporate'>corp_no_role</namePart></name>"
56
+ @corp_author_code = "<name>
57
+ <namePart type='corporate'>corp_author_code</namePart>
58
+ <role><roleTerm type='code' authority='marcrelator'>aut</roleTerm></role>
59
+ </name>"
60
+ @corp_creator_text = "<name>
61
+ <namePart type='corporate'>corp_creator_text</namePart>
62
+ <role><roleTerm type='text' authority='marcrelator'>Creator</roleTerm></role>
63
+ </name>"
64
+ @other_no_role = "<name><namePart type='conference'>conference_no_role</namePart></name>"
65
+ end
66
+ context "marcrelator role Creator" do
67
+ it "should find role with roleTerm type text" do
68
+ @smods_rec.from_str(@mods_start + @plain_creator_text + @mods_end)
69
+ @smods_rec.main_author_w_date.should == 'plain_creator_text'
70
+ end
71
+ it "should find role with roleTerm type code" do
72
+ @smods_rec.from_str(@mods_start + @plain_creator_code + @mods_end)
73
+ @smods_rec.main_author_w_date.should == 'plain_creator_code'
74
+ end
75
+ it "should skip names when role isn't marcrelator authority" do
76
+ @smods_rec.from_str(@mods_start + @plain_creator_non_mr + @mods_end)
77
+ @smods_rec.main_author_w_date.should == nil
78
+ end
79
+ it "should skip names without roles in favor of marcrelator role of 'Creator'" do
80
+ @smods_rec.from_str(@mods_start + @personal_no_role + @plain_creator_text + @other_no_role + @mods_end)
81
+ @smods_rec.main_author_w_date.should == 'plain_creator_text'
82
+ @smods_rec.from_str(@mods_start + @corp_no_role + @plain_creator_code + @mods_end)
83
+ @smods_rec.main_author_w_date.should == 'plain_creator_code'
84
+ end
85
+ it "shouldn't care about name type" do
86
+ @smods_rec.from_str(@mods_start + @personal_creator_code + @corp_creator_text + @mods_end)
87
+ @smods_rec.main_author_w_date.should == 'personal_creator_code'
88
+ @smods_rec.from_str(@mods_start + @personal_no_role + @corp_creator_text + @mods_end)
89
+ @smods_rec.main_author_w_date.should == 'corp_creator_text'
90
+ end
91
+ end
92
+
93
+ context "marcrelator role Author" do
94
+ it "should find role with roleTerm type text" do
95
+ @smods_rec.from_str(@mods_start + @plain_author_text + @mods_end)
96
+ @smods_rec.main_author_w_date.should == 'plain_author_text'
97
+ end
98
+ it "should find role with roleTerm type code" do
99
+ @smods_rec.from_str(@mods_start + @plain_author_code + @mods_end)
100
+ @smods_rec.main_author_w_date.should == 'plain_author_code'
101
+ end
102
+ it "should skip names when role isn't marcrelator authority" do
103
+ @smods_rec.from_str(@mods_start + @plain_author_non_mr + @mods_end)
104
+ @smods_rec.main_author_w_date.should == nil
105
+ end
106
+ it "should skip names without roles in favor of marcrelator role of 'Author'" do
107
+ @smods_rec.from_str(@mods_start + @personal_no_role + @plain_author_text + @other_no_role + @mods_end)
108
+ @smods_rec.main_author_w_date.should == 'plain_author_text'
109
+ @smods_rec.from_str(@mods_start + @corp_no_role + @personal_no_role + @plain_author_code + @mods_end)
110
+ @smods_rec.main_author_w_date.should == 'plain_author_code'
111
+ end
112
+ it "shouldn't care about name type" do
113
+ @smods_rec.from_str(@mods_start + @personal_author_text + @corp_author_code + @mods_end)
114
+ @smods_rec.main_author_w_date.should == 'personal_author_text'
115
+ @smods_rec.from_str(@mods_start + @personal_no_role + @corp_author_code + @mods_end)
116
+ @smods_rec.main_author_w_date.should == 'corp_author_code'
117
+ end
118
+ end
119
+
120
+ it "should be a String" do
121
+ @smods_rec.from_str(@mods_start + @personal_author_text + @corp_creator_text + @mods_end)
122
+ @smods_rec.main_author_w_date.should be_an_instance_of(String)
123
+ end
124
+
125
+ it "should take first name with marcrelator role of 'Creator' or 'Author'" do
126
+ @smods_rec.from_str(@mods_start + @personal_author_text + @corp_creator_text + @mods_end)
127
+ @smods_rec.main_author_w_date.should == 'personal_author_text'
128
+ @smods_rec.from_str(@mods_start + @corp_creator_text + @personal_creator_code + @mods_end)
129
+ @smods_rec.main_author_w_date.should == 'corp_creator_text'
130
+ end
131
+
132
+ it "should take the first name without a role if there are no instances of marcrelator role 'Creator' or 'Actor'" do
133
+ @smods_rec.from_str(@mods_start + @plain_author_non_mr + @personal_other_role + @personal_no_role + @plain_no_role + @mods_end)
134
+ @smods_rec.main_author_w_date.should == 'personal_no_role'
135
+ end
136
+
137
+ it "should be nil if there is no name with marcrelator role of 'Creator' or 'Author' and no name without a role" do
138
+ @smods_rec.from_str(@mods_start + @plain_author_non_mr + @personal_other_role + @mods_end)
139
+ @smods_rec.main_author_w_date.should == nil
140
+ end
141
+
142
+ it "should use the display name if it is present" do
143
+ m = "<mods #{@ns_decl}><name type='personal'>
144
+ <namePart type='given'>John</namePart>
145
+ <namePart type='family'>Huston</namePart>
146
+ <displayForm>q</displayForm>
147
+ </name>
148
+ <name type='personal'><namePart>Crusty The Clown</namePart></name>
149
+ <name type='corporate'><namePart>Watchful Eye</namePart></name>
150
+ <name type='corporate'>
151
+ <namePart>Exciting Prints</namePart>
152
+ <role><roleTerm type='text'>lithographer</roleTerm></role>
153
+ </name>
154
+ </mods>"
155
+ @smods_rec.from_str(m)
156
+ @smods_rec.main_author_w_date.should == 'q'
157
+ end
158
+ it "should include dates, when available" do
159
+ m = "<mods #{@ns_decl}><name type='personal'>
160
+ <namePart>personal</namePart>
161
+ <namePart type='date'>1984-</namePart>
162
+ </name></mods>"
163
+ @smods_rec.from_str(m)
164
+ @smods_rec.main_author_w_date.should == 'personal, 1984-'
165
+ m = "<mods #{@ns_decl}><name>
166
+ <namePart>plain</namePart>
167
+ <namePart type='date'>1954-</namePart>
168
+ </name></mods>"
169
+ @smods_rec.from_str(m)
170
+ @smods_rec.main_author_w_date.should == 'plain, 1954-'
171
+ m = "<mods #{@ns_decl}><name type='corporate'>
172
+ <namePart>corporate</namePart>
173
+ <namePart type='date'>1990-</namePart>
174
+ </name></mods>"
175
+ @smods_rec.from_str(m)
176
+ @smods_rec.main_author_w_date.should == 'corporate, 1990-'
177
+ end
178
+ end # main_author_w_date
179
+
180
+ context "additional_authors_w_dates" do
181
+ before(:all) do
182
+ m = "<mods #{@ns_decl}><name type='personal'>
183
+ <namePart type='given'>John</namePart>
184
+ <namePart type='family'>Huston</namePart>
185
+ <displayForm>q</displayForm>
186
+ </name>
187
+ <name type='personal'>
188
+ <namePart>Crusty The Clown</namePart>
189
+ <namePart type='date'>1990-</namePart>
190
+ </name>
191
+ <name type='corporate'>
192
+ <namePart>Watchful Eye</namePart>
193
+ <namePart type='date'>1850-</namePart>
194
+ </name>
195
+ <name type='corporate'>
196
+ <namePart>Exciting Prints</namePart>
197
+ <role><roleTerm type='text'>lithographer</roleTerm></role>
198
+ </name>
199
+ <name>
200
+ <namePart>plain</namePart>
201
+ </name>
202
+ <name type='conference'>
203
+ <namePart>conference</namePart>
204
+ </name>
205
+ <name type='family'>
206
+ <namePart>family</namePart>
207
+ </name>
208
+ </mods>"
209
+ @smods_rec.from_str(m)
210
+ @addl_authors = @smods_rec.additional_authors_w_dates
211
+ end
212
+ it "should be an Array of Strings" do
213
+ @addl_authors.should be_an_instance_of(Array)
214
+ @addl_authors.first.should be_an_instance_of(String)
215
+ end
216
+ it "should not include main author" do
217
+ @addl_authors.should_not include(@smods_rec.main_author_w_date)
218
+ end
219
+ it "should include personal authors that are not main author" do
220
+ @addl_authors.should include('Crusty The Clown, 1990-')
221
+ end
222
+ it "should include corporate (and other) authors that are not main author" do
223
+ @addl_authors.should include('Watchful Eye, 1850-')
224
+ @addl_authors.should include('Exciting Prints')
225
+ end
226
+ it "should include plain authors" do
227
+ @addl_authors.should include('plain')
228
+ end
229
+ it "should include conference and other typed authors" do
230
+ @addl_authors.should include('conference')
231
+ @addl_authors.should include('family')
232
+ end
233
+ it "should include dates, when available" do
234
+ @addl_authors.should include('Crusty The Clown, 1990-')
235
+ @addl_authors.should include('Watchful Eye, 1850-')
236
+ end
237
+ it "should not include roles" do
238
+ @addl_authors.find { |a| a =~ Regexp.new('lithographer') }.should == nil
239
+ end
240
+ end # additional_authors_w_dates
241
+
242
+ end
@@ -0,0 +1,118 @@
1
+ # encoding: UTF-8
2
+ require 'spec_helper'
3
+ require 'stanford-mods/searchworks'
4
+
5
+ describe "Searchworks mixin for Stanford::Mods::Record" do
6
+
7
+ before(:all) do
8
+ @smods_rec = Stanford::Mods::Record.new
9
+ @ns_decl = "xmlns='#{Mods::MODS_NS}'"
10
+ end
11
+
12
+ it "sw_access_facet" do
13
+ @smods_rec.sw_access_facet.should == ['Online']
14
+ end
15
+
16
+ context "languages" do
17
+ it "should use the SearchWorks controlled vocabulary" do
18
+ m = "<mods #{@ns_decl}><language><languageTerm authority='iso639-2b' type='code'>per ara, dut</languageTerm></language></mods>"
19
+ @smods_rec.from_str m
20
+ langs = @smods_rec.sw_language_facet
21
+ langs.size.should == 3
22
+ langs.should include("Persian")
23
+ langs.should include("Arabic")
24
+ langs.should include("Dutch")
25
+ langs.should_not include("Dutch; Flemish")
26
+ end
27
+ it "should not have duplicates" do
28
+ m = "<mods #{@ns_decl}><language><languageTerm type='code' authority='iso639-2b'>eng</languageTerm><languageTerm type='text'>English</languageTerm></language></mods>"
29
+ @smods_rec.from_str m
30
+ langs = @smods_rec.sw_language_facet
31
+ langs.size.should == 1
32
+ langs.should include("English")
33
+ end
34
+ end
35
+
36
+ context "authors" do
37
+ before(:all) do
38
+ m = "<mods #{@ns_decl}><name type='personal'>
39
+ <namePart type='given'>John</namePart>
40
+ <namePart type='family'>Huston</namePart>
41
+ <displayForm>q</displayForm>
42
+ </name>
43
+ <name type='personal'>
44
+ <namePart>Crusty The Clown</namePart>
45
+ <namePart type='date'>1990-</namePart>
46
+ </name>
47
+ <name type='corporate'>
48
+ <namePart>Watchful Eye</namePart>
49
+ <namePart type='date'>1850-</namePart>
50
+ </name>
51
+ <name type='corporate'>
52
+ <namePart>Exciting Prints</namePart>
53
+ </name>
54
+ <name>
55
+ <namePart>plain</namePart>
56
+ </name>
57
+ <name type='conference'>
58
+ <namePart>conference</namePart>
59
+ </name>
60
+ <name type='family'>
61
+ <namePart>family</namePart>
62
+ </name>
63
+ <titleInfo><title>Jerk</title><nonSort>The </nonSort></titleInfo>
64
+ </mods>"
65
+ @smods_rec.from_str(m)
66
+ end
67
+ it "main author (for author_1xx_search)" do
68
+ @smods_rec.should_receive(:main_author_w_date) # in stanford-mods.rb
69
+ @smods_rec.sw_main_author
70
+ end
71
+ it "additional authors (for author_7xx_search)" do
72
+ @smods_rec.should_receive(:additional_authors_w_dates) # in stanford-mods.rb
73
+ @smods_rec.sw_addl_authors
74
+ end
75
+ it "person_authors (for author_person_facet, author_person_display)" do
76
+ @smods_rec.should_receive(:personal_names_w_dates) # in Mods gem
77
+ @smods_rec.sw_person_authors
78
+ end
79
+ it "non-person authors (for author_other_facet)" do
80
+ @smods_rec.sw_impersonal_authors.should == ['Watchful Eye, 1850-', 'Exciting Prints', 'plain', 'conference', 'family']
81
+ end
82
+ it "corporate_authors (for author_corp_display)" do
83
+ @smods_rec.sw_corporate_authors.should == ['Watchful Eye, 1850-', 'Exciting Prints']
84
+ end
85
+ it "meeting_authors (for author_meeting_display)" do
86
+ @smods_rec.sw_meeting_authors.should == ['conference']
87
+ end
88
+ context "author sort" do
89
+ it "should be a String" do
90
+ @smods_rec.sw_sort_author.should == 'qJerk'
91
+ end
92
+ it "should include the main author, as retrieved by :main_author_w_date" do
93
+ @smods_rec.should_receive(:main_author_w_date) # in stanford-mods.rb
94
+ @smods_rec.sw_sort_author
95
+ end
96
+ it "should append the sort title, as retrieved by :sort_title" do
97
+ @smods_rec.should_receive(:sort_title) # in Mods gem
98
+ @smods_rec.sw_sort_author
99
+ end
100
+ it "should not begin or end with whitespace" do
101
+ @smods_rec.sw_sort_author.should == @smods_rec.sw_sort_author.strip
102
+ end
103
+ it "should substitute the java Character.MAX_CODE_POINT for nil main_author so missing main authors sort last" do
104
+ r = Stanford::Mods::Record.new
105
+ r.from_str "<mods #{@ns_decl}><titleInfo><title>Jerk</title></titleInfo></mods>"
106
+ r.sw_sort_author.should =~ / Jerk$/
107
+ r.sw_sort_author.should match("\u{FFFF}")
108
+ r.sw_sort_author.should match("\xEF\xBF\xBF")
109
+ end
110
+ it "should not have any ascii punctuation marks" do
111
+ r = Stanford::Mods::Record.new
112
+ r.from_str "<mods #{@ns_decl}><titleInfo><title>J,e.r;;;k</title></titleInfo></mods>"
113
+ r.sw_sort_author.should =~ / Jerk$/
114
+ end
115
+ end
116
+ end
117
+
118
+ end
@@ -3,6 +3,9 @@ require 'stanford-mods/searchworks'
3
3
 
4
4
  describe "Values for SearchWorks Solr" do
5
5
  # from https://consul.stanford.edu/display/NGDE/Required+and+Recommended+Solr+Fields+for+SearchWorks+documents
6
+ before(:all) do
7
+ @ns_decl = "xmlns='#{Mods::MODS_NS}'"
8
+ end
6
9
 
7
10
  context "required fields" do
8
11
  context "DOR specific" do
@@ -39,6 +42,7 @@ describe "Values for SearchWorks Solr" do
39
42
  it "access_facet" do
40
43
  Stanford::Mods::Record.new.sw_access_facet.should == ['Online']
41
44
  end
45
+ # title convenience methods are implemented in the Mods gem; no special work here
42
46
  context "title fields" do
43
47
  context "for display" do
44
48
  it "short title" do
@@ -76,8 +80,8 @@ describe "Values for SearchWorks Solr" do
76
80
  end
77
81
  context "language" do
78
82
  it "should use the SearchWorks controlled vocabulary" do
79
- m = '<mods><language><languageTerm authority="iso639-2b" type="code">per ara, dut</languageTerm></language></mods>'
80
- r = Stanford::Mods::Record.new
83
+ m = "<mods #{@ns_decl}><language><languageTerm authority='iso639-2b' type='code'>per ara, dut</languageTerm></language></mods>"
84
+ r = Stanford::Mods::Record.new()
81
85
  r.from_str(m)
82
86
  langs = r.sw_language_facet
83
87
  langs.size.should == 3
@@ -87,7 +91,7 @@ describe "Values for SearchWorks Solr" do
87
91
  langs.should_not include("Dutch; Flemish")
88
92
  end
89
93
  it "should not have duplicates" do
90
- m = '<mods><language><languageTerm type="code" authority="iso639-2b">eng</languageTerm><languageTerm type="text">English</languageTerm></language></mods>'
94
+ m = "<mods #{@ns_decl}><language><languageTerm type='code' authority='iso639-2b'>eng</languageTerm><languageTerm type='text'>English</languageTerm></language></mods>"
91
95
  r = Stanford::Mods::Record.new
92
96
  r.from_str(m)
93
97
  langs = r.sw_language_facet
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stanford-mods
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-11-13 00:00:00.000000000 Z
13
+ date: 2012-12-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: mods
@@ -151,6 +151,8 @@ files:
151
151
  - lib/stanford-mods/searchworks_languages.rb
152
152
  - lib/stanford-mods/version.rb
153
153
  - spec/kolb_spec.rb
154
+ - spec/name_spec.rb
155
+ - spec/searchworks_spec.rb
154
156
  - spec/spec_helper.rb
155
157
  - spec/values_for_req_sw_spec.rb
156
158
  - stanford-mods.gemspec
@@ -168,7 +170,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
168
170
  version: '0'
169
171
  segments:
170
172
  - 0
171
- hash: 3798331701017040481
173
+ hash: 2263895694555249166
172
174
  required_rubygems_version: !ruby/object:Gem::Requirement
173
175
  none: false
174
176
  requirements:
@@ -177,7 +179,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
177
179
  version: '0'
178
180
  segments:
179
181
  - 0
180
- hash: 3798331701017040481
182
+ hash: 2263895694555249166
181
183
  requirements: []
182
184
  rubyforge_project:
183
185
  rubygems_version: 1.8.24
@@ -186,6 +188,8 @@ specification_version: 3
186
188
  summary: Stanford specific wrangling of MODS metadata
187
189
  test_files:
188
190
  - spec/kolb_spec.rb
191
+ - spec/name_spec.rb
192
+ - spec/searchworks_spec.rb
189
193
  - spec/spec_helper.rb
190
194
  - spec/values_for_req_sw_spec.rb
191
195
  has_rdoc: