deterministic_random_username 1.0.0
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 +7 -0
- data/.gitignore +34 -0
- data/LICENSE +21 -0
- data/README.md +50 -0
- data/Rakefile +8 -0
- data/lib/random_username.rb +31 -0
- data/lib/random_username/adjectives.txt +366 -0
- data/lib/random_username/nouns.txt +185 -0
- data/lib/random_username/version.rb +3 -0
- data/random_username.gemspec +18 -0
- data/test/test_random_username.rb +100 -0
- metadata +56 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2776d7065566bee4587e26775c466d75f7314781
|
4
|
+
data.tar.gz: b9f6964d29b8104789bddddf8c9bcf5705a7562f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bc39dedb8086072fa4cc73c985f803f2866678c96c2deb73b3c76a6146a732bba35a2d1baa18b8baa70eaf176d3684a9854e124718edef6e711b226887fc024c
|
7
|
+
data.tar.gz: 7ca739d5c642e6124787d7b0a71ac288570621f9700fb496c3c5997e3491ed7820b7b10c314ca629db79443da1774aaa166fccec295e294ea104572824240ae8
|
data/.gitignore
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/_yardoc/
|
20
|
+
/doc/
|
21
|
+
/rdoc/
|
22
|
+
|
23
|
+
## Environment normalisation:
|
24
|
+
/.bundle/
|
25
|
+
/lib/bundler/man/
|
26
|
+
|
27
|
+
# for a library or gem, you might want to ignore these files since the code is
|
28
|
+
# intended to run in multiple environments; otherwise, check them in:
|
29
|
+
Gemfile.lock
|
30
|
+
.ruby-version
|
31
|
+
.ruby-gemset
|
32
|
+
|
33
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
34
|
+
.rvmrc
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2014 Poll Everywhere
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# RandomUsername
|
2
|
+
|
3
|
+
A random Heroku-style name generator.
|
4
|
+
|
5
|
+
# Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem "random_username"
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install random_username
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
```
|
22
|
+
RandomUsername.username
|
23
|
+
=> "hollowlight"
|
24
|
+
=> "legitsunrise"
|
25
|
+
=> "earthyleaf"
|
26
|
+
|
27
|
+
RandomUsername.username(:min_length => 6, :max_length => 8)
|
28
|
+
=> "fitcow"
|
29
|
+
=> "boldhero"
|
30
|
+
=> "topchip"
|
31
|
+
|
32
|
+
RandomUsername.noun
|
33
|
+
=> "sunrise"
|
34
|
+
=> "prize"
|
35
|
+
=> "sage"
|
36
|
+
|
37
|
+
RandomUsername.adjective
|
38
|
+
=> "heroic"
|
39
|
+
=> "worthy"
|
40
|
+
=> "enigmatic"
|
41
|
+
```
|
42
|
+
|
43
|
+
## Contributing
|
44
|
+
|
45
|
+
1. Fork it
|
46
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
47
|
+
3. Include tests with your changes (run `rake` to test)
|
48
|
+
4. Commit your changes (`git commit -am 'Add some feature'`)
|
49
|
+
5. Push to the branch (`git push origin my-new-feature`)
|
50
|
+
6. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require "random_username/version"
|
2
|
+
|
3
|
+
module RandomUsername
|
4
|
+
RandomUsername::Error = Class.new(StandardError)
|
5
|
+
|
6
|
+
def self.adjective(options = {})
|
7
|
+
get_item("adjectives", options)
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.noun(options = {})
|
11
|
+
get_item("nouns", options)
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.username(options = {})
|
15
|
+
options[:max_length] /= 2 if options[:max_length]
|
16
|
+
options[:min_length] /= 2 if options[:min_length]
|
17
|
+
adjective(options) + noun(options)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.get_item(filename, options = {})
|
21
|
+
items = items_from_file(filename)
|
22
|
+
items.select!{ |item| item.length <= options[:max_length] } if options[:max_length]
|
23
|
+
items.select!{ |item| item.length >= options[:min_length] } if options[:min_length]
|
24
|
+
items.sample(random: options[:random] || Random.new) || fail(RandomUsername::Error, "No words found")
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.items_from_file(filename)
|
28
|
+
filepath = File.expand_path("../random_username/#{filename}.txt", __FILE__)
|
29
|
+
File.read(filepath).split("\n")
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,366 @@
|
|
1
|
+
able
|
2
|
+
action
|
3
|
+
active
|
4
|
+
actual
|
5
|
+
adept
|
6
|
+
adored
|
7
|
+
adroit
|
8
|
+
affectionate
|
9
|
+
agile
|
10
|
+
airy
|
11
|
+
alert
|
12
|
+
alive
|
13
|
+
alter
|
14
|
+
amiable
|
15
|
+
ample
|
16
|
+
and
|
17
|
+
anima
|
18
|
+
apt
|
19
|
+
ardent
|
20
|
+
are
|
21
|
+
astute
|
22
|
+
august
|
23
|
+
avid
|
24
|
+
awake
|
25
|
+
aware
|
26
|
+
balmy
|
27
|
+
benevolent
|
28
|
+
big
|
29
|
+
billowing
|
30
|
+
blessed
|
31
|
+
bold
|
32
|
+
boss
|
33
|
+
brainy
|
34
|
+
brave
|
35
|
+
brawny
|
36
|
+
breezy
|
37
|
+
brief
|
38
|
+
bright
|
39
|
+
brisk
|
40
|
+
busy
|
41
|
+
calm
|
42
|
+
can
|
43
|
+
canny
|
44
|
+
cared
|
45
|
+
caring
|
46
|
+
casual
|
47
|
+
celestial
|
48
|
+
charming
|
49
|
+
chic
|
50
|
+
chief
|
51
|
+
choice
|
52
|
+
chosen
|
53
|
+
chummy
|
54
|
+
civic
|
55
|
+
civil
|
56
|
+
classy
|
57
|
+
clean
|
58
|
+
clear
|
59
|
+
clever
|
60
|
+
close
|
61
|
+
cogent
|
62
|
+
composed
|
63
|
+
cool
|
64
|
+
cosmic
|
65
|
+
cozy
|
66
|
+
cuddly
|
67
|
+
cute
|
68
|
+
dainty
|
69
|
+
dandy
|
70
|
+
dapper
|
71
|
+
daring
|
72
|
+
dear
|
73
|
+
decent
|
74
|
+
deep
|
75
|
+
deft
|
76
|
+
deluxe
|
77
|
+
devout
|
78
|
+
direct
|
79
|
+
divine
|
80
|
+
doted
|
81
|
+
doting
|
82
|
+
dreamy
|
83
|
+
driven
|
84
|
+
dry
|
85
|
+
earthy
|
86
|
+
easy
|
87
|
+
elated
|
88
|
+
energized
|
89
|
+
enigmatic
|
90
|
+
equal
|
91
|
+
exact
|
92
|
+
exotic
|
93
|
+
expert
|
94
|
+
exuberant
|
95
|
+
fair
|
96
|
+
famed
|
97
|
+
famous
|
98
|
+
fancy
|
99
|
+
fast
|
100
|
+
fiery
|
101
|
+
fine
|
102
|
+
fit
|
103
|
+
flashy
|
104
|
+
fleek
|
105
|
+
fleet
|
106
|
+
flowing
|
107
|
+
fluent
|
108
|
+
fluffy
|
109
|
+
fluttering
|
110
|
+
flying
|
111
|
+
fond
|
112
|
+
frank
|
113
|
+
free
|
114
|
+
fresh
|
115
|
+
full
|
116
|
+
fun
|
117
|
+
funny
|
118
|
+
fuscia
|
119
|
+
genial
|
120
|
+
gentle
|
121
|
+
giddy
|
122
|
+
gifted
|
123
|
+
giving
|
124
|
+
glad
|
125
|
+
gnarly
|
126
|
+
gold
|
127
|
+
golden
|
128
|
+
good
|
129
|
+
goodly
|
130
|
+
graceful
|
131
|
+
grand
|
132
|
+
great
|
133
|
+
green
|
134
|
+
groovy
|
135
|
+
guided
|
136
|
+
gutsy
|
137
|
+
haloed
|
138
|
+
happy
|
139
|
+
hardy
|
140
|
+
harmonious
|
141
|
+
hearty
|
142
|
+
heroic
|
143
|
+
high
|
144
|
+
hip
|
145
|
+
hollow
|
146
|
+
holy
|
147
|
+
honest
|
148
|
+
huge
|
149
|
+
humane
|
150
|
+
humble
|
151
|
+
hunky
|
152
|
+
icy
|
153
|
+
ideal
|
154
|
+
immune
|
155
|
+
indigo
|
156
|
+
inquisitive
|
157
|
+
jazzed
|
158
|
+
jazzy
|
159
|
+
jolly
|
160
|
+
jovial
|
161
|
+
joyful
|
162
|
+
joyous
|
163
|
+
jubilant
|
164
|
+
juicy
|
165
|
+
just
|
166
|
+
keen
|
167
|
+
khaki
|
168
|
+
kind
|
169
|
+
kingly
|
170
|
+
large
|
171
|
+
lavish
|
172
|
+
lawful
|
173
|
+
left
|
174
|
+
legal
|
175
|
+
legit
|
176
|
+
light
|
177
|
+
like
|
178
|
+
liked
|
179
|
+
likely
|
180
|
+
limber
|
181
|
+
limitless
|
182
|
+
lively
|
183
|
+
loved
|
184
|
+
lovely
|
185
|
+
loyal
|
186
|
+
lucid
|
187
|
+
lucky
|
188
|
+
lush
|
189
|
+
main
|
190
|
+
major
|
191
|
+
master
|
192
|
+
mature
|
193
|
+
max
|
194
|
+
maxed
|
195
|
+
mellow
|
196
|
+
merciful
|
197
|
+
merry
|
198
|
+
mighty
|
199
|
+
mint
|
200
|
+
mirthful
|
201
|
+
modern
|
202
|
+
modest
|
203
|
+
money
|
204
|
+
moonlit
|
205
|
+
moral
|
206
|
+
moving
|
207
|
+
mucho
|
208
|
+
mutual
|
209
|
+
mysterious
|
210
|
+
native
|
211
|
+
natural
|
212
|
+
near
|
213
|
+
neat
|
214
|
+
needed
|
215
|
+
new
|
216
|
+
nice
|
217
|
+
nifty
|
218
|
+
nimble
|
219
|
+
noble
|
220
|
+
normal
|
221
|
+
noted
|
222
|
+
novel
|
223
|
+
okay
|
224
|
+
open
|
225
|
+
outrageous
|
226
|
+
overt
|
227
|
+
pacific
|
228
|
+
parched
|
229
|
+
peachy
|
230
|
+
peppy
|
231
|
+
pithy
|
232
|
+
placid
|
233
|
+
pleasant
|
234
|
+
plucky
|
235
|
+
plum
|
236
|
+
poetic
|
237
|
+
poised
|
238
|
+
polite
|
239
|
+
posh
|
240
|
+
potent
|
241
|
+
pretty
|
242
|
+
prime
|
243
|
+
primo
|
244
|
+
prized
|
245
|
+
pro
|
246
|
+
prompt
|
247
|
+
proper
|
248
|
+
proud
|
249
|
+
pumped
|
250
|
+
punchy
|
251
|
+
pure
|
252
|
+
purring
|
253
|
+
quaint
|
254
|
+
quick
|
255
|
+
quiet
|
256
|
+
rad
|
257
|
+
radioactive
|
258
|
+
rapid
|
259
|
+
rare
|
260
|
+
ready
|
261
|
+
real
|
262
|
+
regal
|
263
|
+
resilient
|
264
|
+
rich
|
265
|
+
right
|
266
|
+
robust
|
267
|
+
rooted
|
268
|
+
rosy
|
269
|
+
rugged
|
270
|
+
safe
|
271
|
+
sassy
|
272
|
+
saucy
|
273
|
+
savvy
|
274
|
+
scenic
|
275
|
+
secret
|
276
|
+
seemly
|
277
|
+
serene
|
278
|
+
sharp
|
279
|
+
showy
|
280
|
+
shrewd
|
281
|
+
simple
|
282
|
+
sleek
|
283
|
+
slick
|
284
|
+
smart
|
285
|
+
smiley
|
286
|
+
smooth
|
287
|
+
snappy
|
288
|
+
snazzy
|
289
|
+
snowy
|
290
|
+
snugly
|
291
|
+
social
|
292
|
+
sole
|
293
|
+
solitary
|
294
|
+
sound
|
295
|
+
spacial
|
296
|
+
spicy
|
297
|
+
spiffy
|
298
|
+
spry
|
299
|
+
stable
|
300
|
+
star
|
301
|
+
stark
|
302
|
+
steady
|
303
|
+
stoic
|
304
|
+
strong
|
305
|
+
stunning
|
306
|
+
sturdy
|
307
|
+
suave
|
308
|
+
subtle
|
309
|
+
sunny
|
310
|
+
sunset
|
311
|
+
super
|
312
|
+
superb
|
313
|
+
sure
|
314
|
+
swank
|
315
|
+
sweet
|
316
|
+
swell
|
317
|
+
swift
|
318
|
+
talented
|
319
|
+
teal
|
320
|
+
the
|
321
|
+
thriving
|
322
|
+
tidy
|
323
|
+
timely
|
324
|
+
top
|
325
|
+
tops
|
326
|
+
tough
|
327
|
+
touted
|
328
|
+
tranquil
|
329
|
+
trim
|
330
|
+
tropical
|
331
|
+
true
|
332
|
+
trusty
|
333
|
+
undisturbed
|
334
|
+
unique
|
335
|
+
united
|
336
|
+
unsightly
|
337
|
+
unwavering
|
338
|
+
upbeat
|
339
|
+
uplifting
|
340
|
+
urbane
|
341
|
+
usable
|
342
|
+
useful
|
343
|
+
utmost
|
344
|
+
valid
|
345
|
+
vast
|
346
|
+
vestal
|
347
|
+
viable
|
348
|
+
vital
|
349
|
+
vivid
|
350
|
+
vocal
|
351
|
+
vogue
|
352
|
+
voiceless
|
353
|
+
volant
|
354
|
+
wandering
|
355
|
+
wanted
|
356
|
+
warm
|
357
|
+
wealthy
|
358
|
+
whispering
|
359
|
+
whole
|
360
|
+
winged
|
361
|
+
wired
|
362
|
+
wise
|
363
|
+
witty
|
364
|
+
wooden
|
365
|
+
worthy
|
366
|
+
zealous
|
@@ -0,0 +1,185 @@
|
|
1
|
+
abyss
|
2
|
+
animal
|
3
|
+
apple
|
4
|
+
atoll
|
5
|
+
aurora
|
6
|
+
autumn
|
7
|
+
bacon
|
8
|
+
badlands
|
9
|
+
ball
|
10
|
+
banana
|
11
|
+
bath
|
12
|
+
beach
|
13
|
+
bear
|
14
|
+
bed
|
15
|
+
bee
|
16
|
+
bike
|
17
|
+
bird
|
18
|
+
boat
|
19
|
+
book
|
20
|
+
bowl
|
21
|
+
branch
|
22
|
+
bread
|
23
|
+
breeze
|
24
|
+
briars
|
25
|
+
brook
|
26
|
+
brush
|
27
|
+
bunny
|
28
|
+
candy
|
29
|
+
canopy
|
30
|
+
canyon
|
31
|
+
car
|
32
|
+
cat
|
33
|
+
cave
|
34
|
+
cavern
|
35
|
+
cereal
|
36
|
+
chair
|
37
|
+
chasm
|
38
|
+
chip
|
39
|
+
cliff
|
40
|
+
coal
|
41
|
+
coast
|
42
|
+
cookie
|
43
|
+
cove
|
44
|
+
cow
|
45
|
+
crater
|
46
|
+
creek
|
47
|
+
darkness
|
48
|
+
dawn
|
49
|
+
desert
|
50
|
+
dew
|
51
|
+
dog
|
52
|
+
door
|
53
|
+
dove
|
54
|
+
drylands
|
55
|
+
duck
|
56
|
+
dusk
|
57
|
+
earth
|
58
|
+
fall
|
59
|
+
farm
|
60
|
+
fern
|
61
|
+
field
|
62
|
+
firefly
|
63
|
+
fish
|
64
|
+
fjord
|
65
|
+
flood
|
66
|
+
flower
|
67
|
+
flowers
|
68
|
+
fog
|
69
|
+
foliage
|
70
|
+
forest
|
71
|
+
freeze
|
72
|
+
frog
|
73
|
+
fu
|
74
|
+
galaxy
|
75
|
+
garden
|
76
|
+
geyser
|
77
|
+
gift
|
78
|
+
glass
|
79
|
+
grove
|
80
|
+
guide
|
81
|
+
guru
|
82
|
+
hat
|
83
|
+
hug
|
84
|
+
hero
|
85
|
+
hill
|
86
|
+
horse
|
87
|
+
house
|
88
|
+
hurricane
|
89
|
+
ice
|
90
|
+
iceberg
|
91
|
+
island
|
92
|
+
juice
|
93
|
+
lagoon
|
94
|
+
lake
|
95
|
+
land
|
96
|
+
lawn
|
97
|
+
leaf
|
98
|
+
leaves
|
99
|
+
light
|
100
|
+
lion
|
101
|
+
marsh
|
102
|
+
meadow
|
103
|
+
milk
|
104
|
+
mist
|
105
|
+
moon
|
106
|
+
moss
|
107
|
+
mountain
|
108
|
+
mouse
|
109
|
+
nature
|
110
|
+
oasis
|
111
|
+
ocean
|
112
|
+
pants
|
113
|
+
peak
|
114
|
+
pebble
|
115
|
+
pine
|
116
|
+
pilot
|
117
|
+
plane
|
118
|
+
planet
|
119
|
+
plant
|
120
|
+
plateau
|
121
|
+
pond
|
122
|
+
prize
|
123
|
+
rabbit
|
124
|
+
rain
|
125
|
+
range
|
126
|
+
reef
|
127
|
+
reserve
|
128
|
+
resonance
|
129
|
+
river
|
130
|
+
rock
|
131
|
+
sage
|
132
|
+
salute
|
133
|
+
sanctuary
|
134
|
+
sand
|
135
|
+
sands
|
136
|
+
shark
|
137
|
+
shelter
|
138
|
+
shirt
|
139
|
+
shoe
|
140
|
+
silence
|
141
|
+
sky
|
142
|
+
smokescreen
|
143
|
+
snowflake
|
144
|
+
socks
|
145
|
+
soil
|
146
|
+
soul
|
147
|
+
soup
|
148
|
+
sparrow
|
149
|
+
spoon
|
150
|
+
spring
|
151
|
+
star
|
152
|
+
stone
|
153
|
+
storm
|
154
|
+
stream
|
155
|
+
summer
|
156
|
+
summit
|
157
|
+
sun
|
158
|
+
sunrise
|
159
|
+
sunset
|
160
|
+
sunshine
|
161
|
+
surf
|
162
|
+
swamp
|
163
|
+
table
|
164
|
+
teacher
|
165
|
+
temple
|
166
|
+
thorns
|
167
|
+
tiger
|
168
|
+
tigers
|
169
|
+
towel
|
170
|
+
train
|
171
|
+
tree
|
172
|
+
truck
|
173
|
+
tsunami
|
174
|
+
tundra
|
175
|
+
valley
|
176
|
+
volcano
|
177
|
+
water
|
178
|
+
waterfall
|
179
|
+
waves
|
180
|
+
wild
|
181
|
+
willow
|
182
|
+
window
|
183
|
+
winds
|
184
|
+
winter
|
185
|
+
zebra
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/random_username/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.name = "deterministic_random_username"
|
6
|
+
gem.version = RandomUsername::VERSION
|
7
|
+
gem.license = "MIT"
|
8
|
+
gem.authors = ["Michael Foley", "Brian Glusman"]
|
9
|
+
gem.email = ["mike@polleverywhere.com"]
|
10
|
+
gem.description = %q{Generate random or deterministic Heroku-style names}
|
11
|
+
gem.summary = %q{Generate random or deterministic Heroku-style names}
|
12
|
+
gem.homepage = "https://github.com/stellaservice/random_username"
|
13
|
+
|
14
|
+
gem.files = `git ls-files`.split("\n")
|
15
|
+
gem.executables = []
|
16
|
+
gem.test_files = `git ls-files -- test/*`.split("\n")
|
17
|
+
gem.require_paths = ["lib"]
|
18
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
require "minitest/autorun"
|
2
|
+
require "random_username"
|
3
|
+
|
4
|
+
class TestRandomUsername < Minitest::Test
|
5
|
+
def all_adjectives
|
6
|
+
@all_adjectives ||= RandomUsername.items_from_file("adjectives")
|
7
|
+
end
|
8
|
+
|
9
|
+
def all_nouns
|
10
|
+
@all_nouns ||= RandomUsername.items_from_file("nouns")
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_adjective
|
14
|
+
adjective = RandomUsername.adjective
|
15
|
+
refute_empty adjective
|
16
|
+
assert_includes all_adjectives, adjective
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_adjective_max_length
|
20
|
+
adjective = RandomUsername.adjective(:max_length => 4)
|
21
|
+
assert adjective.length <= 4
|
22
|
+
end
|
23
|
+
|
24
|
+
def test_adjective_invalid_max_length
|
25
|
+
assert_raises RandomUsername::Error do
|
26
|
+
RandomUsername.adjective(:max_length => 1)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_adjective_min_length
|
31
|
+
adjective = RandomUsername.adjective(:min_length => 8)
|
32
|
+
assert adjective.length >= 8
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_adjective_invalid_min_length
|
36
|
+
assert_raises RandomUsername::Error do
|
37
|
+
RandomUsername.adjective(:min_length => 100)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_noun
|
42
|
+
noun = RandomUsername.noun
|
43
|
+
refute_empty noun
|
44
|
+
assert_includes all_nouns, noun
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_noun_max_length
|
48
|
+
noun = RandomUsername.noun(:max_length => 4)
|
49
|
+
assert noun.length <= 4
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_noun_invalid_max_length
|
53
|
+
assert_raises RandomUsername::Error do
|
54
|
+
RandomUsername.noun(:max_length => 1)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_noun_min_length
|
59
|
+
noun = RandomUsername.noun(:min_length => 8)
|
60
|
+
assert noun.length >= 8
|
61
|
+
end
|
62
|
+
|
63
|
+
def test_noun_invalid_min_length
|
64
|
+
assert_raises RandomUsername::Error do
|
65
|
+
RandomUsername.noun(:min_length => 100)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def test_username
|
70
|
+
username = RandomUsername.username
|
71
|
+
refute_empty username
|
72
|
+
anchor = (2..username.length).detect do |i|
|
73
|
+
all_adjectives.include?(username[0..i])
|
74
|
+
end
|
75
|
+
assert_includes all_adjectives, username[0..anchor]
|
76
|
+
assert_includes all_nouns, username[anchor+1..-1]
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_username_max_length
|
80
|
+
username = RandomUsername.username(:max_length => 10)
|
81
|
+
assert username.length <= 10
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_username_invalid_max_length
|
85
|
+
assert_raises RandomUsername::Error do
|
86
|
+
RandomUsername.username(:max_length => 2)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_username_min_length
|
91
|
+
username = RandomUsername.username(:min_length => 10)
|
92
|
+
assert username.length >= 10
|
93
|
+
end
|
94
|
+
|
95
|
+
def test_username_invalid_min_length
|
96
|
+
assert_raises RandomUsername::Error do
|
97
|
+
RandomUsername.username(:min_length => 100)
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
metadata
ADDED
@@ -0,0 +1,56 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: deterministic_random_username
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Michael Foley
|
8
|
+
- Brian Glusman
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2016-12-05 00:00:00.000000000 Z
|
13
|
+
dependencies: []
|
14
|
+
description: Generate random or deterministic Heroku-style names
|
15
|
+
email:
|
16
|
+
- mike@polleverywhere.com
|
17
|
+
executables: []
|
18
|
+
extensions: []
|
19
|
+
extra_rdoc_files: []
|
20
|
+
files:
|
21
|
+
- ".gitignore"
|
22
|
+
- LICENSE
|
23
|
+
- README.md
|
24
|
+
- Rakefile
|
25
|
+
- lib/random_username.rb
|
26
|
+
- lib/random_username/adjectives.txt
|
27
|
+
- lib/random_username/nouns.txt
|
28
|
+
- lib/random_username/version.rb
|
29
|
+
- random_username.gemspec
|
30
|
+
- test/test_random_username.rb
|
31
|
+
homepage: https://github.com/stellaservice/random_username
|
32
|
+
licenses:
|
33
|
+
- MIT
|
34
|
+
metadata: {}
|
35
|
+
post_install_message:
|
36
|
+
rdoc_options: []
|
37
|
+
require_paths:
|
38
|
+
- lib
|
39
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - ">="
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '0'
|
49
|
+
requirements: []
|
50
|
+
rubyforge_project:
|
51
|
+
rubygems_version: 2.6.8
|
52
|
+
signing_key:
|
53
|
+
specification_version: 4
|
54
|
+
summary: Generate random or deterministic Heroku-style names
|
55
|
+
test_files:
|
56
|
+
- test/test_random_username.rb
|