redaction 0.2.0 → 0.4.0

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
  SHA256:
3
- metadata.gz: 8c7c1ab9e4c83779e70bd6cc332671fd69a007281c34b4c64ea4ce309ca1eb49
4
- data.tar.gz: b2c8ef0998df228f1062b91e6a3d4cff740071c3d41cb5082d34431254e2b446
3
+ metadata.gz: d9ba1c11cd9618292859be01f037bb64da083a5873020ea489ab07e5f54411b2
4
+ data.tar.gz: 85f6bc9d21d79b37a9d061d002e1fec8b00841dd135b1d40a6b1d1c5146d891d
5
5
  SHA512:
6
- metadata.gz: 1ec8127de732264971eef233c3ee8366db0eb660e84b427901180729c0f5d7c253d227c3591c6a3ab403b1e930dbcf709935d224382dd4cdc79b2736fee9056e
7
- data.tar.gz: 0fb500148ce2f328f96d59bf0ff497bc908a6d2641e363d9fa5e7f9d6301cc0c2a1ba429025c6986c91103d0ae70036b11198c20225921cb9b5628389ab1c853
6
+ metadata.gz: 29a8813e86d71875213d8ae10531ce9582a2c590c5918716339e035efbd2472b758822cb53fcafa79b356485208cdea72d64cf76d676c18761a91f92284cbe70
7
+ data.tar.gz: 27cbf2162fda8b3e0dc80aeecf477df6ea872adc8b6743b09c90e6153090b8707e0e85a68a96f0ca478d2d528796d7b0b9c5f99307f0d9760986aaba593deac9
data/README.md CHANGED
@@ -114,6 +114,16 @@ class User < ApplicationRecord
114
114
  end
115
115
  ```
116
116
 
117
+ ### Configuration
118
+ Redaction has the following configuration options:
119
+ | Option | Default | Description |
120
+ |:------------|:------------|:------------|
121
+ | `email_domain` | `nil` | Set to a string to use a custom domain for redacted emails. i.e. `Redaction.config.email_domain = "my-domain.dev" |
122
+ | `progress_bar`| `true` | Set to false to not use the built in progress bar when redacting |
123
+ | `force_redaction` | `false` | Set to true to alway fill a column with redacted content even if the attribute is `nil` or empty |
124
+
125
+ It is reccomended that you put your configuration in an initializer like `config/initializers/redaction.rb`
126
+
117
127
  ## Roadmap
118
128
  - [ ] Raise Error or at least a message when skipping a passed in Model
119
129
  - [ ] Configuration (touch, email domains, etc)
@@ -12,6 +12,8 @@ module Redaction
12
12
  options = config.redaction
13
13
 
14
14
  options.email_domain = options.email_domain
15
+ options.progress_bar = options.key?(:progress_bar) ? options.progress_bar : true
16
+ options.force_redaction = options.key?(:force_redaction) ? options.force_redaction : false
15
17
 
16
18
  ActiveSupport.on_load(:active_record) do
17
19
  include Redaction::Redactable
@@ -17,7 +17,7 @@ module Redaction
17
17
  redactor = Redaction.find(redactor_type)
18
18
 
19
19
  attributes.each do |attribute|
20
- if send(attribute).present?
20
+ if Redaction.config.force_redaction || send(attribute).present?
21
21
  send("#{attribute}=", redactor.call(self, {attribute: attribute}))
22
22
  end
23
23
  end
@@ -14,11 +14,11 @@ module Redaction
14
14
  models_to_redact.each do |model|
15
15
  next if model.redacted_attributes.empty?
16
16
 
17
- model_progress = progress_bar(model.name, model.count)
17
+ model_progress = progress_bar(model.name, model.count) if Redaction.config.progress_bar
18
18
 
19
19
  model.all.unscoped.find_each do |record|
20
20
  record.redact!
21
- model_progress.increment
21
+ model_progress.increment if Redaction.config.progress_bar
22
22
  end
23
23
  end
24
24
  end
@@ -1,3 +1,3 @@
1
1
  module Redaction
2
- VERSION = "0.2.0"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redaction
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Drew Bragg
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-06 00:00:00.000000000 Z
11
+ date: 2022-11-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -30,28 +30,28 @@ dependencies:
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: '0'
33
+ version: 2.20.0
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
- version: '0'
40
+ version: 2.20.0
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: ruby-progressbar
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
46
46
  - !ruby/object:Gem::Version
47
- version: '0'
47
+ version: 1.11.0
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - ">="
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 1.11.0
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: standard
57
57
  requirement: !ruby/object:Gem::Requirement