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 +4 -4
- data/.gitignore +0 -0
- data/.rspec +0 -0
- data/.rvmrc +0 -0
- data/.travis.yml +0 -0
- data/Gemfile +0 -0
- data/LICENSE.txt +0 -0
- data/README.md +0 -0
- data/Rakefile +0 -0
- data/able.gemspec +0 -0
- data/lib/able.rb +0 -0
- data/lib/able/emailable.rb +0 -0
- data/lib/able/fullnameable.rb +0 -0
- data/lib/able/tokenizer.rb +0 -0
- data/lib/able/version.rb +1 -1
- data/lib/ext/integer.rb +0 -0
- data/lib/ext/kernel.rb +16 -4
- data/lib/ext/string.rb +0 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06e95a0cad498159cb8aa84963ba3536943be99d
|
4
|
+
data.tar.gz: f37f1cd9bd4420fc9c193530774ef31e05a44785
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/able/emailable.rb
CHANGED
File without changes
|
data/lib/able/fullnameable.rb
CHANGED
File without changes
|
data/lib/able/tokenizer.rb
CHANGED
File without changes
|
data/lib/able/version.rb
CHANGED
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
|
-
|
34
|
-
|
33
|
+
unless sql_logging
|
34
|
+
old_logger = ActiveRecord::Base.logger
|
35
|
+
ActiveRecord::Base.logger = nil
|
36
|
+
end
|
35
37
|
|
36
|
-
|
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
|
+
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-
|
11
|
+
date: 2016-09-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|