attr_encrypted 1.3.5 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/attr_encrypted/adapters/active_record.rb +14 -1
- data/lib/attr_encrypted/version.rb +2 -2
- data/test/active_record_test.rb +15 -0
- metadata +34 -60
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8be516fee846217b6cc95a706bc87bbc267f7d71
|
4
|
+
data.tar.gz: f72d166a492c0efc4a7fd2a84b863fb3b4ea8d5a
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ed046ac7c9e40406f871e00e3e95821002605b62022d556b8ac5dcc5a7ce9f06e38925b6a1849e1dfb3ee7a4666ce2a2e15e1130f20f53eb246017fcb362dbd3
|
7
|
+
data.tar.gz: c27e6b6c8b4644a8daf02c4fc50f607878dac6a3a86e71181e28f3a78c71da5b7abed88094b61ac6fa9a558a08934d572b5a7169830c93592deabfd79c285512
|
@@ -16,6 +16,7 @@ if defined?(ActiveRecord::Base)
|
|
16
16
|
alias_method_chain :reload, :attr_encrypted
|
17
17
|
|
18
18
|
attr_encrypted_options[:encode] = true
|
19
|
+
|
19
20
|
class << self
|
20
21
|
alias_method :attr_encryptor, :attr_encrypted
|
21
22
|
alias_method_chain :method_missing, :attr_encrypted
|
@@ -49,7 +50,19 @@ if defined?(ActiveRecord::Base)
|
|
49
50
|
# <tt>attr_encrypted</tt> method
|
50
51
|
def attr_encrypted(*attrs)
|
51
52
|
super
|
52
|
-
|
53
|
+
options = attrs.extract_options!
|
54
|
+
attr = attrs.pop
|
55
|
+
options.merge! encrypted_attributes[attr]
|
56
|
+
|
57
|
+
define_method("#{attr}_changed?") do
|
58
|
+
send(attr) != decrypt(attr, send("#{options[:attribute]}_was"))
|
59
|
+
end
|
60
|
+
|
61
|
+
define_method("#{attr}_was") do
|
62
|
+
decrypt(attr, send("#{options[:attribute]}_was")) if send("#{attr}_changed?")
|
63
|
+
end
|
64
|
+
|
65
|
+
alias_method "#{attr}_before_type_cast", attr
|
53
66
|
end
|
54
67
|
|
55
68
|
def attribute_instance_methods_as_symbols
|
data/test/active_record_test.rb
CHANGED
@@ -164,6 +164,21 @@ class ActiveRecordTest < Minitest::Test
|
|
164
164
|
assert_equal account.key, hash
|
165
165
|
end
|
166
166
|
|
167
|
+
def test_should_create_changed_predicate
|
168
|
+
person = Person.create!(:email => 'test@example.com')
|
169
|
+
assert !person.email_changed?
|
170
|
+
person.email = 'test2@example.com'
|
171
|
+
assert person.email_changed?
|
172
|
+
end
|
173
|
+
|
174
|
+
def test_should_create_was_predicate
|
175
|
+
original_email = 'test@example.com'
|
176
|
+
person = Person.create!(:email => original_email)
|
177
|
+
assert !person.email_was
|
178
|
+
person.email = 'test2@example.com'
|
179
|
+
assert_equal person.email_was, original_email
|
180
|
+
end
|
181
|
+
|
167
182
|
if ::ActiveRecord::VERSION::STRING > "4.0"
|
168
183
|
def test_should_assign_attributes
|
169
184
|
@user = UserWithProtectedAttribute.new :login => 'login', :is_admin => false
|
metadata
CHANGED
@@ -1,8 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: attr_encrypted
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
5
|
-
prerelease:
|
4
|
+
version: 1.4.0
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Sean Huber
|
@@ -12,76 +11,67 @@ authors:
|
|
12
11
|
autorequire:
|
13
12
|
bindir: bin
|
14
13
|
cert_chain: []
|
15
|
-
date: 2016-
|
14
|
+
date: 2016-02-23 00:00:00.000000000 Z
|
16
15
|
dependencies:
|
17
16
|
- !ruby/object:Gem::Dependency
|
18
17
|
name: encryptor
|
19
18
|
requirement: !ruby/object:Gem::Requirement
|
20
|
-
none: false
|
21
19
|
requirements:
|
22
|
-
- - ~>
|
20
|
+
- - "~>"
|
23
21
|
- !ruby/object:Gem::Version
|
24
22
|
version: 1.3.0
|
25
23
|
type: :runtime
|
26
24
|
prerelease: false
|
27
25
|
version_requirements: !ruby/object:Gem::Requirement
|
28
|
-
none: false
|
29
26
|
requirements:
|
30
|
-
- - ~>
|
27
|
+
- - "~>"
|
31
28
|
- !ruby/object:Gem::Version
|
32
29
|
version: 1.3.0
|
33
30
|
- !ruby/object:Gem::Dependency
|
34
31
|
name: activerecord
|
35
32
|
requirement: !ruby/object:Gem::Requirement
|
36
|
-
none: false
|
37
33
|
requirements:
|
38
|
-
- -
|
34
|
+
- - ">="
|
39
35
|
- !ruby/object:Gem::Version
|
40
36
|
version: 2.0.0
|
41
37
|
type: :development
|
42
38
|
prerelease: false
|
43
39
|
version_requirements: !ruby/object:Gem::Requirement
|
44
|
-
none: false
|
45
40
|
requirements:
|
46
|
-
- -
|
41
|
+
- - ">="
|
47
42
|
- !ruby/object:Gem::Version
|
48
43
|
version: 2.0.0
|
49
44
|
- !ruby/object:Gem::Dependency
|
50
45
|
name: minitest
|
51
46
|
requirement: !ruby/object:Gem::Requirement
|
52
|
-
none: false
|
53
47
|
requirements:
|
54
|
-
- -
|
48
|
+
- - ">="
|
55
49
|
- !ruby/object:Gem::Version
|
56
50
|
version: '0'
|
57
51
|
type: :development
|
58
52
|
prerelease: false
|
59
53
|
version_requirements: !ruby/object:Gem::Requirement
|
60
|
-
none: false
|
61
54
|
requirements:
|
62
|
-
- -
|
55
|
+
- - ">="
|
63
56
|
- !ruby/object:Gem::Version
|
64
57
|
version: '0'
|
65
58
|
- !ruby/object:Gem::Dependency
|
66
59
|
name: datamapper
|
67
60
|
requirement: !ruby/object:Gem::Requirement
|
68
|
-
none: false
|
69
61
|
requirements:
|
70
|
-
- -
|
62
|
+
- - ">="
|
71
63
|
- !ruby/object:Gem::Version
|
72
64
|
version: '0'
|
73
65
|
type: :development
|
74
66
|
prerelease: false
|
75
67
|
version_requirements: !ruby/object:Gem::Requirement
|
76
|
-
none: false
|
77
68
|
requirements:
|
78
|
-
- -
|
69
|
+
- - ">="
|
79
70
|
- !ruby/object:Gem::Version
|
80
71
|
version: '0'
|
81
72
|
- !ruby/object:Gem::Dependency
|
82
73
|
name: addressable
|
83
74
|
requirement: !ruby/object:Gem::Requirement
|
84
|
-
none: false
|
85
75
|
requirements:
|
86
76
|
- - '='
|
87
77
|
- !ruby/object:Gem::Version
|
@@ -89,7 +79,6 @@ dependencies:
|
|
89
79
|
type: :development
|
90
80
|
prerelease: false
|
91
81
|
version_requirements: !ruby/object:Gem::Requirement
|
92
|
-
none: false
|
93
82
|
requirements:
|
94
83
|
- - '='
|
95
84
|
- !ruby/object:Gem::Version
|
@@ -97,71 +86,62 @@ dependencies:
|
|
97
86
|
- !ruby/object:Gem::Dependency
|
98
87
|
name: mocha
|
99
88
|
requirement: !ruby/object:Gem::Requirement
|
100
|
-
none: false
|
101
89
|
requirements:
|
102
|
-
- - ~>
|
90
|
+
- - "~>"
|
103
91
|
- !ruby/object:Gem::Version
|
104
92
|
version: 1.0.0
|
105
93
|
type: :development
|
106
94
|
prerelease: false
|
107
95
|
version_requirements: !ruby/object:Gem::Requirement
|
108
|
-
none: false
|
109
96
|
requirements:
|
110
|
-
- - ~>
|
97
|
+
- - "~>"
|
111
98
|
- !ruby/object:Gem::Version
|
112
99
|
version: 1.0.0
|
113
100
|
- !ruby/object:Gem::Dependency
|
114
101
|
name: sequel
|
115
102
|
requirement: !ruby/object:Gem::Requirement
|
116
|
-
none: false
|
117
103
|
requirements:
|
118
|
-
- -
|
104
|
+
- - ">="
|
119
105
|
- !ruby/object:Gem::Version
|
120
106
|
version: '0'
|
121
107
|
type: :development
|
122
108
|
prerelease: false
|
123
109
|
version_requirements: !ruby/object:Gem::Requirement
|
124
|
-
none: false
|
125
110
|
requirements:
|
126
|
-
- -
|
111
|
+
- - ">="
|
127
112
|
- !ruby/object:Gem::Version
|
128
113
|
version: '0'
|
129
114
|
- !ruby/object:Gem::Dependency
|
130
115
|
name: sqlite3
|
131
116
|
requirement: !ruby/object:Gem::Requirement
|
132
|
-
none: false
|
133
117
|
requirements:
|
134
|
-
- -
|
118
|
+
- - ">="
|
135
119
|
- !ruby/object:Gem::Version
|
136
120
|
version: '0'
|
137
121
|
type: :development
|
138
122
|
prerelease: false
|
139
123
|
version_requirements: !ruby/object:Gem::Requirement
|
140
|
-
none: false
|
141
124
|
requirements:
|
142
|
-
- -
|
125
|
+
- - ">="
|
143
126
|
- !ruby/object:Gem::Version
|
144
127
|
version: '0'
|
145
128
|
- !ruby/object:Gem::Dependency
|
146
129
|
name: dm-sqlite-adapter
|
147
130
|
requirement: !ruby/object:Gem::Requirement
|
148
|
-
none: false
|
149
131
|
requirements:
|
150
|
-
- -
|
132
|
+
- - ">="
|
151
133
|
- !ruby/object:Gem::Version
|
152
134
|
version: '0'
|
153
135
|
type: :development
|
154
136
|
prerelease: false
|
155
137
|
version_requirements: !ruby/object:Gem::Requirement
|
156
|
-
none: false
|
157
138
|
requirements:
|
158
|
-
- -
|
139
|
+
- - ">="
|
159
140
|
- !ruby/object:Gem::Version
|
160
141
|
version: '0'
|
161
142
|
- !ruby/object:Gem::Dependency
|
162
143
|
name: rake
|
163
144
|
requirement: !ruby/object:Gem::Requirement
|
164
|
-
none: false
|
165
145
|
requirements:
|
166
146
|
- - '='
|
167
147
|
- !ruby/object:Gem::Version
|
@@ -169,7 +149,6 @@ dependencies:
|
|
169
149
|
type: :development
|
170
150
|
prerelease: false
|
171
151
|
version_requirements: !ruby/object:Gem::Requirement
|
172
|
-
none: false
|
173
152
|
requirements:
|
174
153
|
- - '='
|
175
154
|
- !ruby/object:Gem::Version
|
@@ -177,33 +156,29 @@ dependencies:
|
|
177
156
|
- !ruby/object:Gem::Dependency
|
178
157
|
name: simplecov
|
179
158
|
requirement: !ruby/object:Gem::Requirement
|
180
|
-
none: false
|
181
159
|
requirements:
|
182
|
-
- -
|
160
|
+
- - ">="
|
183
161
|
- !ruby/object:Gem::Version
|
184
162
|
version: '0'
|
185
163
|
type: :development
|
186
164
|
prerelease: false
|
187
165
|
version_requirements: !ruby/object:Gem::Requirement
|
188
|
-
none: false
|
189
166
|
requirements:
|
190
|
-
- -
|
167
|
+
- - ">="
|
191
168
|
- !ruby/object:Gem::Version
|
192
169
|
version: '0'
|
193
170
|
- !ruby/object:Gem::Dependency
|
194
171
|
name: simplecov-rcov
|
195
172
|
requirement: !ruby/object:Gem::Requirement
|
196
|
-
none: false
|
197
173
|
requirements:
|
198
|
-
- -
|
174
|
+
- - ">="
|
199
175
|
- !ruby/object:Gem::Version
|
200
176
|
version: '0'
|
201
177
|
type: :development
|
202
178
|
prerelease: false
|
203
179
|
version_requirements: !ruby/object:Gem::Requirement
|
204
|
-
none: false
|
205
180
|
requirements:
|
206
|
-
- -
|
181
|
+
- - ">="
|
207
182
|
- !ruby/object:Gem::Version
|
208
183
|
version: '0'
|
209
184
|
description: Generates attr_accessors that encrypt and decrypt attributes transparently
|
@@ -216,14 +191,14 @@ executables: []
|
|
216
191
|
extensions: []
|
217
192
|
extra_rdoc_files: []
|
218
193
|
files:
|
194
|
+
- MIT-LICENSE
|
195
|
+
- README.rdoc
|
196
|
+
- Rakefile
|
197
|
+
- lib/attr_encrypted.rb
|
219
198
|
- lib/attr_encrypted/adapters/active_record.rb
|
220
199
|
- lib/attr_encrypted/adapters/data_mapper.rb
|
221
200
|
- lib/attr_encrypted/adapters/sequel.rb
|
222
201
|
- lib/attr_encrypted/version.rb
|
223
|
-
- lib/attr_encrypted.rb
|
224
|
-
- MIT-LICENSE
|
225
|
-
- Rakefile
|
226
|
-
- README.rdoc
|
227
202
|
- test/active_record_test.rb
|
228
203
|
- test/attr_encrypted_test.rb
|
229
204
|
- test/compatibility_test.rb
|
@@ -238,31 +213,30 @@ files:
|
|
238
213
|
- test/test_helper.rb
|
239
214
|
homepage: http://github.com/attr-encrypted/attr_encrypted
|
240
215
|
licenses: []
|
216
|
+
metadata: {}
|
241
217
|
post_install_message:
|
242
218
|
rdoc_options:
|
243
|
-
- --line-numbers
|
244
|
-
- --inline-source
|
245
|
-
- --main
|
219
|
+
- "--line-numbers"
|
220
|
+
- "--inline-source"
|
221
|
+
- "--main"
|
246
222
|
- README.rdoc
|
247
223
|
require_paths:
|
248
224
|
- lib
|
249
225
|
required_ruby_version: !ruby/object:Gem::Requirement
|
250
|
-
none: false
|
251
226
|
requirements:
|
252
|
-
- -
|
227
|
+
- - ">="
|
253
228
|
- !ruby/object:Gem::Version
|
254
229
|
version: '0'
|
255
230
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
256
|
-
none: false
|
257
231
|
requirements:
|
258
|
-
- -
|
232
|
+
- - ">="
|
259
233
|
- !ruby/object:Gem::Version
|
260
234
|
version: '0'
|
261
235
|
requirements: []
|
262
236
|
rubyforge_project:
|
263
|
-
rubygems_version:
|
237
|
+
rubygems_version: 2.4.5.1
|
264
238
|
signing_key:
|
265
|
-
specification_version:
|
239
|
+
specification_version: 4
|
266
240
|
summary: Encrypt and decrypt attributes
|
267
241
|
test_files:
|
268
242
|
- test/active_record_test.rb
|