active_record_encryption 0.2.1 → 0.3.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
  SHA256:
3
- metadata.gz: 585c87bfd8ce7dc5dd9aa303a89f23b5f7f7060e53401538465214e717f4cf4e
4
- data.tar.gz: adf27af387edb8ff6cac34ea735c8189e26889a59c22b8f0eb19fe190cc8f27f
3
+ metadata.gz: bc2770632c4ba57ce5f3b807e9fe4e45ef18e959176ae907635e65a0de4f686d
4
+ data.tar.gz: 7f98301e66f31aaa043cd5c3a2ab58e655d7da9023bd8fd1d6a310b938b642e6
5
5
  SHA512:
6
- metadata.gz: '09cf19da814c601fafc4e5e05c64ac2eb6926f540e2116e2536c0eef1ef72529f1d2865403f2a7475ddd53b8de0ef5f1d42cfa8408b42fc48b0552ef74e8a569'
7
- data.tar.gz: 9a6602b13e6ced26450cee8ed43feab631ecd1a2cb009ed26d7a0f0df9a3a482f34b2cc7f63dc52316574c7274680b8296be1c749df83c4387d8287da7e5f178
6
+ metadata.gz: 5884f04a7b4e6fab65ce2044502b5387c172917442c4d29715bd368c75cdecd9b49bb6862c8493bd7668bd3780c431d036fbd8dfac5a2cd9d6a12e33e2453790
7
+ data.tar.gz: 6f1c82c9b173fe8d6cdb19cf6a71e6dc9ef8be793028b27a5e230b0f885554c700f105f2354b1c74d905d49384afcb44480f3f9f5254c15867e0a8200ade8c0c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.3.0
2
+
3
+ - Support rails 6.1.0 #22
4
+ - Ensure casting only when Rails less than 6.0 #21
5
+ - Fix Ruby 2.7 keyword arguments warnings #20
6
+
1
7
  ## 0.2.1
2
8
 
3
9
  - Fixes #13 Add `:cipher` option to `active_support` encryptor to change cipher.
data/README.md CHANGED
@@ -49,7 +49,7 @@ class PointLog < ActiveRecord::Base
49
49
  encrypted_attribute(:serialized_address, :string)
50
50
 
51
51
  # Change encryptor
52
- encrypted_attribute(:name, :field, encryption: { encryptor: :active_support, key: ENV['ENCRYPTION_KEY'], salt: ['ENCRYPTION_SALT'] })
52
+ encrypted_attribute(:name, :field, encryption: { encryptor: :active_support, key: ENV['ENCRYPTION_KEY'], salt: ENV['ENCRYPTION_SALT'] })
53
53
  end
54
54
  ```
55
55
 
@@ -6,7 +6,7 @@ module ActiveRecordEncryption
6
6
 
7
7
  module ClassMethods
8
8
  def encrypted_attribute(name, subtype, **options)
9
- attribute(name, :encryption, options.merge(subtype: subtype))
9
+ attribute(name, :encryption, **options, subtype: subtype)
10
10
  end
11
11
  end
12
12
  end
@@ -4,7 +4,7 @@ module ActiveRecordEncryption
4
4
  module Encryptor
5
5
  # Abstract interface of encryptor
6
6
  class Base
7
- def initialize(*); end
7
+ def initialize(*, **); end
8
8
 
9
9
  def encrypt(value)
10
10
  value
@@ -2,32 +2,15 @@
2
2
 
3
3
  module ActiveRecordEncryption
4
4
  module Encryptor
5
- class Registry
6
- def initialize
7
- @registrations = []
8
- end
9
-
10
- def register(encryptor_name, klass = nil, **options, &block)
11
- block ||= proc { |_, *args| klass.new(*args) }
12
- registrations << Registration.new(encryptor_name, block, **options)
13
- end
14
-
15
- def lookup(symbol, *args)
16
- registration = find_registration(symbol, *args)
17
-
18
- if registration
19
- registration.call(self, symbol, *args)
20
- else
21
- raise ArgumentError, "Unknown encryptor #{symbol.inspect}"
22
- end
23
- end
24
-
5
+ class Registry < ActiveModel::Type::Registry
25
6
  private
26
7
 
27
- attr_reader :registrations
8
+ def registration_klass
9
+ Registration
10
+ end
28
11
 
29
- def find_registration(symbol, *args)
30
- registrations.find { |registration| registration.matches?(symbol, *args) }
12
+ def find_registration(symbol, *args, **kwargs)
13
+ registrations.find { |r| r.matches?(symbol, *args, **kwargs) }
31
14
  end
32
15
  end
33
16
 
@@ -15,15 +15,19 @@ module ActiveRecordEncryption
15
15
  # User.attribute(:id, :boolean)
16
16
  # User.where(id: 'string').to_sql #=> SELECT `users`.* FROM `users` WHERE `users`.`id` = TRUE
17
17
  # User.where(id: true).to_sql #=> SELECT `users`.* FROM `users` WHERE `users`.`id` = TRUE
18
- refine ActiveModel::Type::Decimal do
19
- def serialize(value)
20
- cast(value)
18
+ if ActiveRecord.gem_version < Gem::Version.create('6.0')
19
+ # https://github.com/rails/rails/commit/a741208f80dd33420a56486bd9ed2b0b9862234a
20
+ refine ActiveModel::Type::Decimal do
21
+ def serialize(value)
22
+ cast(value)
23
+ end
21
24
  end
22
- end
23
25
 
24
- refine ActiveModel::Type::Boolean do
25
- def serialize(value)
26
- cast(value)
26
+ # https://github.com/rails/rails/commit/34cc301f03aea2e579d6687a9ea9782afc1089a0
27
+ refine ActiveModel::Type::Boolean do
28
+ def serialize(value)
29
+ cast(value)
30
+ end
27
31
  end
28
32
  end
29
33
 
@@ -57,7 +57,7 @@ module ActiveRecordEncryption
57
57
  if encryptor.is_a?(Symbol)
58
58
  ActiveRecordEncryption::Encryptor.lookup(encryptor, **options)
59
59
  elsif encryptor.is_a?(Class)
60
- encryptor.new(options)
60
+ encryptor.new(**options)
61
61
  else
62
62
  encryptor
63
63
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActiveRecordEncryption
4
- VERSION = '0.2.1'
4
+ VERSION = '0.3.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_record_encryption
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.1
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - alpaca-tc
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-12-18 00:00:00.000000000 Z
11
+ date: 2021-03-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -38,20 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
- - !ruby/object:Gem::Dependency
42
- name: bundler
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '1.16'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: '1.16'
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: guard-rspec
57
43
  requirement: !ruby/object:Gem::Requirement
@@ -98,16 +84,16 @@ dependencies:
98
84
  name: mysql2
99
85
  requirement: !ruby/object:Gem::Requirement
100
86
  requirements:
101
- - - "<"
87
+ - - ">="
102
88
  - !ruby/object:Gem::Version
103
- version: 0.5.0
89
+ version: '0'
104
90
  type: :development
105
91
  prerelease: false
106
92
  version_requirements: !ruby/object:Gem::Requirement
107
93
  requirements:
108
- - - "<"
94
+ - - ">="
109
95
  - !ruby/object:Gem::Version
110
- version: 0.5.0
96
+ version: '0'
111
97
  - !ruby/object:Gem::Dependency
112
98
  name: pry
113
99
  requirement: !ruby/object:Gem::Requirement
@@ -208,7 +194,7 @@ homepage: https://github.com/alpaca-tc/active_record_encryption
208
194
  licenses:
209
195
  - MIT
210
196
  metadata: {}
211
- post_install_message:
197
+ post_install_message:
212
198
  rdoc_options: []
213
199
  require_paths:
214
200
  - lib
@@ -223,9 +209,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
223
209
  - !ruby/object:Gem::Version
224
210
  version: '0'
225
211
  requirements: []
226
- rubyforge_project:
227
- rubygems_version: 2.7.3
228
- signing_key:
212
+ rubygems_version: 3.1.4
213
+ signing_key:
229
214
  specification_version: 4
230
215
  summary: Transparent ActiveRecord encryption
231
216
  test_files: []