username 1.0.0 → 1.0.1
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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +3 -2
- data/lib/generators/templates/initializer.rb +3 -0
- data/lib/username/configuration.rb +2 -0
- data/lib/username/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 30a2016ad31e9aabae42451d8f93f7f090ac25659a77bc35b4a1933ea60e4159
|
4
|
+
data.tar.gz: aafae93ad37efc1eb2ef0e7c887c47c1f37fcf29802676a772f4cff3e81b1cbf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1ba518f119955a8eb4982f73824f667babb33b5df160ef88178104e2fb833c617b6ec74e89091fc805056cbb0bad7e3bc0ce67732c25a45c3e113910f929edc
|
7
|
+
data.tar.gz: 83c2e53ab7d4f52d66f04f84f3b854b325131466be304ba70f5accd4b831a246710d30d88288d2aaec9d9ea77e3d5fdccce7e2652ee1147d75583dc61f886b99
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -65,7 +65,7 @@ Username adds a validator to prevent the use of invalid usernames.
|
|
65
65
|
### Methods
|
66
66
|
|
67
67
|
```ruby
|
68
|
-
# If a username is
|
68
|
+
# If a username is valid for an ActiveRecord class
|
69
69
|
User.username_valid? 'test'
|
70
70
|
|
71
71
|
# If a username is available for an ActiveRecord model
|
@@ -80,10 +80,11 @@ You can configure Username by passing a block to `configure`. This can be done i
|
|
80
80
|
|
81
81
|
```ruby
|
82
82
|
Username.configure do |config|
|
83
|
-
config.
|
83
|
+
config.forbidden = []
|
84
84
|
end
|
85
85
|
```
|
86
86
|
|
87
|
+
* `forbidden` Array of forbidden usernames. Takes an array of strings. Defaults to `[]`.
|
87
88
|
* `minlength` Minimum length for usernames. Takes an integer. Defaults to `1`.
|
88
89
|
* `maxlength` Maximum length for usernames. Takes an integer. Defaults to `20`.
|
89
90
|
* `regex` Strings not matching this regular expression are invalid as usernames. Takes a regular expression. Defaults to `/\A[a-zA-Z0-9_\.]*\z/`.
|
@@ -12,6 +12,7 @@ module Username
|
|
12
12
|
class Configuration
|
13
13
|
|
14
14
|
attr_accessor :models
|
15
|
+
attr_accessor :forbidden
|
15
16
|
attr_accessor :minlength
|
16
17
|
attr_accessor :maxlength
|
17
18
|
attr_accessor :regex
|
@@ -19,6 +20,7 @@ module Username
|
|
19
20
|
|
20
21
|
def initialize
|
21
22
|
@models = []
|
23
|
+
@forbidden = []
|
22
24
|
@minlength = 1
|
23
25
|
@maxlength = 20
|
24
26
|
@regex = /\A[a-zA-Z0-9_\.]*\z/
|
data/lib/username/version.rb
CHANGED