text-gen 0.4.5 → 0.4.6

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: 02fd2c65e429137da43b5784b654ca722dfaccf73726b28b143b4833a5a0909f
4
- data.tar.gz: 55e1fe463d792ce890a8dd6efd42d874ff27025db96757b1b90ad5ea019cf46a
3
+ metadata.gz: 7818963b925f0327e1788fac07898d955c4197721a901a38f83f5311355a81fd
4
+ data.tar.gz: e3620212fb2ea2154b1e06444c875462e7c68a1c60a2c6fb45a92b28729a60a9
5
5
  SHA512:
6
- metadata.gz: 2869868f716e2f7a291d9991c5634977f95354b7ed3a63c14347dc24585b840623853ea0d5c8e41286cca49f52b5471bed33e25ff079bf2eb6fb1566d13fe7a7
7
- data.tar.gz: 95af5a1e2adead3965d8c942ed1b40ba15aae50d58e5e7ab268074b7297314f91b41a25b7de1b38a7bb0f2fa84693578b14996b1cc700df5f4261ab309e0f916
6
+ metadata.gz: '048df93a9adb0c5764fd55e90e0bffceacc7f078b5741a8f7c30365755570043101fa7668969a67d6588a17da126945ba0f0d5e4e413a112d4ec4b13d7af5acf'
7
+ data.tar.gz: 244bddd0a689bc18451dc780fa7604a0fbf326ad591fadf9aecf6cb20e203ad31837f8da6c7ab8a9f2240dfbab743523f900a3234243becba538a70dbd471136
@@ -99,11 +99,11 @@ module Text
99
99
  end
100
100
 
101
101
  def run_weighted_items(items, meta, depth)
102
- total_weight = items.sum { |item| item.fetch("weight", 1).to_i }
102
+ total_weight = items.sum { |item| [item.fetch("weight", 1).to_i, 1].max }
103
103
  rand_weight = rand(total_weight)
104
104
  current_weight = 0
105
105
  item = items.find do |item|
106
- current_weight += item.fetch("weight", 1).to_i
106
+ current_weight += [item.fetch("weight", 1).to_i, 1].max
107
107
  current_weight > rand_weight
108
108
  end
109
109
  return unless item
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Text
4
4
  module Gen
5
- VERSION = "0.4.5"
5
+ VERSION = "0.4.6"
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.4.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - G Palmer