stanford-mods 1.1.2 → 1.1.3
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 +4 -4
- data/.rspec +1 -0
- data/README.rdoc +12 -13
- data/Rakefile +3 -5
- data/config/mappings_hash.rb +22 -23
- data/lib/stanford-mods/searchworks.rb +91 -93
- data/lib/stanford-mods/version.rb +1 -1
- data/lib/stanford-mods.rb +7 -7
- data/spec/name_spec.rb +43 -43
- data/spec/searchworks_basic_spec.rb +49 -0
- data/spec/searchworks_format_spec.rb +7 -7
- data/spec/searchworks_pub_dates_spec.rb +50 -52
- data/spec/searchworks_spec.rb +25 -25
- data/spec/searchworks_subject_raw_spec.rb +83 -83
- data/spec/searchworks_subject_spec.rb +97 -93
- data/spec/searchworks_title_spec.rb +10 -10
- data/stanford-mods.gemspec +10 -10
- metadata +24 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9722c214d739a32c67490100bccdf57afb4b65ba
|
4
|
+
data.tar.gz: 76b4d92135bba2f46582d8e88358bba16c4c8502
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e31936949c817eac3eba720ff0e65b5aa9ce9a423c47fc77a2e13d5782b1f7a1c65f02ee30830c2bdd0035c2aa0f1a8fb4cb0d16ccf59c42eddfec20398709c
|
7
|
+
data.tar.gz: 2a47a14e8f912f9b7e8c528107d47ea0cf19ceeea10a291ae060d442ac96474da8356f047f63ff1a7c00e3d52996dffadc434071e7e91102fbfbbee5ec17fd81
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/README.rdoc
CHANGED
@@ -26,30 +26,29 @@ Or install it yourself as:
|
|
26
26
|
|
27
27
|
1. add stanford-mods to your gemfile
|
28
28
|
2. require 'stanford-mods'
|
29
|
-
3. (I don't think you will also need to require 'mods', but you might)
|
30
29
|
|
31
30
|
> m = Stanford::Mods::Record.new
|
32
31
|
> m.from_str('<mods><genre>ape</genre></mods>')
|
33
32
|
> m.genre
|
34
|
-
|
35
|
-
|
36
|
-
|
33
|
+
=> [#<Nokogiri::XML::Element:0x3fe07b48bb24 name="genre" children=[#<Nokogiri::XML::Text:0x3fe07a09a7dc "ape">]>]
|
34
|
+
> m.genre.text
|
35
|
+
=> "ape"
|
37
36
|
|
38
37
|
> m.to_be_removed <-- method I wrote in stanford-mods for proof of concept
|
39
38
|
in foo!
|
40
|
-
=> nil
|
39
|
+
=> nil
|
41
40
|
|
42
41
|
Example Using SearchWorks Mixins:
|
43
42
|
|
44
43
|
> require 'stanford-mods/searchworks'
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
53
52
|
|
54
53
|
1. Fork it
|
55
54
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
data/Rakefile
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
#!/usr/bin/env rake
|
2
2
|
require "bundler/gem_tasks"
|
3
|
-
|
4
|
-
require 'rake'
|
5
3
|
require 'bundler'
|
6
4
|
|
7
5
|
require 'rspec/core/rake_task'
|
@@ -16,9 +14,9 @@ rescue Bundler::BundlerError => e
|
|
16
14
|
exit e.status_code
|
17
15
|
end
|
18
16
|
|
19
|
-
task :default => :ci
|
17
|
+
task :default => :ci
|
20
18
|
|
21
|
-
desc "run continuous integration suite (tests, coverage, docs)"
|
19
|
+
desc "run continuous integration suite (tests, coverage, docs)"
|
22
20
|
task :ci => [:rspec, :doc]
|
23
21
|
|
24
22
|
task :spec => :rspec
|
@@ -42,5 +40,5 @@ rescue LoadError
|
|
42
40
|
task :doc do
|
43
41
|
abort "Please install the YARD gem to generate rdoc."
|
44
42
|
end
|
45
|
-
end
|
43
|
+
end
|
46
44
|
|
data/config/mappings_hash.rb
CHANGED
@@ -12,27 +12,27 @@ name_to_xpath = {
|
|
12
12
|
'type_of_resource' => '//typeOfResource/text()', # .to_s
|
13
13
|
|
14
14
|
# name
|
15
|
-
'corporate_authors' => '//mods/name[@type="corporate"]', # .ea .xpath('namePart').collect{ |a| a.text }.join(' ')
|
16
|
-
'personal_authors'
|
15
|
+
'corporate_authors' => '//mods/name[@type="corporate"]', # .ea .xpath('namePart').collect{ |a| a.text }.join(' ')
|
16
|
+
'personal_authors' => '//mods/name[@type="personal"]', # .ea .xpath('namePart').collect{ |a| a.text }.join(' ')
|
17
17
|
|
18
18
|
# titleInfo
|
19
|
-
'title'
|
20
|
-
'subtitle'
|
21
|
-
'full_title'
|
19
|
+
'title' => '//mods/titleInfo[not(@type="alternative")]', # .first, extract_title_from_title_info(node)
|
20
|
+
'subtitle' => '//mods/titleInfo/subTitle' #.first.text
|
21
|
+
'full_title' => '//mods/titleInfo', # .first, extract_full_title_from_title_info(node)
|
22
22
|
'title_variant' => '//mods/titleInfo[@type="alternative"]', # .first, extract_title_from_title_info(node)
|
23
23
|
|
24
24
|
# language
|
25
|
-
'language_codes' => "//language/languageTerm[@authority='iso639-2b'][@type='code']/text()",
|
26
|
-
'language_words' => "//language/languageTerm[@type='text']/text()|//language/text()",
|
25
|
+
'language_codes' => "//language/languageTerm[@authority='iso639-2b'][@type='code']/text()",
|
26
|
+
'language_words' => "//language/languageTerm[@type='text']/text()|//language/text()",
|
27
27
|
|
28
28
|
# physicalDescription
|
29
|
-
'physical_description_extent'
|
30
|
-
'physical_description_form'
|
29
|
+
'physical_description_extent' => '//physicalDescription/extent/text()', # .to_s
|
30
|
+
'physical_description_form' => '//physicalDescription/form/text()', # .to_s
|
31
31
|
'physical_description_media_type' => '//physicalDescription/internetMediaType/text()', # .to_s
|
32
32
|
|
33
33
|
# location
|
34
34
|
'physical_location' => '//location/physicalLocation/text()', # .to_s
|
35
|
-
'location_url'
|
35
|
+
'location_url' => '//location/url/text()', # .to_s
|
36
36
|
|
37
37
|
# relatedItem
|
38
38
|
'relateditem_location_url' => '//relatedItem/location/url/text()', # .to_s
|
@@ -40,17 +40,17 @@ name_to_xpath = {
|
|
40
40
|
|
41
41
|
# originInfo
|
42
42
|
'create_start_date' => '//originInfo/dateCreated[@point="start"]/text()', #.to_s - comes from passed node, not root
|
43
|
-
'create_end_date'
|
44
|
-
'date_issued'
|
45
|
-
'place_terms'
|
46
|
-
'publishers'
|
43
|
+
'create_end_date' => '//originInfo/dateCreated[@point="end"]/text()', #.to_s - comes from passed node, not root
|
44
|
+
'date_issued' => '//originInfo/dateIssued/text()', #.to_s - comes from passed node, not root
|
45
|
+
'place_terms' => '//originInfo/place/placeTerm/text()', # .to_s put in array, then .flatten.uniq
|
46
|
+
'publishers' => '//originInfo/publisher/text()', # .to_s put in array, then .flatten.uniq
|
47
47
|
# pub_date / pub_year
|
48
48
|
|
49
49
|
# subject
|
50
|
-
'subject_names'
|
51
|
-
'subject_topics'
|
50
|
+
'subject_names' => '//subject/name', # .ea .xpath('namePart/text().to_a.join(' ') then .uniq
|
51
|
+
'subject_topics' => '//subject/topic/text()', # .ea .to_s as array then .uniq
|
52
52
|
'subject_geographic' => '//subject/geographic/text()', # .ea .to_s as array then .uniq
|
53
|
-
'subject_temporal'
|
53
|
+
'subject_temporal' => '//subject/temporal/text()', # .ea .to_s as array then .uniq
|
54
54
|
# # TODO: subject/temporal can be either a string or an iso8601 date
|
55
55
|
# At some point we may need to handle date parsing here, but as a first
|
56
56
|
# pass, just assume everything is a string
|
@@ -62,18 +62,17 @@ name_to_xpath = {
|
|
62
62
|
# end
|
63
63
|
# else
|
64
64
|
'subject_title_info' => '//subject/titleInfo', # .ea extract_full_title_from_title_info(node), then .flatten.uniq
|
65
|
-
|
65
|
+
|
66
66
|
'fulltext' => '//text()', # .collect { |n| n.to_s }.join(' ')
|
67
|
-
|
67
|
+
|
68
68
|
# TODO: simple element variants:
|
69
|
-
#
|
69
|
+
#
|
70
70
|
# genre authority
|
71
71
|
# accessCondition type
|
72
72
|
# note displayLabel
|
73
73
|
# MISSING:
|
74
74
|
# date_created
|
75
|
-
|
75
|
+
|
76
76
|
# TODO: collections
|
77
|
-
|
78
|
-
}
|
79
77
|
|
78
|
+
}
|