change_the_subject 0.2.0 → 0.3.1

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: 6b45a14c33badf6a311132a98cc7959b945b28d8da61ad21b09eee6f0f8e6774
4
- data.tar.gz: 248e10868c0fcf12809c3b622ca8b862d82b3a4929ae6d237c37d4c8709c6941
3
+ metadata.gz: c054ca78537a191161b14b984e0e84c90600d37e7b9337bb866fb3e443f187cb
4
+ data.tar.gz: 8072cbcd7062190d744028fd27cafbf9e6693ff1b98af0950b7a952d7b454385
5
5
  SHA512:
6
- metadata.gz: 0c716ee1de1d56c66631e4b6fac28c68f7818d7aa49f23770a3fc6cabcf20d484598a9ced6ec88eb130c133edd70a28f6f8ea6c186febee6a1f755d97bcf7694
7
- data.tar.gz: e99339c56451a6bb58816d765a7580fe362bb7390e2d7bb09cd53b06e9431314349e80a5d1f03256fdb290afb60e46f8490b271aa8af72fed4dd01a186225046
6
+ metadata.gz: 11193e5258e338bf4f833644eb455c713e780e7f08997973f9a3fe4de1929411783fe0e5097dcbc1eff02ed13884c15718dc8b13969b52c04f5ab1d5f2e7acd8
7
+ data.tar.gz: 7f4efe74c31dc4fc4c08b9c532633482363f519cc84a14ac943b8a83f3c2d428c8001d0203334bf57bd5faac06ab19db548414cb80c81a6b350fa909bee2ccaf
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- change_the_subject (0.1.0)
4
+ change_the_subject (0.3.1)
5
5
  yaml
6
6
 
7
7
  GEM
@@ -62,7 +62,7 @@ GEM
62
62
  simplecov-html (0.12.3)
63
63
  simplecov_json_formatter (0.1.4)
64
64
  unicode-display_width (2.3.0)
65
- yaml (0.2.0)
65
+ yaml (0.2.1)
66
66
 
67
67
  PLATFORMS
68
68
  arm64-darwin-21
@@ -79,4 +79,4 @@ DEPENDENCIES
79
79
  simplecov
80
80
 
81
81
  BUNDLED WITH
82
- 2.3.18
82
+ 2.3.22
@@ -76,3 +76,6 @@
76
76
  "Indians of the West Indies":
77
77
  replacement: "Indigenous peoples of the West Indies"
78
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.\""
79
+ "Gender identity disorders":
80
+ replacement: "Gender dysphoria"
81
+ 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."'
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ChangeTheSubject
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.1"
5
5
  end
@@ -6,18 +6,18 @@ require "yaml"
6
6
  class ChangeTheSubject
7
7
  class Error < StandardError; end
8
8
 
9
- def self.fix(subject_terms:, separator: nil)
10
- new(separator: separator).fix(subject_terms: subject_terms)
9
+ def self.fix(subject_terms:, separators: nil)
10
+ new(separators: separators).fix(subject_terms: subject_terms)
11
11
  end
12
12
 
13
- def self.check_for_replacement(term:, separator: nil)
14
- new(separator: separator).check_for_replacement(term: term)
13
+ def self.check_for_replacement(term:, separators: nil)
14
+ new(separators: separators).check_for_replacement(term: term)
15
15
  end
16
16
 
17
- attr_reader :separator
17
+ attr_reader :separators
18
18
 
19
- def initialize(separator: nil)
20
- @separator = separator || "—"
19
+ def initialize(separators: nil)
20
+ @separators = separators || ["—"]
21
21
  end
22
22
 
23
23
  def terms_mapping
@@ -44,14 +44,18 @@ class ChangeTheSubject
44
44
  # @param [String] term
45
45
  # @return [String]
46
46
  def check_for_replacement(term:)
47
- subterms = term.split(separator)
48
- subfield_a = subterms.first
49
- replacement = terms_mapping[subfield_a]
50
- return term unless replacement
51
-
52
- subterms.delete(subfield_a)
53
- subterms.prepend(replacement["replacement"])
54
- subterms.join(separator)
47
+ separators.each do |separator|
48
+ subterms = term.split(separator)
49
+ subfield_a = subterms.first
50
+ replacement = terms_mapping[subfield_a]
51
+ next unless replacement
52
+
53
+ subterms.delete(subfield_a)
54
+ subterms.prepend(replacement["replacement"])
55
+ return subterms.join(separator)
56
+ end
57
+
58
+ term
55
59
  end
56
60
 
57
61
  private
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.2.0
4
+ version: 0.3.1
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: 2022-09-16 00:00:00.000000000 Z
14
+ date: 2022-12-07 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: yaml