porticor_bombarder 0.0.2 → 0.0.3
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/lib/porticor_bombarder/version.rb +1 -1
- data/lib/tasks/encrypt_existing_attrs.rake +21 -10
- metadata +2 -3
- data/.idea/porticor_bombarder.iml +0 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1c4b5213a75a15a37fdebff0c158ace9de761a03
|
4
|
+
data.tar.gz: ee5050d9167f9698a49030cb2e454d8ec33dc187
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1744ea66a3f1ef45eaec232b0db6196ad16fb206128889a4baecdd30250cca0dd6821ec2268a0fd151a86885192c1e5777fc00b05e3926003ed32b034e651c4
|
7
|
+
data.tar.gz: 0efe2f08572d24f0cbf019521c91c945782a5fed20a7888321364f914de6e7c957adc00fe1b680969bcabefb015f1cd830c940ce65144e8b9b0b8718fcc71603
|
@@ -2,30 +2,41 @@ require 'rake'
|
|
2
2
|
namespace :porticor_bombarder do
|
3
3
|
PORTICOR_ENCRYPTED_ATTRIBUTES = YAML.load_file(File.join('config', 'porticor_attrs.yml'))
|
4
4
|
|
5
|
-
desc 'encrypt existing attributes'
|
6
|
-
task :encrypt => :environment do
|
5
|
+
desc 'encrypt existing attributes with batches default size is 100'
|
6
|
+
task :encrypt, [:batch_size] => :environment do |t, args|
|
7
|
+
|
8
|
+
batch_size = args[:batch_size] || 100
|
9
|
+
|
7
10
|
PORTICOR_ENCRYPTED_ATTRIBUTES.each do |key, value|
|
11
|
+
|
8
12
|
obj_class = key.to_s.classify.constantize
|
9
13
|
case true
|
10
14
|
when value.is_a?(Hash)
|
11
15
|
value.values.flatten.each do |column_name|
|
12
|
-
obj_class.
|
13
|
-
obj.send(column_name.to_sym)
|
14
|
-
|
15
|
-
|
16
|
+
obj_class.find_each(batch_size: batch_size) do |obj|
|
17
|
+
if obj.send(column_name.to_sym) and (_match_data = obj.send(column_name.to_sym).match(/^##([\s\S]*)##/))
|
18
|
+
begin
|
19
|
+
obj.update(column_name => _match_data[1])
|
20
|
+
rescue Exception => e
|
21
|
+
puts "Got error message #{e.message} for #{obj.inspect}"
|
22
|
+
end
|
16
23
|
end
|
17
24
|
end
|
18
25
|
end
|
19
26
|
when value.is_a?(Array)
|
20
27
|
value.each do |column_name|
|
21
|
-
obj_class.
|
22
|
-
obj.send(column_name.to_sym)
|
23
|
-
|
24
|
-
|
28
|
+
obj_class.find_each(batch_size: batch_size) do |obj|
|
29
|
+
if obj.send(column_name.to_sym) and (_match_data = obj.send(column_name.to_sym).match(/^##([\s\S]*)##/))
|
30
|
+
begin
|
31
|
+
obj.update(column_name => _match_data[1])
|
32
|
+
rescue Exception => e
|
33
|
+
puts "Got error message #{e.message} for #{obj.inspect}"
|
34
|
+
end
|
25
35
|
end
|
26
36
|
end
|
27
37
|
end
|
28
38
|
else
|
39
|
+
raise StandardError.new('while inspecting columns type in schema something went wrong.')
|
29
40
|
end
|
30
41
|
end
|
31
42
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: porticor_bombarder
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- rajeevkannav
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-09-
|
11
|
+
date: 2014-09-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -116,7 +116,6 @@ extensions: []
|
|
116
116
|
extra_rdoc_files: []
|
117
117
|
files:
|
118
118
|
- .gitignore
|
119
|
-
- .idea/porticor_bombarder.iml
|
120
119
|
- Gemfile
|
121
120
|
- LICENSE.txt
|
122
121
|
- README.md
|
@@ -1,31 +0,0 @@
|
|
1
|
-
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
-
<module type="RUBY_MODULE" version="4">
|
3
|
-
<component name="FacetManager">
|
4
|
-
<facet type="gem" name="Ruby Gem">
|
5
|
-
<configuration>
|
6
|
-
<option name="GEM_APP_ROOT_PATH" value="$MODULE_DIR$" />
|
7
|
-
<option name="GEM_APP_TEST_PATH" value="" />
|
8
|
-
<option name="GEM_APP_LIB_PATH" value="$MODULE_DIR$/lib" />
|
9
|
-
</configuration>
|
10
|
-
</facet>
|
11
|
-
</component>
|
12
|
-
<component name="NewModuleRootManager">
|
13
|
-
<content url="file://$MODULE_DIR$" />
|
14
|
-
<orderEntry type="inheritedJdk" />
|
15
|
-
<orderEntry type="sourceFolder" forTests="false" />
|
16
|
-
<orderEntry type="module-library">
|
17
|
-
<library name="porticor_bombarder (v0.0.1, /home/kannav/workspace/headerlabs/gems/porticor_bombarder) [path][gem]">
|
18
|
-
<CLASSES>
|
19
|
-
<root url="file://$MODULE_DIR$/lib" />
|
20
|
-
<root url="file://$MODULE_DIR$/.idea" />
|
21
|
-
</CLASSES>
|
22
|
-
<SOURCES>
|
23
|
-
<root url="file://$MODULE_DIR$/lib" />
|
24
|
-
<root url="file://$MODULE_DIR$/.idea" />
|
25
|
-
</SOURCES>
|
26
|
-
</library>
|
27
|
-
</orderEntry>
|
28
|
-
<orderEntry type="library" scope="PROVIDED" name="bundler (v1.6.2, RVM: ruby-2.1.0) [gem]" level="application" />
|
29
|
-
</component>
|
30
|
-
</module>
|
31
|
-
|