inprovise 0.2.8 → 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/inprovise/logger.rb +27 -24
- data/lib/inprovise/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ZGIxYjZiN2VkYTY2OTEwNjVjMDg3OTBiMmUyYzM4YzVmZTZlZmIxMQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NWRjZTgzZTY1ZGEzN2NiZTU2NWRjYTBkODIxNzA0YTA5MGQxMTVjNg==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
N2I3Yzc5M2ZlOGVjZTJmMDUzNjcxODRhZWIwNjk3OTg0YjUwMzM2Y2EwZWI0
|
10
|
+
OGI0ZDQzNzBmZjU5YzBkNzZiN2ZhMGRlNzkxMDZlNDM0NzhlMTg3NjZiOWJj
|
11
|
+
YzIyMzcwODEyY2I2NWIzNDAwMzg0YTJmYzA3YzU3YTdhMjJjMDc=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZTg4ZTc3MTA1Y2NkMDkwODE2YWNmMjdjZWQzYjQzNTY4ZjZkZTdjMDNiMDNk
|
14
|
+
ZjFiY2QwOWQ5OGNiOWM5ZTkwNWQ2MTQ1MjNiOGQ0ZGIwZGQ2Yzg2OGNjMTkz
|
15
|
+
MmY3Y2VkNjQwOWI5NWU1YjVlYzZkZjM2M2YwYTkwYzQ0MDI4MTY=
|
data/lib/inprovise/logger.rb
CHANGED
@@ -19,10 +19,6 @@ class Inprovise::Logger
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def initialize(node, task)
|
22
|
-
@streams = {
|
23
|
-
:stdout => { :ios => $stdout, :buffer => [{col: nil, ln: '', cr: false}] },
|
24
|
-
:stderr => { :ios => $stderr, :buffer => [{col: nil, ln: '', cr: false}] }
|
25
|
-
}
|
26
22
|
@node = node
|
27
23
|
set_task(task)
|
28
24
|
end
|
@@ -84,6 +80,17 @@ class Inprovise::Logger
|
|
84
80
|
end
|
85
81
|
private :buffer
|
86
82
|
|
83
|
+
def next_line(stream)
|
84
|
+
lnbuf = buffer(stream).shift || {}
|
85
|
+
[lnbuf[:col], lnbuf[:ln], lnbuf[:cr]]
|
86
|
+
end
|
87
|
+
private :next_line
|
88
|
+
|
89
|
+
def push_line(stream, col, ln, cr)
|
90
|
+
buffer(stream) << {col: col, ln: ln, cr: cr ? true : false}
|
91
|
+
end
|
92
|
+
private :push_line
|
93
|
+
|
87
94
|
def put(msg, color=nil, stream=:stdout)
|
88
95
|
streambuf = buffer(stream)
|
89
96
|
streambuf.last[:col] ||= color
|
@@ -98,30 +105,26 @@ class Inprovise::Logger
|
|
98
105
|
private :puts
|
99
106
|
|
100
107
|
def do_print(stream=:stdout)
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
if cr || !streambuf.empty?
|
107
|
-
out = lnbuf[:col] ? txt.to_s.send(lnbuf[:col]) : txt
|
108
|
+
until buffer(stream).empty?
|
109
|
+
col, ln, cr_at_start = next_line(stream)
|
110
|
+
ln.scan(/([^\r]*)(\r)?/) do |txt, cr|
|
111
|
+
nl = buffer(stream).size > 0
|
112
|
+
if cr || nl
|
108
113
|
unless txt.empty?
|
109
|
-
|
110
|
-
ios(stream).print "
|
114
|
+
out = col ? txt.to_s.send(col) : txt
|
115
|
+
ios(stream).print "\r".to_eol if cr_at_start
|
116
|
+
ios(stream).print "#{@node} [#{@task.bold}] #{out}"
|
111
117
|
end
|
112
|
-
|
113
|
-
|
114
|
-
clear_to_eol = cr ? true : false
|
115
|
-
break unless cr # next line or cr?
|
116
|
-
else
|
117
|
-
streambuf << if txt.empty?
|
118
|
-
# restart with empty line
|
119
|
-
{col:nil,ln:'',cr:clear_to_eol}
|
118
|
+
if cr
|
119
|
+
ios(stream).flush
|
120
120
|
else
|
121
|
-
|
122
|
-
{col:lnbuf[:col],ln:txt,cr:clear_to_eol}
|
121
|
+
ios(stream).puts unless txt.empty? && !cr_at_start
|
123
122
|
end
|
124
|
-
|
123
|
+
cr_at_start = cr
|
124
|
+
else
|
125
|
+
# cache for later
|
126
|
+
push_line(stream, txt.empty? ? nil : col, txt, cr_at_start)
|
127
|
+
return # done printing for now
|
125
128
|
end
|
126
129
|
end
|
127
130
|
end
|
data/lib/inprovise/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: inprovise
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Corino
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-09-
|
11
|
+
date: 2016-09-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: colored
|