change_the_subject 0.3.4 → 0.3.5

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: f8a0956d2724b06f4d4bf159ef8a92236bb040d689cb0ca886b262c14f3fdff3
4
+ data.tar.gz: 3fc1fb0de44f65beaa8823077e17679ee990d04a1cf9dc61774bd7598535dcfc
5
5
  SHA512:
6
- metadata.gz: 4075dce7dc3b7c11ad76ccdb126ab0548e34e02fd8655725e2f8d63dffd98162bcdf5db018bdbe238b5d8b2cfd8b553be430dabb5b2379974d4e29aa4ea0682a
7
- data.tar.gz: a897b2b57f526ea2b1e3cbec70816fa888984de5cd2682cf0bf11cdfdfcbfec9d2d6451588e0ec88b2e4d056fea2177b8d9c4de57805c3ac0188407e2e613dc6
6
+ metadata.gz: 5bf724643816e357bb6c80d5b386fc9ed6249edc07cab9ccfd4090ce1a02892a0a76c20d548574b452bece0651e8e6a8f5b47f04fef32e95e23b33f48ff0b2df
7
+ data.tar.gz: 5388b39ec7c4dd8456989b5a10ea66ea0d4deb28571e154e2316c78a1fdbb1431cf09f14f644ea1e208a8922d796cd90f8e0f43f77a79fd3ffb34838ade3c4a8
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.5)
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,6 +62,7 @@ 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
 
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,16 @@
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."
@@ -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.5"
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.5
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-07-09 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: yaml