acts_as_scrubbable 0.0.9 → 0.1.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 +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +17 -5
- data/lib/acts_as_scrubbable/scrubbable.rb +6 -7
- data/lib/acts_as_scrubbable/tasks.rb +27 -3
- data/lib/acts_as_scrubbable/version.rb +1 -1
- data/spec/db/schema.rb +1 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6390e59999100796cea61137d66569b2bf71378f
|
4
|
+
data.tar.gz: b263aaf6593de485d4b90d382154e6431f0eec27
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2627b29f34e4a34064e93a922587c2021fa15da1e2d6656bd6d6a8af47732a36adee12cf79218d0eb3185f605217e8fb6cee58e4f274e03db2583c7ae6f11e3
|
7
|
+
data.tar.gz: 5f3b8997f284cfb89be881c0a61be908224d47e9016fcbd4e4057d74a580ef6d9f9c451774acaede3c186965b1c86d7d994e472a472ae4b715caec085d060f35
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -44,16 +44,22 @@ end
|
|
44
44
|
|
45
45
|
|
46
46
|
### To run
|
47
|
+
|
48
|
+
The confirmation message will be the db host
|
49
|
+
|
47
50
|
```
|
48
51
|
rake scrub
|
49
52
|
|
50
53
|
....
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
54
|
+
2015-11-19 10:52:51 -0800: [WARN] - Please verify the information below to continue
|
55
|
+
2015-11-19 10:52:51 -0800: [WARN] - Host: 127.0.0.1
|
56
|
+
2015-11-19 10:52:51 -0800: [WARN] - Database: blog_development
|
57
|
+
Type '127.0.0.1' to continue.
|
58
|
+
-> 127.0.0.1
|
59
|
+
2015-11-19 10:52:51 -0800: [WARN] -- : Scrubbing classes
|
60
|
+
2015-11-19 10:52:51 -0800: [WARN] -- : Scrubbing ClassToScrub
|
55
61
|
...
|
56
|
-
|
62
|
+
2015-11-19 10:52:51 -0800: [WARN] -- : Scrub Complete!
|
57
63
|
|
58
64
|
```
|
59
65
|
|
@@ -63,6 +69,12 @@ In the case you are automating the rake task and want to skip the confirmation
|
|
63
69
|
rake scrub SKIP_CONFIRM=true
|
64
70
|
```
|
65
71
|
|
72
|
+
If you want to limit the classes you to be scrubbed you can set the `SCRUB_CLASSES` variable
|
73
|
+
|
74
|
+
```
|
75
|
+
rake scrub SCRUB_CLASSES=Blog,Post
|
76
|
+
```
|
77
|
+
|
66
78
|
|
67
79
|
|
68
80
|
### Extending
|
@@ -7,18 +7,17 @@ module ActsAsScrubbable
|
|
7
7
|
end
|
8
8
|
|
9
9
|
|
10
|
-
def acts_as_scrubbable(*scrubbable_fields)
|
10
|
+
def acts_as_scrubbable(*scrubbable_fields, **mapped_fields)
|
11
11
|
|
12
12
|
class_attribute :scrubbable_fields
|
13
13
|
|
14
14
|
self.scrubbable_fields = {}
|
15
|
-
|
16
15
|
scrubbable_fields.each do |_field|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
16
|
+
self.scrubbable_fields[_field] = _field
|
17
|
+
end
|
18
|
+
|
19
|
+
mapped_fields.each do |_field|
|
20
|
+
self.scrubbable_fields[_field.first] = _field.last
|
22
21
|
end
|
23
22
|
|
24
23
|
class_eval do
|
@@ -11,14 +11,26 @@ namespace :scrub do
|
|
11
11
|
require 'logger'
|
12
12
|
require 'parallel'
|
13
13
|
|
14
|
+
|
14
15
|
include Term::ANSIColor
|
15
16
|
|
16
17
|
@logger = Logger.new($stdout)
|
18
|
+
@logger.formatter = proc do |severity, datetime, progname, msg|
|
19
|
+
"#{datetime}: [#{severity}] - #{msg}\n"
|
20
|
+
end
|
21
|
+
|
22
|
+
db_host = ActiveRecord::Base.connection_config[:host]
|
23
|
+
db_name = ActiveRecord::Base.connection_config[:database]
|
24
|
+
|
25
|
+
@logger.warn "Please verify the information below to continue".red
|
26
|
+
@logger.warn "Host: ".red + " #{db_host}".white
|
27
|
+
@logger.warn "Database: ".red + "#{db_name}".white
|
17
28
|
|
18
29
|
unless ENV["SKIP_CONFIRM"] == "true"
|
19
|
-
|
20
|
-
|
21
|
-
|
30
|
+
|
31
|
+
answer = ask("Type '#{db_host}' to continue. \n".red + '-> '.white)
|
32
|
+
unless answer == db_host
|
33
|
+
@logger.error "exiting ...".red
|
22
34
|
exit
|
23
35
|
end
|
24
36
|
end
|
@@ -30,6 +42,18 @@ namespace :scrub do
|
|
30
42
|
@total_scrubbed = 0
|
31
43
|
|
32
44
|
ar_classes = ActiveRecord::Base.descendants.select{|d| d.scrubbable? }.sort_by{|d| d.to_s }
|
45
|
+
|
46
|
+
|
47
|
+
# if the ENV variable is set
|
48
|
+
|
49
|
+
unless ENV["SCRUB_CLASSES"].blank?
|
50
|
+
class_list = ENV["SCRUB_CLASSES"].split(",")
|
51
|
+
class_list = class_list.map {|_class_str| _class_str.constantize }
|
52
|
+
ar_classes = ar_classes & class_list
|
53
|
+
end
|
54
|
+
|
55
|
+
@logger.info "Srubbable Classes: #{ar_classes.join(', ')}".white
|
56
|
+
|
33
57
|
Parallel.each(ar_classes) do |ar_class|
|
34
58
|
|
35
59
|
# Removing any find or initialize callbacks from model
|
data/spec/db/schema.rb
CHANGED