acts_as_scrubbable 0.0.1 → 0.0.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: 506eed204743c2535bcd8c437775b5e8d6b3d2a8
4
- data.tar.gz: 6bce5efb2ca185f2b7db1947e8d6846350a47da4
3
+ metadata.gz: 4234c5c4fc17e4e56651d0af73d4d8618479722f
4
+ data.tar.gz: 1cced9cfe5e6c3a798326778370f10ca34332aab
5
5
  SHA512:
6
- metadata.gz: b71edf80be083447af3df693eb8429b47ff8c900c203bf1072c6a744d45a8dd6119359aafe257156a57193f06c3c777b8c3c54e3de8122c14950ed9c7245a48b
7
- data.tar.gz: 05aeb0d66ac9763fef8574dcbca5793ccdb44c849b165a3f4004afd25c85ad2beaa672c7e7f4dc9f6cc79a67c1c3063b151fb9e074adf4b3b231dee9448979f6
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.1)
5
- activerecord (~> 4.1.13)
6
- activesupport (~> 4.1.13)
7
- faker (~> 1.4.3)
8
- highline (~> 1.7.8)
9
- railties (~> 4.1.13)
10
- term-ansicolor (~> 1.3.2)
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.1)
125
+ activerecord-nulldb-adapter (~> 0.3)
126
126
  acts_as_scrubbable!
127
- guard (~> 2.13.0)
128
- guard-rspec (~> 4.6.4)
129
- pry-byebug (~> 3.2.0)
130
- rspec (~> 3.3.0)
131
- terminal-notifier-guard (~> 1.6.4)
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] = if value == :first_name
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
@@ -1,3 +1,3 @@
1
1
  module ActsAsScrubbable
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
@@ -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
 
@@ -15,5 +15,5 @@ end
15
15
  class NonScrubbableModel < ActiveRecord::Base; end
16
16
 
17
17
  class ScrubbableModel < ActiveRecord::Base
18
- acts_as_scrubbable :first_name, address1: :street_address
18
+ acts_as_scrubbable :first_name, :address1 => :street_address, :lat => :latitude
19
19
  end
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.1
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-04 00:00:00.000000000 Z
11
+ date: 2015-11-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport