console 1.7.0 → 1.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dc9d8c829a0609b619169fd4607c88c9d2ec53e8bad01a7f3b85ef614718169d
4
- data.tar.gz: 793221c44e39ee199ad34e3452a335d3c3838d84b5aab445680a7ff378009ba1
3
+ metadata.gz: a8cd747edadd12f8a9c8f01538e8e89986cb5ac6632d743f8ca4280c18166dba
4
+ data.tar.gz: 4c6eb9b8ebd974af8eac9ecf7db5ac9a7998fcc8116468a0a81a4cb1b317063a
5
5
  SHA512:
6
- metadata.gz: 4aa2ca6d6dfedcaf36964f4877adf3c984db619b146d6dda4eea927286ac302cd01c738a848fb232829201fd3e4ec0e9377e29079342ed2c12720c68376af73e
7
- data.tar.gz: 8d8364cacd0743b2a4713debf583f9d82f9d8ef9b534b7564fcf6e95e1ca52c0112e61e154e24a10935eb6b05e56fffceb900cf1a26dc73080f419ae6d19f679
6
+ metadata.gz: acd069d149e295163cf2bdf8a45b12d72ec77c677b988e0e0554fb789bf724d09284c48e181dc6927cf5590a81ac69f9e442dc186bb4caf371fac6675e0e34c8
7
+ data.tar.gz: 8dc2fd1bd53a653e26190b8a818a25c80b50482eec4e2d44a572897199530ea5265349f1d3fe616cf34797f222516d1957b15ac256882ea631e708c687d74e51
@@ -7,6 +7,7 @@ matrix:
7
7
  - rvm: 2.4
8
8
  - rvm: 2.5
9
9
  - rvm: 2.6
10
+ - rvm: 2.7
10
11
  - rvm: 2.6
11
12
  env: COVERAGE=PartialSummary,Coveralls
12
13
  - rvm: truffleruby
@@ -26,6 +26,23 @@ require_relative 'xterm'
26
26
 
27
27
  module Console
28
28
  module Terminal
29
+ # This, and all related methods, is considered private.
30
+ CONSOLE_START_AT = 'CONSOLE_START_AT'
31
+
32
+ # Exports CONSOLE_START which can be used to synchronize the start times of all child processes when they log using delta time.
33
+ def self.start_at!(environment = ENV)
34
+ if time_string = environment[CONSOLE_START_AT]
35
+ start_at = Time.parse(time_string) rescue nil
36
+ end
37
+
38
+ unless start_at
39
+ start_at = Time.now
40
+ environment[CONSOLE_START_AT] = start_at.to_s
41
+ end
42
+
43
+ return start_at
44
+ end
45
+
29
46
  def self.for(io)
30
47
  if io.isatty
31
48
  XTerm.new(io)
@@ -35,9 +52,9 @@ module Console
35
52
  end
36
53
 
37
54
  class Logger
38
- def initialize(io = $stderr, verbose: nil, **options)
55
+ def initialize(io = $stderr, verbose: nil, start_at: Terminal.start_at!, **options)
39
56
  @io = io
40
- @start = Time.now
57
+ @start_at = start_at
41
58
 
42
59
  @terminal = Terminal.for(io)
43
60
 
@@ -49,6 +66,7 @@ module Console
49
66
 
50
67
  @terminal[:logger_prefix] ||= @terminal.style(nil, nil, nil)
51
68
  @terminal[:logger_suffix] ||= @terminal.style(:white, nil, :faint)
69
+ @terminal[:subject] ||= @terminal.style(nil, nil, :bold)
52
70
  @terminal[:debug] = @terminal.style(:cyan)
53
71
  @terminal[:info] = @terminal.style(:green)
54
72
  @terminal[:warn] = @terminal.style(:yellow)
@@ -121,7 +139,9 @@ module Console
121
139
  suffix = " #{@terminal[:logger_suffix]}[pid=#{Process.pid}] [#{Time.now}]#{@terminal.reset}"
122
140
  end
123
141
 
124
- output.puts "#{@terminal[:logger_prefix]}#{subject}#{@terminal.reset}#{suffix}", prefix: "#{prefix_style}#{prefix}:#{@terminal.reset} "
142
+ prefix = "#{prefix_style}#{prefix}:#{@terminal.reset} "
143
+
144
+ output.puts "#{@terminal[:subject]}#{subject}#{@terminal.reset}#{suffix}", prefix: prefix
125
145
  end
126
146
 
127
147
  def format_value(value, output)
@@ -133,7 +153,7 @@ module Console
133
153
  end
134
154
 
135
155
  def time_offset_prefix
136
- offset = Time.now - @start
156
+ offset = Time.now - @start_at
137
157
  minutes = (offset/60).floor
138
158
  seconds = (offset - (minutes*60))
139
159
 
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Console
22
- VERSION = "1.7.0"
22
+ VERSION = "1.7.1"
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.0
4
+ version: 1.7.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-28 00:00:00.000000000 Z
11
+ date: 2020-01-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: covered