change_the_subject 0.2.0 → 0.3.0

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: e31b7ca05a148620fadf5080c29622314291b4ab3dc002ae76bf0385d56df57b
4
+ data.tar.gz: 8fc444360e01543dfda734714b76190847067e4897106a90c81bfb20b0cb7206
5
5
  SHA512:
6
- metadata.gz: 0c716ee1de1d56c66631e4b6fac28c68f7818d7aa49f23770a3fc6cabcf20d484598a9ced6ec88eb130c133edd70a28f6f8ea6c186febee6a1f755d97bcf7694
7
- data.tar.gz: e99339c56451a6bb58816d765a7580fe362bb7390e2d7bb09cd53b06e9431314349e80a5d1f03256fdb290afb60e46f8490b271aa8af72fed4dd01a186225046
6
+ metadata.gz: bc0d1ae40e9a89d7124dfdd7ffbe264a09b6a1548b8faa5af0c234f203cf7700e7812f8c437cde7d703fdc87f415faa68b358dae4c2b6e1f4523b56483945094
7
+ data.tar.gz: d01d1bb8684a7adb0d364e12f424edf0655c88d7a29bb6831154a713576e71d584fc4297dce151c611688eff019092848afc2e2af474798f39c288d63c4ffaa9
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.2.0)
5
5
  yaml
6
6
 
7
7
  GEM
@@ -79,4 +79,4 @@ DEPENDENCIES
79
79
  simplecov
80
80
 
81
81
  BUNDLED WITH
82
- 2.3.18
82
+ 2.3.22
@@ -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.0"
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.0
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-09-19 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: yaml