uniqueness 0.7.0 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/uniqueness/generator.rb +10 -2
- data/lib/uniqueness/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: 41b32d19faa7d590bc7d61cb4abc3b73606af2b3
|
4
|
+
data.tar.gz: 1b5f46edc116b2d6a57d46122e06f48fe7f1f220
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ab219f0fa3965d390b0b287cbc6c5941bff889a9612b45cde6a68379dd99037305fbaceb7db03f02f256d035b8484e6213f2d4506b76d5267fc38fe36c8957fe
|
7
|
+
data.tar.gz: 28164f8565242a7cf322a925f3ce351e9fde8c8de772c4788f49b795d72d474aac0c8d3e642a33c4658f1070cf62f0462c670b1a6b67cf7408e9fe31bd880253
|
data/lib/uniqueness/generator.rb
CHANGED
@@ -6,7 +6,9 @@ module Uniqueness
|
|
6
6
|
dict = uniqueness_dictionary - options[:blacklist]
|
7
7
|
dict -= [*(:A..:Z)].map(&:to_s) unless options[:case_sensitive]
|
8
8
|
dict -= uniqueness_ambigious_dictionary if options[:type].to_sym == :human
|
9
|
-
|
9
|
+
dict = uniqueness_numbers_dictionary if options[:type].to_sym == :numbers
|
10
|
+
code = Array.new(options[:length]).map { dict[rand(dict.length)] }.join
|
11
|
+
"#{options[:prefix]}#{code}#{options[:suffix]}"
|
10
12
|
end
|
11
13
|
|
12
14
|
# Dictionary used for uniqueness generation
|
@@ -18,13 +20,19 @@ module Uniqueness
|
|
18
20
|
[:b, :B, :o, :O, :q, :i, :I, :l, :L, :s, :S, :u, :U, :z, :Z, :g, 1, 2, 9, 5].map(&:to_s)
|
19
21
|
end
|
20
22
|
|
23
|
+
def uniqueness_numbers_dictionary
|
24
|
+
[*(0..9)].map(&:to_s)
|
25
|
+
end
|
26
|
+
|
21
27
|
# Default sorting options
|
22
28
|
def uniqueness_default_options
|
23
29
|
{
|
24
30
|
length: 32,
|
25
31
|
type: :auto,
|
26
32
|
blacklist: [],
|
27
|
-
scope: []
|
33
|
+
scope: [],
|
34
|
+
suffix: '',
|
35
|
+
prefix: ''
|
28
36
|
}
|
29
37
|
end
|
30
38
|
end
|
data/lib/uniqueness/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: uniqueness
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Omar Abdel-Wahab
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-06
|
11
|
+
date: 2017-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -176,7 +176,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
176
176
|
version: '0'
|
177
177
|
requirements: []
|
178
178
|
rubyforge_project:
|
179
|
-
rubygems_version: 2.
|
179
|
+
rubygems_version: 2.4.8
|
180
180
|
signing_key:
|
181
181
|
specification_version: 4
|
182
182
|
summary: Adds unique attribute support to ActiveModel models.
|