stanford-mods 1.0.3 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4d5012f113350896de50bcb147a50b21177ad523
4
- data.tar.gz: 3a91ab13a3c35c0ebd9a93ff3512285c13986a1b
3
+ metadata.gz: 00674c31e1fc276d254e80b69d023dc5791b8f6c
4
+ data.tar.gz: d5448fb18520caaae0020e836acb26ae25ffee1c
5
5
  SHA512:
6
- metadata.gz: 85c0b6bdd15c6e9a09f567164e9aacd9d3555930b228b4270b8ba72d8d90bc9e970c9f7aaecf4c1484daa0de53207dee885fd0f72b7ecac96239d784e0f58e2b
7
- data.tar.gz: 96159a0d40c32c5c63f994622514f09c742d33740667dee36eace14e0b68e0857d0514c123ed58baa8c0d2938edecfd62373153a8b2e4d8ae82757541ef37fac
6
+ metadata.gz: d9aaa70cf1f63dd16c7a52f029f926f494802a29640e01c53c522bb99e761c1db06fd90809d9c1a962a3470bdc83f13b4e2d05f57162b61d981d65c272132b99
7
+ data.tar.gz: 275f10f95d7e7037db5309d8c79384e1d7f52ca47d407d0846219ff8c905eec5023a7013ae1f745c3b416533a28912fa3e870fb6e1919560a57244dc452b09c8
@@ -1,11 +1,13 @@
1
1
  language: ruby
2
2
  script: rake rspec
3
3
  rvm:
4
- - 2.1.1
4
+ - 2.2.0
5
+ - 2.1.5
5
6
  - 2.0.0
6
7
  - 1.9.3
7
8
  - ruby-head
8
- - jruby-19mode # JRuby in 1.9 mode
9
+ - jruby-1.7.9-d19 # fails after 1.7.10 for some reason
10
+ # - jruby-19mode # JRuby in 1.9 mode
9
11
  # - jruby-head # failing 2014-07
10
12
  notifications:
11
13
  email:
@@ -59,6 +59,7 @@ Example Using SearchWorks Mixins:
59
59
  6. Create new Pull Request
60
60
 
61
61
  == Releases
62
+ * <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
62
63
  * <b>1.0.3</b> format_main value 'Article' is now 'Book'
63
64
  * <b>1.0.2</b> add format_main and sw_genre tests to searchworks.rb
64
65
  * <b>1.0.1</b> sw_title_display keeps appropriate trailing punct more or less per spec in solrmarc-sw sw_index.properties
@@ -383,52 +383,22 @@ module Stanford
383
383
  vals
384
384
  end
385
385
 
386
+ # For the date display only, the first place to look is in the dates without encoding=marc array.
387
+ # If no such dates, select the first date in the pub_dates array. Otherwise return nil
388
+ # @return [String] value for the pub_date_display Solr field for this document or nil if none
386
389
  def pub_date_display
387
- if pub_dates
388
- pub_dates.first
389
- else
390
- nil
391
- end
392
- end
393
-
394
- # @return [Array<String>] values for the pub_date_group_facet
395
- # @deprecated
396
- def pub_date_groups year
397
- if not year
390
+ return dates_no_marc_encoding.first unless dates_no_marc_encoding.empty?
391
+ return pub_dates.first unless pub_dates.empty?
398
392
  return nil
399
- end
400
- year=year.to_i
401
- current_year=Time.new.year.to_i
402
- result = []
403
- if year >= current_year - 1
404
- result << "This year"
405
- else
406
- if year >= current_year - 3
407
- result << "Last 3 years"
408
- else
409
- if year >= current_year - 10
410
- result << "Last 10 years"
411
- else
412
- if year >= current_year - 50
413
- result << "Last 50 years"
414
- else
415
- result << "More than 50 years ago"
416
- end
417
- end
418
- end
419
- end
420
393
  end
421
394
 
422
- #get the dates from dateIssued, and dateCreated merged into 1 array.
423
- # @return [Array<String>] values for the issue_date_display Solr field for this document or nil if none
395
+ # For the date indexing, sorting and faceting, the first place to look is in the dates with encoding=marc array.
396
+ # If that doesn't exist, look in the dates without encoding=marc array. Otherwise return nil
397
+ # @return [Array<String>] values for the date Solr field for this document or nil if none
424
398
  def pub_dates
425
- vals = self.term_values([:origin_info,:dateIssued])
426
- if vals
427
- vals = vals.concat self.term_values([:origin_info,:dateCreated]) unless not self.term_values([:origin_info,:dateCreated])
428
- else
429
- vals = self.term_values([:origin_info,:dateCreated])
430
- end
431
- vals and vals.empty? ? nil : vals
399
+ return dates_marc_encoding unless dates_marc_encoding.empty?
400
+ return dates_no_marc_encoding unless dates_no_marc_encoding.empty?
401
+ return nil
432
402
  end
433
403
 
434
404
  def is_number?(object)
@@ -813,7 +783,40 @@ module Stanford
813
783
  end
814
784
  end
815
785
  return nil
816
- end
786
+ end
787
+
788
+ # @return [Array<String>] dates from dateIssued and dateCreated tags from origin_info with encoding="marc"
789
+ def dates_marc_encoding
790
+ split_date_encodings unless @dates_marc_encoding
791
+ return @dates_marc_encoding
792
+ end
793
+
794
+ # @return [Array<String>] dates from dateIssued and dateCreated tags from origin_info with encoding not "marc"
795
+ def dates_no_marc_encoding
796
+ split_date_encodings unless @dates_no_marc_encoding
797
+ return @dates_no_marc_encoding
798
+ end
799
+
800
+ # Populate @dates_marc_encoding and @dates_no_marc_encoding from dateIssued and dateCreated tags from origin_info
801
+ # with and without encoding=marc
802
+ def split_date_encodings
803
+ @dates_marc_encoding = []
804
+ @dates_no_marc_encoding = []
805
+ self.origin_info.dateIssued.each { |di|
806
+ if di.encoding == "marc"
807
+ @dates_marc_encoding << di.text
808
+ else
809
+ @dates_no_marc_encoding << di.text
810
+ end
811
+ }
812
+ self.origin_info.dateCreated.each { |dc|
813
+ if dc.encoding == "marc"
814
+ @dates_marc_encoding << dc.text
815
+ else
816
+ @dates_no_marc_encoding << dc.text
817
+ end
818
+ }
819
+ end
817
820
  end # class Record
818
821
  end # Module Mods
819
822
  end # Module Stanford
@@ -1,6 +1,6 @@
1
1
  module Stanford
2
2
  module Mods
3
3
  # this is the Ruby Gem version
4
- VERSION = "1.0.3"
4
+ VERSION = "1.1.0"
5
5
  end
6
6
  end
@@ -122,6 +122,16 @@ describe "Date methods (searchworks.rb)" do
122
122
  @smods_rec.pub_date_sort.should =='0800'
123
123
  @smods_rec.pub_date_facet.should == '9th century'
124
124
  end
125
+ it 'should use the dateIssued without marc encoding for pub_date_display and the one with marc encoding for indexing, sorting and faceting' do
126
+ m = "<mods #{@ns_decl}><originInfo><dateIssued>[186-?]</dateIssued><dateIssued encoding=\"marc\">1860</dateIssued><issuance>monographic</issuance></originInfo>"
127
+ @smods_rec = Stanford::Mods::Record.new
128
+ @smods_rec.from_str(m)
129
+
130
+ @smods_rec.pub_date_display.should == '[186-?]'
131
+ @smods_rec.pub_date.should =='1860'
132
+ @smods_rec.pub_date_sort.should =='1860'
133
+ @smods_rec.pub_date_facet.should == '1860'
134
+ end
125
135
  end # pub_date
126
136
 
127
137
  context "dates with u notation (198u, 19uu)" do
@@ -204,31 +214,4 @@ describe "Date methods (searchworks.rb)" do
204
214
  end
205
215
  end
206
216
 
207
- context "pub_date_groups" do
208
- it 'should generate the groups' do
209
- m = "<mods #{@ns_decl}><originInfo>
210
- <dateCreated>1904</dateCreated>
211
- </originInfo></mods>"
212
- @smods_rec = Stanford::Mods::Record.new
213
- @smods_rec.from_str(m)
214
- @smods_rec.pub_date_groups(1904).should == ['More than 50 years ago']
215
- end
216
- it 'should work for a modern date too' do
217
- m = "<mods #{@ns_decl}><originInfo>
218
- <dateCreated>1904</dateCreated>
219
- </originInfo></mods>"
220
- @smods_rec = Stanford::Mods::Record.new
221
- @smods_rec.from_str(m)
222
- @smods_rec.pub_date_groups(2013).should == ["This year"]
223
- end
224
- it 'should work ok given a nil date' do
225
- m = "<mods #{@ns_decl}><originInfo>
226
- <dateCreated>1904</dateCreated>
227
- </originInfo></mods>"
228
- @smods_rec = Stanford::Mods::Record.new
229
- @smods_rec.from_str(m)
230
- @smods_rec.pub_date_groups(nil).should == nil
231
- end
232
- end #context pub date groups
233
-
234
- end
217
+ end
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.0.3
4
+ version: 1.1.0
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: 2014-08-28 00:00:00.000000000 Z
12
+ date: 2015-01-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mods
@@ -133,7 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  version: '0'
134
134
  requirements: []
135
135
  rubyforge_project:
136
- rubygems_version: 2.2.2
136
+ rubygems_version: 2.4.3
137
137
  signing_key:
138
138
  specification_version: 4
139
139
  summary: Stanford specific wrangling of MODS metadata