change_the_subject 0.3.4 → 0.3.6

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
  SHA256:
3
- metadata.gz: 840263d3d71e3f44176d9fab63d94d009383ff41d9bf35e3a59e014e3dac1e96
4
- data.tar.gz: 5d621a18099b9da1ba0f176591b322c165695dd837fba0ab12ecb17cf58eabb6
3
+ metadata.gz: 1512dad6ec282f50dd9891ac10f0304eef7e566f202af7e0b869c0c101d24ffa
4
+ data.tar.gz: 602152e6fdad2ec73359bb994bf2f1bc6728311f143d9c20dba20f698eb7b381
5
5
  SHA512:
6
- metadata.gz: 4075dce7dc3b7c11ad76ccdb126ab0548e34e02fd8655725e2f8d63dffd98162bcdf5db018bdbe238b5d8b2cfd8b553be430dabb5b2379974d4e29aa4ea0682a
7
- data.tar.gz: a897b2b57f526ea2b1e3cbec70816fa888984de5cd2682cf0bf11cdfdfcbfec9d2d6451588e0ec88b2e4d056fea2177b8d9c4de57805c3ac0188407e2e613dc6
6
+ metadata.gz: 96a3e99d821468d4e08a528e724ddf8ee8c294db1484c1018990529e38876a864e74f533932aef78ed227994412bbb388c49c8872c155f5f617d935767a0b1d2
7
+ data.tar.gz: f3df96cf53476044528c51315603e92345adb03e931b8d5b2d3b0bee1ae69431628cfc80a9a2984e9292af85a203734af1b7bc33f79fd052625f4b1de2e2a5ad
data/.circleci/config.yml CHANGED
@@ -4,7 +4,7 @@ jobs:
4
4
  parameters:
5
5
  ruby:
6
6
  description: "Ruby version"
7
- default: "2.7.5"
7
+ default: "3.3.6"
8
8
  type: "string"
9
9
  docker:
10
10
  - image: cimg/ruby:<< parameters.ruby >>
@@ -36,4 +36,4 @@ workflows:
36
36
  - test:
37
37
  matrix:
38
38
  parameters:
39
- ruby: ["2.7.5", "3.0.0"]
39
+ ruby: ["3.1.6", "3.2.6", "3.3.6"]
data/.tool-versions CHANGED
@@ -1 +1 @@
1
- ruby 3.0.0
1
+ ruby 3.1.6
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- change_the_subject (0.3.4)
4
+ change_the_subject (0.3.6)
5
5
  yaml
6
6
 
7
7
  GEM
@@ -26,7 +26,8 @@ GEM
26
26
  rainbow (3.1.1)
27
27
  rake (13.0.6)
28
28
  regexp_parser (2.5.0)
29
- rexml (3.2.5)
29
+ rexml (3.2.8)
30
+ strscan (>= 3.0.9)
30
31
  rspec (3.11.0)
31
32
  rspec-core (~> 3.11.0)
32
33
  rspec-expectations (~> 3.11.0)
@@ -61,11 +62,13 @@ GEM
61
62
  simplecov_json_formatter (~> 0.1)
62
63
  simplecov-html (0.12.3)
63
64
  simplecov_json_formatter (0.1.4)
65
+ strscan (3.1.0)
64
66
  unicode-display_width (2.3.0)
65
67
  yaml (0.2.1)
66
68
 
67
69
  PLATFORMS
68
70
  arm64-darwin-21
71
+ arm64-darwin-24
69
72
  x86_64-darwin-20
70
73
  x86_64-darwin-21
71
74
 
data/README.md CHANGED
@@ -37,6 +37,12 @@ After checking out the repo, run `bin/setup` to install dependencies. Then, run
37
37
 
38
38
  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).
39
39
 
40
+ ### Running the tests
41
+
42
+ ```
43
+ bundle exec rspec
44
+ ```
45
+
40
46
  ## Contributing
41
47
  The configuration for this gem is managed by the Inclusive and Reparative Metadata Working Group (IRMWG). Send questions or comments about the configuration to harmfullanguage@princeton.libanswers.com.
42
48
 
@@ -94,3 +94,19 @@
94
94
  "Gays":
95
95
  replacement: "Gay people"
96
96
  rationale: "This subject heading has been updated by the Library of Congress, but some partner records have not yet been updated to reflect this."
97
+ # The following term will match if the first two subfields in the field are "Japanese Americans" and "Evacuation and relocation, 1942-1945"
98
+ ["Japanese Americans", "Evacuation and relocation, 1942-1945"]:
99
+ replacement: ["Japanese Americans", "Forced removal and internment, 1942-1945"]
100
+ rationale: "This subject heading has been updated by the Library of Congress, but some partner records have not yet been updated to reflect this."
101
+ ["Aleuts", "Evacuation and relocation, 1942-1945"]:
102
+ replacement: ["Aleuts", "Forced removal and internment, 1942-1945"]
103
+ rationale: "This subject heading has been updated by the Library of Congress, but some partner records have not yet been updated to reflect this."
104
+ ["German Americans", "Evacuation and relocation, 1942-1945"]:
105
+ replacement: ["German Americans", "Forced removal and internment, 1942-1945"]
106
+ rationale: "This subject heading has been updated by the Library of Congress, but some partner records have not yet been updated to reflect this."
107
+ ["Italian Americans", "Evacuation and relocation, 1942-1945"]:
108
+ replacement: ["Italian Americans", "Forced removal and internment, 1942-1945"]
109
+ rationale: "This subject heading has been updated by the Library of Congress, but some partner records have not yet been updated to reflect this."
110
+ "Convict labor":
111
+ replacement: "Prison labor"
112
+ rationale: "Prison labor is currently listed in LCSH as a variant of the authorized heading Convict labor. However, Convict labor appears to have become less commonly used and prison labor to have a broader historical scope. This title change was recommended by the Prison Teaching Initiative at Princeton."
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ChangeTheSubject
4
- VERSION = "0.3.4"
4
+ VERSION = "0.3.6"
5
5
  end
@@ -46,13 +46,13 @@ class ChangeTheSubject
46
46
  def check_for_replacement(term:)
47
47
  separators.each do |separator|
48
48
  subterms = term.split(separator)
49
- subfield_a = subterms.first
50
- replacement = terms_mapping[subfield_a]
49
+ replacement = replacement_config_for_subterms(subterms)
51
50
  next unless replacement
52
51
 
53
- subterms.delete(subfield_a)
54
- subterms.prepend(replacement["replacement"])
55
- return subterms.join(separator)
52
+ new_terms = replacement_terms(replacement)
53
+ return subterms.drop(new_terms.count)
54
+ .prepend(new_terms)
55
+ .join(separator)
56
56
  end
57
57
 
58
58
  term
@@ -60,6 +60,24 @@ class ChangeTheSubject
60
60
 
61
61
  private
62
62
 
63
+ def replacement_config_for_subterms(subterms)
64
+ matching_key = terms_mapping.keys.find do |term_to_replace|
65
+ term_matches_subterms?(term_to_replace, subterms)
66
+ end
67
+ return terms_mapping[matching_key] if matching_key
68
+ end
69
+
70
+ def term_matches_subterms?(term, subterms)
71
+ term_as_array = Array(term)
72
+ term_as_array.count.times.all? do |index|
73
+ term_as_array[index] == subterms[index]
74
+ end
75
+ end
76
+
77
+ def replacement_terms(configured_term)
78
+ Array(configured_term["replacement"])
79
+ end
80
+
63
81
  def config
64
82
  @config ||= config_yaml
65
83
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: change_the_subject
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Max Kadel
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: exe
13
13
  cert_chain: []
14
- date: 2024-05-22 00:00:00.000000000 Z
14
+ date: 2024-12-09 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: yaml
@@ -142,7 +142,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
142
142
  - !ruby/object:Gem::Version
143
143
  version: '0'
144
144
  requirements: []
145
- rubygems_version: 3.2.3
145
+ rubygems_version: 3.3.27
146
146
  signing_key:
147
147
  specification_version: 4
148
148
  summary: Provides configuration and utilities for replacing archaic subject terms