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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc774cc54d5e3bf9c96be4e34c314467e2ce8434a7acf7b059c24b86865ecdc6
4
- data.tar.gz: be5c6cf385afaf2e6c9722d595c63907842839003e49aeb95e1163026a7d2639
3
+ metadata.gz: eb8134534352969dd1f48e568f92e3ee1b6a8bcde97be1e44ef6e941e0437ead
4
+ data.tar.gz: 5992182d9ed1f729ee350703f7a591b67a5f8b101ef420159f8d35bb40c2e0d4
5
5
  SHA512:
6
- metadata.gz: 6133aad107df630aa40f63f56905c1afff80837baebe78f13a5a5610c6279c41757c14b91b34e3abdb83e2f8e574720a0a0614f18808e19beb700cf6a77f84f8
7
- data.tar.gz: f8a4fe934e7a8b3777ae94effeb61fe62b55ed0d740ea8c9030028bd2092b405d14556f077b19f1eeefad8654511b97e8bd51d8ff7a1635216071d5c304e502e
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(*args, style: nil)
50
+ def write(*arguments, style: nil)
51
51
  if style and prefix = self[style]
52
52
  @output.write(prefix)
53
- @output.write(*args)
53
+ @output.write(*arguments)
54
54
  @output.write(self.reset)
55
55
  else
56
- @output.write(*args)
56
+ @output.write(*arguments)
57
57
  end
58
58
  end
59
59
 
60
- def puts(*args, style: nil)
60
+ def puts(*arguments, style: nil)
61
61
  if style and prefix = self[style]
62
62
  @output.write(prefix)
63
- @output.puts(*args)
63
+ @output.puts(*arguments)
64
64
  @output.write(self.reset)
65
65
  else
66
- @output.puts(*args)
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
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Console
22
- VERSION = "1.7.2"
22
+ VERSION = "1.8.0"
23
23
  end
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.7.2
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-27 00:00:00.000000000 Z
11
+ date: 2020-02-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: covered