voltron-encrypt 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 278557400ef5996ade0a48d3e1ebee0a87b33ffd
|
4
|
+
data.tar.gz: 012b9e1797827875d2233e47379b7cf95d0229f4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 95bd857aabae26567eb21d75844c83545af403a09977be7278ff5814ea40d65917f73195387e8b56bcefed87e498bcea1cc80bdb2da6a66c9546d4957f6f7703
|
7
|
+
data.tar.gz: 94463817979f129f636ac7a5c7500b1da19c1fc9850783f375609a8cdbd9bf940899d899d8d0940614b6c65cbeebfc313cc9be32d9831f4a35f4b4518d55a848
|
data/lib/voltron/encrypt.rb
CHANGED
@@ -39,7 +39,7 @@ module Voltron
|
|
39
39
|
encoded = encode(input)
|
40
40
|
|
41
41
|
pattern = ["\\b([_\\-])*"]
|
42
|
-
encoded.
|
42
|
+
encoded.chars.each do |c|
|
43
43
|
subs = translations[c.downcase] || []
|
44
44
|
c = "\\#{c}" if c == "-"
|
45
45
|
pattern << "[#{c}#{subs.join}]([_\\-])*"
|
@@ -76,7 +76,7 @@ module Voltron
|
|
76
76
|
|
77
77
|
def digits
|
78
78
|
rnd = Random.new(Voltron.config.encrypt.seed.to_s.to_i(24))
|
79
|
-
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".
|
79
|
+
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".chars.shuffle(random: rnd)
|
80
80
|
end
|
81
81
|
end
|
82
82
|
end
|
@@ -6,28 +6,22 @@ module Voltron
|
|
6
6
|
def ids_writer(ids)
|
7
7
|
if klass.has_encrypted_id?
|
8
8
|
ids.reject!(&:blank?)
|
9
|
-
|
9
|
+
records = klass.find(ids)
|
10
|
+
replace(Array.wrap(records))
|
10
11
|
else
|
11
12
|
super ids
|
12
13
|
end
|
13
14
|
end
|
14
15
|
|
15
16
|
def ids_reader
|
16
|
-
if
|
17
|
-
|
18
|
-
|
19
|
-
record.to_param
|
20
|
-
else
|
21
|
-
record.send(reflection.association_primary_key)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
else
|
25
|
-
if klass.has_encrypted_id?
|
26
|
-
scope.map(&:to_param)
|
17
|
+
if klass.has_encrypted_id?
|
18
|
+
if loaded?
|
19
|
+
load_target.map(&:to_param)
|
27
20
|
else
|
28
|
-
|
29
|
-
scope.pluck(column)
|
21
|
+
scope.map(&:to_param)
|
30
22
|
end
|
23
|
+
else
|
24
|
+
super
|
31
25
|
end
|
32
26
|
end
|
33
27
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: voltron-encrypt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Hainer
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|