text-gen 0.13.2 → 0.13.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5581ccb42efa3604510e17f8af69e6d5b804cc60702f6e1f7001cebf8def8c54
4
- data.tar.gz: 840ffc9473992cb64850991e4ee442c774acee38ddbdf40e81257be9c69b756d
3
+ metadata.gz: a89e9918a7f7feb924839507c942523f6a765faf4374c2e8c68919c87e98be62
4
+ data.tar.gz: 63dc2c142d41e7c3e83b07bfaf1549ef348651ec29ddb2c06516878bed7e4780
5
5
  SHA512:
6
- metadata.gz: 511f34f2a2a29d8c50a85d8b63f504b420047db4e219783525ab855ccd41582b6e9673b3f02bcbb5c2ea1ed9fdf515160a5a6e3b18b251686f55cf0ee3cb10fd
7
- data.tar.gz: 1b74d7812ff49c5026afd623630435921b7f366c754388439e628a00e0766919458cebf6a22f93bd914f307d8016138b1bcab15104cb01bac3cc132c454d5eb5
6
+ metadata.gz: d56e45920ff31deff8c73c86f4c4f845028268863a18a4f86501ecaf5023998d702c7d4948076af5ce5bec8f4a948bb3d63f0387c368c1e041756c8a13ae70d5
7
+ data.tar.gz: 8f452deb1b88360ca9f2f7e83ab202192d822ef3b87a6811ce5229c40aeff37262f000a63b004a8d772900888368b1db41083f290082a83cda681e4beedc478a
@@ -60,6 +60,10 @@ module Text
60
60
  @keys.last
61
61
  end
62
62
 
63
+ def current_key_without_category
64
+ current_key.split(">")&.last
65
+ end
66
+
63
67
  def current_strategy
64
68
  @strategy_stack.last&.first || "weighted"
65
69
  end
@@ -69,12 +73,12 @@ module Text
69
73
  end
70
74
 
71
75
  def remember(result)
72
- @remembered << [current_key, result]
76
+ @remembered << [current_key_without_category, result]
73
77
  result
74
78
  end
75
79
 
76
80
  def remembered(key = nil)
77
- key ||= current_key
81
+ key ||= current_key_without_category
78
82
  @remembered.select { |k, _r| k == key }.map(&:last)
79
83
  end
80
84
 
@@ -6,9 +6,9 @@ module Text
6
6
  # Return nil if the text value has already been generated
7
7
  class Distinct < Base
8
8
  def result(context, result)
9
- return result if key != context.current_key
9
+ return result if key != context.current_key && key != context.current_key_without_category
10
10
 
11
- previous = context.remembered(key)
11
+ previous = context.remembered
12
12
  return if previous.any? { |r| r.text.strip.downcase == result.text.strip.downcase }
13
13
 
14
14
  result
@@ -5,9 +5,9 @@ module Text
5
5
  module Filter
6
6
  class Remember < Base
7
7
  def result(context, result)
8
- return result if key != context.current_key
8
+ return result if key != context.current_key && key != context.current_key_without_category
9
9
 
10
- previous = context.remembered(key)
10
+ previous = context.remembered
11
11
  return previous.sample unless previous.nil? || previous.empty?
12
12
 
13
13
  result
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Text
4
4
  module Gen
5
- VERSION = "0.13.2"
5
+ VERSION = "0.13.4"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: text-gen
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.13.2
4
+ version: 0.13.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - G Palmer