kiba-plus 0.1.15 → 0.1.16

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: 0e1dce9dada36e8dfe05f8fb763290c09fefdddb
4
- data.tar.gz: 5cebb5aac9d4e0c5dde7c1a8a75a821e8d47b2d5
3
+ metadata.gz: 257ad79c9bf88386c966076e00b7ef9ae70c3f9a
4
+ data.tar.gz: 0a355add33a1a458b09ff2a68f09f2a7412fbf3d
5
5
  SHA512:
6
- metadata.gz: 47f0b2212d7d203048424a3d20bdf93b7673bf7fbfd88de8812413998b08464b5a157db45c81b5ed4163051e57e73ff97e2ba4cbac3ff0077f463718cd952c3f
7
- data.tar.gz: 71e19684a0fd7893dff572d03afb3af1fe75af5379592b6f0e7d50873abd19b8f7abb127dc2d53a79ab8bdaf07228ac06445332a5adb10c3fd3b0c50e3884339
6
+ metadata.gz: 12449db4db53d485251dde8fd664e2062fc82149825636ba55c37e7f2c853184cbfae4c90f7336e1666205e1b03737d7e029b84586f26526c5f6bd5abb4c1a40
7
+ data.tar.gz: 1ad1409f452190020f91ee7c83aa76dec01ca82c991088054225a1a4e8bddb246258f2ea09228d9ff9a3ff4e3244935845bb1a21a085403eca468d294517635a
@@ -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
@@ -1,5 +1,5 @@
1
1
  module Kiba
2
2
  module Plus
3
- VERSION = "0.1.15"
3
+ VERSION = "0.1.16"
4
4
  end
5
5
  end
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.15
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-23 00:00:00.000000000 Z
11
+ date: 2017-08-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: kiba