anonymous 0.1.1 → 0.1.2

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: d683875143716c1f88d1f357b794ccde3f1b8b9e
4
- data.tar.gz: cd9333dae0d8859396e106efc54c579ab50e214e
3
+ metadata.gz: 40963ad833689274bbdc27c4d4d624ee22830a6e
4
+ data.tar.gz: c23c358c093b884661fcdfa0b78b5a0a56802c8f
5
5
  SHA512:
6
- metadata.gz: f59daf6693ef9f8dc85a3ba34ccce68cca7eadb445acacfec6f25bcee48443168c548ef6fb50ab76f3c8771df69b58a7f82c0516b71f93ab6bc5a8335006f36c
7
- data.tar.gz: 937bd58e5c9539f1ec7261af2cb8668d37501adf6df507a110e50e0c67ddb5f7bee4783dbbc37a5b82e981e1a8ad3034ace6e03ca8e534138dd0762aac968be7
6
+ metadata.gz: 97c736f7cadb09b0edcfd7bde0c688bd06eb147943dd0170a730125c170e022e117bb21101ce58bd3655f9dfe9dbcbd0c4879c3f5a9b1a73bf399297d11d40f7
7
+ data.tar.gz: bc1e69cfabe2e11fd2ca658c8d66185a10d125bb282eae3de1bcb08a28fe10600d4fed5972bb84ec728fe7bd9a1d209be5323cfee70c8505e28c2f8de40d60d1
@@ -2,7 +2,6 @@
2
2
  sudo: false
3
3
  language: ruby
4
4
  rvm:
5
- - 2.2
6
5
  - 2.3
7
6
  - 2.4
8
7
  - 2.5
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- anonymous (0.1.1)
4
+ anonymous (0.1.2)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -82,7 +82,7 @@ user.phone_number
82
82
  ```
83
83
 
84
84
  The only difference between `anonymize!` and `anonymize` is that the former
85
- calls `update!` and the latter calls `update`.
85
+ calls `update_attributes!` and the latter calls `update_attributes`.
86
86
 
87
87
  ## Configuration
88
88
 
@@ -22,6 +22,8 @@ Gem::Specification.new do |spec|
22
22
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
23
23
  spec.require_paths = ["lib"]
24
24
 
25
+ spec.required_ruby_version = ">= 2.3"
26
+
25
27
  spec.add_development_dependency "bundler", "~> 1.17"
26
28
  spec.add_development_dependency "rake", "~> 10.0"
27
29
  spec.add_development_dependency "rspec", "~> 3.0"
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- anonymous (0.0.1)
4
+ anonymous (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- anonymous (0.0.1)
4
+ anonymous (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -25,7 +25,7 @@ GEM
25
25
  coderay (1.1.2)
26
26
  concurrent-ruby (1.1.4)
27
27
  diff-lcs (1.3)
28
- i18n (1.2.0)
28
+ i18n (1.3.0)
29
29
  concurrent-ruby (~> 1.0)
30
30
  method_source (0.9.2)
31
31
  minitest (5.11.3)
@@ -1,20 +1,20 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- anonymous (0.0.1)
4
+ anonymous (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- activemodel (5.1.4)
10
- activesupport (= 5.1.4)
11
- activerecord (5.1.4)
12
- activemodel (= 5.1.4)
13
- activesupport (= 5.1.4)
9
+ activemodel (5.1.6.1)
10
+ activesupport (= 5.1.6.1)
11
+ activerecord (5.1.6.1)
12
+ activemodel (= 5.1.6.1)
13
+ activesupport (= 5.1.6.1)
14
14
  arel (~> 8.0)
15
- activesupport (5.1.4)
15
+ activesupport (5.1.6.1)
16
16
  concurrent-ruby (~> 1.0, >= 1.0.2)
17
- i18n (~> 0.7)
17
+ i18n (>= 0.7, < 2)
18
18
  minitest (~> 5.1)
19
19
  tzinfo (~> 1.1)
20
20
  appraisal (2.2.0)
@@ -25,7 +25,7 @@ GEM
25
25
  coderay (1.1.2)
26
26
  concurrent-ruby (1.1.4)
27
27
  diff-lcs (1.3)
28
- i18n (0.9.5)
28
+ i18n (1.3.0)
29
29
  concurrent-ruby (~> 1.0)
30
30
  method_source (0.9.2)
31
31
  minitest (5.11.3)
@@ -1,18 +1,18 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- anonymous (0.0.1)
4
+ anonymous (0.1.1)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
8
8
  specs:
9
- activemodel (5.2.1)
10
- activesupport (= 5.2.1)
11
- activerecord (5.2.1)
12
- activemodel (= 5.2.1)
13
- activesupport (= 5.2.1)
9
+ activemodel (5.2.2)
10
+ activesupport (= 5.2.2)
11
+ activerecord (5.2.2)
12
+ activemodel (= 5.2.2)
13
+ activesupport (= 5.2.2)
14
14
  arel (>= 9.0)
15
- activesupport (5.2.1)
15
+ activesupport (5.2.2)
16
16
  concurrent-ruby (~> 1.0, >= 1.0.2)
17
17
  i18n (>= 0.7, < 2)
18
18
  minitest (~> 5.1)
@@ -25,7 +25,7 @@ GEM
25
25
  coderay (1.1.2)
26
26
  concurrent-ruby (1.1.4)
27
27
  diff-lcs (1.3)
28
- i18n (1.2.0)
28
+ i18n (1.3.0)
29
29
  concurrent-ruby (~> 1.0)
30
30
  method_source (0.9.2)
31
31
  minitest (5.11.3)
@@ -1,7 +1,7 @@
1
1
  require "anonymous/version"
2
2
  require "anonymous/configuration"
3
3
  require "anonymous/anonymizer"
4
- require "anonymous/active_record"
4
+ require "anonymous/active_record" if defined? ::ActiveRecord
5
5
 
6
6
  module Anonymous
7
7
  def configure
@@ -1,8 +1,9 @@
1
1
  require_relative './anonymizer'
2
+ require_relative './not_implemented_error'
2
3
 
3
4
  module Anonymous
4
5
  # This module handles anonymization for ActiveRecord models. In order to
5
- # impliment this module you must define a private #anonymization_definitions
6
+ # implement this module you must define a private #anonymization_definitions
6
7
  # method in your model.
7
8
  #
8
9
  # Retry Functionality:
@@ -13,7 +14,7 @@ module Anonymous
13
14
  module ActiveRecord
14
15
  def anonymize!
15
16
  anonymizer = Anonymizer.new(attributes, anonymization_definitions)
16
- update!(anonymizer.anonymized_attributes)
17
+ update_attributes!(anonymizer.anonymized_attributes)
17
18
  rescue ::ActiveRecord::RecordNotUnique => e
18
19
  @anonymization_attempts ||= 0
19
20
  max_retries = Anonymous.configuration.max_anonymize_retries
@@ -25,7 +26,7 @@ module Anonymous
25
26
 
26
27
  def anonymize
27
28
  anonymizer = Anonymizer.new(attributes, anonymization_definitions)
28
- update(anonymizer.anonymized_attributes)
29
+ update_attributes(anonymizer.anonymized_attributes)
29
30
  rescue ::ActiveRecord::RecordNotUnique => e
30
31
  @anonymization_attempts ||= 0
31
32
  max_retries = Anonymous.configuration.max_anonymize_retries
@@ -34,5 +35,13 @@ module Anonymous
34
35
  @anonymization_attempts += 1
35
36
  retry
36
37
  end
38
+
39
+ private
40
+
41
+ def anonymization_definitions
42
+ message = "Class #{self.class.name} must implement an #anonymization_definitions method to use the Anonymous::ActiveRecord functionality."
43
+
44
+ raise NotImplementedError, message
45
+ end
37
46
  end
38
47
  end
@@ -0,0 +1,3 @@
1
+ module Anonymous
2
+ class NotImplementedError < StandardError; end
3
+ end
@@ -1,3 +1,3 @@
1
1
  module Anonymous
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: anonymous
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Stonehill
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-12-23 00:00:00.000000000 Z
11
+ date: 2018-12-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -139,6 +139,7 @@ files:
139
139
  - lib/anonymous/active_record.rb
140
140
  - lib/anonymous/anonymizer.rb
141
141
  - lib/anonymous/configuration.rb
142
+ - lib/anonymous/not_implemented_error.rb
142
143
  - lib/anonymous/version.rb
143
144
  homepage: https://github.com/jamesstonehill/anonymous
144
145
  licenses:
@@ -152,7 +153,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
152
153
  requirements:
153
154
  - - ">="
154
155
  - !ruby/object:Gem::Version
155
- version: '0'
156
+ version: '2.3'
156
157
  required_rubygems_version: !ruby/object:Gem::Requirement
157
158
  requirements:
158
159
  - - ">="