stanford-mods 1.1.4 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 263c241c3db2224132441cf57740be7ac0c73495
4
- data.tar.gz: 735eb6fe63c5227159a69b271ce5af61024f2f83
3
+ metadata.gz: 209b8e1644beeed8c28948b1acdba20b7d63a414
4
+ data.tar.gz: d3f4b45f2d6f990c3084a67e4eca651a83ecd7e0
5
5
  SHA512:
6
- metadata.gz: 38de7ce352621e92605efb02bbccf6c79200779e7648a766e72592eb334236cead01a7470dcc2cd7e3846ba5fc5a299f8a5c836977784b4a87eaf638ae4beb28
7
- data.tar.gz: b2380744c02745e5a545350a39fa904cbc531367018f1b2054d3346dd17053c928be1cc9382ac5e1f1a234f01e115b6aac02f7e221d1fc3a59188b84a2da18c9
6
+ metadata.gz: 00b048ecb711ea342bb7071bf5422f06c48f40bf81b7b67590211d9eb0a59774d28991396dfc1c0aa54c7cbe354407183fbd87f28c318517c0a7d08c12bceca4
7
+ data.tar.gz: a9b70f9cf519fae69b9e557281b156913735d465e83044ab6286caafeac0ca5ce2dde623cbdac58d91522e547041c175c602f5cb3cd39b5b68aed38fcc3ba772
data/README.md ADDED
@@ -0,0 +1,91 @@
1
+ # Stanford::Mods
2
+
3
+ [<img
4
+ src="https://secure.travis-ci.org/sul-dlss/stanford-mods.png?branch=master" alt="Build Status"/>](http://travis-ci.org/sul-dlss/stanford-mods) [<img
5
+ src="https://coveralls.io/repos/sul-dlss/stanford-mods/badge.png" alt="Coverage Status"/>](https://coveralls.io/r/sul-dlss/stanford-mods) [<img
6
+ src="https://gemnasium.com/sul-dlss/stanford-mods.png" alt="Dependency Status"/>](https://gemnasium.com/sul-dlss/stanford-mods) [<img
7
+ src="https://badge.fury.io/rb/stanford-mods.svg" alt="Gem Version"/>](http://badge.fury.io/rb/stanford-mods)
8
+
9
+ A Gem with Stanford specific wranglings of MODS (Metadata Object Description Schema)
10
+ metadata from DOR, the Stanford Digital Object Repository.
11
+
12
+ Source code at [github](https://github.com/sul-dlss/stanford-mods/).
13
+
14
+ Generated API docs at [rubydoc.info](http://rubydoc.info/github/sul-dlss/stanford-mods/).
15
+
16
+ ## Installation
17
+
18
+ Add this line to your application's Gemfile:
19
+
20
+ gem 'stanford-mods'
21
+
22
+ And then execute:
23
+
24
+ $ bundle
25
+
26
+ Or install it yourself as:
27
+
28
+ $ gem install stanford-mods
29
+
30
+ ## Usage
31
+
32
+ 1. add stanford-mods to your gemfile
33
+ 2.
34
+ ```ruby
35
+ require 'stanford-mods'
36
+ m = Stanford::Mods::Record.new
37
+ m.from_str('<mods><genre>ape</genre></mods>')
38
+ m.genre # <Nokogiri::XML::Element:0x3fe07b48bb24 name="genre" children=[#<Nokogiri::XML::Text:0x3fe07a09a7dc "ape">]>
39
+ m.genre.text # "ape"
40
+ ```
41
+
42
+ Example Using SearchWorks Mixins:
43
+
44
+ ```ruby
45
+ require 'stanford-mods/searchworks'
46
+ m = Stanford::Mods::Record.new
47
+ m.from_str('<mods><language><languageTerm authority="iso639-2b" type="code">dut</languageTerm></language></mods>')
48
+ m.language_facet # ['Dutch'], from Searchworks mixin
49
+ m.languages # ['Dutch; Flemish'] from mods gem
50
+ ```
51
+
52
+ ## Contributing
53
+
54
+ 1. Fork it
55
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
56
+ 3. Write code and tests.
57
+ 4. Commit your changes (`git commit -am 'Added some feature'`)
58
+ 5. Push to the branch (`git push origin my-new-feature`)
59
+ 6. Create new Pull Request
60
+
61
+ ## Releases
62
+ * **1.1.2** Corrected java `Character.MAX_CODE_POINT` value from u{FFFF} to u{10FFFF}
63
+ * **1.1.1** Minor bug fixes
64
+ * **1.1.0** Changed mechanism for determining dates for display only and for
65
+ indexing, sorting, and faceting and removed deprecated pub_date_group method
66
+ * **1.0.3** `format_main` value 'Article' is now 'Book'
67
+ * **1.0.2** add `format_main` and `sw_genre` tests to searchworks.rb
68
+ * **1.0.1** `sw_title_display` keeps appropriate trailing punct more or less per spec in solrmarc-sw `sw_index.properties`
69
+ * **1.0.0** `sw_full_title` now includes partName and partNumber;
70
+ `sw_title_display` created to be like `sw_full_title` but without trailing punctuation; sw format for typeOfResource sound recording; genre value is
71
+ librettos, plural; sw format algorithm accommodates first letter upcase; genre value report does NOT map to a format, genre value 'project report'
72
+ with ToR text is 'Book'
73
+ * **0.0.27** add genres 'Issue brief', 'Book chapter' and 'Working paper' to map to searchworks format 'Book'
74
+ * **0.0.26** map typeOfResource 'sound recording-musical' to searchworks format 'Music - Recording' with spaces
75
+ * **0.0.25** map typeOfResource 'text' and genre 'report' to searchworks format 'Book'
76
+ * **0.0.24** Largely cosmetic refactoring for easier maintenance.
77
+ * **0.0.23** Added logic for dealing with "u-notation" approximate dates, e.g., 198u
78
+ * **0.0.20** Added mapping for typeOfResource notated music
79
+ * **0.0.19** Additional mappings, including Hydrus formats (GRYPHONDOR-207)
80
+ * **0.0.11** escape regex special characters when using short title in a regex
81
+ * **0.0.10** get rid of `ignore_me` files
82
+ * **0.0.9** add `sw_subject_names` and `sw_subject_titles` methods to searchworks mixin
83
+ * **0.0.8** require stanford-mods/searchworks in stanford-mods (top level)
84
+ * **0.0.7** added `sw_geographic_search` to searchworks mixin
85
+ * **0.0.6** various title methods added to searchworks mixin
86
+ * **0.0.5** `main_author_w_date`, `additional_authors_w_dates` added to Stanford::Mods::Record; various author methods added to searchworks mixin
87
+ * **0.0.4** KolbRecord started
88
+ * **0.0.3** began SearchWorks mixins with `sw_access_facet` and `sw_language_facet`
89
+ * **0.0.2** add usage instructions to README
90
+ * **0.0.1** Initial commit - grab name
91
+
data/Rakefile CHANGED
@@ -32,8 +32,8 @@ begin
32
32
 
33
33
  YARD::Rake::YardocTask.new(:doc) do |yt|
34
34
  yt.files = Dir.glob(File.join(project_root, 'lib', '**', '*.rb')) +
35
- [ File.join(project_root, 'README.rdoc') ]
36
- yt.options = ['--output-dir', doc_dest_dir, '--readme', 'README.rdoc', '--title', 'Stanford-Mods Documentation']
35
+ [ File.join(project_root, 'README.md') ]
36
+ yt.options = ['--output-dir', doc_dest_dir, '--readme', 'README.md', '--title', 'Stanford-Mods Documentation']
37
37
  end
38
38
  rescue LoadError
39
39
  desc "Generate YARD Documentation"
@@ -41,4 +41,3 @@ rescue LoadError
41
41
  abort "Please install the YARD gem to generate rdoc."
42
42
  end
43
43
  end
44
-
@@ -191,7 +191,7 @@ module Stanford
191
191
  end
192
192
 
193
193
  val = '' + ( sw_full_title ? sw_full_title : '')
194
- val.sub!(Regexp.new("^" + nonSort), '') if nonSort
194
+ val.sub!(Regexp.new("^" + Regexp.escape(nonSort)), '') if nonSort
195
195
  val.gsub!(/[[:punct:]]*/, '').strip
196
196
  val.squeeze(" ").strip
197
197
  end
@@ -425,7 +425,7 @@ module Stanford
425
425
  year = []
426
426
  pruned_dates = []
427
427
  dates.each do |f_date|
428
- #remove ? and []
428
+ #remove ? and []
429
429
  if (f_date.length == 4 && f_date.end_with?('?'))
430
430
  pruned_dates << f_date.gsub('?','0')
431
431
  else
@@ -1,6 +1,6 @@
1
1
  module Stanford
2
2
  module Mods
3
3
  # this is the Ruby Gem version
4
- VERSION = "1.1.4"
4
+ VERSION = "1.1.5"
5
5
  end
6
6
  end
@@ -4,7 +4,6 @@ require 'spec_helper'
4
4
  describe "Date methods (searchworks.rb)" do
5
5
 
6
6
  before(:all) do
7
- @smods_rec = Stanford::Mods::Record.new
8
7
  @ns_decl = "xmlns='#{Mods::MODS_NS}'"
9
8
  end
10
9
 
@@ -22,11 +21,14 @@ describe "Date methods (searchworks.rb)" do
22
21
  end
23
22
 
24
23
  context "pub_date" do
24
+ before :each do
25
+ @smods_rec = Stanford::Mods::Record.new
26
+ end
27
+
25
28
  it "should choose the first date" do
26
29
  m = "<mods #{@ns_decl}><originInfo>
27
30
  <dateCreated>1904</dateCreated>
28
31
  </originInfo></mods>"
29
- @smods_rec = Stanford::Mods::Record.new
30
32
  @smods_rec.from_str(m)
31
33
  expect(@smods_rec.pub_date).to eq('1904')
32
34
  end
@@ -34,7 +36,6 @@ describe "Date methods (searchworks.rb)" do
34
36
  m = "<mods #{@ns_decl}><originInfo>
35
37
  <dateCreated>Aug. 3rd, 1886</dateCreated>
36
38
  </originInfo></mods>"
37
- @smods_rec = Stanford::Mods::Record.new
38
39
  @smods_rec.from_str(m)
39
40
  expect(@smods_rec.pub_date).to eq('1886')
40
41
  end
@@ -42,7 +43,6 @@ describe "Date methods (searchworks.rb)" do
42
43
  m = "<mods #{@ns_decl}><originInfo>
43
44
  <dateCreated>Aug. 3rd, [18]86?</dateCreated>
44
45
  </originInfo></mods>"
45
- @smods_rec = Stanford::Mods::Record.new
46
46
  @smods_rec.from_str(m)
47
47
  expect(@smods_rec.pub_date).to eq('1886')
48
48
  end
@@ -50,31 +50,26 @@ describe "Date methods (searchworks.rb)" do
50
50
  m = "<mods #{@ns_decl}><originInfo>
51
51
  <dateCreated>early 1890s</dateCreated>
52
52
  </originInfo></mods>"
53
- @smods_rec = Stanford::Mods::Record.new
54
53
  @smods_rec.from_str(m)
55
54
  expect(@smods_rec.pub_date).to eq('1890')
56
55
  end
57
56
  it 'should choose a date ending with CE if there are multiple dates' do
58
57
  m = "<mods #{@ns_decl}><originInfo><dateIssued>7192 AM (li-Adam) / 1684 CE</dateIssued><issuance>monographic</issuance></originInfo>"
59
- @smods_rec = Stanford::Mods::Record.new
60
58
  @smods_rec.from_str(m)
61
59
  expect(@smods_rec.pub_date).to eq('1684')
62
60
  end
63
61
  it 'should handle hyphenated range dates' do
64
62
  m = "<mods #{@ns_decl}><originInfo><dateIssued>1282 AH / 1865-6 CE</dateIssued><issuance>monographic</issuance></originInfo>"
65
- @smods_rec = Stanford::Mods::Record.new
66
63
  @smods_rec.from_str(m)
67
64
  expect(@smods_rec.pub_date).to eq('1865')
68
65
  end
69
66
  it 'should work with multiple 4 digit dates' do
70
67
  m = "<mods #{@ns_decl}><originInfo><dateCreated>Text dated June 4, 1594; miniatures added by 1596</dateCreated></originInfo>"
71
- @smods_rec = Stanford::Mods::Record.new
72
68
  @smods_rec.from_str(m)
73
- expect(@smods_rec.pub_date).to eq('1594')
69
+ expect(@smods_rec.pub_date).to eq('1594')
74
70
  end
75
71
  it 'should work on 3 digit BC dates' do
76
72
  m = "<mods #{@ns_decl}><originInfo><dateCreated>300 B.C.</dateCreated></originInfo>"
77
- @smods_rec = Stanford::Mods::Record.new
78
73
  @smods_rec.from_str(m)
79
74
  expect(@smods_rec.pub_year).to eq('-700')
80
75
  expect(@smods_rec.pub_date).to eq('-700')
@@ -83,7 +78,6 @@ describe "Date methods (searchworks.rb)" do
83
78
  end
84
79
  it 'should handle century based dates' do
85
80
  m = "<mods #{@ns_decl}><originInfo><dateIssued>13th century AH / 19th CE</dateIssued><issuance>monographic</issuance></originInfo>"
86
- @smods_rec = Stanford::Mods::Record.new
87
81
  @smods_rec.from_str(m)
88
82
  expect(@smods_rec.pub_date_facet).to eq('19th century')
89
83
  expect(@smods_rec.pub_date_sort).to eq('1800')
@@ -91,7 +85,6 @@ describe "Date methods (searchworks.rb)" do
91
85
  end
92
86
  it 'should handle multiple CE dates' do
93
87
  m = "<mods #{@ns_decl}><originInfo><dateIssued>6 Dhu al-Hijjah 923 AH / 1517 CE -- 7 Rabi I 924 AH / 1518 CE</dateIssued><issuance>monographic</issuance></originInfo>"
94
- @smods_rec = Stanford::Mods::Record.new
95
88
  @smods_rec.from_str(m)
96
89
  expect(@smods_rec.pub_date).to eq('1517')
97
90
  expect(@smods_rec.pub_date_sort).to eq('1517')
@@ -99,7 +92,6 @@ describe "Date methods (searchworks.rb)" do
99
92
  end
100
93
  it 'should handle this case from walters' do
101
94
  m = "<mods #{@ns_decl}><originInfo><dateIssued>Late 14th or early 15th century CE</dateIssued><issuance>monographic</issuance></originInfo>"
102
- @smods_rec = Stanford::Mods::Record.new
103
95
  @smods_rec.from_str(m)
104
96
  expect(@smods_rec.pub_date).to eq('14--')
105
97
  expect(@smods_rec.pub_date_sort).to eq('1400')
@@ -107,7 +99,6 @@ describe "Date methods (searchworks.rb)" do
107
99
  end
108
100
  it 'should work on 3 digit dates' do
109
101
  m = "<mods #{@ns_decl}><originInfo><dateIssued>966 CE</dateIssued><issuance>monographic</issuance></originInfo>"
110
- @smods_rec = Stanford::Mods::Record.new
111
102
  @smods_rec.from_str(m)
112
103
  expect(@smods_rec.pub_date).to eq('966')
113
104
  expect(@smods_rec.pub_date_sort).to eq('0966')
@@ -115,7 +106,6 @@ describe "Date methods (searchworks.rb)" do
115
106
  end
116
107
  it 'should work on 3 digit dates' do
117
108
  m = "<mods #{@ns_decl}><originInfo><dateIssued>3rd century AH / 9th CE</dateIssued><issuance>monographic</issuance></originInfo>"
118
- @smods_rec = Stanford::Mods::Record.new
119
109
  @smods_rec.from_str(m)
120
110
  expect(@smods_rec.pub_date).to eq('8--')
121
111
  expect(@smods_rec.pub_date_sort).to eq('0800')
@@ -123,7 +113,6 @@ describe "Date methods (searchworks.rb)" do
123
113
  end
124
114
  it 'should use the dateIssued without marc encoding for pub_date_display and the one with marc encoding for indexing, sorting and faceting' do
125
115
  m = "<mods #{@ns_decl}><originInfo><dateIssued>[186-?]</dateIssued><dateIssued encoding=\"marc\">1860</dateIssued><issuance>monographic</issuance></originInfo>"
126
- @smods_rec = Stanford::Mods::Record.new
127
116
  @smods_rec.from_str(m)
128
117
  expect(@smods_rec.pub_date_display).to eq('[186-?]')
129
118
  expect(@smods_rec.pub_date).to eq('1860')
@@ -132,7 +121,6 @@ describe "Date methods (searchworks.rb)" do
132
121
  end
133
122
  it 'should use the dateIssued without marc encoding for pub_date_display and the one with marc encoding for indexing, sorting and faceting' do
134
123
  m = "<mods #{@ns_decl}><originInfo><dateIssued>1860?]</dateIssued><dateIssued encoding=\"marc\">186?</dateIssued><issuance>monographic</issuance></originInfo>"
135
- @smods_rec = Stanford::Mods::Record.new
136
124
  @smods_rec.from_str(m)
137
125
  expect(@smods_rec.pub_date_display).to eq('1860?]')
138
126
  expect(@smods_rec.pub_date).to eq('1860')
@@ -353,8 +353,9 @@ describe "Subject fields (searchworks.rb)" do
353
353
  end
354
354
  it "should be like geographic_search with the trailing punctuation (and preceding spaces) removed" do
355
355
  m = "<mods #{@ns_decl}><subject>
356
- <geographic>comma,</geographic>
357
- <geographic>semicolon;</geographic>
356
+ <geographic> comma,</geographic>
357
+ <geographic>
358
+ semicolon;</geographic>
358
359
  <geographic>backslash \\</geographic>
359
360
  <geographic>internal, punct;uation</geographic>
360
361
  </subject></mods>"
@@ -1,7 +1,7 @@
1
1
  # encoding: UTF-8
2
2
  require 'spec_helper'
3
3
 
4
- describe "title fields (searchworks.rb)" do
4
+ describe 'title fields (searchworks.rb)' do
5
5
  before(:all) do
6
6
  @smods_rec = Stanford::Mods::Record.new
7
7
  @ns_decl = "xmlns='#{Mods::MODS_NS}'"
@@ -9,18 +9,18 @@ describe "title fields (searchworks.rb)" do
9
9
  @smods_rec.from_str m
10
10
  end
11
11
 
12
- context "short title (for title_245a_search, title_245a_display) " do
13
- it "should call :short_titles" do
12
+ context 'short title (for title_245a_search, title_245a_display) ' do
13
+ it 'should call :short_titles' do
14
14
  expect(@smods_rec).to receive(:short_titles) # in Mods gem
15
15
  @smods_rec.sw_short_title
16
16
  end
17
- it "should be a String" do
17
+ it 'should be a String' do
18
18
  expect(@smods_rec.sw_short_title).to eq 'The Jerk'
19
19
  end
20
20
  end
21
21
 
22
- context "full title (for title_245_search, title_full_display)" do
23
- it "should be a String" do
22
+ context 'full title (for title_245_search, title_full_display)' do
23
+ it 'should be a String' do
24
24
  expect(@smods_rec.sw_full_title).to eq 'The Jerk : A Tale of Tourettes.'
25
25
  end
26
26
  it 'should cope with regex chars' do
@@ -31,9 +31,9 @@ describe "title fields (searchworks.rb)" do
31
31
  expect(@smods_rec.sw_full_title).to eq 'Pius V. Saint, [Michaele Gisleri),'
32
32
  end
33
33
 
34
- context "punctuation" do
35
- context "no subtitle" do
36
- it "end title with a period" do
34
+ context 'punctuation' do
35
+ context 'no subtitle' do
36
+ it 'end title with a period' do
37
37
  m = "<mods #{@ns_decl}>
38
38
  <titleInfo>
39
39
  <nonSort>The</nonSort>
@@ -42,7 +42,7 @@ describe "title fields (searchworks.rb)" do
42
42
  @smods_rec.from_str(m)
43
43
  expect(@smods_rec.sw_full_title).to eq 'The Olympics.'
44
44
  end
45
- it "title already ends in period" do
45
+ it 'title already ends in period' do
46
46
  m = "<mods #{@ns_decl}>
47
47
  <titleInfo>
48
48
  <nonSort>The</nonSort>
@@ -51,7 +51,7 @@ describe "title fields (searchworks.rb)" do
51
51
  @smods_rec.from_str(m)
52
52
  expect(@smods_rec.sw_full_title).to eq 'The Olympics.'
53
53
  end
54
- it "title already ends in other punctuation" do
54
+ it 'title already ends in other punctuation' do
55
55
  m = "<mods #{@ns_decl}>
56
56
  <titleInfo>
57
57
  <nonSort>The</nonSort>
@@ -61,8 +61,8 @@ describe "title fields (searchworks.rb)" do
61
61
  expect(@smods_rec.sw_full_title).to eq 'The Olympics!'
62
62
  end
63
63
  end # no subtitle
64
- context "subtitle" do
65
- it "end title with a colon" do
64
+ context 'subtitle' do
65
+ it 'end title with a colon' do
66
66
  m = "<mods #{@ns_decl}>
67
67
  <titleInfo>
68
68
  <nonSort>The</nonSort>
@@ -72,7 +72,7 @@ describe "title fields (searchworks.rb)" do
72
72
  @smods_rec.from_str(m)
73
73
  expect(@smods_rec.sw_full_title).to eq 'The Olympics : a history.'
74
74
  end
75
- it "title already ends with colon" do
75
+ it 'title already ends with colon' do
76
76
  m = "<mods #{@ns_decl}>
77
77
  <titleInfo>
78
78
  <nonSort>The</nonSort>
@@ -83,7 +83,7 @@ describe "title fields (searchworks.rb)" do
83
83
  expect(@smods_rec.sw_full_title).to eq 'The Olympics : a history.'
84
84
  end #
85
85
  # "end subtitle with period" - see above
86
- it "subtitle already ends with period" do
86
+ it 'subtitle already ends with period' do
87
87
  m = "<mods #{@ns_decl}>
88
88
  <titleInfo>
89
89
  <nonSort>The</nonSort>
@@ -93,7 +93,7 @@ describe "title fields (searchworks.rb)" do
93
93
  @smods_rec.from_str(m)
94
94
  expect(@smods_rec.sw_full_title).to eq 'The Olympics : a history.'
95
95
  end
96
- it "subtitle already ends with other punctuation" do
96
+ it 'subtitle already ends with other punctuation' do
97
97
  m = "<mods #{@ns_decl}>
98
98
  <titleInfo>
99
99
  <nonSort>The</nonSort>
@@ -104,9 +104,9 @@ describe "title fields (searchworks.rb)" do
104
104
  expect(@smods_rec.sw_full_title).to eq 'The Olympics : a history?'
105
105
  end
106
106
  end # subtitle
107
- context "partName" do
108
- context "no partNumber" do
109
- it "end partName with period" do
107
+ context 'partName' do
108
+ context 'no partNumber' do
109
+ it 'end partName with period' do
110
110
  m = "<mods #{@ns_decl}>
111
111
  <titleInfo>
112
112
  <nonSort>The</nonSort>
@@ -124,7 +124,7 @@ describe "title fields (searchworks.rb)" do
124
124
  @smods_rec.from_str(m)
125
125
  expect(@smods_rec.sw_full_title).to eq 'cfb. Appendix.'
126
126
  end
127
- it "partName already ends with period" do
127
+ it 'partName already ends with period' do
128
128
  m = "<mods #{@ns_decl}>
129
129
  <titleInfo>
130
130
  <nonSort>The</nonSort>
@@ -143,8 +143,8 @@ describe "title fields (searchworks.rb)" do
143
143
  expect(@smods_rec.sw_full_title).to eq 'cfb. Appendix.'
144
144
  end
145
145
  end # no partNumber
146
- context "partNumber" do
147
- it "end partNumber with comma" do
146
+ context 'partNumber' do
147
+ it 'end partNumber with comma' do
148
148
  m = "<mods #{@ns_decl}>
149
149
  <titleInfo>
150
150
  <nonSort>The</nonSort>
@@ -164,7 +164,7 @@ describe "title fields (searchworks.rb)" do
164
164
  @smods_rec.from_str(m)
165
165
  expect(@smods_rec.sw_full_title).to eq 'cfb. 1894, Appendix.'
166
166
  end
167
- it "partNumber already ends with comma" do
167
+ it 'partNumber already ends with comma' do
168
168
  m = "<mods #{@ns_decl}>
169
169
  <titleInfo>
170
170
  <nonSort>The</nonSort>
@@ -186,8 +186,8 @@ describe "title fields (searchworks.rb)" do
186
186
  end
187
187
  end
188
188
  end # partName
189
- context "no partName, but partNumber" do
190
- it "end partNumber with period" do
189
+ context 'no partName, but partNumber' do
190
+ it 'end partNumber with period' do
191
191
  m = "<mods #{@ns_decl}>
192
192
  <titleInfo>
193
193
  <nonSort>The</nonSort>
@@ -205,7 +205,7 @@ describe "title fields (searchworks.rb)" do
205
205
  @smods_rec.from_str(m)
206
206
  expect(@smods_rec.sw_full_title).to eq 'cfb. 1894.'
207
207
  end
208
- it "parNumber already ends in period" do
208
+ it 'parNumber already ends in period' do
209
209
  m = "<mods #{@ns_decl}>
210
210
  <titleInfo>
211
211
  <nonSort>The</nonSort>
@@ -223,7 +223,7 @@ describe "title fields (searchworks.rb)" do
223
223
  @smods_rec.from_str(m)
224
224
  expect(@smods_rec.sw_full_title).to eq 'cfb. 1894.'
225
225
  end
226
- it "partNumber already ends with other punctuation" do
226
+ it 'partNumber already ends with other punctuation' do
227
227
  m = "<mods #{@ns_decl}>
228
228
  <titleInfo>
229
229
  <nonSort>The</nonSort>
@@ -245,11 +245,10 @@ describe "title fields (searchworks.rb)" do
245
245
  end # punctuation
246
246
  end # sw_full_title
247
247
 
248
- context "sw_title_display removes end punctuation of sw_full_title_display" do
249
-
248
+ context 'sw_title_display removes end punctuation of sw_full_title_display' do
250
249
  # title_display = custom, removeTrailingPunct(245abdefghijklmnopqrstuvwxyz, [\\\\,/;:], ([A-Za-z]{4}|[0-9]{3}|\\)|\\,))
251
250
  context "should remove trailing \,/;:." do
252
- it "retains other trailing chars" do
251
+ it 'retains other trailing chars' do
253
252
  m = "<mods #{@ns_decl}><titleInfo>
254
253
  <title>The Jerk?</title>
255
254
  </titleInfo></mods>"
@@ -261,42 +260,42 @@ describe "title fields (searchworks.rb)" do
261
260
  @smods_rec.from_str(m)
262
261
  expect(@smods_rec.sw_title_display).to eq 'The Jerk!'
263
262
  end
264
- it "removes trailing comma" do
263
+ it 'removes trailing comma' do
265
264
  m = "<mods #{@ns_decl}><titleInfo>
266
265
  <title>The Jerk,</title>
267
266
  </titleInfo></mods>"
268
267
  @smods_rec.from_str(m)
269
268
  expect(@smods_rec.sw_title_display).to eq 'The Jerk'
270
269
  end
271
- it "removes trailing semicolon" do
270
+ it 'removes trailing semicolon' do
272
271
  m = "<mods #{@ns_decl}><titleInfo>
273
272
  <title>The Jerk;</title>
274
273
  </titleInfo></mods>"
275
274
  @smods_rec.from_str(m)
276
275
  expect(@smods_rec.sw_title_display).to eq 'The Jerk'
277
276
  end
278
- it "removes trailing colon" do
277
+ it 'removes trailing colon' do
279
278
  m = "<mods #{@ns_decl}><titleInfo>
280
279
  <title>The Jerk:</title>
281
280
  </titleInfo></mods>"
282
281
  @smods_rec.from_str(m)
283
282
  expect(@smods_rec.sw_title_display).to eq 'The Jerk'
284
283
  end
285
- it "removes trailing slash" do
284
+ it 'removes trailing slash' do
286
285
  m = "<mods #{@ns_decl}><titleInfo>
287
286
  <title>The Jerk /</title>
288
287
  </titleInfo></mods>"
289
288
  @smods_rec.from_str(m)
290
289
  expect(@smods_rec.sw_title_display).to eq 'The Jerk'
291
290
  end
292
- it "removes trailing backslash" do
291
+ it 'removes trailing backslash' do
293
292
  m = "<mods #{@ns_decl}><titleInfo>
294
293
  <title>The Jerk \</title>
295
294
  </titleInfo></mods>"
296
295
  @smods_rec.from_str(m)
297
296
  expect(@smods_rec.sw_title_display).to eq 'The Jerk'
298
297
  end
299
- it "removes multiple trailing punctuation" do
298
+ it 'removes multiple trailing punctuation' do
300
299
  m = "<mods #{@ns_decl}><titleInfo>
301
300
  <title>The Jerk.,\</title>
302
301
  </titleInfo></mods>"
@@ -304,8 +303,8 @@ describe "title fields (searchworks.rb)" do
304
303
  expect(@smods_rec.sw_title_display).to eq 'The Jerk'
305
304
  end
306
305
  end
307
- context "no subtitle" do
308
- it "end title with a period" do
306
+ context 'no subtitle' do
307
+ it 'end title with a period' do
309
308
  m = "<mods #{@ns_decl}>
310
309
  <titleInfo>
311
310
  <nonSort>The</nonSort>
@@ -314,7 +313,7 @@ describe "title fields (searchworks.rb)" do
314
313
  @smods_rec.from_str(m)
315
314
  expect(@smods_rec.sw_title_display).to eq 'The Olympics'
316
315
  end
317
- it "title already ends in period" do
316
+ it 'title already ends in period' do
318
317
  m = "<mods #{@ns_decl}>
319
318
  <titleInfo>
320
319
  <nonSort>The</nonSort>
@@ -323,7 +322,7 @@ describe "title fields (searchworks.rb)" do
323
322
  @smods_rec.from_str(m)
324
323
  expect(@smods_rec.sw_title_display).to eq 'The Olympics'
325
324
  end
326
- it "title already ends in other punctuation" do
325
+ it 'title already ends in other punctuation' do
327
326
  m = "<mods #{@ns_decl}>
328
327
  <titleInfo>
329
328
  <nonSort>The</nonSort>
@@ -333,8 +332,8 @@ describe "title fields (searchworks.rb)" do
333
332
  expect(@smods_rec.sw_title_display).to eq 'The Olympics!'
334
333
  end
335
334
  end # no subtitle
336
- context "subtitle" do
337
- it "end title with a colon" do
335
+ context 'subtitle' do
336
+ it 'end title with a colon' do
338
337
  m = "<mods #{@ns_decl}>
339
338
  <titleInfo>
340
339
  <nonSort>The</nonSort>
@@ -344,7 +343,7 @@ describe "title fields (searchworks.rb)" do
344
343
  @smods_rec.from_str(m)
345
344
  expect(@smods_rec.sw_title_display).to eq 'The Olympics : a history'
346
345
  end
347
- it "title already ends with colon" do
346
+ it 'title already ends with colon' do
348
347
  m = "<mods #{@ns_decl}>
349
348
  <titleInfo>
350
349
  <nonSort>The</nonSort>
@@ -355,7 +354,7 @@ describe "title fields (searchworks.rb)" do
355
354
  expect(@smods_rec.sw_title_display).to eq 'The Olympics : a history'
356
355
  end #
357
356
  # "end subtitle with period" - see above
358
- it "subtitle already ends with period" do
357
+ it 'subtitle already ends with period' do
359
358
  m = "<mods #{@ns_decl}>
360
359
  <titleInfo>
361
360
  <nonSort>The</nonSort>
@@ -365,7 +364,7 @@ describe "title fields (searchworks.rb)" do
365
364
  @smods_rec.from_str(m)
366
365
  expect(@smods_rec.sw_title_display).to eq 'The Olympics : a history'
367
366
  end
368
- it "subtitle already ends with other punctuation" do
367
+ it 'subtitle already ends with other punctuation' do
369
368
  m = "<mods #{@ns_decl}>
370
369
  <titleInfo>
371
370
  <nonSort>The</nonSort>
@@ -376,9 +375,9 @@ describe "title fields (searchworks.rb)" do
376
375
  expect(@smods_rec.sw_title_display).to eq 'The Olympics : a history?'
377
376
  end
378
377
  end # subtitle
379
- context "partName" do
380
- context "no partNumber" do
381
- it "end partName with period" do
378
+ context 'partName' do
379
+ context 'no partNumber' do
380
+ it 'end partName with period' do
382
381
  m = "<mods #{@ns_decl}>
383
382
  <titleInfo>
384
383
  <nonSort>The</nonSort>
@@ -396,7 +395,7 @@ describe "title fields (searchworks.rb)" do
396
395
  @smods_rec.from_str(m)
397
396
  expect(@smods_rec.sw_title_display).to eq 'cfb. Appendix'
398
397
  end
399
- it "partName already ends with period" do
398
+ it 'partName already ends with period' do
400
399
  m = "<mods #{@ns_decl}>
401
400
  <titleInfo>
402
401
  <nonSort>The</nonSort>
@@ -415,8 +414,8 @@ describe "title fields (searchworks.rb)" do
415
414
  expect(@smods_rec.sw_title_display).to eq 'cfb. Appendix'
416
415
  end
417
416
  end # no partNumber
418
- context "partNumber" do
419
- it "end partNumber with comma" do
417
+ context 'partNumber' do
418
+ it 'end partNumber with comma' do
420
419
  m = "<mods #{@ns_decl}>
421
420
  <titleInfo>
422
421
  <nonSort>The</nonSort>
@@ -436,7 +435,7 @@ describe "title fields (searchworks.rb)" do
436
435
  @smods_rec.from_str(m)
437
436
  expect(@smods_rec.sw_title_display).to eq 'cfb. 1894, Appendix'
438
437
  end
439
- it "partNumber already ends with comma" do
438
+ it 'partNumber already ends with comma' do
440
439
  m = "<mods #{@ns_decl}>
441
440
  <titleInfo>
442
441
  <nonSort>The</nonSort>
@@ -458,8 +457,8 @@ describe "title fields (searchworks.rb)" do
458
457
  end
459
458
  end
460
459
  end # partName
461
- context "no partName, but partNumber" do
462
- it "end partNumber with period" do
460
+ context 'no partName, but partNumber' do
461
+ it 'end partNumber with period' do
463
462
  m = "<mods #{@ns_decl}>
464
463
  <titleInfo>
465
464
  <nonSort>The</nonSort>
@@ -477,7 +476,7 @@ describe "title fields (searchworks.rb)" do
477
476
  @smods_rec.from_str(m)
478
477
  expect(@smods_rec.sw_title_display).to eq 'cfb. 1894'
479
478
  end
480
- it "parNumber already ends in period" do
479
+ it 'parNumber already ends in period' do
481
480
  m = "<mods #{@ns_decl}>
482
481
  <titleInfo>
483
482
  <nonSort>The</nonSort>
@@ -495,7 +494,7 @@ describe "title fields (searchworks.rb)" do
495
494
  @smods_rec.from_str(m)
496
495
  expect(@smods_rec.sw_title_display).to eq 'cfb. 1894'
497
496
  end
498
- it "partNumber already ends with other punctuation" do
497
+ it 'partNumber already ends with other punctuation' do
499
498
  m = "<mods #{@ns_decl}>
500
499
  <titleInfo>
501
500
  <nonSort>The</nonSort>
@@ -516,7 +515,7 @@ describe "title fields (searchworks.rb)" do
516
515
  end # no partName but partNumber
517
516
  end # sw_title_display
518
517
 
519
- context "additional titles (for title_variant_search)" do
518
+ context 'additional titles (for title_variant_search)' do
520
519
  before(:all) do
521
520
  m = "<mods #{@ns_decl}>
522
521
  <titleInfo type='alternative'><title>Alternative</title></titleInfo>
@@ -526,14 +525,14 @@ describe "title fields (searchworks.rb)" do
526
525
  @smods_rec.from_str(m)
527
526
  @addl_titles = @smods_rec.sw_addl_titles
528
527
  end
529
- it "should not include the main title" do
528
+ it 'should not include the main title' do
530
529
  expect(@addl_titles.size).to eq 2
531
530
  expect(@addl_titles).not_to include(@smods_rec.sw_full_title)
532
531
  end
533
- it "should include any extra main titles" do
532
+ it 'should include any extra main titles' do
534
533
  expect(@addl_titles).to include('Joke')
535
534
  end
536
- it "should include all alternative titles" do
535
+ it 'should include all alternative titles' do
537
536
  expect(@addl_titles).to include('Alternative')
538
537
  end
539
538
  it 'should cope with regexp chars in the short title when determining addl titles' do
@@ -547,29 +546,34 @@ describe "title fields (searchworks.rb)" do
547
546
  end
548
547
  end
549
548
 
550
- context "sort title" do
551
- it "should be a String" do
549
+ context 'sort title' do
550
+ it 'should be a String' do
552
551
  expect(@smods_rec.sw_sort_title).to be_an_instance_of(String)
553
552
  end
554
- it "should use the sw_full_title as a starting point" do
553
+ it 'should use the sw_full_title as a starting point' do
555
554
  expect(@smods_rec).to receive(:sw_full_title)
556
555
  @smods_rec.sw_sort_title
557
556
  end
558
- it "should not begin or end with whitespace" do
557
+ it 'should not begin or end with whitespace' do
559
558
  m = "<mods #{@ns_decl}>
560
559
  <titleInfo><title> Jerk </title></titleInfo>
561
560
  </mods>"
562
561
  @smods_rec.from_str(m)
563
562
  expect(@smods_rec.sw_sort_title).to eq @smods_rec.sw_sort_title.strip
564
563
  end
565
- it "should not have any punctuation marks" do
564
+ it 'should not have any punctuation marks' do
566
565
  r = Stanford::Mods::Record.new
567
566
  r.from_str "<mods #{@ns_decl}><titleInfo><title>J,e.r;;;k</title></titleInfo></mods>"
568
567
  expect(r.sw_sort_title).to match /^Jerk$/
569
568
  end
569
+ it 'should properly handle nonSort tags with metacharacters' do
570
+ r = Stanford::Mods::Record.new
571
+ r.from_str "<mods #{@ns_decl}><titleInfo><nonSort>[“</nonSort><title>In hat mappa lector... cum enim tota Chilensis regionus...”]</title></titleInfo></mods>"
572
+ expect(r.sw_sort_title).to match /^In hat mappa lector cum enim tota Chilensis regionus$/
573
+ end
570
574
  end
571
575
 
572
- context "part number should be in full title and sort title", :jira => ['INDEX-31', 'GRYPHONDOR-372'] do
576
+ context 'part number should be in full title and sort title', jira: ['INDEX-31', 'GRYPHONDOR-372'] do
573
577
  before(:all) do
574
578
  @mccarthy_smods_rec = Stanford::Mods::Record.new
575
579
  mccarthy = "<mods #{@ns_decl}>
@@ -607,30 +611,29 @@ describe "title fields (searchworks.rb)" do
607
611
  </titleInfo></mods>"
608
612
  @all_smods_rec.from_str(all)
609
613
  end
610
- it "short titles" do
614
+ it 'short titles' do
611
615
  expect(@mccarthy_smods_rec.sw_short_title).to eql 'McCarthy, John'
612
616
  expect(@insp_general_smods_rec.sw_short_title).to eql 'Semiannual report to Congress'
613
617
  expect(@cfb_smods_rec.sw_short_title).to eql 'cfb'
614
618
  expect(@all_smods_rec.sw_short_title).to eql 'The Olympics'
615
619
  end
616
- it "full titles" do
620
+ it 'full titles' do
617
621
  expect(@mccarthy_smods_rec.sw_full_title).to eql 'McCarthy, John. Part 2.'
618
622
  expect(@insp_general_smods_rec.sw_full_title).to eql 'Semiannual report to Congress. October 1, 1998 - March 31, 1999.'
619
623
  expect(@cfb_smods_rec.sw_full_title).to eql 'cfb. 1894, Appendix.'
620
624
  expect(@all_smods_rec.sw_full_title).to eql 'The Olympics : a history. Part 1, Ancient.'
621
625
  end
622
- it "additional titles" do
626
+ it 'additional titles' do
623
627
  expect(@mccarthy_smods_rec.sw_addl_titles).to eql []
624
628
  expect(@insp_general_smods_rec.sw_addl_titles).to eql []
625
629
  expect(@cfb_smods_rec.sw_addl_titles).to eql []
626
630
  expect(@all_smods_rec.sw_addl_titles).to eql []
627
631
  end
628
- it "sort title" do
632
+ it 'sort title' do
629
633
  expect(@mccarthy_smods_rec.sw_sort_title).to eql 'McCarthy John Part 2'
630
634
  expect(@insp_general_smods_rec.sw_sort_title).to eql 'Semiannual report to Congress October 1 1998 March 31 1999'
631
635
  expect(@cfb_smods_rec.sw_sort_title).to eql 'cfb 1894 Appendix'
632
636
  expect(@all_smods_rec.sw_sort_title).to eql 'Olympics a history Part 1 Ancient'
633
637
  end
634
638
  end
635
-
636
639
  end
@@ -10,7 +10,7 @@ Gem::Specification.new do |gem|
10
10
  gem.summary = "Stanford specific wrangling of MODS metadata"
11
11
  gem.homepage = "https://github.com/sul-dlss/stanford-mods"
12
12
 
13
- gem.extra_rdoc_files = ["LICENSE", "README.rdoc"]
13
+ gem.extra_rdoc_files = ["LICENSE", "README.md"]
14
14
  gem.files = `git ls-files`.split($\)
15
15
  gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
16
16
  gem.test_files = gem.files.grep(%r{^spec/})
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: 1.1.4
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naomi Dushay
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2015-02-19 00:00:00.000000000 Z
12
+ date: 2015-10-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mods
@@ -90,7 +90,7 @@ executables: []
90
90
  extensions: []
91
91
  extra_rdoc_files:
92
92
  - LICENSE
93
- - README.rdoc
93
+ - README.md
94
94
  files:
95
95
  - ".coveralls.yml"
96
96
  - ".gitignore"
@@ -99,7 +99,7 @@ files:
99
99
  - ".yardopts"
100
100
  - Gemfile
101
101
  - LICENSE
102
- - README.rdoc
102
+ - README.md
103
103
  - Rakefile
104
104
  - config/mappings_hash.rb
105
105
  - lib/stanford-mods.rb
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  version: '0'
136
136
  requirements: []
137
137
  rubyforge_project:
138
- rubygems_version: 2.2.2
138
+ rubygems_version: 2.4.8
139
139
  signing_key:
140
140
  specification_version: 4
141
141
  summary: Stanford specific wrangling of MODS metadata
data/README.rdoc DELETED
@@ -1,85 +0,0 @@
1
- = Stanford::Mods
2
-
3
- {<img src="https://secure.travis-ci.org/sul-dlss/stanford-mods.png?branch=master" alt="Build Status" />}[http://travis-ci.org/sul-dlss/stanford-mods] {<img src="https://coveralls.io/repos/sul-dlss/stanford-mods/badge.png" alt="Coverage Status" />}[https://coveralls.io/r/sul-dlss/stanford-mods] {<img src="https://gemnasium.com/sul-dlss/stanford-mods.png" alt="Dependency Status" />}[https://gemnasium.com/sul-dlss/stanford-mods] {<img src="https://badge.fury.io/rb/stanford-mods.svg" alt="Gem Version" />}[http://badge.fury.io/rb/stanford-mods]
4
-
5
- A Gem with Stanford specific wranglings of MODS (Metadata Object Description Schema) metadata from DOR, the Stanford Digital Object Repository.
6
-
7
- Source code at https://github.com/sul-dlss/stanford-mods/
8
-
9
- Generated API docs at http://rubydoc.info/github/sul-dlss/stanford-mods/
10
-
11
- == Installation
12
-
13
- Add this line to your application's Gemfile:
14
-
15
- gem 'stanford-mods'
16
-
17
- And then execute:
18
-
19
- $ bundle
20
-
21
- Or install it yourself as:
22
-
23
- $ gem install stanford-mods
24
-
25
- == Usage
26
-
27
- 1. add stanford-mods to your gemfile
28
- 2. require 'stanford-mods'
29
-
30
- > m = Stanford::Mods::Record.new
31
- > m.from_str('<mods><genre>ape</genre></mods>')
32
- > m.genre
33
- => [#<Nokogiri::XML::Element:0x3fe07b48bb24 name="genre" children=[#<Nokogiri::XML::Text:0x3fe07a09a7dc "ape">]>]
34
- > m.genre.text
35
- => "ape"
36
-
37
- > m.to_be_removed <-- method I wrote in stanford-mods for proof of concept
38
- in foo!
39
- => nil
40
-
41
- Example Using SearchWorks Mixins:
42
-
43
- > require 'stanford-mods/searchworks'
44
- > m = Stanford::Mods::Record.new
45
- > m.from_str('<mods><language><languageTerm authority="iso639-2b" type="code">dut</languageTerm></language></mods>')
46
- > m.language_facet <-- from Searchworks mixin
47
- => ['Dutch']
48
- > m.languages <-- from mods gem
49
- => ['Dutch; Flemish']
50
-
51
- == Contributing
52
-
53
- 1. Fork it
54
- 2. Create your feature branch (`git checkout -b my-new-feature`)
55
- 3. Write code and tests.
56
- 4. Commit your changes (`git commit -am 'Added some feature'`)
57
- 5. Push to the branch (`git push origin my-new-feature`)
58
- 6. Create new Pull Request
59
-
60
- == Releases
61
- * <b>1.1.2</b> Corrected java Character.MAX_CODE_POINT value from \u{FFFF} to \u{10FFFF}
62
- * <b>1.1.1</b> Minor bug fixes
63
- * <b>1.1.0</b> Changed mechanism for determining dates for display only and for indexing, sorting, and faceting and removed deprecated pub_date_group method
64
- * <b>1.0.3</b> format_main value 'Article' is now 'Book'
65
- * <b>1.0.2</b> add format_main and sw_genre tests to searchworks.rb
66
- * <b>1.0.1</b> sw_title_display keeps appropriate trailing punct more or less per spec in solrmarc-sw sw_index.properties
67
- * <b>1.0.0</b> sw_full_title now includes partName and partNumber; sw_title_display created to be like sw_full_title but without trailing punctuation; sw format for typeOfResource sound recording; genre value is librettos, plural; sw format algorithm accommodates first letter upcase; genre value report does NOT map to a format, genre value 'project report' with ToR text is 'Book'
68
- * <b>0.0.27</b> add genres 'Issue brief', 'Book chapter' and 'Working paper' to map to searchworks format 'Book'
69
- * <b>0.0.26</b> map typeOfResource 'sound recording-musical' to searchworks format 'Music - Recording' with spaces
70
- * <b>0.0.25</b> map typeOfResource 'text' and genre 'report' to searchworks format 'Book'
71
- * <b>0.0.24</b> Largely cosmetic refactoring for easier maintenance.
72
- * <b>0.0.23</b> Added logic for dealing with "u-notation" approximate dates, e.g., 198u
73
- * <b>0.0.20</b> Added mapping for typeOfResource notated music
74
- * <b>0.0.19</b> Additional mappings, including Hydrus formats (GRYPHONDOR-207)
75
- * <b>0.0.11</b> escape regex special characters when using short title in a regex
76
- * <b>0.0.10</b> get rid of ignore_me files
77
- * <b>0.0.9</b> add sw_subject_names and sw_subject_titles methods to searchworks mixin
78
- * <b>0.0.8</b> require stanford-mods/searchworks in stanford-mods (top level)
79
- * <b>0.0.7</b> added sw_geographic_search to searchworks mixin
80
- * <b>0.0.6</b> various title methods added to searchworks mixin
81
- * <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
82
- * <b>0.0.4</b> KolbRecord started
83
- * <b>0.0.3</b> began SearchWorks mixins with sw_access_facet and sw_language_facet
84
- * <b>0.0.2</b> add usage instructions to readme
85
- * <b>0.0.1</b> Initial commit - grab name