acts_as_scrubbable 0.0.1 → 0.0.2
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 +13 -13
- data/README.md +26 -0
- data/lib/acts_as_scrubbable/scrub.rb +4 -29
- data/lib/acts_as_scrubbable/version.rb +1 -1
- data/lib/acts_as_scrubbable.rb +27 -0
- data/spec/support/database.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4234c5c4fc17e4e56651d0af73d4d8618479722f
|
4
|
+
data.tar.gz: 1cced9cfe5e6c3a798326778370f10ca34332aab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ce7605fe9907554adcab36eec514ed28320062e778f012a321ecf6dece86ed8249d1401632156c615b21ef4e816677f04f76cd38a7929bb9036aa0d07700352
|
7
|
+
data.tar.gz: 5ec1de24a3bedf7497b6d33205811800a8a7736b0c23b03a98eb26d862971e15e5ba338a682019bb72b9d22c89b9e96642353117f51ba741080b252a1695fd38
|
data/Gemfile.lock
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
acts_as_scrubbable (0.0.
|
5
|
-
activerecord (~> 4.1
|
6
|
-
activesupport (~> 4.1
|
7
|
-
faker (~> 1.4
|
8
|
-
highline (~> 1.7
|
9
|
-
railties (~> 4.1
|
10
|
-
term-ansicolor (~> 1.3
|
4
|
+
acts_as_scrubbable (0.0.2)
|
5
|
+
activerecord (~> 4.1)
|
6
|
+
activesupport (~> 4.1)
|
7
|
+
faker (~> 1.4)
|
8
|
+
highline (~> 1.7)
|
9
|
+
railties (~> 4.1)
|
10
|
+
term-ansicolor (~> 1.3)
|
11
11
|
|
12
12
|
GEM
|
13
13
|
remote: https://rubygems.org/
|
@@ -122,13 +122,13 @@ PLATFORMS
|
|
122
122
|
ruby
|
123
123
|
|
124
124
|
DEPENDENCIES
|
125
|
-
activerecord-nulldb-adapter (~> 0.3
|
125
|
+
activerecord-nulldb-adapter (~> 0.3)
|
126
126
|
acts_as_scrubbable!
|
127
|
-
guard (~> 2.13
|
128
|
-
guard-rspec (~> 4.6
|
129
|
-
pry-byebug (~> 3.2
|
130
|
-
rspec (~> 3.3
|
131
|
-
terminal-notifier-guard (~> 1.6
|
127
|
+
guard (~> 2.13)
|
128
|
+
guard-rspec (~> 4.6)
|
129
|
+
pry-byebug (~> 3.2)
|
130
|
+
rspec (~> 3.3)
|
131
|
+
terminal-notifier-guard (~> 1.6)
|
132
132
|
|
133
133
|
BUNDLED WITH
|
134
134
|
1.10.6
|
data/README.md
CHANGED
@@ -34,3 +34,29 @@ class Address
|
|
34
34
|
acts_as_scrubbable :lng => :longitude, :lat => :latitude
|
35
35
|
end
|
36
36
|
```
|
37
|
+
|
38
|
+
|
39
|
+
### To run
|
40
|
+
```
|
41
|
+
rake scrub
|
42
|
+
|
43
|
+
....
|
44
|
+
Type SCRUB to continue.
|
45
|
+
SCRUB
|
46
|
+
W, [2015-11-05T14:09:20.900771 #64194] WARN -- : Scrubbing classes
|
47
|
+
I, [2015-11-05T14:09:24.228012 #64194] INFO -- : Scrubbing ClassToScrub
|
48
|
+
...
|
49
|
+
I, [2015-11-05T14:09:25.615155 #64194] INFO -- : Scrub Complete!
|
50
|
+
|
51
|
+
```
|
52
|
+
|
53
|
+
|
54
|
+
### Extending
|
55
|
+
|
56
|
+
You may find the need to extend or add additional generators
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
ActsAsScrubbable.configure do |c|
|
60
|
+
c.add :email_with_prefix, -> { "prefix-#{Faker::Internet.email}" }
|
61
|
+
end
|
62
|
+
```
|
@@ -2,43 +2,18 @@ module ActsAsScrubbable
|
|
2
2
|
module Scrub
|
3
3
|
|
4
4
|
def scrub!
|
5
|
-
require 'faker'
|
6
|
-
|
7
5
|
if self.class.scrubbable?
|
8
6
|
_updates = {}
|
7
|
+
|
9
8
|
scrubbable_fields.each do |key, value|
|
10
9
|
next if self.send(key).blank?
|
11
10
|
|
12
|
-
_updates[key] =
|
13
|
-
Faker::Name.first_name
|
14
|
-
elsif value == :last_name
|
15
|
-
Faker::Name.last_name
|
16
|
-
elsif value == :full_name
|
17
|
-
Faker::Name.name
|
18
|
-
elsif value == :middle_name
|
19
|
-
Faker::Name.name
|
20
|
-
elsif value == :street_address
|
21
|
-
Faker::Address.street_address
|
22
|
-
elsif value == :secondary_address
|
23
|
-
Faker::Address.secondary_address
|
24
|
-
elsif value == :city
|
25
|
-
Faker::Address.city
|
26
|
-
elsif value == :latitude
|
27
|
-
Faker::Address.latitude
|
28
|
-
elsif value == :longitude
|
29
|
-
Faker::Address.longitude
|
30
|
-
elsif value == :email
|
31
|
-
Faker::Internet.email
|
32
|
-
elsif value == :name_title
|
33
|
-
Faker::Name.title
|
34
|
-
elsif value == :company_name
|
35
|
-
Faker::Company.name
|
36
|
-
else
|
37
|
-
nil
|
38
|
-
end
|
11
|
+
_updates[key] = ActsAsScrubbable.scrub_map[value].call
|
39
12
|
end
|
13
|
+
|
40
14
|
self.update_columns(_updates) unless _updates.empty?
|
41
15
|
end
|
16
|
+
|
42
17
|
end
|
43
18
|
end
|
44
19
|
end
|
data/lib/acts_as_scrubbable.rb
CHANGED
@@ -10,6 +10,33 @@ module ActsAsScrubbable
|
|
10
10
|
autoload :Scrubbable
|
11
11
|
autoload :Scrub
|
12
12
|
autoload :VERSION
|
13
|
+
|
14
|
+
def self.configure(&block)
|
15
|
+
yield self
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.add(key, value)
|
19
|
+
ActsAsScrubbable.scrub_map[key] = value
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.scrub_map
|
23
|
+
require 'faker'
|
24
|
+
|
25
|
+
@_scrub_map ||= {
|
26
|
+
:first_name => -> { Faker::Name.first_name },
|
27
|
+
:last_name => -> { Faker::Name.first_name },
|
28
|
+
:middle_name => -> { Faker::Name.name },
|
29
|
+
:full_name => -> { Faker::Name.name },
|
30
|
+
:email => -> { Faker::Internet.email },
|
31
|
+
:name_title => -> { Faker::Name.title },
|
32
|
+
:company_name => -> { Faker::Company.name },
|
33
|
+
:street_address => -> { Faker::Address.street_address },
|
34
|
+
:secondary_address => -> { Faker::Address.secondary_address },
|
35
|
+
:city => -> { Faker::Address.city },
|
36
|
+
:latitude => -> { Faker::Address.latitude },
|
37
|
+
:longitude => -> { Faker::Address.longitude }
|
38
|
+
}
|
39
|
+
end
|
13
40
|
end
|
14
41
|
|
15
42
|
|
data/spec/support/database.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_scrubbable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samer Masry
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|