porticor_bombarder 0.0.2 → 0.0.3

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: 9c40284aa3cd320d3c98f5fe274cce38aab70763
4
- data.tar.gz: de12579903115dbe21f1a1cc3d610e0c2c26aa1c
3
+ metadata.gz: 1c4b5213a75a15a37fdebff0c158ace9de761a03
4
+ data.tar.gz: ee5050d9167f9698a49030cb2e454d8ec33dc187
5
5
  SHA512:
6
- metadata.gz: 18c01cd8d0b9e578eb3a9556cea2125e78f112e6489b39b3704ce759b229f1c7e91644e28e18d5ac75b636bdeeda11c9cdb4b61b5dd9ef0458a1a9b59bbdb6c6
7
- data.tar.gz: 7699ad6852a0dcae7cdd914a538ef4f4e865a723cee51d6f9cfa93cee4f61ad72a189c31016410c031c5ff6a75992d62e7771a5a99ec398e4816587fe553ff98
6
+ metadata.gz: c1744ea66a3f1ef45eaec232b0db6196ad16fb206128889a4baecdd30250cca0dd6821ec2268a0fd151a86885192c1e5777fc00b05e3926003ed32b034e651c4
7
+ data.tar.gz: 0efe2f08572d24f0cbf019521c91c945782a5fed20a7888321364f914de6e7c957adc00fe1b680969bcabefb015f1cd830c940ce65144e8b9b0b8718fcc71603
@@ -1,3 +1,3 @@
1
1
  module PorticorBombarder
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
@@ -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.all.each do |obj|
13
- obj.send(column_name.to_sym)
14
- if (_match_data = obj.send(column_name.to_sym).match(/^##([\s\S]*)##/))
15
- obj.update(column_name => _match_data[1])
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.all.each do |obj|
22
- obj.send(column_name.to_sym)
23
- if (_match_data = obj.send(column_name.to_sym).match(/^##([\s\S]*)##/))
24
- obj.update(column_name => _match_data[1])
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.2
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-09 00:00:00.000000000 Z
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
-