random_username 1.0.2 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5407d640098b7775c6530debe44b9aaadc476af1
4
- data.tar.gz: b5e8e0c1f3097a9840a9a1d6a70bc041977ebf9b
3
+ metadata.gz: c079b0203e002f6bf8266581f034f864262a8d84
4
+ data.tar.gz: 8de9562cd21557b529555e5e6c0b33f8bebc0cf5
5
5
  SHA512:
6
- metadata.gz: d8b4a023ba60de6782b9268ce01927fbec737a48d7d97669f1ceea4216aabecfa40de32b7a8ebf6d445b490f932d4093c82a464fba41b1707a89f9671b2a3ec0
7
- data.tar.gz: 0c9e619d3896c12eb167005a95a5b0e1bc3e0b34cee18b815e8d516694470e48868aaa9f43485078e7ea26ff8f5b8e43b6eef81c15582b8ff62ed92d4db73ab2
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
- RandomUsername.noun
22
- => "sunrise"
23
- => "prize"
24
- => "sage"
25
-
26
- RandomUsername.adjective
27
- => "heroic"
28
- => "worthy"
29
- => "enigmatic"
30
-
31
- RandomUsername.username
32
- => "hollowlight"
33
- => "legitsunrise"
34
- => "earthyleaf"
35
-
36
- RandomUsername.username(:max_length => 6)
37
- => "fitcow"
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
 
@@ -1,3 +1,3 @@
1
1
  module RandomUsername
2
- VERSION = "1.0.2"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -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.2
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-01-31 00:00:00.000000000 Z
11
+ date: 2015-03-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Generate random Heroku-style names
14
14
  email: