noid 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 1cc8131a9c265bd3f5a97a0a1a6127473c7aac72
4
- data.tar.gz: 251bc9bf4d40a678c7feef0dacd6df64eba6fbf6
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ MDE0ZDYxMWVjODZhOGEwODM0NDRiZThjZmZhMWU3YTVjZjZjYTEwNw==
5
+ data.tar.gz: !binary |-
6
+ ZWY4NGM2YjcwMGViNmQxMTk1MmU1OTYzNGFiMDQ1ODk1YTI1ZjE3Mw==
5
7
  SHA512:
6
- metadata.gz: ec5f8701d9b8e0a3b6751bccc2c34112380604c32eae49b13a2c9aa94b016c38726a92bf8f653df2b922552664bbce74f0b6d955035cb83420c10c13b5771e5a
7
- data.tar.gz: 22659b109cabc3de9feff9febb2a4f059802ed0b6dc0fcb83758d4c750ef4ccadc724286714cfce52260de3a8b656de979717b868f20da94e0c20d6124edca7c
8
+ metadata.gz: !binary |-
9
+ MmIxY2RiNWUzNjFmZmE1MmY4YjE1YjgxZTFkZTIwMDZhNWYwZTI1ZWM5NWE5
10
+ MDcyZDFhMmE5ZWQxZDVhOWIwYzRmNjdjOGViZjA4NDQ4ZjcwOTViOWU3ZDcz
11
+ NDE5ZjhhNWIwMDk3Y2IzZGUzZDI1Zjk5ZDE3NzBlYTE1MDVjNGE=
12
+ data.tar.gz: !binary |-
13
+ MDdlODMyZDMxYWExNzM5MTY4ZGY5ZjkzNzJhMDc0MDUwODg0OTA2OGEwNDJh
14
+ MzRmNDdjNTk0NWE4NzkzZTYwMDJlNTBmZGY0MjgwZmMwZWNlNjgwMWMzZTYw
15
+ NjYyNWM3OGMxYzMxNTVmOGZkNTU1Y2RkMDQ5MTc2Y2I4YzczY2M=
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.0
1
+ 0.7.1
@@ -72,7 +72,7 @@ module Noid
72
72
  @seed = @rand.seed
73
73
  @seq = seq || 0
74
74
 
75
- seq.times { @rand.rand } if seq
75
+ seq.times { next_random } if seq
76
76
 
77
77
  @rand
78
78
  end
@@ -82,15 +82,20 @@ module Noid
82
82
  @seq += 1
83
83
  case template.generator
84
84
  when 'r'
85
- raise Exception("Exhausted noid sequence pool") if counters.size == 0
86
- i = @rand.rand(counters.size)
87
- n = counters[i][:value]
88
- counters[i][:value] += 1
89
- counters.delete_at(i) if counters[i][:value] == counters[i][:max]
85
+ n = next_random
90
86
  end
91
87
  n
92
88
  end
93
89
 
90
+ def next_random
91
+ raise Exception("Exhausted noid sequence pool") if counters.size == 0
92
+ i = @rand.rand(counters.size)
93
+ n = counters[i][:value]
94
+ counters[i][:value] += 1
95
+ counters.delete_at(i) if counters[i][:value] == counters[i][:max]
96
+ n
97
+ end
98
+
94
99
  ##
95
100
  # Counters to use for quasi-random NOID sequences
96
101
  def counters
@@ -128,11 +128,16 @@ describe Noid::Minter do
128
128
  it "given a specific seed and sequence, identifiers should be replicable" do
129
129
  minter = Noid::Minter.new(:template => "63q.redek")
130
130
  minter.seed(23456789, 567)
131
- minter.mint.should == "63qh305"
131
+ mint1 = minter.mint
132
+ dump1 = minter.dump
132
133
 
133
134
  minter = Noid::Minter.new(:template => "63q.redek")
134
135
  minter.seed(23456789, 567)
135
- minter.mint.should == "63qh305"
136
+ mint2 = minter.mint
137
+ dump2 = minter.dump
138
+ expect(dump1).to eql(dump2)
139
+ expect(mint1).to eql(mint2)
140
+ mint1.should == "63qb41v" # "63qh305" was the value from a slightly buggy impl
136
141
  end
137
142
  end
138
143
 
@@ -171,6 +176,24 @@ describe Noid::Minter do
171
176
 
172
177
  end
173
178
 
179
+ describe "with large seeds" do
180
+ it "should not reproduce noids with constructed sequences" do
181
+ minter = Noid::Minter.new(:template => 'ldpd:.reeeeeeee')
182
+ minter.seed(192548637498850379850405658298152906991)
183
+ first_values = (1..1000).collect {|c| minter.mint}
184
+
185
+ values = []
186
+ (0..999).each do |i|
187
+ minter = Noid::Minter.new(:template => 'ldpd:.reeeeeeee')
188
+ minter.seed(192548637498850379850405658298152906991, i)
189
+ values << minter.mint
190
+ expect(values[i]).to eql first_values[i]
191
+ end
192
+ values.uniq!
193
+ expect(values.length).to eql 1000
194
+ end
195
+ end
196
+
174
197
  describe "multithreading-safe example" do
175
198
  before do
176
199
  require 'yaml'
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: noid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Beer
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-15 00:00:00.000000000 Z
11
+ date: 2014-09-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ! '>='
18
18
  - !ruby/object:Gem::Version
19
19
  version: '0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ! '>='
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '>='
31
+ - - ! '>='
32
32
  - !ruby/object:Gem::Version
33
33
  version: '0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '>='
38
+ - - ! '>='
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: rspec
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - '>='
45
+ - - ! '>='
46
46
  - !ruby/object:Gem::Version
47
47
  version: '2.0'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - '>='
52
+ - - ! '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '2.0'
55
55
  description: Nice Opaque Identifier
@@ -83,18 +83,20 @@ require_paths:
83
83
  - lib
84
84
  required_ruby_version: !ruby/object:Gem::Requirement
85
85
  requirements:
86
- - - '>='
86
+ - - ! '>='
87
87
  - !ruby/object:Gem::Version
88
88
  version: 1.9.3
89
89
  required_rubygems_version: !ruby/object:Gem::Requirement
90
90
  requirements:
91
- - - '>='
91
+ - - ! '>='
92
92
  - !ruby/object:Gem::Version
93
93
  version: '0'
94
94
  requirements: []
95
95
  rubyforge_project: noid
96
- rubygems_version: 2.1.11
96
+ rubygems_version: 2.2.2
97
97
  signing_key:
98
98
  specification_version: 4
99
99
  summary: Nice Opaque Identifier
100
- test_files: []
100
+ test_files:
101
+ - spec/lib/minter_spec.rb
102
+ - spec/spec_helper.rb