console 1.7.2 → 1.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/console/terminal/text.rb +30 -7
- data/lib/console/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb8134534352969dd1f48e568f92e3ee1b6a8bcde97be1e44ef6e941e0437ead
|
4
|
+
data.tar.gz: 5992182d9ed1f729ee350703f7a591b67a5f8b101ef420159f8d35bb40c2e0d4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f70f82899ad1e7fd31969ff98ca8b15604aff8b4749fdd31dafa5ae2a1959d6c507a0d1a9e048920c629aeea4990358bf6658baccd87bd656e691daa9b11a53
|
7
|
+
data.tar.gz: 2d590c94668bbdfcd29d2457c99dc169855aa3294c3ae3978b27f658cb99e98b41cb3a7faa8662f7d6ab1824dd2e2f7d6312c120e2db61c35480d58ebd0b9a35
|
@@ -26,7 +26,7 @@ module Console
|
|
26
26
|
class Text
|
27
27
|
def initialize(output)
|
28
28
|
@output = output
|
29
|
-
@styles = {}
|
29
|
+
@styles = {reset: self.reset}
|
30
30
|
end
|
31
31
|
|
32
32
|
def [] key
|
@@ -47,25 +47,48 @@ module Console
|
|
47
47
|
def reset
|
48
48
|
end
|
49
49
|
|
50
|
-
def write(*
|
50
|
+
def write(*arguments, style: nil)
|
51
51
|
if style and prefix = self[style]
|
52
52
|
@output.write(prefix)
|
53
|
-
@output.write(*
|
53
|
+
@output.write(*arguments)
|
54
54
|
@output.write(self.reset)
|
55
55
|
else
|
56
|
-
@output.write(*
|
56
|
+
@output.write(*arguments)
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
def puts(*
|
60
|
+
def puts(*arguments, style: nil)
|
61
61
|
if style and prefix = self[style]
|
62
62
|
@output.write(prefix)
|
63
|
-
@output.puts(*
|
63
|
+
@output.puts(*arguments)
|
64
64
|
@output.write(self.reset)
|
65
65
|
else
|
66
|
-
@output.puts(*
|
66
|
+
@output.puts(*arguments)
|
67
67
|
end
|
68
68
|
end
|
69
|
+
|
70
|
+
# Print out the given arguments.
|
71
|
+
# When the argument is a symbol, look up the style and inject it into the output stream.
|
72
|
+
# When the argument is a proc/lambda, call it with self as the argument.
|
73
|
+
# When the argument is anything else, write it directly to the output.
|
74
|
+
def print(*arguments)
|
75
|
+
arguments.each do |argument|
|
76
|
+
case argument
|
77
|
+
when Symbol
|
78
|
+
@output.write(self[argument])
|
79
|
+
when Proc
|
80
|
+
argument.call(self)
|
81
|
+
else
|
82
|
+
@output.write(argument)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# Print out the arguments as per {#print}, followed by the reset sequence and a newline.
|
88
|
+
def print_line(*arguments)
|
89
|
+
print(*arguments)
|
90
|
+
@output.puts(self.reset)
|
91
|
+
end
|
69
92
|
end
|
70
93
|
end
|
71
94
|
end
|
data/lib/console/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: console
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Samuel Williams
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-01
|
11
|
+
date: 2020-02-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: covered
|