uniqueness 0.7.0 → 0.8.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: 99d56bdd5db29acb11bcd1259aafe34004684f88
4
- data.tar.gz: 6cea06eaa400b0ee4c1c96aaa765aec6a5912288
3
+ metadata.gz: 41b32d19faa7d590bc7d61cb4abc3b73606af2b3
4
+ data.tar.gz: 1b5f46edc116b2d6a57d46122e06f48fe7f1f220
5
5
  SHA512:
6
- metadata.gz: d093e6299223e48b634116ee995b5b878a404bfa6424bb106735bb756f725ec577246f32127078184363e29e993f750235820bd4fa56cbdc38a6fd2372d86e50
7
- data.tar.gz: 242b28d6005cd2daaa3616510ec9459a0341973ef5bada7f97a00d265eb566d7c378be806ee178f09feb1fdcc145575476e89f805ecfb0a3e1f50f42a00f63db
6
+ metadata.gz: ab219f0fa3965d390b0b287cbc6c5941bff889a9612b45cde6a68379dd99037305fbaceb7db03f02f256d035b8484e6213f2d4506b76d5267fc38fe36c8957fe
7
+ data.tar.gz: 28164f8565242a7cf322a925f3ce351e9fde8c8de772c4788f49b795d72d474aac0c8d3e642a33c4658f1070cf62f0462c670b1a6b67cf7408e9fe31bd880253
@@ -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
- Array.new(options[:length]).map { dict[rand(dict.length)] }.join
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
@@ -1,3 +1,3 @@
1
1
  module Uniqueness
2
- VERSION = '0.7.0'.freeze
2
+ VERSION = '0.8.0'.freeze
3
3
  end
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.7.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-02 00:00:00.000000000 Z
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.6.12
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.