polo 0.3.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
  SHA1:
3
- metadata.gz: d3f754e19121b0fb417f692c5ee333daeb8de049
4
- data.tar.gz: 326da5077810478da02f66de52e749cac05866cc
3
+ metadata.gz: 483557d0954078851b9347111a7a12f0b05c8e0f
4
+ data.tar.gz: 2b8a51a7311f52430395643d5e0ec87ed5aecd3e
5
5
  SHA512:
6
- metadata.gz: 453c79f229642062534266178aabc162bbfdf06231c2b0237c828ef9277cc96c9987a9471096664a06c16b313f058c95f68e194bdd824a79ec01f232ad3a55f1
7
- data.tar.gz: bfa5e063eb14430036621742fb3bc72e5159cf307a3efbd2e09894fb93c95c5face35766e8e78a7496ae9d2c7f05349796c021cd5452319271af0a688ea2a5a5
6
+ metadata.gz: 040ec1e967f3b2fd5d05f161da7d9690949c4e1aa0afe34d302c9fc35237b34ac54aaa6c3ff629191c1848c888588d58993dcd594fc7fe7a1f9a07f824025c21
7
+ data.tar.gz: c4b15706f954e20f09f7a59048bf4d999cdd7b5000d5fcbcd0c22f2860ca2eb95a20592a46e11c27d543f2add93782d531d07d3fa43c7ea3d6efb80003b9a00d
data/.gitignore CHANGED
File without changes
data/.rspec CHANGED
File without changes
File without changes
File without changes
data/Appraisals CHANGED
File without changes
@@ -1,3 +1,13 @@
1
+ ## 0.4.0
2
+
3
+ ### Breaking Changes
4
+
5
+ - None
6
+
7
+ ### Added
8
+ - [#40](https://github.com/IFTTT/polo/pull/40) Support for optional 2nd instance argument
9
+
10
+
1
11
  ## 0.3.0
2
12
 
3
13
  ### Breaking Changes
File without changes
data/Gemfile CHANGED
File without changes
File without changes
data/README.md CHANGED
@@ -137,7 +137,7 @@ Warning: This is not a security feature. Fields can still easily be rearranged b
137
137
 
138
138
  #### Advanced Obfuscation
139
139
 
140
- For more advanced obfuscation, you can pass in a custom obfuscation strategy. Polo will take in a lambda that can be used to transform sensitive data.
140
+ For more advanced obfuscation, you can pass in a custom obfuscation strategy. Polo will take in a lambda that can be used to transform sensitive data.
141
141
 
142
142
  Using a `:symbol` as an obfuscate key targets all columns of that name. Passing an SQL selector as a `String` will target columns within the specified table.
143
143
 
@@ -148,14 +148,21 @@ Polo.configure do
148
148
  first_part = email.split("@")[0]
149
149
  "#{first_part}@test.com"
150
150
  end
151
-
151
+
152
152
  credit_card_strategy = lambda do |credit_card|
153
153
  "4123 4567 8910 1112"
154
154
  end
155
-
155
+
156
+ # If you need the context of the record for its fields, it is accessible
157
+ # in the second argument of the strategy
158
+ social_security_strategy = lambda do |ssn, instance|
159
+ sprintf("%09d", instance.id)
160
+ end
161
+
156
162
  obfuscate({
157
163
  'chefs.email' => email_strategy, # This only applies to the "email" column in the "chefs" table
158
- :credit_card => credit_card_strategy # This applies to any column named "credit_card" across every table
164
+ :credit_card => credit_card_strategy, # This applies to any column named "credit_card" across every table
165
+ :ssn_strategy => social_security_strategy
159
166
  })
160
167
  end
161
168
 
@@ -200,4 +207,3 @@ $ bundle exec appraisal rake
200
207
  ## License
201
208
 
202
209
  The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
203
-
data/Rakefile CHANGED
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -46,8 +46,8 @@ module Polo
46
46
 
47
47
  correct_table = table.nil? || instance.class.table_name == table
48
48
 
49
- if correct_table && value = instance.attributes[field]
50
- instance.send("#{field}=", new_field_value(field, strategy, value))
49
+ if correct_table && instance.attributes[field]
50
+ instance.send("#{field}=", new_field_value(field, strategy, instance))
51
51
  end
52
52
  end
53
53
  end
@@ -65,11 +65,12 @@ module Polo
65
65
  attrs & fields.map { |pair| field_name(pair.first) }
66
66
  end
67
67
 
68
- def new_field_value(field, strategy, value)
68
+ def new_field_value(field, strategy, instance)
69
+ value = instance.attributes[field]
69
70
  if strategy.nil?
70
71
  value.split("").shuffle.join
71
72
  else
72
- strategy.call(value)
73
+ strategy.arity == 1 ? strategy.call(value) : strategy.call(value, instance)
73
74
  end
74
75
  end
75
76
  end
@@ -1,3 +1,3 @@
1
1
  module Polo
2
- VERSION = "0.3.0"
2
+ VERSION = "0.4.0"
3
3
  end
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Netto Farah
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-04-08 00:00:00.000000000 Z
11
+ date: 2016-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord