spicy-proton 2.0.0 → 2.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -48,7 +48,7 @@ module Spicy::Disk
48
48
  end
49
49
 
50
50
  def word(*args)
51
- self.seek(*args) do |index, _|
51
+ seek(*args) do |index, _|
52
52
  @file.seek(@origin + index * @width, IO::SEEK_SET)
53
53
  @file.read(@width).strip
54
54
  end
@@ -33,7 +33,7 @@ module Spicy::Memory
33
33
  end
34
34
 
35
35
  def word(*args)
36
- self.seek(*args) do |index, length|
36
+ seek(*args) do |index, length|
37
37
  index -= (@cumulative[length - 1] || 0)
38
38
  @words[length][index]
39
39
  end
@@ -2,6 +2,8 @@ require 'securerandom'
2
2
 
3
3
  module Spicy
4
4
  module Seek
5
+ private
6
+
5
7
  def seek(opts = {}, &found)
6
8
  min, max, length = opts[:min], opts[:max], opts[:length]
7
9
 
@@ -17,10 +19,8 @@ module Spicy
17
19
  max = [max || length || @max, @max].min
18
20
 
19
21
  rand_min = @cumulative[min - 1] || 0
20
- rand_max = @cumulative[max] || @cumulative[@max]
21
-
22
- range = rand_max - rand_min + 1
23
- index = rand_min + SecureRandom.random_number(range)
22
+ rand_max = (@cumulative[max] || @cumulative[@max]) - 1
23
+ index = rand(rand_min, rand_max)
24
24
 
25
25
  min.upto(max) do |len|
26
26
  if @cumulative[len] > index
@@ -30,5 +30,10 @@ module Spicy
30
30
 
31
31
  nil
32
32
  end
33
+
34
+ def rand(low, high)
35
+ range = high - low + 1
36
+ low + SecureRandom.random_number(range)
37
+ end
33
38
  end
34
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spicy-proton
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Schmich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-31 00:00:00.000000000 Z
11
+ date: 2017-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bindata
@@ -77,5 +77,5 @@ rubyforge_project:
77
77
  rubygems_version: 2.6.8
78
78
  signing_key:
79
79
  specification_version: 4
80
- summary: Generate a random adjective-noun word pair.
80
+ summary: Generate a random English adjective-noun word pair.
81
81
  test_files: []