kiba-plus 0.1.15 → 0.1.16
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/kiba/plus/source/pg.rb +18 -3
- data/lib/kiba/plus/version.rb +1 -1
- 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: 257ad79c9bf88386c966076e00b7ef9ae70c3f9a
|
|
4
|
+
data.tar.gz: 0a355add33a1a458b09ff2a68f09f2a7412fbf3d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 12449db4db53d485251dde8fd664e2062fc82149825636ba55c37e7f2c853184cbfae4c90f7336e1666205e1b03737d7e029b84586f26526c5f6bd5abb4c1a40
|
|
7
|
+
data.tar.gz: 1ad1409f452190020f91ee7c83aa76dec01ca82c991088054225a1a4e8bddb246258f2ea09228d9ff9a3ff4e3244935845bb1a21a085403eca468d294517635a
|
data/lib/kiba/plus/source/pg.rb
CHANGED
|
@@ -18,7 +18,8 @@ module Kiba
|
|
|
18
18
|
:connect_url,
|
|
19
19
|
:schema,
|
|
20
20
|
:query,
|
|
21
|
-
:stream
|
|
21
|
+
:stream,
|
|
22
|
+
:process_bar
|
|
22
23
|
)
|
|
23
24
|
@client = PG.connect(connect_url)
|
|
24
25
|
@client.exec "SET search_path TO %s" % [ options[:schema] ] if options[:schema]
|
|
@@ -26,7 +27,7 @@ module Kiba
|
|
|
26
27
|
|
|
27
28
|
def each
|
|
28
29
|
Kiba::Plus.logger.info query
|
|
29
|
-
if stream
|
|
30
|
+
if stream?
|
|
30
31
|
# http://www.rubydoc.info/github/ged/ruby-pg/PG%2FConnection%3Aset_single_row_mode
|
|
31
32
|
client.send_query(query)
|
|
32
33
|
client.set_single_row_mode
|
|
@@ -34,12 +35,14 @@ module Kiba
|
|
|
34
35
|
res = client.get_result or break
|
|
35
36
|
res.check
|
|
36
37
|
res.each do |row|
|
|
38
|
+
print_process_bar if process_bar?
|
|
37
39
|
yield(row)
|
|
38
40
|
end
|
|
39
41
|
end
|
|
40
42
|
else
|
|
41
43
|
results = client.query(query)
|
|
42
44
|
results.each do |row|
|
|
45
|
+
print_process_bar if process_bar?
|
|
43
46
|
yield(row)
|
|
44
47
|
end
|
|
45
48
|
end
|
|
@@ -55,9 +58,21 @@ module Kiba
|
|
|
55
58
|
options.fetch(:query)
|
|
56
59
|
end
|
|
57
60
|
|
|
58
|
-
def stream
|
|
61
|
+
def stream?
|
|
59
62
|
options.fetch(:stream, false)
|
|
60
63
|
end
|
|
64
|
+
|
|
65
|
+
def process_bar?
|
|
66
|
+
options.fetch(:process_bar, true)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def print_process_bar
|
|
70
|
+
@num ||= 1
|
|
71
|
+
$stdout.print "." * @num
|
|
72
|
+
$stdout.print "\r"
|
|
73
|
+
$stdout.flush
|
|
74
|
+
@num = @num + 1
|
|
75
|
+
end
|
|
61
76
|
end
|
|
62
77
|
end
|
|
63
78
|
end
|
data/lib/kiba/plus/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kiba-plus
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.16
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Hooopo
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-08-
|
|
11
|
+
date: 2017-08-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: kiba
|