change_the_subject 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.circleci/config.yml +39 -0
- data/.gitignore +11 -0
- data/.rspec +3 -0
- data/.rubocop.yml +27 -0
- data/.tool-versions +1 -0
- data/Gemfile +7 -0
- data/Gemfile.lock +82 -0
- data/LICENSE +15 -0
- data/README.md +35 -0
- data/Rakefile +8 -0
- data/bin/console +15 -0
- data/bin/setup +8 -0
- data/change_the_subject.gemspec +36 -0
- data/config/change_the_subject.yml +78 -0
- data/lib/change_the_subject/version.rb +5 -0
- data/lib/change_the_subject.rb +74 -0
- metadata +149 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 3640fe5de11bf3140e0cc2dd5000e46c871b915091fc7cae37eef93261adde20
|
4
|
+
data.tar.gz: 7ad884518e4ad331f5432f231adc7975b3951e4dd97351fe1482c7cdedaf311b
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 856d78cf1026e52d63b06c5cd786495a6c097e4f73ccb92948089537759ed5426d325b0a534afd2554df46ac531cc9344d460f8b1c6811efc850a3d28e575d08
|
7
|
+
data.tar.gz: 4d756fffc1b334b7e943fe01aa9ce6500c192d795344ce659efaedd257c0e69d9c4cce54b691dd647d05bf97cfc69375aa13661ea64120f4bd412230c0df122a
|
@@ -0,0 +1,39 @@
|
|
1
|
+
version: 2.1
|
2
|
+
jobs:
|
3
|
+
test:
|
4
|
+
parameters:
|
5
|
+
ruby:
|
6
|
+
description: "Ruby version"
|
7
|
+
default: "2.7.5"
|
8
|
+
type: "string"
|
9
|
+
docker:
|
10
|
+
- image: cimg/ruby:<< parameters.ruby >>
|
11
|
+
steps:
|
12
|
+
- checkout
|
13
|
+
- run:
|
14
|
+
name: Run the default task
|
15
|
+
command: |
|
16
|
+
gem install bundler -v 2.3.18
|
17
|
+
bundle install
|
18
|
+
bundle exec rake
|
19
|
+
rubocop:
|
20
|
+
parameters:
|
21
|
+
docker:
|
22
|
+
- image: cimg/ruby:3.0.0
|
23
|
+
steps:
|
24
|
+
- checkout
|
25
|
+
- run:
|
26
|
+
name: Run rubocop
|
27
|
+
command: |
|
28
|
+
gem install bundler -v 2.3.18
|
29
|
+
bundle install
|
30
|
+
bundle exec rubocop
|
31
|
+
|
32
|
+
workflows:
|
33
|
+
all-tests:
|
34
|
+
jobs:
|
35
|
+
- rubocop
|
36
|
+
- test:
|
37
|
+
matrix:
|
38
|
+
parameters:
|
39
|
+
ruby: ["2.7.5", "3.0.0"]
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-rspec
|
3
|
+
|
4
|
+
AllCops:
|
5
|
+
TargetRubyVersion: 3.0
|
6
|
+
DisplayCopNames: true
|
7
|
+
NewCops: enable
|
8
|
+
SuggestExtensions: false
|
9
|
+
Exclude:
|
10
|
+
- 'change_the_subject.gemspec'
|
11
|
+
- 'tmp/**/*'
|
12
|
+
|
13
|
+
Layout/LineLength:
|
14
|
+
Enabled: false
|
15
|
+
|
16
|
+
RSpec/ContextWording:
|
17
|
+
Enabled: false
|
18
|
+
|
19
|
+
RSpec/ExampleLength:
|
20
|
+
Enabled: false
|
21
|
+
|
22
|
+
RSpec/MultipleExpectations:
|
23
|
+
Enabled: false
|
24
|
+
|
25
|
+
Style/StringLiterals:
|
26
|
+
Enabled: true
|
27
|
+
EnforcedStyle: double_quotes
|
data/.tool-versions
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
ruby 3.0.0
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,82 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
change_the_subject (0.1.0)
|
5
|
+
yaml
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
ast (2.4.2)
|
11
|
+
byebug (11.1.3)
|
12
|
+
coderay (1.1.3)
|
13
|
+
diff-lcs (1.5.0)
|
14
|
+
docile (1.4.0)
|
15
|
+
json (2.6.2)
|
16
|
+
method_source (1.0.0)
|
17
|
+
parallel (1.22.1)
|
18
|
+
parser (3.1.2.1)
|
19
|
+
ast (~> 2.4.1)
|
20
|
+
pry (0.14.1)
|
21
|
+
coderay (~> 1.1)
|
22
|
+
method_source (~> 1.0)
|
23
|
+
pry-byebug (3.10.1)
|
24
|
+
byebug (~> 11.0)
|
25
|
+
pry (>= 0.13, < 0.15)
|
26
|
+
rainbow (3.1.1)
|
27
|
+
rake (13.0.6)
|
28
|
+
regexp_parser (2.5.0)
|
29
|
+
rexml (3.2.5)
|
30
|
+
rspec (3.11.0)
|
31
|
+
rspec-core (~> 3.11.0)
|
32
|
+
rspec-expectations (~> 3.11.0)
|
33
|
+
rspec-mocks (~> 3.11.0)
|
34
|
+
rspec-core (3.11.0)
|
35
|
+
rspec-support (~> 3.11.0)
|
36
|
+
rspec-expectations (3.11.1)
|
37
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
38
|
+
rspec-support (~> 3.11.0)
|
39
|
+
rspec-mocks (3.11.1)
|
40
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
41
|
+
rspec-support (~> 3.11.0)
|
42
|
+
rspec-support (3.11.1)
|
43
|
+
rubocop (1.36.0)
|
44
|
+
json (~> 2.3)
|
45
|
+
parallel (~> 1.10)
|
46
|
+
parser (>= 3.1.2.1)
|
47
|
+
rainbow (>= 2.2.2, < 4.0)
|
48
|
+
regexp_parser (>= 1.8, < 3.0)
|
49
|
+
rexml (>= 3.2.5, < 4.0)
|
50
|
+
rubocop-ast (>= 1.20.1, < 2.0)
|
51
|
+
ruby-progressbar (~> 1.7)
|
52
|
+
unicode-display_width (>= 1.4.0, < 3.0)
|
53
|
+
rubocop-ast (1.21.0)
|
54
|
+
parser (>= 3.1.1.0)
|
55
|
+
rubocop-rspec (2.13.1)
|
56
|
+
rubocop (~> 1.33)
|
57
|
+
ruby-progressbar (1.11.0)
|
58
|
+
simplecov (0.21.2)
|
59
|
+
docile (~> 1.1)
|
60
|
+
simplecov-html (~> 0.11)
|
61
|
+
simplecov_json_formatter (~> 0.1)
|
62
|
+
simplecov-html (0.12.3)
|
63
|
+
simplecov_json_formatter (0.1.4)
|
64
|
+
unicode-display_width (2.3.0)
|
65
|
+
yaml (0.2.0)
|
66
|
+
|
67
|
+
PLATFORMS
|
68
|
+
arm64-darwin-21
|
69
|
+
x86_64-darwin-20
|
70
|
+
x86_64-darwin-21
|
71
|
+
|
72
|
+
DEPENDENCIES
|
73
|
+
change_the_subject!
|
74
|
+
pry-byebug
|
75
|
+
rake (~> 13.0)
|
76
|
+
rspec (~> 3.0)
|
77
|
+
rubocop (= 1.36)
|
78
|
+
rubocop-rspec
|
79
|
+
simplecov
|
80
|
+
|
81
|
+
BUNDLED WITH
|
82
|
+
2.3.18
|
data/LICENSE
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
##########################################################################
|
2
|
+
# Copyright 2022 Princeton University Library
|
3
|
+
# Additional copyright may be held by others, as reflected in the commit log
|
4
|
+
#
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
|
+
# you may not use this file except in compliance with the License.
|
7
|
+
# You may obtain a copy of the License at
|
8
|
+
#
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
10
|
+
#
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
14
|
+
# See the License for the specific language governing permissions and
|
15
|
+
# limitations under the License.
|
data/README.md
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
# ChangeTheSubject
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/change_the_subject`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'change_the_subject'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle install
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install change_the_subject
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
30
|
+
|
31
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/change_the_subject.
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "change_the_subject"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
11
|
+
# require "pry"
|
12
|
+
# Pry.start
|
13
|
+
|
14
|
+
require "irb"
|
15
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/change_the_subject/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "change_the_subject"
|
7
|
+
spec.version = ChangeTheSubject::VERSION
|
8
|
+
spec.authors = ["Max Kadel", "Anna Headley", "Trey Pendragon", "Eliot Jordan"]
|
9
|
+
spec.email = ["digital-library@princeton.libanswers.com"]
|
10
|
+
|
11
|
+
spec.summary = "Provides configuration and utilities for replacing archaic subject terms with preferred subject terms"
|
12
|
+
spec.homepage = "https://github.com/pulibrary/change_the_subject"
|
13
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.3.0")
|
14
|
+
|
15
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
19
|
+
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
21
|
+
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
22
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
|
24
|
+
end
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
spec.add_dependency "yaml"
|
30
|
+
|
31
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
32
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
33
|
+
spec.add_development_dependency "rubocop", "1.36"
|
34
|
+
spec.add_development_dependency "rubocop-rspec"
|
35
|
+
spec.add_development_dependency "simplecov"
|
36
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
"Illegal aliens":
|
2
|
+
replacement: "Undocumented immigrants"
|
3
|
+
rationale: "The term immigrant or undocumented/unauthorized immigrants are the terms LoC proposed as replacements for illegal aliens and other uses of the world alien in LCSH."
|
4
|
+
"Women illegal aliens":
|
5
|
+
replacement: "Women undocumented immigrants"
|
6
|
+
rationale: "The term immigrant or undocumented/unauthorized immigrants are the terms LoC proposed as replacements for illegal aliens and other uses of the world alien in LCSH."
|
7
|
+
"Illegal aliens in literature":
|
8
|
+
replacement: "Undocumented immigrants in literature"
|
9
|
+
rationale: "The term immigrant or undocumented/unauthorized immigrants are the terms LoC proposed as replacements for illegal aliens and other uses of the world alien in LCSH."
|
10
|
+
"Children of illegal aliens":
|
11
|
+
replacement: "Children of undocumented immigrants"
|
12
|
+
rationale: "The term immigrant or undocumented/unauthorized immigrants are the terms LoC proposed as replacements for illegal aliens and other uses of the world alien in LCSH."
|
13
|
+
"Illegal alien children":
|
14
|
+
replacement: "Undocumented immigrant children"
|
15
|
+
rationale: "The term immigrant or undocumented/unauthorized immigrants are the terms LoC proposed as replacements for illegal aliens and other uses of the world alien in LCSH."
|
16
|
+
"Illegal immigration":
|
17
|
+
replacement: "Undocumented immigrants"
|
18
|
+
rationale: "The term immigrant or undocumented/unauthorized immigrants are the terms LoC proposed as replacements for illegal aliens and other uses of the world alien in LCSH."
|
19
|
+
"Illegal immigration in literature":
|
20
|
+
replacement: "Undocumented immigrants in literature"
|
21
|
+
rationale: "The term immigrant or undocumented/unauthorized immigrants are the terms LoC proposed as replacements for illegal aliens and other uses of the world alien in LCSH."
|
22
|
+
"Alien criminals":
|
23
|
+
replacement: "Noncitizen criminals"
|
24
|
+
rationale: "The term Noncitizen is the term LoC proposed as replacements for aliens and other uses of the word alien in LCSH."
|
25
|
+
"Aliens":
|
26
|
+
replacement: "Noncitizens"
|
27
|
+
rationale: "The term Noncitizen is the term LoC proposed as replacements for aliens and other uses of the word alien in LCSH."
|
28
|
+
"Aliens in art":
|
29
|
+
replacement: "Noncitizens in art"
|
30
|
+
rationale: "The term Noncitizen is the term LoC proposed as replacements for aliens and other uses of the word alien in LCSH."
|
31
|
+
"Aliens in literature":
|
32
|
+
replacement: "Noncitizens in literature"
|
33
|
+
rationale: "The term Noncitizen is the term LoC proposed as replacements for aliens and other uses of the word alien in LCSH."
|
34
|
+
"Aliens in mass media":
|
35
|
+
replacement: "Noncitizens in mass media"
|
36
|
+
rationale: "The term Noncitizen is the term LoC proposed as replacements for aliens and other uses of the word alien in LCSH."
|
37
|
+
"Church work with aliens":
|
38
|
+
replacement: "Church work with noncitizens"
|
39
|
+
rationale: "The term Noncitizen is the term LoC proposed as replacements for aliens and other uses of the word alien in LCSH."
|
40
|
+
"Officials and employees, Alien":
|
41
|
+
replacement: "Officials and employees, Noncitizen"
|
42
|
+
rationale: "The term Noncitizen is the term LoC proposed as replacements for aliens and other uses of the word alien in LCSH."
|
43
|
+
"Aliens (Greek law)":
|
44
|
+
replacement: "Noncitizens (Greek law)"
|
45
|
+
rationale: "The term Noncitizen is the term LoC proposed as replacements for aliens and other uses of the word alien in LCSH."
|
46
|
+
"Aliens (Roman law)":
|
47
|
+
replacement: "Noncitizens (Roman law)"
|
48
|
+
rationale: "The term Noncitizen is the term LoC proposed as replacements for aliens and other uses of the word alien in LCSH."
|
49
|
+
"Child slaves":
|
50
|
+
replacement: "Enslaved children"
|
51
|
+
rationale: "In addition to its usage by TRLN, this term falls in line with recommendations included in the community-sourced document P. Gabrielle Foreman, et al. “Writing about Slavery/Teaching About Slavery: This Might Help” and Archives for Black Lives in Philadelphia Anti-Racist Description Resources."
|
52
|
+
"Indian slaves":
|
53
|
+
replacement: "Enslaved indigenous peoples"
|
54
|
+
rationale: "In addition to its usage by TRLN, this term falls in line with recommendations included in the community-sourced document P. Gabrielle Foreman, et al. “Writing about Slavery/Teaching About Slavery: This Might Help.” Capitalization of \"Indigenous\" appears to be preferred by those from Indigenous communities, for example see https://www.lib.sfu.ca/about/branches-depts/slc/writing/inclusive-antiracist-writing/bipoc and https://www.ictinc.ca/blog/indigenous-peoples-terminology-guidelines-for-usage. As this is a broad term, when possible, one should include the name of the community(ies) or nation(s) of the people in the record. "
|
55
|
+
"Older slaves":
|
56
|
+
replacement: "Enslaved older people"
|
57
|
+
rationale: "The use of \"enslaved\" falls in line with recommendations included in the community-sourced document P. Gabrielle Foreman, et al. \"Writing about Slavery/Teaching About Slavery: This Might Help\" and Archives for Black Lives in Philadelphia Anti-Racist Description Resources. \"Older people\" is the current LC preferred term: https://id.loc.gov/search/?q=memberOf:http://id.loc.gov/authorities/demographicTerms/collection_LCDGT_Age. "
|
58
|
+
"Slaves":
|
59
|
+
replacement: "Enslaved persons"
|
60
|
+
rationale: "In addition to its usage by TRLN, this term falls in line with recommendations included in the community-sourced document P. Gabrielle Foreman, et al. \"Writing about Slavery/Teaching About Slavery: This Might Help\" and Archives for Black Lives in Philadelphia Anti-Racist Description Resources."
|
61
|
+
"Women slaves":
|
62
|
+
replacement: "Enslaved women"
|
63
|
+
rationale: "In addition to its usage by TRLN, this term falls in line with recommendations included in the community-sourced document P. Gabrielle Foreman, et al. \"Writing about Slavery/Teaching About Slavery: This Might Help\" and Archives for Black Lives in Philadelphia Anti-Racist Description Resources."
|
64
|
+
"Indians of Central America":
|
65
|
+
replacement: "Indigenous peoples of Central America"
|
66
|
+
rationale: "This term is used by TRLN; according to our research, this terminology is preferred and widely regarded as a more inclusive term. It is important to include the geographic region in the subject term when possible, as there are Indigenous peoples throughout the world. When possible, it is respectful to also include the name of the community(ies) or nation(s) of the people in the record, for example \"Chumash,\" \"Tonkawa,\" \"Rapa Nui,\" \"Huetar.\""
|
67
|
+
"Indians of Mexico":
|
68
|
+
replacement: "Indigenous peoples of Mexico"
|
69
|
+
rationale: "This term is used by TRLN; according to our research, this terminology is preferred and widely regarded as a more inclusive term. It is important to include the geographic region in the subject term when possible, as there are Indigenous peoples throughout the world. When possible, it is respectful to also include the name of the community(ies) or nation(s) of the people in the record, for example \"Chumash,\" \"Tonkawa,\" \"Rapa Nui,\" \"Huetar.\""
|
70
|
+
"Indians of North America":
|
71
|
+
replacement: "Indigenous peoples of North America"
|
72
|
+
rationale: "This term is used by TRLN; according to our research, this terminology is preferred and widely regarded as a more inclusive term. It is important to include the geographic region in the subject term when possible, as there are Indigenous peoples throughout the world. When possible, it is respectful to also include the name of the community(ies) or nation(s) of the people in the record, for example \"Chumash,\" \"Tonkawa,\" \"Rapa Nui,\" \"Huetar.\""
|
73
|
+
"Indians of South America":
|
74
|
+
replacement: "Indigenous peoples of South America"
|
75
|
+
rationale: "This term is used by TRLN; according to our research, this terminology is preferred and widely regarded as a more inclusive term. It is important to include the geographic region in the subject term when possible, as there are Indigenous peoples throughout the world. When possible, it is respectful to also include the name of the community(ies) or nation(s) of the people in the record, for example \"Chumash,\" \"Tonkawa,\" \"Rapa Nui,\" \"Huetar.\""
|
76
|
+
"Indians of the West Indies":
|
77
|
+
replacement: "Indigenous peoples of the West Indies"
|
78
|
+
rationale: "This term is used by TRLN; according to our research, this terminology is preferred and widely regarded as a more inclusive term. It is important to include the geographic region in the subject term when possible, as there are Indigenous peoples throughout the world. When possible, it is respectful to also include the name of the community(ies) or nation(s) of the people in the record, for example \"Chumash,\" \"Tonkawa,\" \"Rapa Nui,\" \"Huetar.\""
|
@@ -0,0 +1,74 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "yaml"
|
4
|
+
require "pry-byebug"
|
5
|
+
|
6
|
+
# The creation and management of metadata are not neutral activities.
|
7
|
+
class ChangeTheSubject
|
8
|
+
class Error < StandardError; end
|
9
|
+
|
10
|
+
def self.fix(subject_terms:, separator: nil)
|
11
|
+
new(separator: separator).fix(subject_terms: subject_terms)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.check_for_replacement(term:, separator: nil)
|
15
|
+
new(separator: separator).check_for_replacement(term: term)
|
16
|
+
end
|
17
|
+
|
18
|
+
attr_reader :separator
|
19
|
+
|
20
|
+
def initialize(separator: nil)
|
21
|
+
@separator = separator || "—"
|
22
|
+
end
|
23
|
+
|
24
|
+
def terms_mapping
|
25
|
+
@terms_mapping ||= config
|
26
|
+
end
|
27
|
+
|
28
|
+
# Given an array of subject terms, replace the ones that need replacing
|
29
|
+
# @param [<String>] subject_terms
|
30
|
+
# @return [<String>]
|
31
|
+
def fix(subject_terms:)
|
32
|
+
return [] if subject_terms.nil?
|
33
|
+
|
34
|
+
subject_terms = subject_terms.compact.reject(&:empty?)
|
35
|
+
return [] if subject_terms.empty? || subject_terms.nil?
|
36
|
+
|
37
|
+
subject_terms.map do |term|
|
38
|
+
replacement = check_for_replacement(term: term)
|
39
|
+
replacement unless replacement.empty?
|
40
|
+
end.compact.uniq
|
41
|
+
end
|
42
|
+
|
43
|
+
# Given a term, check whether there is a suggested replacement. If there is, return
|
44
|
+
# it. If there is not, return the term unaltered.
|
45
|
+
# @param [String] term
|
46
|
+
# @return [String]
|
47
|
+
def check_for_replacement(term:)
|
48
|
+
subterms = term.split(separator)
|
49
|
+
subfield_a = subterms.first
|
50
|
+
replacement = terms_mapping[subfield_a]
|
51
|
+
return term unless replacement
|
52
|
+
|
53
|
+
subterms.delete(subfield_a)
|
54
|
+
subterms.prepend(replacement["replacement"])
|
55
|
+
subterms.join(separator)
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def config
|
61
|
+
@config ||= config_yaml
|
62
|
+
end
|
63
|
+
|
64
|
+
def config_yaml
|
65
|
+
change_the_subject_erb = ERB.new(File.read(change_the_subject_config_file)).result
|
66
|
+
YAML.safe_load(change_the_subject_erb, aliases: true)
|
67
|
+
rescue StandardError, SyntaxError => e
|
68
|
+
raise Error, "#{change_the_subject_config_file} was found, but could not be parsed. \n#{e.inspect}"
|
69
|
+
end
|
70
|
+
|
71
|
+
def change_the_subject_config_file
|
72
|
+
File.join(File.dirname(__FILE__), "../", "config", "change_the_subject.yml")
|
73
|
+
end
|
74
|
+
end
|
metadata
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: change_the_subject
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Max Kadel
|
8
|
+
- Anna Headley
|
9
|
+
- Trey Pendragon
|
10
|
+
- Eliot Jordan
|
11
|
+
autorequire:
|
12
|
+
bindir: exe
|
13
|
+
cert_chain: []
|
14
|
+
date: 2022-09-15 00:00:00.000000000 Z
|
15
|
+
dependencies:
|
16
|
+
- !ruby/object:Gem::Dependency
|
17
|
+
name: yaml
|
18
|
+
requirement: !ruby/object:Gem::Requirement
|
19
|
+
requirements:
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
requirements:
|
34
|
+
- - "~>"
|
35
|
+
- !ruby/object:Gem::Version
|
36
|
+
version: '13.0'
|
37
|
+
type: :development
|
38
|
+
prerelease: false
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - "~>"
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '13.0'
|
44
|
+
- !ruby/object:Gem::Dependency
|
45
|
+
name: rspec
|
46
|
+
requirement: !ruby/object:Gem::Requirement
|
47
|
+
requirements:
|
48
|
+
- - "~>"
|
49
|
+
- !ruby/object:Gem::Version
|
50
|
+
version: '3.0'
|
51
|
+
type: :development
|
52
|
+
prerelease: false
|
53
|
+
version_requirements: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - "~>"
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: '3.0'
|
58
|
+
- !ruby/object:Gem::Dependency
|
59
|
+
name: rubocop
|
60
|
+
requirement: !ruby/object:Gem::Requirement
|
61
|
+
requirements:
|
62
|
+
- - '='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '1.36'
|
65
|
+
type: :development
|
66
|
+
prerelease: false
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
68
|
+
requirements:
|
69
|
+
- - '='
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '1.36'
|
72
|
+
- !ruby/object:Gem::Dependency
|
73
|
+
name: rubocop-rspec
|
74
|
+
requirement: !ruby/object:Gem::Requirement
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
type: :development
|
80
|
+
prerelease: false
|
81
|
+
version_requirements: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
- !ruby/object:Gem::Dependency
|
87
|
+
name: simplecov
|
88
|
+
requirement: !ruby/object:Gem::Requirement
|
89
|
+
requirements:
|
90
|
+
- - ">="
|
91
|
+
- !ruby/object:Gem::Version
|
92
|
+
version: '0'
|
93
|
+
type: :development
|
94
|
+
prerelease: false
|
95
|
+
version_requirements: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
description:
|
101
|
+
email:
|
102
|
+
- digital-library@princeton.libanswers.com
|
103
|
+
executables: []
|
104
|
+
extensions: []
|
105
|
+
extra_rdoc_files: []
|
106
|
+
files:
|
107
|
+
- ".circleci/config.yml"
|
108
|
+
- ".gitignore"
|
109
|
+
- ".rspec"
|
110
|
+
- ".rubocop.yml"
|
111
|
+
- ".tool-versions"
|
112
|
+
- Gemfile
|
113
|
+
- Gemfile.lock
|
114
|
+
- LICENSE
|
115
|
+
- README.md
|
116
|
+
- Rakefile
|
117
|
+
- bin/console
|
118
|
+
- bin/setup
|
119
|
+
- change_the_subject.gemspec
|
120
|
+
- config/change_the_subject.yml
|
121
|
+
- lib/change_the_subject.rb
|
122
|
+
- lib/change_the_subject/version.rb
|
123
|
+
homepage: https://github.com/pulibrary/change_the_subject
|
124
|
+
licenses: []
|
125
|
+
metadata:
|
126
|
+
allowed_push_host: https://rubygems.org
|
127
|
+
homepage_uri: https://github.com/pulibrary/change_the_subject
|
128
|
+
source_code_uri: https://github.com/pulibrary/change_the_subject
|
129
|
+
post_install_message:
|
130
|
+
rdoc_options: []
|
131
|
+
require_paths:
|
132
|
+
- lib
|
133
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: 2.3.0
|
138
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
requirements: []
|
144
|
+
rubygems_version: 3.2.3
|
145
|
+
signing_key:
|
146
|
+
specification_version: 4
|
147
|
+
summary: Provides configuration and utilities for replacing archaic subject terms
|
148
|
+
with preferred subject terms
|
149
|
+
test_files: []
|