change_the_subject 0.3.3 → 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: 93a323c7be102c29ca27cedee07f7586bc3e88fb5829b2b4841f8e8ec903aebc
4
- data.tar.gz: 7355143afda00985700ff78493630baff96bdc3055c46dac4d64f79aa5b0c69a
3
+ metadata.gz: f8a0956d2724b06f4d4bf159ef8a92236bb040d689cb0ca886b262c14f3fdff3
4
+ data.tar.gz: 3fc1fb0de44f65beaa8823077e17679ee990d04a1cf9dc61774bd7598535dcfc
5
5
  SHA512:
6
- metadata.gz: efb4a20422392edf75953446de51330ef54056fb24397fe6f9a7c5f42d50164f94ffe492c43a521989b4da053199feca10b81498ceb71f308f7e9aff7a7d3fe1
7
- data.tar.gz: a15d48cf4ce21d3d8fcd35ab8ae63c5dd6b9a58370635c946e1eb0224749826ea0323cd97f786b8f3be1c967a48101f3aa8d511f8ecd5745bf5a74dc27cbd679
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.3)
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
 
@@ -91,3 +91,19 @@
91
91
  "Gender identity disorders in adolescence":
92
92
  replacement: "Gender dysphoria in adolescence"
93
93
  rationale: '"Gender identity disorder" was removed from the DSM -- the primary diagnostic manual used by psychiatric and psychological professionals in the U.S. -- nearly a decade ago, and replaced with "Gender dysphoria."'
94
+ "Gays":
95
+ replacement: "Gay people"
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.3"
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.3
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: 2023-07-07 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