smooth_terminal_print 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/smooth_terminal_print.rb +19 -2
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 196b6528f01de22e4e69d8186712fd223db0a40f
4
- data.tar.gz: 3ad41e7a55d2281a052e42e9e599e4ada72a4264
3
+ metadata.gz: 8f0586e38bbb9d3bea892e5607aa39d204a0364b
4
+ data.tar.gz: 603cb30f4282c8557d0cfe134e916ab960daef63
5
5
  SHA512:
6
- metadata.gz: 30902b9db313ac36f751d87029dc7253fa0f55c985a16d2a0e70ceceb5735ba2df4220e7c3fb39221d6cce61d380a9d2a3b649e03962e4e68e7788b4e9c3cad2
7
- data.tar.gz: 121ad3c5b4c0bc7fb83a5f977b2fe1f09db86bc07c6239cf416ced8c7706850bf8c262a0c73522c273c3f114929c1e5ff7a7ce7aeb7307cd26206cdb264afa42
6
+ metadata.gz: 0425af7c364c0c1f4b1b41cedeb984a93a36dbbf85905e4b32ff9727809e85e2833920821ca37df544785b234fa6ce85fa31aaf7b42990c6774ed4e9fec98dd8
7
+ data.tar.gz: 89f2ba09ce36b3b15dcc91ca461952da10992756b5247e516f4f92aa4b5495f9df7e04522de7d05df5fb6bcd9d85e22381d960e2d047b7ce50150e20a91a3a07
@@ -1,16 +1,29 @@
1
+ require 'stringio'
2
+
1
3
  module SmoothTerminalPrint
2
4
  extend self
3
5
 
4
6
  def start(&block)
5
7
  @stp_reset_timer ||= Time.now.to_i
6
-
8
+
7
9
  if(Time.now.to_i - @stp_reset_timer > 1)
8
- print "\e[2J"
10
+ clear_screen
9
11
  @stp_reset_timer = Time.now.to_i
10
12
  end
11
13
  hide_cursor
12
14
  move_to_top_left
15
+
16
+ out = StringIO.new
17
+ $stdout = out
13
18
  yield
19
+ out.rewind
20
+
21
+ num_lines = ((`tput lines`).strip.to_i) - 5
22
+ num_lines.times do
23
+ STDOUT.puts out.gets
24
+ end
25
+
26
+ $stdout = STDOUT
14
27
  end
15
28
 
16
29
  def stop
@@ -19,6 +32,10 @@ module SmoothTerminalPrint
19
32
  end
20
33
 
21
34
  private
35
+ def clear_screen
36
+ print "\e[2J"
37
+ end
38
+
22
39
  def hide_cursor
23
40
  print "\e[?25l"
24
41
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smooth_terminal_print
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Sykes