random_username 1.0.2 → 1.1.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 +21 -17
- data/lib/random_username/version.rb +1 -1
- data/lib/random_username.rb +2 -0
- data/test/test_random_username.rb +33 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c079b0203e002f6bf8266581f034f864262a8d84
|
4
|
+
data.tar.gz: 8de9562cd21557b529555e5e6c0b33f8bebc0cf5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ac4d0dca6305d03dc491dfbb17fb9eb686e0b21dfb2d6af0516689587ec93b49b3d23121190681e9e0c630795af39f0e4baa5f295167bd8dda5b6463bb2cce7
|
7
|
+
data.tar.gz: a0f83a218efb06c2edae462a582221eeaa8b92a56d4814e5d4838bac5d8f796931f3e97e50417d08c2846e19c03c1468629f69bd55e901254e1ddb8721eaa335
|
data/README.md
CHANGED
@@ -18,23 +18,27 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
+
```
|
38
42
|
|
39
43
|
## Contributing
|
40
44
|
|
data/lib/random_username.rb
CHANGED
@@ -13,12 +13,14 @@ module RandomUsername
|
|
13
13
|
|
14
14
|
def self.username(options = {})
|
15
15
|
options[:max_length] /= 2 if options[:max_length]
|
16
|
+
options[:min_length] /= 2 if options[:min_length]
|
16
17
|
adjective(options) + noun(options)
|
17
18
|
end
|
18
19
|
|
19
20
|
def self.get_item(filename, options = {})
|
20
21
|
items = items_from_file(filename)
|
21
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]
|
22
24
|
items.sample || fail(RandomUsername::Error, "No words found")
|
23
25
|
end
|
24
26
|
|
@@ -27,6 +27,17 @@ class TestRandomUsername < Minitest::Test
|
|
27
27
|
end
|
28
28
|
end
|
29
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
|
+
|
30
41
|
def test_noun
|
31
42
|
noun = RandomUsername.noun
|
32
43
|
refute_empty noun
|
@@ -44,6 +55,17 @@ class TestRandomUsername < Minitest::Test
|
|
44
55
|
end
|
45
56
|
end
|
46
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
|
+
|
47
69
|
def test_username
|
48
70
|
username = RandomUsername.username
|
49
71
|
refute_empty username
|
@@ -64,4 +86,15 @@ class TestRandomUsername < Minitest::Test
|
|
64
86
|
RandomUsername.username(:max_length => 2)
|
65
87
|
end
|
66
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
|
67
100
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: random_username
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Foley
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Generate random Heroku-style names
|
14
14
|
email:
|