able 0.1.4 → 0.1.5

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: 375a99d24d70203258f5d235ade3088182097302
4
- data.tar.gz: afecad7c5c6e6b015825221d5a0a3ac56625d28f
3
+ metadata.gz: 06e95a0cad498159cb8aa84963ba3536943be99d
4
+ data.tar.gz: f37f1cd9bd4420fc9c193530774ef31e05a44785
5
5
  SHA512:
6
- metadata.gz: ca3a53d44651d77710fd9bb45b43c172009d64bf47787c5952c089a156385cdb337fb9eff6dd8bae2fb62d4b858a891e0e2612beb7e00f409db583d52050afdc
7
- data.tar.gz: 006295e17471daa7be685f12d5f404e012a30964a9b12313b01a06807e5cf59376b184b6c735aae69448d6cff6e371c57df0614ea252bec2eefa1b0ece0eaa59
6
+ metadata.gz: 226482a2b4644e5e694ab81956804e722e04d317223c91bc9d77741fa0779f3f13a74ffc9b9be5b099e25ac3e1350386449b9b47cd7c355f30a62e6330184577
7
+ data.tar.gz: 17b35e2c493948f739074113dd91c7b4132a558ec2240173cdb0acef0bb851c31175a21b8492dc66fa05223c2121297e0f798ae01026ead2fdd93380d5377439
data/.gitignore CHANGED
File without changes
data/.rspec CHANGED
File without changes
data/.rvmrc CHANGED
File without changes
data/.travis.yml CHANGED
File without changes
data/Gemfile CHANGED
File without changes
data/LICENSE.txt CHANGED
File without changes
data/README.md CHANGED
File without changes
data/Rakefile CHANGED
File without changes
data/able.gemspec CHANGED
File without changes
data/lib/able.rb CHANGED
File without changes
File without changes
File without changes
File without changes
data/lib/able/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Able
2
- VERSION = '0.1.4'
2
+ VERSION = '0.1.5'
3
3
  end
data/lib/ext/integer.rb CHANGED
File without changes
data/lib/ext/kernel.rb CHANGED
@@ -23,17 +23,20 @@ module Kernel
23
23
  end
24
24
 
25
25
  # Is good for rake tasks, migrations etc.
26
- def each_with_progress(collection)
26
+ def each_with_progress(collection, sql_logging: false, batch: true)
27
27
  progress = 0
28
28
 
29
29
  all_count = collection.count
30
30
  puts_with_time "Found before: #{all_count} items."
31
31
  i = 0
32
32
 
33
- collection.find_each(batch_size: 1000) do |item|
34
- yield item
33
+ unless sql_logging
34
+ old_logger = ActiveRecord::Base.logger
35
+ ActiveRecord::Base.logger = nil
36
+ end
35
37
 
36
- i = i + 1
38
+ iterator_proc = Proc.new do |item|
39
+ yield item, i
37
40
 
38
41
  current_progress = ((i * 100) / all_count.to_f).floor
39
42
  if current_progress > progress
@@ -41,6 +44,15 @@ module Kernel
41
44
  puts_with_time "Done #{progress}%. #{i} of #{all_count} records."
42
45
  end
43
46
 
47
+ i = i + 1
48
+ end
49
+
50
+ batch ?
51
+ collection.find_each(batch_size: 1000) { |item| iterator_proc.call(item) } :
52
+ collection.each { |item| iterator_proc.call(item) }
53
+
54
+ unless sql_logging
55
+ ActiveRecord::Base.logger = old_logger
44
56
  end
45
57
 
46
58
  puts_with_time "Left after: #{collection.count} items."
data/lib/ext/string.rb CHANGED
File without changes
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: able
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - entity
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-08-18 00:00:00.000000000 Z
11
+ date: 2016-09-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler