stanford-mods 1.0.1 → 1.0.2

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: a99ffd1547688f19839564988a43e698223bc3ac
4
- data.tar.gz: 261a71cbde0d578de0c1b6f43fe329bf531c20ab
3
+ metadata.gz: 2811e50451509b7e00a879532aa64d9095705dd5
4
+ data.tar.gz: 59b2860b06e6b3c1911bf2bc7eb182eb42717acb
5
5
  SHA512:
6
- metadata.gz: 996cc6f68f4fb8f3154a21423668e188826c46305ab2cd1445c871f0bcf7a20c0e362332b42ceebdee9be8a70e2ad0420532516356009ef4b7b1c1327e4cb3b3
7
- data.tar.gz: 7ebf7b202fd71b7c546fde56f1064092f116e146f023c44a7d4f993ce39db0f88d402306fcdae44f081cffbd82fffdc5aeecb06c764567fc52c5df413ed87ccd
6
+ metadata.gz: f44b0b10b632573073ec57ea1eb2743dd339f2e6e2e1299a79d36f299d27600c1b3647d8b3b0ebe730ef0527341f23ba94ed0e574c3c5de29aa4d56167cfeb00
7
+ data.tar.gz: e57c8c2dff5cf4011ee9d8f5bac257a2afcf779237a5eb95af5f3f1c69d155e1d243fbd7561282372710f3621213bea6f816fff905c610b020cc02792a0a8bbe
@@ -6,7 +6,7 @@ rvm:
6
6
  - 1.9.3
7
7
  - ruby-head
8
8
  - jruby-19mode # JRuby in 1.9 mode
9
- - jruby-head
9
+ # - jruby-head # failing 2014-07
10
10
  notifications:
11
11
  email:
12
12
  - ndushay@stanford.edu
@@ -59,6 +59,7 @@ Example Using SearchWorks Mixins:
59
59
  6. Create new Pull Request
60
60
 
61
61
  == Releases
62
+ * <b>1.0.2</b> add format_main and sw_genre tests to searchworks.rb
62
63
  * <b>1.0.1</b> sw_title_display keeps appropriate trailing punct more or less per spec in solrmarc-sw sw_index.properties
63
64
  * <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'
64
65
  * <b>0.0.27</b> add genres 'Issue brief', 'Book chapter' and 'Working paper' to map to searchworks format 'Book'
@@ -527,8 +527,8 @@ module Stanford
527
527
 
528
528
  # select one or more format values from the controlled vocabulary here:
529
529
  # http://searchworks-solr-lb.stanford.edu:8983/solr/select?facet.field=format&rows=0&facet.sort=index
530
- # based on the dor_content_type
531
- # @return [String] value in the SearchWorks controlled vocabulary
530
+ # @return <Array[String]> value in the SearchWorks controlled vocabulary
531
+ # @deprecated - kept for backwards compatibility but not part of SW UI redesign work Summer 2014
532
532
  def format
533
533
  val = []
534
534
  types = self.term_values(:typeOfResource)
@@ -579,6 +579,87 @@ module Stanford
579
579
  val.uniq
580
580
  end
581
581
 
582
+ # select one or more format values from the controlled vocabulary per JVine Summer 2014
583
+ # http://searchworks-solr-lb.stanford.edu:8983/solr/select?facet.field=format_main_ssim&rows=0&facet.sort=index
584
+ # @return <Array[String]> value in the SearchWorks controlled vocabulary
585
+ def format_main
586
+ val = []
587
+ types = self.term_values(:typeOfResource)
588
+ if types
589
+ genres = self.term_values(:genre)
590
+ issuance = self.term_values([:origin_info,:issuance])
591
+ types.each do |type|
592
+ case type
593
+ when 'cartographic'
594
+ val << 'Map'
595
+ when 'mixed material'
596
+ val << 'Archive/Manuscript'
597
+ when 'moving image'
598
+ val << 'Video'
599
+ when 'notated music'
600
+ val << 'Music score'
601
+ when 'software, multimedia'
602
+ if genres and (genres.include?('dataset') || genres.include?('Dataset'))
603
+ val << 'Dataset'
604
+ else
605
+ val << 'Software/Multimedia'
606
+ end
607
+ when 'sound recording-musical'
608
+ val << 'Music recording'
609
+ when 'sound recording-nonmusical', 'sound recording'
610
+ val << 'Sound recording'
611
+ when 'still image'
612
+ val << 'Image'
613
+ when 'text'
614
+ article_genres = ['article', 'Article',
615
+ 'book chapter', 'Book chapter', 'Book Chapter',
616
+ 'issue brief', 'Issue brief', 'Issue Brief',
617
+ 'project report', 'Project report', 'Project Report',
618
+ 'student project report', 'Student project report', 'Student Project report', 'Student Project Report',
619
+ 'technical report', 'Technical report', 'Technical Report',
620
+ 'working paper', 'Working paper', 'Working Paper'
621
+ ]
622
+ val << 'Article' if genres and !(genres & article_genres).empty?
623
+ val << 'Book' if issuance and issuance.include? 'monographic'
624
+ book_genres = ['conference publication', 'Conference publication', 'Conference Publication',
625
+ 'instruction', 'Instruction',
626
+ 'librettos', 'Librettos',
627
+ 'thesis', 'Thesis'
628
+ ]
629
+ val << 'Book' if genres and !(genres & book_genres).empty?
630
+ val << 'Journal/Periodical' if issuance and issuance.include? 'continuing'
631
+ when 'three dimensional object'
632
+ val << 'Object'
633
+ end
634
+ end
635
+ end
636
+ val.uniq
637
+ end
638
+
639
+ # return values for the genre facet in SearchWorks
640
+ # @return <Array[String]>
641
+ def sw_genre
642
+ val = []
643
+ genres = self.term_values(:genre)
644
+ if genres
645
+ val << genres.map(&:capitalize)
646
+ val.flatten! if !val.empty?
647
+ if genres.include?('thesis') || genres.include?('Thesis')
648
+ val << 'Thesis/Dissertation'
649
+ val.delete 'Thesis'
650
+ end
651
+ conf_pub = ['conference publication', 'Conference publication', 'Conference Publication']
652
+ if !(genres & conf_pub).empty?
653
+ types = self.term_values(:typeOfResource)
654
+ if types && types.include?('text')
655
+ val << 'Conference proceedings'
656
+ val.delete 'Conference publication'
657
+ end
658
+ end
659
+ end
660
+ val.uniq
661
+ end
662
+
582
663
  # @return [String] value with the numeric catkey in it, or nil if none exists
583
664
  def catkey
584
665
  catkey=self.term_values([:record_info,:recordIdentifier])
@@ -1,6 +1,6 @@
1
1
  module Stanford
2
2
  module Mods
3
3
  # this is the Ruby Gem version
4
- VERSION = "1.0.1"
4
+ VERSION = "1.0.2"
5
5
  end
6
6
  end
@@ -1,251 +1,631 @@
1
1
  # encoding: UTF-8
2
2
  require 'spec_helper'
3
3
 
4
- describe "Format field from Searchworks mixin for Stanford::Mods::Record" do
4
+ describe "Format fields (searchworks.rb)" do
5
5
 
6
6
  before(:all) do
7
7
  @smods_rec = Stanford::Mods::Record.new
8
8
  @ns_decl = "xmlns='#{Mods::MODS_NS}'"
9
9
  end
10
10
 
11
- context "Book:" do
12
- context "typeOfResource text," do
13
- it 'originInfo/issuance monographic' do
14
- m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><originInfo><issuance>monographic</issuance></originInfo></mods>"
15
- @smods_rec.from_str(m)
16
- expect(@smods_rec.format).to eq ['Book']
17
- end
18
- context "genre" do
19
- it "'book chapter'", :email => 'mods-squad 2014-05-22, Joanna Dyla' do
20
- m = "<mods #{@ns_decl}><genre>book chapter</genre><typeOfResource>text</typeOfResource></mods>"
21
- @smods_rec.from_str(m)
22
- expect(@smods_rec.format).to eq ['Book']
23
- m = "<mods #{@ns_decl}><genre>Book chapter</genre><typeOfResource>text</typeOfResource></mods>"
24
- @smods_rec.from_str(m)
25
- expect(@smods_rec.format).to eq ['Book']
26
- m = "<mods #{@ns_decl}><genre>Book Chapter</genre><typeOfResource>text</typeOfResource></mods>"
11
+ context "format" do
12
+ context "Book:" do
13
+ context "typeOfResource text," do
14
+ it 'originInfo/issuance monographic' do
15
+ m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><originInfo><issuance>monographic</issuance></originInfo></mods>"
27
16
  @smods_rec.from_str(m)
28
17
  expect(@smods_rec.format).to eq ['Book']
29
18
  end
30
- it "'issue brief'", :email => 'mods-squad 2014-05-22, Joanna Dyla' do
31
- m = "<mods #{@ns_decl}><genre>issue brief</genre><typeOfResource>text</typeOfResource></mods>"
32
- @smods_rec.from_str(m)
33
- expect(@smods_rec.format).to eq ['Book']
34
- m = "<mods #{@ns_decl}><genre>Issue brief</genre><typeOfResource>text</typeOfResource></mods>"
35
- @smods_rec.from_str(m)
36
- expect(@smods_rec.format).to eq ['Book']
37
- m = "<mods #{@ns_decl}><genre>Issue Brief</genre><typeOfResource>text</typeOfResource></mods>"
38
- @smods_rec.from_str(m)
39
- expect(@smods_rec.format).to eq ['Book']
40
- end
41
- it "'librettos'", :jira => 'INDEX-98' do
42
- m = "<mods #{@ns_decl}><genre>librettos</genre><typeOfResource>text</typeOfResource></mods>"
43
- @smods_rec.from_str(m)
44
- expect(@smods_rec.format).to eq ['Book']
45
- m = "<mods #{@ns_decl}><genre>Librettos</genre><typeOfResource>text</typeOfResource></mods>"
46
- @smods_rec.from_str(m)
47
- expect(@smods_rec.format).to eq ['Book']
48
- end
49
- it "'libretto' isn't valid", :jira => 'INDEX-98' do
50
- m = "<mods #{@ns_decl}><genre>libretto</genre><typeOfResource>text</typeOfResource></mods>"
51
- @smods_rec.from_str(m)
52
- expect(@smods_rec.format).to eq []
53
- end
54
- it "'project report'", :jira => 'GRYP-170', :github => 'gdor-indexer/#7' do
55
- m = "<mods #{@ns_decl}><genre>project report</genre><typeOfResource>text</typeOfResource></mods>"
56
- @smods_rec.from_str(m)
57
- expect(@smods_rec.format).to eq ['Book']
58
- m = "<mods #{@ns_decl}><genre>Project report</genre><typeOfResource>text</typeOfResource></mods>"
59
- @smods_rec.from_str(m)
60
- expect(@smods_rec.format).to eq ['Book']
61
- m = "<mods #{@ns_decl}><genre>Project Report</genre><typeOfResource>text</typeOfResource></mods>"
62
- @smods_rec.from_str(m)
63
- expect(@smods_rec.format).to eq ['Book']
64
- end
65
- it "'report' isn't valid", :jira => 'GRYP-170', :github => 'gdor-indexer/#7' do
66
- m = "<mods #{@ns_decl}><genre>report</genre><typeOfResource>text</typeOfResource></mods>"
67
- @smods_rec.from_str(m)
68
- expect(@smods_rec.format).to eq []
69
- end
70
- it "'technical report'", :jira => 'GRYPHONDOR-207' do
71
- m = "<mods #{@ns_decl}><genre>technical report</genre><typeOfResource>text</typeOfResource></mods>"
72
- @smods_rec.from_str(m)
73
- expect(@smods_rec.format).to eq ['Book']
74
- m = "<mods #{@ns_decl}><genre>Technical report</genre><typeOfResource>text</typeOfResource></mods>"
75
- @smods_rec.from_str(m)
76
- expect(@smods_rec.format).to eq ['Book']
77
- m = "<mods #{@ns_decl}><genre>Technical Report</genre><typeOfResource>text</typeOfResource></mods>"
78
- @smods_rec.from_str(m)
79
- expect(@smods_rec.format).to eq ['Book']
80
- end
81
- it "'working paper'", :email => 'mods-squad 2014-05-22, Joanna Dyla' do
82
- m = "<mods #{@ns_decl}><genre>working paper</genre><typeOfResource>text</typeOfResource></mods>"
83
- @smods_rec.from_str(m)
84
- expect(@smods_rec.format).to eq ['Book']
85
- m = "<mods #{@ns_decl}><genre>Working paper</genre><typeOfResource>text</typeOfResource></mods>"
86
- @smods_rec.from_str(m)
87
- expect(@smods_rec.format).to eq ['Book']
88
- m = "<mods #{@ns_decl}><genre>Working Paper</genre><typeOfResource>text</typeOfResource></mods>"
89
- @smods_rec.from_str(m)
90
- expect(@smods_rec.format).to eq ['Book']
19
+ context "genre" do
20
+ it "'book chapter'", :email => 'mods-squad 2014-05-22, Joanna Dyla' do
21
+ m = "<mods #{@ns_decl}><genre>book chapter</genre><typeOfResource>text</typeOfResource></mods>"
22
+ @smods_rec.from_str(m)
23
+ expect(@smods_rec.format).to eq ['Book']
24
+ m = "<mods #{@ns_decl}><genre>Book chapter</genre><typeOfResource>text</typeOfResource></mods>"
25
+ @smods_rec.from_str(m)
26
+ expect(@smods_rec.format).to eq ['Book']
27
+ m = "<mods #{@ns_decl}><genre>Book Chapter</genre><typeOfResource>text</typeOfResource></mods>"
28
+ @smods_rec.from_str(m)
29
+ expect(@smods_rec.format).to eq ['Book']
30
+ end
31
+ it "'issue brief'", :email => 'mods-squad 2014-05-22, Joanna Dyla' do
32
+ m = "<mods #{@ns_decl}><genre>issue brief</genre><typeOfResource>text</typeOfResource></mods>"
33
+ @smods_rec.from_str(m)
34
+ expect(@smods_rec.format).to eq ['Book']
35
+ m = "<mods #{@ns_decl}><genre>Issue brief</genre><typeOfResource>text</typeOfResource></mods>"
36
+ @smods_rec.from_str(m)
37
+ expect(@smods_rec.format).to eq ['Book']
38
+ m = "<mods #{@ns_decl}><genre>Issue Brief</genre><typeOfResource>text</typeOfResource></mods>"
39
+ @smods_rec.from_str(m)
40
+ expect(@smods_rec.format).to eq ['Book']
41
+ end
42
+ it "'librettos'", :jira => 'INDEX-98' do
43
+ m = "<mods #{@ns_decl}><genre>librettos</genre><typeOfResource>text</typeOfResource></mods>"
44
+ @smods_rec.from_str(m)
45
+ expect(@smods_rec.format).to eq ['Book']
46
+ m = "<mods #{@ns_decl}><genre>Librettos</genre><typeOfResource>text</typeOfResource></mods>"
47
+ @smods_rec.from_str(m)
48
+ expect(@smods_rec.format).to eq ['Book']
49
+ end
50
+ it "'libretto' isn't valid", :jira => 'INDEX-98' do
51
+ m = "<mods #{@ns_decl}><genre>libretto</genre><typeOfResource>text</typeOfResource></mods>"
52
+ @smods_rec.from_str(m)
53
+ expect(@smods_rec.format).to eq []
54
+ end
55
+ it "'project report'", :jira => 'GRYP-170', :github => 'gdor-indexer/#7' do
56
+ m = "<mods #{@ns_decl}><genre>project report</genre><typeOfResource>text</typeOfResource></mods>"
57
+ @smods_rec.from_str(m)
58
+ expect(@smods_rec.format).to eq ['Book']
59
+ m = "<mods #{@ns_decl}><genre>Project report</genre><typeOfResource>text</typeOfResource></mods>"
60
+ @smods_rec.from_str(m)
61
+ expect(@smods_rec.format).to eq ['Book']
62
+ m = "<mods #{@ns_decl}><genre>Project Report</genre><typeOfResource>text</typeOfResource></mods>"
63
+ @smods_rec.from_str(m)
64
+ expect(@smods_rec.format).to eq ['Book']
65
+ end
66
+ it "'report' isn't valid", :jira => 'GRYP-170', :github => 'gdor-indexer/#7' do
67
+ m = "<mods #{@ns_decl}><genre>report</genre><typeOfResource>text</typeOfResource></mods>"
68
+ @smods_rec.from_str(m)
69
+ expect(@smods_rec.format).to eq []
70
+ end
71
+ it "'technical report'", :jira => 'GRYPHONDOR-207' do
72
+ m = "<mods #{@ns_decl}><genre>technical report</genre><typeOfResource>text</typeOfResource></mods>"
73
+ @smods_rec.from_str(m)
74
+ expect(@smods_rec.format).to eq ['Book']
75
+ m = "<mods #{@ns_decl}><genre>Technical report</genre><typeOfResource>text</typeOfResource></mods>"
76
+ @smods_rec.from_str(m)
77
+ expect(@smods_rec.format).to eq ['Book']
78
+ m = "<mods #{@ns_decl}><genre>Technical Report</genre><typeOfResource>text</typeOfResource></mods>"
79
+ @smods_rec.from_str(m)
80
+ expect(@smods_rec.format).to eq ['Book']
81
+ end
82
+ it "'working paper'", :email => 'mods-squad 2014-05-22, Joanna Dyla' do
83
+ m = "<mods #{@ns_decl}><genre>working paper</genre><typeOfResource>text</typeOfResource></mods>"
84
+ @smods_rec.from_str(m)
85
+ expect(@smods_rec.format).to eq ['Book']
86
+ m = "<mods #{@ns_decl}><genre>Working paper</genre><typeOfResource>text</typeOfResource></mods>"
87
+ @smods_rec.from_str(m)
88
+ expect(@smods_rec.format).to eq ['Book']
89
+ m = "<mods #{@ns_decl}><genre>Working Paper</genre><typeOfResource>text</typeOfResource></mods>"
90
+ @smods_rec.from_str(m)
91
+ expect(@smods_rec.format).to eq ['Book']
92
+ end
91
93
  end
92
94
  end
93
- end
94
- end # 'Book'
95
+ end # 'Book'
95
96
 
96
- context "Computer File: typeOfResource 'software, multimedia'" do
97
- it "no genre (e.g. Dataset)" do
98
- m = "<mods #{@ns_decl}><typeOfResource>software, multimedia</typeOfResource></mods>"
99
- @smods_rec.from_str(m)
100
- expect(@smods_rec.format).to eq ['Computer File']
97
+ context "Computer File: typeOfResource 'software, multimedia'" do
98
+ it "no genre (e.g. Dataset)" do
99
+ m = "<mods #{@ns_decl}><typeOfResource>software, multimedia</typeOfResource></mods>"
100
+ @smods_rec.from_str(m)
101
+ expect(@smods_rec.format).to eq ['Computer File']
102
+ end
103
+ it "genre 'game'", :jira => 'GRYPHONDOR-207' do
104
+ m = "<mods #{@ns_decl}><genre>game</genre><typeOfResource>software, multimedia</typeOfResource></mods>"
105
+ @smods_rec.from_str(m)
106
+ expect(@smods_rec.format).to eq ['Computer File']
107
+ m = "<mods #{@ns_decl}><genre>Game</genre><typeOfResource>software, multimedia</typeOfResource></mods>"
108
+ @smods_rec.from_str(m)
109
+ expect(@smods_rec.format).to eq ['Computer File']
110
+ end
101
111
  end
102
- it "genre 'game'", :jira => 'GRYPHONDOR-207' do
103
- m = "<mods #{@ns_decl}><genre>game</genre><typeOfResource>software, multimedia</typeOfResource></mods>"
112
+
113
+ it "Conference Proceedings: typeOfResource 'text', genre 'conference publication'", :jira => 'GRYPHONDOR-207' do
114
+ m = "<mods #{@ns_decl}><genre>conference publication</genre><typeOfResource>text</typeOfResource></mods>"
115
+ @smods_rec.from_str(m)
116
+ expect(@smods_rec.format).to eq ['Conference Proceedings']
117
+ m = "<mods #{@ns_decl}><genre>Conference publication</genre><typeOfResource>text</typeOfResource></mods>"
104
118
  @smods_rec.from_str(m)
105
- expect(@smods_rec.format).to eq ['Computer File']
106
- m = "<mods #{@ns_decl}><genre>Game</genre><typeOfResource>software, multimedia</typeOfResource></mods>"
119
+ expect(@smods_rec.format).to eq ['Conference Proceedings']
120
+ m = "<mods #{@ns_decl}><genre>Conference Publication</genre><typeOfResource>text</typeOfResource></mods>"
107
121
  @smods_rec.from_str(m)
108
- expect(@smods_rec.format).to eq ['Computer File']
122
+ expect(@smods_rec.format).to eq ['Conference Proceedings']
109
123
  end
110
- end
111
-
112
- it "Conference Proceedings: typeOfResource 'text', genre 'conference publication'", :jira => 'GRYPHONDOR-207' do
113
- m = "<mods #{@ns_decl}><genre>conference publication</genre><typeOfResource>text</typeOfResource></mods>"
114
- @smods_rec.from_str(m)
115
- expect(@smods_rec.format).to eq ['Conference Proceedings']
116
- m = "<mods #{@ns_decl}><genre>Conference publication</genre><typeOfResource>text</typeOfResource></mods>"
117
- @smods_rec.from_str(m)
118
- expect(@smods_rec.format).to eq ['Conference Proceedings']
119
- m = "<mods #{@ns_decl}><genre>Conference Publication</genre><typeOfResource>text</typeOfResource></mods>"
120
- @smods_rec.from_str(m)
121
- expect(@smods_rec.format).to eq ['Conference Proceedings']
122
- end
123
124
 
124
- it "Journal/Periodical: typeOfResource 'text', genre 'article'" do
125
- m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre>article</genre></mods>"
126
- @smods_rec.from_str(m)
127
- expect(@smods_rec.format).to eq ['Journal/Periodical']
128
- m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre>Article</genre></mods>"
129
- @smods_rec.from_str(m)
130
- expect(@smods_rec.format).to eq ['Journal/Periodical']
131
- end
125
+ context "Journal/Periodical: typeOfResource 'text'," do
126
+ it "genre 'article" do
127
+ m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre>article</genre></mods>"
128
+ @smods_rec.from_str(m)
129
+ expect(@smods_rec.format).to eq ['Journal/Periodical']
130
+ m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre>Article</genre></mods>"
131
+ @smods_rec.from_str(m)
132
+ expect(@smods_rec.format).to eq ['Journal/Periodical']
133
+ end
134
+ it "originInfo/issuance 'continuing'" do
135
+ m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><originInfo><issuance>continuing</issuance></originInfo></mods>"
136
+ @smods_rec.from_str(m)
137
+ expect(@smods_rec.format).to eq ['Journal/Periodical']
138
+ end
139
+ end
132
140
 
133
- it "Image: typeOfResource 'still image'" do
134
- m = "<mods #{@ns_decl}><typeOfResource>still image</typeOfResource></mods>"
135
- @smods_rec.from_str(m)
136
- expect(@smods_rec.format).to eq ['Image']
137
- end
141
+ it "Image: typeOfResource 'still image'" do
142
+ m = "<mods #{@ns_decl}><typeOfResource>still image</typeOfResource></mods>"
143
+ @smods_rec.from_str(m)
144
+ expect(@smods_rec.format).to eq ['Image']
145
+ end
146
+
147
+ it "Manuscript/Archive: typeOfResource 'mixed material'" do
148
+ m = "<mods #{@ns_decl}><typeOfResource>mixed material</typeOfResource></mods>"
149
+ @smods_rec.from_str(m)
150
+ expect(@smods_rec.format).to eq ['Manuscript/Archive']
151
+ end
152
+
153
+ it "Map/Globe: typeOfResource 'cartographic'" do
154
+ m = "<mods #{@ns_decl}><typeOfResource>cartographic</typeOfResource></mods>"
155
+ @smods_rec.from_str(m)
156
+ expect(@smods_rec.format).to eq ['Map/Globe']
157
+ end
138
158
 
139
- it "Music - Recording: typeOfResource 'sound recording-musical'", :jira => 'GRYPHONDOR-207' do
140
- m = "<mods #{@ns_decl}><typeOfResource>sound recording-musical</typeOfResource></mods>"
141
- @smods_rec.from_str(m)
142
- expect(@smods_rec.format).to eq ['Music - Recording']
143
- end
159
+ it "Music - Recording: typeOfResource 'sound recording-musical'", :jira => 'GRYPHONDOR-207' do
160
+ m = "<mods #{@ns_decl}><typeOfResource>sound recording-musical</typeOfResource></mods>"
161
+ @smods_rec.from_str(m)
162
+ expect(@smods_rec.format).to eq ['Music - Recording']
163
+ end
144
164
 
145
- it "Music - Score: typeOfResource 'notated music'" do
146
- m = "<mods #{@ns_decl}><typeOfResource>notated music</typeOfResource></mods>"
147
- @smods_rec.from_str(m)
148
- expect(@smods_rec.format).to eq ['Music - Score']
149
- end
165
+ it "Music - Score: typeOfResource 'notated music'" do
166
+ m = "<mods #{@ns_decl}><typeOfResource>notated music</typeOfResource></mods>"
167
+ @smods_rec.from_str(m)
168
+ expect(@smods_rec.format).to eq ['Music - Score']
169
+ end
150
170
 
151
- it "Other: typeOfResource 'text', genre 'student project report'", :email => 'from Vitus, August 16, 2013' do
152
- m = "<mods #{@ns_decl}><genre>student project report</genre><typeOfResource>text</typeOfResource></mods>"
153
- @smods_rec.from_str(m)
154
- expect(@smods_rec.format).to eq ['Other']
155
- m = "<mods #{@ns_decl}><genre>Student project report</genre><typeOfResource>text</typeOfResource></mods>"
156
- @smods_rec.from_str(m)
157
- expect(@smods_rec.format).to eq ['Other']
158
- m = "<mods #{@ns_decl}><genre>Student Project report</genre><typeOfResource>text</typeOfResource></mods>"
159
- @smods_rec.from_str(m)
160
- expect(@smods_rec.format).to eq ['Other']
161
- m = "<mods #{@ns_decl}><genre>Student Project Report</genre><typeOfResource>text</typeOfResource></mods>"
162
- @smods_rec.from_str(m)
163
- expect(@smods_rec.format).to eq ['Other']
164
- end
165
-
166
- context "Sound Recording:" do
167
- it "typeOfResource 'sound recording-nonmusical', genre 'sound", :jira => 'GRYPHONDOR-207' do
168
- m = "<mods #{@ns_decl}><genre>sound</genre><typeOfResource>sound recording-nonmusical</typeOfResource></mods>"
171
+ it "Other: typeOfResource 'text', genre 'student project report'", :email => 'from Vitus, August 16, 2013' do
172
+ m = "<mods #{@ns_decl}><genre>student project report</genre><typeOfResource>text</typeOfResource></mods>"
169
173
  @smods_rec.from_str(m)
170
- expect(@smods_rec.format).to eq ['Sound Recording']
171
- m = "<mods #{@ns_decl}><genre>Sound</genre><typeOfResource>sound recording-nonmusical</typeOfResource></mods>"
174
+ expect(@smods_rec.format).to eq ['Other']
175
+ m = "<mods #{@ns_decl}><genre>Student project report</genre><typeOfResource>text</typeOfResource></mods>"
172
176
  @smods_rec.from_str(m)
173
- expect(@smods_rec.format).to eq ['Sound Recording']
177
+ expect(@smods_rec.format).to eq ['Other']
178
+ m = "<mods #{@ns_decl}><genre>Student Project report</genre><typeOfResource>text</typeOfResource></mods>"
179
+ @smods_rec.from_str(m)
180
+ expect(@smods_rec.format).to eq ['Other']
181
+ m = "<mods #{@ns_decl}><genre>Student Project Report</genre><typeOfResource>text</typeOfResource></mods>"
182
+ @smods_rec.from_str(m)
183
+ expect(@smods_rec.format).to eq ['Other']
184
+ end
185
+
186
+ context "Sound Recording:" do
187
+ it "typeOfResource 'sound recording-nonmusical', genre 'sound", :jira => 'GRYPHONDOR-207' do
188
+ m = "<mods #{@ns_decl}><genre>sound</genre><typeOfResource>sound recording-nonmusical</typeOfResource></mods>"
189
+ @smods_rec.from_str(m)
190
+ expect(@smods_rec.format).to eq ['Sound Recording']
191
+ m = "<mods #{@ns_decl}><genre>Sound</genre><typeOfResource>sound recording-nonmusical</typeOfResource></mods>"
192
+ @smods_rec.from_str(m)
193
+ expect(@smods_rec.format).to eq ['Sound Recording']
194
+ end
195
+ it "typeOfResource 'sound recording', genre 'sound", :jira => 'INDEX-94' do
196
+ m = "<mods #{@ns_decl}><genre>sound</genre><typeOfResource>sound recording</typeOfResource></mods>"
197
+ @smods_rec.from_str(m)
198
+ expect(@smods_rec.format).to eq ['Sound Recording']
199
+ m = "<mods #{@ns_decl}><genre>Sound</genre><typeOfResource>sound recording</typeOfResource></mods>"
200
+ @smods_rec.from_str(m)
201
+ expect(@smods_rec.format).to eq ['Sound Recording']
202
+ end
174
203
  end
175
- it "typeOfResource 'sound recording', genre 'sound", :jira => 'INDEX-94' do
176
- m = "<mods #{@ns_decl}><genre>sound</genre><typeOfResource>sound recording</typeOfResource></mods>"
204
+
205
+ it "Thesis: typeOfResource 'text', genre 'thesis'" do
206
+ m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre>thesis</genre></mods>"
177
207
  @smods_rec.from_str(m)
178
- expect(@smods_rec.format).to eq ['Sound Recording']
179
- m = "<mods #{@ns_decl}><genre>Sound</genre><typeOfResource>sound recording</typeOfResource></mods>"
208
+ expect(@smods_rec.format).to eq ['Thesis']
209
+ m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre>Thesis</genre></mods>"
180
210
  @smods_rec.from_str(m)
181
- expect(@smods_rec.format).to eq ['Sound Recording']
211
+ expect(@smods_rec.format).to eq ['Thesis']
182
212
  end
183
- end
184
213
 
185
- it "Thesis: typeOfResource 'text', genre 'thesis'" do
186
- m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre>thesis</genre></mods>"
187
- @smods_rec.from_str(m)
188
- expect(@smods_rec.format).to eq ['Thesis']
189
- m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre>Thesis</genre></mods>"
190
- @smods_rec.from_str(m)
191
- expect(@smods_rec.format).to eq ['Thesis']
192
- end
214
+ context "Video: typeOfResource 'moving image'" do
215
+ it "no genre" do
216
+ m = "<mods #{@ns_decl}><typeOfResource>moving image</typeOfResource></mods>"
217
+ @smods_rec.from_str(m)
218
+ expect(@smods_rec.format).to eq ['Video']
219
+ end
220
+ it "genre 'motion picture'", :jira => 'GRYPHONDOR-207' do
221
+ m = "<mods #{@ns_decl}><genre>motion picture</genre><typeOfResource>moving image</typeOfResource></mods>"
222
+ @smods_rec.from_str(m)
223
+ expect(@smods_rec.format).to eq ['Video']
224
+ m = "<mods #{@ns_decl}><genre>Motion Picture</genre><typeOfResource>moving image</typeOfResource></mods>"
225
+ @smods_rec.from_str(m)
226
+ expect(@smods_rec.format).to eq ['Video']
227
+ m = "<mods #{@ns_decl}><genre>Motion Picture</genre><typeOfResource>moving image</typeOfResource></mods>"
228
+ @smods_rec.from_str(m)
229
+ expect(@smods_rec.format).to eq ['Video']
230
+ end
231
+ end
232
+
233
+ context "multiple format values", :jira => 'INDEX-32' do
234
+ it "multiple typeOfResource elements" do
235
+ m = "<mods #{@ns_decl}><typeOfResource>moving image</typeOfResource><typeOfResource>sound recording</typeOfResource></mods>"
236
+ @smods_rec.from_str(m)
237
+ expect(@smods_rec.format).to eq ['Video', 'Sound Recording']
238
+ end
239
+ it "multiple genre elements, single typeOfResource" do
240
+ m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre>librettos</genre><genre>article</genre></mods>"
241
+ @smods_rec.from_str(m)
242
+ expect(@smods_rec.format).to eq ['Book', 'Journal/Periodical']
243
+ end
244
+ it "mish mash" do
245
+ m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><typeOfResource>still image</typeOfResource><genre>librettos</genre><genre>article</genre></mods>"
246
+ @smods_rec.from_str(m)
247
+ expect(@smods_rec.format).to eq ['Book', 'Journal/Periodical', 'Image']
248
+ end
249
+ it "doesn't give duplicate values" do
250
+ m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre>librettos</genre><genre>issue brief</genre></mods>"
251
+ @smods_rec.from_str(m)
252
+ expect(@smods_rec.format).to eq ['Book']
253
+ end
254
+ end
193
255
 
194
- context "Video: typeOfResource 'moving image'" do
195
- it "no genre" do
196
- m = "<mods #{@ns_decl}><typeOfResource>moving image</typeOfResource></mods>"
256
+ it "empty Array if no typeOfResource field" do
257
+ m = "<mods #{@ns_decl}><originInfo>
258
+ <dateCreated>1904</dateCreated>
259
+ </originInfo></mods>"
197
260
  @smods_rec.from_str(m)
198
- expect(@smods_rec.format).to eq ['Video']
261
+ expect(@smods_rec.format).to eq []
199
262
  end
200
- it "genre 'motion picture'", :jira => 'GRYPHONDOR-207' do
201
- m = "<mods #{@ns_decl}><genre>motion picture</genre><typeOfResource>moving image</typeOfResource></mods>"
263
+
264
+ it "empty Array if weird typeOfResource value" do
265
+ m = "<mods #{@ns_decl}>
266
+ <typeOfResource>foo</typeOfResource>
267
+ </mods>"
202
268
  @smods_rec.from_str(m)
203
- expect(@smods_rec.format).to eq ['Video']
204
- m = "<mods #{@ns_decl}><genre>Motion Picture</genre><typeOfResource>moving image</typeOfResource></mods>"
269
+ expect(@smods_rec.format).to eq []
270
+ end
271
+ end # format
272
+
273
+ context "format_main" do
274
+ it "3D object: typeOfResource 'three dimensional object'" do
275
+ m = "<mods #{@ns_decl}><typeOfResource>three dimensional object</typeOfResource></mods>"
205
276
  @smods_rec.from_str(m)
206
- expect(@smods_rec.format).to eq ['Video']
207
- m = "<mods #{@ns_decl}><genre>Motion Picture</genre><typeOfResource>moving image</typeOfResource></mods>"
277
+ expect(@smods_rec.format_main).to eq ['Object']
278
+ end
279
+
280
+ it "Archive/Manuscript: typeOfResource 'mixed material'" do
281
+ m = "<mods #{@ns_decl}><typeOfResource>mixed material</typeOfResource></mods>"
208
282
  @smods_rec.from_str(m)
209
- expect(@smods_rec.format).to eq ['Video']
283
+ expect(@smods_rec.format_main).to eq ['Archive/Manuscript']
284
+ end
285
+
286
+ context "Article: typeOfResource text, genre" do
287
+ it "'article'" do
288
+ m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre authority=\"marcgt\">article</genre></mods>"
289
+ @smods_rec.from_str(m)
290
+ expect(@smods_rec.format_main).to eq ['Article']
291
+ m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre authority=\"marcgt\">Article</genre></mods>"
292
+ @smods_rec.from_str(m)
293
+ expect(@smods_rec.format_main).to eq ['Article']
294
+ end
295
+ it "'book chapter'", :email => 'mods-squad 2014-05-22, Joanna Dyla' do
296
+ m = "<mods #{@ns_decl}><genre authority=\"local\">book chapter</genre><typeOfResource>text</typeOfResource></mods>"
297
+ @smods_rec.from_str(m)
298
+ expect(@smods_rec.format_main).to eq ['Article']
299
+ m = "<mods #{@ns_decl}><genre authority=\"local\">Book chapter</genre><typeOfResource>text</typeOfResource></mods>"
300
+ @smods_rec.from_str(m)
301
+ expect(@smods_rec.format_main).to eq ['Article']
302
+ m = "<mods #{@ns_decl}><genre authority=\"local\">Book Chapter</genre><typeOfResource>text</typeOfResource></mods>"
303
+ @smods_rec.from_str(m)
304
+ expect(@smods_rec.format_main).to eq ['Article']
305
+ end
306
+ it "'issue brief'", :email => 'mods-squad 2014-05-22, Joanna Dyla' do
307
+ m = "<mods #{@ns_decl}><genre authority=\"local\">issue brief</genre><typeOfResource>text</typeOfResource></mods>"
308
+ @smods_rec.from_str(m)
309
+ expect(@smods_rec.format_main).to eq ['Article']
310
+ m = "<mods #{@ns_decl}><genre authority=\"local\">Issue brief</genre><typeOfResource>text</typeOfResource></mods>"
311
+ @smods_rec.from_str(m)
312
+ expect(@smods_rec.format_main).to eq ['Article']
313
+ m = "<mods #{@ns_decl}><genre authority=\"local\">Issue Brief</genre><typeOfResource>text</typeOfResource></mods>"
314
+ @smods_rec.from_str(m)
315
+ expect(@smods_rec.format_main).to eq ['Article']
316
+ end
317
+ it "'project report'", :jira => 'GRYP-170', :github => 'gdor-indexer/#7' do
318
+ m = "<mods #{@ns_decl}><genre>project report</genre><typeOfResource>text</typeOfResource></mods>"
319
+ @smods_rec.from_str(m)
320
+ expect(@smods_rec.format_main).to eq ['Article']
321
+ m = "<mods #{@ns_decl}><genre>Project report</genre><typeOfResource>text</typeOfResource></mods>"
322
+ @smods_rec.from_str(m)
323
+ expect(@smods_rec.format_main).to eq ['Article']
324
+ m = "<mods #{@ns_decl}><genre>Project Report</genre><typeOfResource>text</typeOfResource></mods>"
325
+ @smods_rec.from_str(m)
326
+ expect(@smods_rec.format_main).to eq ['Article']
327
+ end
328
+ it "'report' isn't valid", :jira => 'GRYP-170', :github => 'gdor-indexer/#7' do
329
+ m = "<mods #{@ns_decl}><genre>report</genre><typeOfResource>text</typeOfResource></mods>"
330
+ @smods_rec.from_str(m)
331
+ expect(@smods_rec.format_main).to eq []
332
+ end
333
+ it "'student project report'", :consul => '/NGDE/Format 2014-05-28' do
334
+ m = "<mods #{@ns_decl}><genre authority=\"local\">student project report</genre><typeOfResource>text</typeOfResource></mods>"
335
+ @smods_rec.from_str(m)
336
+ expect(@smods_rec.format_main).to eq ['Article']
337
+ m = "<mods #{@ns_decl}><genre authority=\"local\">Student project report</genre><typeOfResource>text</typeOfResource></mods>"
338
+ @smods_rec.from_str(m)
339
+ expect(@smods_rec.format_main).to eq ['Article']
340
+ m = "<mods #{@ns_decl}><genre authority=\"local\">Student Project report</genre><typeOfResource>text</typeOfResource></mods>"
341
+ @smods_rec.from_str(m)
342
+ expect(@smods_rec.format_main).to eq ['Article']
343
+ m = "<mods #{@ns_decl}><genre authority=\"local\">Student Project Report</genre><typeOfResource>text</typeOfResource></mods>"
344
+ @smods_rec.from_str(m)
345
+ expect(@smods_rec.format_main).to eq ['Article']
346
+ end
347
+ it "'technical report'", :jira => 'GRYPHONDOR-207' do
348
+ m = "<mods #{@ns_decl}><genre authority=\"marcgt\">technical report</genre><typeOfResource>text</typeOfResource></mods>"
349
+ @smods_rec.from_str(m)
350
+ expect(@smods_rec.format_main).to eq ['Article']
351
+ m = "<mods #{@ns_decl}><genre authority=\"marcgt\">Technical report</genre><typeOfResource>text</typeOfResource></mods>"
352
+ @smods_rec.from_str(m)
353
+ expect(@smods_rec.format_main).to eq ['Article']
354
+ m = "<mods #{@ns_decl}><genre authority=\"marcgt\">Technical Report</genre><typeOfResource>text</typeOfResource></mods>"
355
+ @smods_rec.from_str(m)
356
+ expect(@smods_rec.format_main).to eq ['Article']
357
+ end
358
+ it "'working paper'", :email => 'mods-squad 2014-05-22, Joanna Dyla' do
359
+ m = "<mods #{@ns_decl}><genre authority=\"local\">working paper</genre><typeOfResource>text</typeOfResource></mods>"
360
+ @smods_rec.from_str(m)
361
+ expect(@smods_rec.format_main).to eq ['Article']
362
+ m = "<mods #{@ns_decl}><genre authority=\"local\">Working paper</genre><typeOfResource>text</typeOfResource></mods>"
363
+ @smods_rec.from_str(m)
364
+ expect(@smods_rec.format_main).to eq ['Article']
365
+ m = "<mods #{@ns_decl}><genre authority=\"local\">Working Paper</genre><typeOfResource>text</typeOfResource></mods>"
366
+ @smods_rec.from_str(m)
367
+ expect(@smods_rec.format_main).to eq ['Article']
368
+ end
369
+ end # Article
370
+
371
+ context "Book" do
372
+ context "typeOfResource text," do
373
+ it 'originInfo/issuance monographic' do
374
+ m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><originInfo><issuance>monographic</issuance></originInfo></mods>"
375
+ @smods_rec.from_str(m)
376
+ expect(@smods_rec.format_main).to eq ['Book']
377
+ end
378
+ context "genre" do
379
+ it "'conference publication'", :jira => 'GRYPHONDOR-207' do
380
+ m = "<mods #{@ns_decl}><genre authority=\"marcgt\">conference publication</genre><typeOfResource>text</typeOfResource></mods>"
381
+ @smods_rec.from_str(m)
382
+ expect(@smods_rec.format_main).to eq ['Book']
383
+ m = "<mods #{@ns_decl}><genre authority=\"marcgt\">Conference publication</genre><typeOfResource>text</typeOfResource></mods>"
384
+ @smods_rec.from_str(m)
385
+ expect(@smods_rec.format_main).to eq ['Book']
386
+ m = "<mods #{@ns_decl}><genre authority=\"marcgt\">Conference Publication</genre><typeOfResource>text</typeOfResource></mods>"
387
+ @smods_rec.from_str(m)
388
+ expect(@smods_rec.format_main).to eq ['Book']
389
+ end
390
+ it "'instruction'", :consul => '/NGDE/Format 2014-05-28' do
391
+ # Hydrus 'textbook'
392
+ m = "<mods #{@ns_decl}><genre authority=\"marcgt\">instruction</genre><typeOfResource>text</typeOfResource></mods>"
393
+ @smods_rec.from_str(m)
394
+ expect(@smods_rec.format_main).to eq ['Book']
395
+ m = "<mods #{@ns_decl}><genre authority=\"marcgt\">Instruction</genre><typeOfResource>text</typeOfResource></mods>"
396
+ @smods_rec.from_str(m)
397
+ expect(@smods_rec.format_main).to eq ['Book']
398
+ end
399
+ it "'libretto' isn't valid", :jira => 'INDEX-98' do
400
+ m = "<mods #{@ns_decl}><genre>libretto</genre><typeOfResource>text</typeOfResource></mods>"
401
+ @smods_rec.from_str(m)
402
+ expect(@smods_rec.format_main).to eq []
403
+ end
404
+ it "'librettos'", :jira => 'INDEX-98' do
405
+ m = "<mods #{@ns_decl}><genre>librettos</genre><typeOfResource>text</typeOfResource></mods>"
406
+ @smods_rec.from_str(m)
407
+ expect(@smods_rec.format_main).to eq ['Book']
408
+ m = "<mods #{@ns_decl}><genre>Librettos</genre><typeOfResource>text</typeOfResource></mods>"
409
+ @smods_rec.from_str(m)
410
+ expect(@smods_rec.format_main).to eq ['Book']
411
+ end
412
+ it "'thesis'" do
413
+ m = "<mods #{@ns_decl}><genre authority=\"marcgt\">thesis</genre><typeOfResource>text</typeOfResource></mods>"
414
+ @smods_rec.from_str(m)
415
+ expect(@smods_rec.format_main).to eq ['Book']
416
+ m = "<mods #{@ns_decl}><genre authority=\"marcgt\">Thesis</genre><typeOfResource>text</typeOfResource></mods>"
417
+ @smods_rec.from_str(m)
418
+ expect(@smods_rec.format_main).to eq ['Book']
419
+ end
420
+ end
421
+ end
422
+ end # Book
423
+
424
+ context "Dataset: typeOfResource 'software, multimedia'" do
425
+ it "genre 'dataset'" do
426
+ m = "<mods #{@ns_decl}><genre authority=\"local\">dataset</genre><typeOfResource>software, multimedia</typeOfResource></mods>"
427
+ @smods_rec.from_str(m)
428
+ expect(@smods_rec.format_main).to eq ['Dataset']
429
+ m = "<mods #{@ns_decl}><genre authority=\"local\">Dataset</genre><typeOfResource>software, multimedia</typeOfResource></mods>"
430
+ @smods_rec.from_str(m)
431
+ expect(@smods_rec.format_main).to eq ['Dataset']
432
+ end
210
433
  end
211
- end
212
434
 
213
- context "multiple format values", :jira => 'INDEX-32' do
214
- it "multiple typeOfResource elements" do
215
- m = "<mods #{@ns_decl}><typeOfResource>moving image</typeOfResource><typeOfResource>sound recording</typeOfResource></mods>"
435
+ it "Image: typeOfResource 'still image'" do
436
+ m = "<mods #{@ns_decl}><typeOfResource>still image</typeOfResource></mods>"
216
437
  @smods_rec.from_str(m)
217
- expect(@smods_rec.format).to eq ['Video', 'Sound Recording']
438
+ expect(@smods_rec.format_main).to eq ['Image']
218
439
  end
219
- it "multiple genre elements, single typeOfResource" do
220
- m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre>librettos</genre><genre>article</genre></mods>"
440
+
441
+ it "Journal/Periodical: typeOfResource 'text', originInfo/issuance 'continuing'" do
442
+ m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><originInfo><issuance>continuing</issuance></originInfo></mods>"
221
443
  @smods_rec.from_str(m)
222
- expect(@smods_rec.format).to eq ['Book', 'Journal/Periodical']
444
+ expect(@smods_rec.format_main).to eq ['Journal/Periodical']
223
445
  end
224
- it "mish mash" do
225
- m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><typeOfResource>still image</typeOfResource><genre>librettos</genre><genre>article</genre></mods>"
446
+
447
+ it "Map: typeOfResource 'cartographic'" do
448
+ m = "<mods #{@ns_decl}><typeOfResource>cartographic</typeOfResource></mods>"
226
449
  @smods_rec.from_str(m)
227
- expect(@smods_rec.format).to eq ['Book', 'Journal/Periodical', 'Image']
450
+ expect(@smods_rec.format_main).to eq ['Map']
451
+ end
452
+
453
+ context "Music - Recording: typeOfResource 'sound recording-musical'", :jira => 'GRYPHONDOR-207' do
454
+ it "no genre" do
455
+ m = "<mods #{@ns_decl}><typeOfResource>sound recording-musical</typeOfResource></mods>"
456
+ @smods_rec.from_str(m)
457
+ expect(@smods_rec.format_main).to eq ['Music recording']
458
+ end
459
+ it "genre 'sound'" do
460
+ m = "<mods #{@ns_decl}><typeOfResource>sound recording-musical</typeOfResource><genre authority=\"marcgt\">sound</genre></mods>"
461
+ @smods_rec.from_str(m)
462
+ expect(@smods_rec.format_main).to eq ['Music recording']
463
+ m = "<mods #{@ns_decl}><typeOfResource>sound recording-musical</typeOfResource><genre authority=\"marcgt\">Sound</genre></mods>"
464
+ @smods_rec.from_str(m)
465
+ expect(@smods_rec.format_main).to eq ['Music recording']
466
+ end
228
467
  end
229
- it "doesn't give duplicate values" do
230
- m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre>librettos</genre><genre>issue brief</genre></mods>"
468
+
469
+ it "Music - Score: typeOfResource 'notated music'" do
470
+ m = "<mods #{@ns_decl}><typeOfResource>notated music</typeOfResource></mods>"
231
471
  @smods_rec.from_str(m)
232
- expect(@smods_rec.format).to eq ['Book']
472
+ expect(@smods_rec.format_main).to eq ['Music score']
233
473
  end
234
- end
235
474
 
236
- it "empty Array if no typeOfResource field" do
237
- m = "<mods #{@ns_decl}><originInfo>
238
- <dateCreated>1904</dateCreated>
239
- </originInfo></mods>"
240
- @smods_rec.from_str(m)
241
- expect(@smods_rec.format).to eq []
242
- end
475
+ context "Software/Multimedia: typeOfResource 'software, multimedia'" do
476
+ it "no genre" do
477
+ m = "<mods #{@ns_decl}><typeOfResource>software, multimedia</typeOfResource></mods>"
478
+ @smods_rec.from_str(m)
479
+ expect(@smods_rec.format_main).to eq ['Software/Multimedia']
480
+ end
481
+ it "genre 'game'", :jira => 'GRYPHONDOR-207' do
482
+ m = "<mods #{@ns_decl}><genre authority=\"marcgt\">game</genre><typeOfResource>software, multimedia</typeOfResource></mods>"
483
+ @smods_rec.from_str(m)
484
+ expect(@smods_rec.format_main).to eq ['Software/Multimedia']
485
+ m = "<mods #{@ns_decl}><genre authority=\"marcgt\">Game</genre><typeOfResource>software, multimedia</typeOfResource></mods>"
486
+ @smods_rec.from_str(m)
487
+ expect(@smods_rec.format_main).to eq ['Software/Multimedia']
488
+ end
489
+ end
243
490
 
244
- it "empty Array if weird typeOfResource value" do
245
- m = "<mods #{@ns_decl}><originInfo>
246
- <typeOfResource>foo</typeOfResource>
247
- </originInfo></mods>"
248
- @smods_rec.from_str(m)
249
- expect(@smods_rec.format).to eq []
250
- end
491
+ context "Sound Recording:" do
492
+ it "typeOfResource 'sound recording-nonmusical', genre 'sound", :jira => 'GRYPHONDOR-207' do
493
+ m = "<mods #{@ns_decl}><genre>sound</genre><typeOfResource>sound recording-nonmusical</typeOfResource></mods>"
494
+ @smods_rec.from_str(m)
495
+ expect(@smods_rec.format_main).to eq ['Sound recording']
496
+ m = "<mods #{@ns_decl}><genre>Sound</genre><typeOfResource>sound recording-nonmusical</typeOfResource></mods>"
497
+ @smods_rec.from_str(m)
498
+ expect(@smods_rec.format_main).to eq ['Sound recording']
499
+ end
500
+ it "typeOfResource 'sound recording', genre 'sound", :jira => 'INDEX-94' do
501
+ m = "<mods #{@ns_decl}><genre>sound</genre><typeOfResource>sound recording</typeOfResource></mods>"
502
+ @smods_rec.from_str(m)
503
+ expect(@smods_rec.format_main).to eq ['Sound recording']
504
+ m = "<mods #{@ns_decl}><genre>Sound</genre><typeOfResource>sound recording</typeOfResource></mods>"
505
+ @smods_rec.from_str(m)
506
+ expect(@smods_rec.format_main).to eq ['Sound recording']
507
+ end
508
+ end
509
+
510
+
511
+ context "Video: typeOfResource 'moving image'" do
512
+ it "no genre" do
513
+ m = "<mods #{@ns_decl}><typeOfResource>moving image</typeOfResource></mods>"
514
+ @smods_rec.from_str(m)
515
+ expect(@smods_rec.format_main).to eq ['Video']
516
+ end
517
+ it "genre 'motion picture'", :jira => 'GRYPHONDOR-207' do
518
+ m = "<mods #{@ns_decl}><genre>motion picture</genre><typeOfResource>moving image</typeOfResource></mods>"
519
+ @smods_rec.from_str(m)
520
+ expect(@smods_rec.format_main).to eq ['Video']
521
+ m = "<mods #{@ns_decl}><genre>Motion picture</genre><typeOfResource>moving image</typeOfResource></mods>"
522
+ @smods_rec.from_str(m)
523
+ expect(@smods_rec.format_main).to eq ['Video']
524
+ m = "<mods #{@ns_decl}><genre>Motion Picture</genre><typeOfResource>moving image</typeOfResource></mods>"
525
+ @smods_rec.from_str(m)
526
+ expect(@smods_rec.format_main).to eq ['Video']
527
+ end
528
+ end
529
+
530
+ context "multiple values", :jira => 'INDEX-32' do
531
+ it "multiple typeOfResource elements" do
532
+ m = "<mods #{@ns_decl}><typeOfResource>moving image</typeOfResource><typeOfResource>sound recording</typeOfResource></mods>"
533
+ @smods_rec.from_str(m)
534
+ expect(@smods_rec.format_main).to eq ['Video', 'Sound recording']
535
+ end
536
+ it "multiple genre elements, single typeOfResource" do
537
+ m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre>librettos</genre><genre>article</genre></mods>"
538
+ @smods_rec.from_str(m)
539
+ expect(@smods_rec.format_main).to eq ['Article', 'Book']
540
+ end
541
+ it "mish mash" do
542
+ m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><typeOfResource>still image</typeOfResource><genre>librettos</genre><genre>article</genre></mods>"
543
+ @smods_rec.from_str(m)
544
+ expect(@smods_rec.format_main).to eq ['Article', 'Book', 'Image']
545
+ end
546
+ it "doesn't give duplicate values" do
547
+ m = "<mods #{@ns_decl}><typeOfResource>text</typeOfResource><genre>librettos</genre><genre>thesis</genre></mods>"
548
+ @smods_rec.from_str(m)
549
+ expect(@smods_rec.format_main).to eq ['Book']
550
+ end
551
+ end
552
+
553
+ it "empty Array if no typeOfResource field" do
554
+ m = "<mods #{@ns_decl}><originInfo>
555
+ <dateCreated>1904</dateCreated>
556
+ </originInfo></mods>"
557
+ @smods_rec.from_str(m)
558
+ expect(@smods_rec.format_main).to eq []
559
+ end
560
+
561
+ it "empty Array if weird typeOfResource value" do
562
+ m = "<mods #{@ns_decl}>
563
+ <typeOfResource>foo</typeOfResource>
564
+ </mods>"
565
+ @smods_rec.from_str(m)
566
+ expect(@smods_rec.format_main).to eq []
567
+ end
568
+ end #format_main
569
+
570
+ context "sw_genre" do
571
+ it "Conference proceedings: typeOfResource 'text', genre 'conference publication'" do
572
+ m = "<mods #{@ns_decl}><genre authority=\"marcgt\">conference publication</genre><typeOfResource>text</typeOfResource></mods>"
573
+ @smods_rec.from_str(m)
574
+ expect(@smods_rec.sw_genre).to eq ['Conference proceedings']
575
+ m = "<mods #{@ns_decl}><genre authority=\"marcgt\">Conference publication</genre><typeOfResource>text</typeOfResource></mods>"
576
+ @smods_rec.from_str(m)
577
+ expect(@smods_rec.sw_genre).to eq ['Conference proceedings']
578
+ m = "<mods #{@ns_decl}><genre authority=\"marcgt\">Conference Publication</genre><typeOfResource>text</typeOfResource></mods>"
579
+ @smods_rec.from_str(m)
580
+ expect(@smods_rec.sw_genre).to eq ['Conference proceedings']
581
+ end
582
+ it "Thesis/Dissertation: typeOfResource 'text', genre 'thesis'" do
583
+ m = "<mods #{@ns_decl}><genre authority=\"marcgt\">thesis</genre><typeOfResource>text</typeOfResource></mods>"
584
+ @smods_rec.from_str(m)
585
+ expect(@smods_rec.sw_genre).to eq ['Thesis/Dissertation']
586
+ m = "<mods #{@ns_decl}><genre authority=\"marcgt\">Thesis</genre><typeOfResource>text</typeOfResource></mods>"
587
+ @smods_rec.from_str(m)
588
+ expect(@smods_rec.sw_genre).to eq ['Thesis/Dissertation']
589
+ end
590
+ it "capitalizes the first letter of a genre value" do
591
+ m = "<mods #{@ns_decl}><genre authority=\"marcgt\">student project report</genre></mods>"
592
+ @smods_rec.from_str(m)
593
+ expect(@smods_rec.sw_genre).to eq ['Student project report']
594
+ m = "<mods #{@ns_decl}><genre authority=\"marcgt\">Student project report</genre></mods>"
595
+ @smods_rec.from_str(m)
596
+ expect(@smods_rec.sw_genre).to eq ['Student project report']
597
+ m = "<mods #{@ns_decl}><genre authority=\"marcgt\">Student Project report</genre></mods>"
598
+ @smods_rec.from_str(m)
599
+ expect(@smods_rec.sw_genre).to eq ['Student project report']
600
+ m = "<mods #{@ns_decl}><genre authority=\"marcgt\">Student Project Report</genre></mods>"
601
+ @smods_rec.from_str(m)
602
+ expect(@smods_rec.sw_genre).to eq ['Student project report']
603
+ end
604
+ # NOTE: may need to remove plurals and/or trailing punctuation in future
605
+ it "returns all genre values" do
606
+ m = "<mods #{@ns_decl}>
607
+ <genre>game</genre>
608
+ <genre>foo</genre>
609
+ <genre>technical report</genre>
610
+ </mods>"
611
+ @smods_rec.from_str(m)
612
+ expect(@smods_rec.sw_genre).to eq ['Game', 'Foo', 'Technical report']
613
+ end
614
+ it "doesn't have duplicates" do
615
+ m = "<mods #{@ns_decl}>
616
+ <genre>game</genre>
617
+ <genre>technical report</genre>
618
+ <genre>Game</genre>
619
+ </mods>"
620
+ @smods_rec.from_str(m)
621
+ expect(@smods_rec.sw_genre).to eq ['Game', 'Technical report']
622
+ end
623
+ it "empty Array if no genre values" do
624
+ m = "<mods #{@ns_decl}>
625
+ <typeOfResource>text</typeOfResource>
626
+ </mods>"
627
+ @smods_rec.from_str(m)
628
+ expect(@smods_rec.sw_genre).to eq []
629
+ end
630
+ end # sw_genre
251
631
  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.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Naomi Dushay
@@ -9,76 +9,76 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-06-30 00:00:00.000000000 Z
12
+ date: 2014-07-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: mods
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - '>='
18
+ - - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: '0'
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - '>='
25
+ - - ">="
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: rake
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - '>='
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
34
  version: '0'
35
35
  type: :development
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
- - - '>='
39
+ - - ">="
40
40
  - !ruby/object:Gem::Version
41
41
  version: '0'
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: rdoc
44
44
  requirement: !ruby/object:Gem::Requirement
45
45
  requirements:
46
- - - '>='
46
+ - - ">="
47
47
  - !ruby/object:Gem::Version
48
48
  version: '0'
49
49
  type: :development
50
50
  prerelease: false
51
51
  version_requirements: !ruby/object:Gem::Requirement
52
52
  requirements:
53
- - - '>='
53
+ - - ">="
54
54
  - !ruby/object:Gem::Version
55
55
  version: '0'
56
56
  - !ruby/object:Gem::Dependency
57
57
  name: yard
58
58
  requirement: !ruby/object:Gem::Requirement
59
59
  requirements:
60
- - - '>='
60
+ - - ">="
61
61
  - !ruby/object:Gem::Version
62
62
  version: '0'
63
63
  type: :development
64
64
  prerelease: false
65
65
  version_requirements: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - '>='
67
+ - - ">="
68
68
  - !ruby/object:Gem::Version
69
69
  version: '0'
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rspec
72
72
  requirement: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - '>='
74
+ - - ">="
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
79
  version_requirements: !ruby/object:Gem::Requirement
80
80
  requirements:
81
- - - '>='
81
+ - - ">="
82
82
  - !ruby/object:Gem::Version
83
83
  version: '0'
84
84
  description: Stanford specific wrangling of MODS metadata from DOR, the Stanford Digital
@@ -92,10 +92,10 @@ extra_rdoc_files:
92
92
  - LICENSE
93
93
  - README.rdoc
94
94
  files:
95
- - .coveralls.yml
96
- - .gitignore
97
- - .travis.yml
98
- - .yardopts
95
+ - ".coveralls.yml"
96
+ - ".gitignore"
97
+ - ".travis.yml"
98
+ - ".yardopts"
99
99
  - Gemfile
100
100
  - LICENSE
101
101
  - README.rdoc
@@ -123,12 +123,12 @@ require_paths:
123
123
  - lib
124
124
  required_ruby_version: !ruby/object:Gem::Requirement
125
125
  requirements:
126
- - - '>='
126
+ - - ">="
127
127
  - !ruby/object:Gem::Version
128
128
  version: '0'
129
129
  required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  requirements:
131
- - - '>='
131
+ - - ">="
132
132
  - !ruby/object:Gem::Version
133
133
  version: '0'
134
134
  requirements: []