deacon 0.0.3 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +13 -7
- data/lib/deacon/random_generator.rb +2 -2
- data/lib/deacon/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0e50e2def3625ec24af7c8fc01d515ba4c4868d0
|
4
|
+
data.tar.gz: 9d4207b7f4d061aeedc62da00234d9abf3094a2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4beaf81ad831e2590f1fa9b3b623b3a16963c40d0acdc19b1e2a905d20fe0ae6d87961bfff8bec8b0b7a74e6a20bbdbed55ae98f4651d1357f05c59023375063
|
7
|
+
data.tar.gz: 02818a6a6d50101d801b4e982727076de7f76334b3bf7de6c053253226a46e046594d17173abfa5f27a8bd8338a1f72072fcec2164e5ad6e8218da7a3954bd00
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Deacon - human readable random name generator
|
1
|
+
# [Deacon](https://rubygems.org/gems/deacon) - human readable random name generator
|
2
2
|
|
3
3
|
Out of ideas for incoming bare-metal host names in your cluster? This little
|
4
4
|
gem is a way out! It contains frequently occurring given names and surnames
|
@@ -19,12 +19,10 @@ combinations based on MAC adresses.
|
|
19
19
|
|
20
20
|
The random name generator makes use of [Fibonacci linear feedback shift
|
21
21
|
register](https://en.wikipedia.org/wiki/Linear_feedback_shift_register) which
|
22
|
-
gives deterministic sequence of pseudo-random numbers. Additionally,
|
22
|
+
gives deterministic sequence of pseudo-random numbers. Additionally, algorithm
|
23
23
|
makes sure names with same first name (or gender) and last name are not
|
24
24
|
returned in succession. Since there are about 1% of such cases, there are
|
25
|
-
about 33 million unique total names.
|
26
|
-
is seeded with a random value, so each installation gets unique sequence.
|
27
|
-
Example sequence:
|
25
|
+
about 33 million unique total names. Example sequence:
|
28
26
|
|
29
27
|
* velma-pratico.my.lan
|
30
28
|
* angie-warmbrod.my.lan
|
@@ -34,10 +32,13 @@ Example sequence:
|
|
34
32
|
* don-otero.my.lan
|
35
33
|
* sam-hulan.my.lan
|
36
34
|
|
37
|
-
The polynomial used in linear feedback shift register is
|
35
|
+
The polynomial used in linear feedback shift register is
|
36
|
+
|
37
|
+
x^25 + x^24 + x^23 + x^22 + 1.
|
38
38
|
|
39
39
|
The key thing is to store register (a number) and use it for each generation
|
40
|
-
in order to get non-repeating sequence of name combinations.
|
40
|
+
in order to get non-repeating sequence of name combinations. See an example
|
41
|
+
below.
|
41
42
|
|
42
43
|
### MAC generator
|
43
44
|
|
@@ -91,6 +92,11 @@ Example output:
|
|
91
92
|
PATSY CUSSON
|
92
93
|
HUGH SHIMER
|
93
94
|
|
95
|
+
By default, same firstname or surname successions are removed. To avoid that
|
96
|
+
behavior (e.g. in stateless applications where you can't store register), use
|
97
|
+
|
98
|
+
register, firstname, lastname = generator.generate(register, false)
|
99
|
+
|
94
100
|
Random LFSR generator example:
|
95
101
|
|
96
102
|
require "deacon"
|
@@ -13,12 +13,12 @@ module Deacon
|
|
13
13
|
i - 1
|
14
14
|
end
|
15
15
|
|
16
|
-
def generate(seed = Time.now.utc.to_i)
|
16
|
+
def generate(seed = Time.now.utc.to_i, test_uniquess = true)
|
17
17
|
return [] if seed.nil? || seed == 0
|
18
18
|
index = seed
|
19
19
|
loop do
|
20
20
|
index = next_lfsr25(index)
|
21
|
-
break if unique?(seed, index)
|
21
|
+
break if !test_uniquess || unique?(seed, index)
|
22
22
|
end
|
23
23
|
given_file = (index & 0x1000000) == 0 ? GIVEN_MALE_NAMES_FILE : GIVEN_FEMALE_NAMES_FILE
|
24
24
|
givenname_ix = (index & 0xff0000) >> 16
|
data/lib/deacon/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: deacon
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lukas Zapletal
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rdoc
|
@@ -24,7 +24,7 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
|
-
description: Provides human readable
|
27
|
+
description: Provides human readable names using continious LFSR
|
28
28
|
email:
|
29
29
|
- lukas-x@zapletalovi.com
|
30
30
|
executables: []
|