console 1.13.0 → 1.15.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: cdbb00255589a49fe7d7d8e94361816a0316ae40f88a96b29b3dae6b0b243a05
4
- data.tar.gz: 935c2a4dba52698495892e0dd858c2a6654e154d1edeb07d7b9dbacb52ddaea9
3
+ metadata.gz: c07a7e9199462f58af29e0245ec0bb1bc2320b2fb0ff0538159d8caf50708d71
4
+ data.tar.gz: 7622d420eabaff04e887074aba918a9e25155517641e730a92305eb44de5c911
5
5
  SHA512:
6
- metadata.gz: 208d13a845fef65da3942b11326f9cfb4c0f21b82a97a839dc010261f662ae7483931a510f131141c28b25e8540ff99d7e920118585c167897c4765b80b0e92f
7
- data.tar.gz: 388d12e41c387d37fe4191c49017ca77784d8c397f526a708038d67ef3b35cab87fd0a9aff837c2a9c34227d1a672e7a61027bdc08b2b5fd833c13a179d81326
6
+ metadata.gz: 228f356dfefffa20db989562126ce4d8e2b78584f6c62f1a8750edb8f336b1ea507975cd8963dd895215253b2c1a9bcd765e1f423ae10108219c77922b7e9344
7
+ data.tar.gz: 75b761c38aeda80f76778bf1aa9fc3853f6dda8754066f52f9badd1a56373adfb0d4c56483cda69ffc70f97fa64c4ba2efa8c1334903c6398d136989481d5318
checksums.yaml.gz.sig ADDED
Binary file
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
data/lib/console/clock.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2021, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright, 2021, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
+ #
5
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ # of this software and associated documentation files (the "Software"), to deal
7
+ # in the Software without restriction, including without limitation the rights
8
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ # copies of the Software, and to permit persons to whom the Software is
10
+ # furnished to do so, subject to the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be included in
13
+ # all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ # THE SOFTWARE.
22
+
23
+ require 'logger'
24
+
25
+ module Console
26
+ module Compatible
27
+ class Logger < ::Logger
28
+ class LogDevice
29
+ def initialize(subject, output)
30
+ @subject = subject
31
+ @output = output
32
+ end
33
+
34
+ def write(message)
35
+ @output.call(@subject, message)
36
+ end
37
+
38
+ def call(*arguments, **options)
39
+ @output.call(*arguments, **options)
40
+ end
41
+
42
+ def reopen
43
+ end
44
+
45
+ def close
46
+ end
47
+ end
48
+
49
+ def initialize(subject, output)
50
+ super(nil)
51
+
52
+ @progname = subject
53
+ @logdev = LogDevice.new(@subject, output)
54
+ end
55
+
56
+ def add(severity, message = nil, progname = nil)
57
+ severity ||= UNKNOWN
58
+
59
+ if @logdev.nil? or severity < level
60
+ return true
61
+ end
62
+
63
+ if progname.nil?
64
+ progname = @progname
65
+ end
66
+
67
+ if message.nil?
68
+ if block_given?
69
+ message = yield
70
+ else
71
+ message = progname
72
+ progname = @progname
73
+ end
74
+ end
75
+
76
+ @logdev.call(
77
+ progname, message,
78
+ severity: format_severity(severity)
79
+ )
80
+
81
+ return true
82
+ end
83
+ end
84
+ end
85
+ end
@@ -1,4 +1,5 @@
1
- # frozen_string_literals: true
1
+ # frozen_string_literal: true
2
+
2
3
  #
3
4
  # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
5
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -27,8 +29,8 @@ module Console
27
29
  def to_h
28
30
  end
29
31
 
30
- def as_json
31
- to_h
32
+ def to_json(*arguments)
33
+ JSON.generate([self.class, to_h], *arguments)
32
34
  end
33
35
 
34
36
  def format(buffer, terminal)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -26,13 +28,14 @@ module Console
26
28
  def self.for(*arguments, **options)
27
29
  # Extract out the command environment:
28
30
  if arguments.first.is_a?(Hash)
29
- self.new(*arguments, **options)
31
+ environment = arguments.shift
32
+ self.new(environment, arguments, options)
30
33
  else
31
- self.new(nil, arguments, **options)
34
+ self.new(nil, arguments, options)
32
35
  end
33
36
  end
34
37
 
35
- def initialize(environment, *arguments, **options)
38
+ def initialize(environment, arguments, options)
36
39
  @environment = environment
37
40
  @arguments = arguments
38
41
  @options = options
@@ -53,7 +56,11 @@ module Console
53
56
  end
54
57
 
55
58
  def to_h
56
- {environment: @environment, arguments: @arguments, options: @options}
59
+ Hash.new.tap do |hash|
60
+ hash[:environment] = @environment if @environment&.any?
61
+ hash[:arguments] = @arguments if @arguments&.any?
62
+ hash[:options] = @options if @options&.any?
63
+ end
57
64
  end
58
65
 
59
66
  def format(output, terminal, verbose)
data/lib/console/event.rb CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2021, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2021, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2021, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2021, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2021, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2021, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -27,7 +29,7 @@ module Console
27
29
  module Output
28
30
  def self.new(output = nil, env = ENV, **options)
29
31
  if names = env['CONSOLE_OUTPUT']
30
- names = names.split(',').map(&:to_sym).reverse
32
+ names = names.split(',').reverse
31
33
 
32
34
  names.inject(output) do |output, name|
33
35
  Output.const_get(name).new(output, **options)
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -59,26 +61,59 @@ module Console
59
61
  record[:subject] = subject
60
62
  end
61
63
 
62
- if arguments.any?
63
- record[:arguments] = arguments
64
- end
65
-
66
- if options.any?
67
- record[:options] = options
68
- end
64
+ message = arguments
69
65
 
70
66
  if block_given?
71
67
  if block.arity.zero?
72
- record[:message] = yield
68
+ message << yield
73
69
  else
74
70
  buffer = StringIO.new
75
71
  yield buffer
76
- record[:message] = buffer.string
72
+ message << buffer.string
77
73
  end
78
74
  end
79
75
 
76
+ if message.size == 1
77
+ record[:message] = message.first
78
+ elsif message.any?
79
+ record[:message] = message
80
+ end
81
+
82
+ if exception = find_exception(message)
83
+ record[:error] = {
84
+ kind: exception.class,
85
+ message: exception.message,
86
+ stack: format_stack(exception)
87
+ }
88
+ end
89
+
90
+ record.update(options)
91
+
80
92
  @io.puts(self.dump(record))
81
93
  end
94
+
95
+ private
96
+
97
+ def find_exception(message)
98
+ message.find{|part| part.is_a?(Exception)}
99
+ end
100
+
101
+ def format_stack(exception)
102
+ buffer = StringIO.new
103
+ format_backtrace(exception, buffer)
104
+ return buffer.string
105
+ end
106
+
107
+ def format_backtrace(exception, buffer)
108
+ buffer.puts exception.backtrace
109
+
110
+ if exception = exception.cause
111
+ buffer.puts
112
+ buffer.puts "Caused by: #{exception.class} #{exception.message}"
113
+
114
+ format_backtrace(exception, buffer)
115
+ end
116
+ end
82
117
  end
83
118
  end
84
119
  end
data/lib/console/split.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
 
2
3
  # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
3
4
  #
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2017, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
2
4
  #
3
5
  # Permission is hereby granted, free of charge, to any person obtaining a copy
@@ -19,5 +21,5 @@
19
21
  # THE SOFTWARE.
20
22
 
21
23
  module Console
22
- VERSION = "1.13.0"
24
+ VERSION = "1.15.0"
23
25
  end
data/lib/console.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  #
3
4
  # Copyright, 2019, by Samuel G. D. Williams. <http://www.codeotaku.com>
4
5
  #
data.tar.gz.sig ADDED
@@ -0,0 +1,2 @@
1
+ ��[dS�D�dܵ �!�Mj{q"���1�����C��� C�M^��C����n�CI��E
2
+ �0�%^ZW/\G�rs�3�O"��&4�pvs5�xʛ�����o�N�5���{rD��}�|:����������cG6_0l�m�+�B�v�FҰx�i7*�Ӱ8O_���Po��!f$ ����-R5��8���?3�@�j�w�CB#���c�z>��m����:�dB0��!Q�pá-��鴗 ˪�C�w�;c!��>7��<�5 /Ud7�r�oqWjQA�g�*N&iB��ȭ�� �T�]S�m22y9efX_�3�9��/�r�L�Sh���
metadata CHANGED
@@ -1,14 +1,48 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: console
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.0
4
+ version: 1.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
+ - Robert Schulze
9
+ - Bryan Powell
10
+ - Michael Adams
11
+ - Cyril Roelandt
12
+ - Cédric Boutillier
13
+ - Olle Jonsson
8
14
  autorequire:
9
15
  bindir: bin
10
- cert_chain: []
11
- date: 2021-06-11 00:00:00.000000000 Z
16
+ cert_chain:
17
+ - |
18
+ -----BEGIN CERTIFICATE-----
19
+ MIIEhDCCAuygAwIBAgIBATANBgkqhkiG9w0BAQsFADA3MTUwMwYDVQQDDCxzYW11
20
+ ZWwud2lsbGlhbXMvREM9b3Jpb250cmFuc2Zlci9EQz1jby9EQz1uejAeFw0yMTA4
21
+ MTYwNjMzNDRaFw0yMjA4MTYwNjMzNDRaMDcxNTAzBgNVBAMMLHNhbXVlbC53aWxs
22
+ aWFtcy9EQz1vcmlvbnRyYW5zZmVyL0RDPWNvL0RDPW56MIIBojANBgkqhkiG9w0B
23
+ AQEFAAOCAY8AMIIBigKCAYEAyXLSS/cw+fXJ5e7hi+U/TeChPWeYdwJojDsFY1xr
24
+ xvtqbTTL8gbLHz5LW3QD2nfwCv3qTlw0qI3Ie7a9VMJMbSvgVEGEfQirqIgJXWMj
25
+ eNMDgKsMJtC7u/43abRKx7TCURW3iWyR19NRngsJJmaR51yGGGm2Kfsr+JtKKLtL
26
+ L188Wm3f13KAx7QJU8qyuBnj1/gWem076hzdA7xi1DbrZrch9GCRz62xymJlrJHn
27
+ 9iZEZ7AxrS7vokhMlzSr/XMUihx/8aFKtk+tMLClqxZSmBWIErWdicCGTULXCBNb
28
+ E/mljo4zEVKhlTWpJklMIhr55ZRrSarKFuW7en0+tpJrfsYiAmXMJNi4XAYJH7uL
29
+ rgJuJwSaa/dMz+VmUoo7VKtSfCoOI+6v5/z0sK3oT6sG6ZwyI47DBq2XqNC6tnAj
30
+ w+XmCywiTQrFzMMAvcA7rPI4F0nU1rZId51rOvvfxaONp+wgTi4P8owZLw0/j0m4
31
+ 8C20DYi6EYx4AHDXiLpElWh3AgMBAAGjgZowgZcwCQYDVR0TBAIwADALBgNVHQ8E
32
+ BAMCBLAwHQYDVR0OBBYEFB6ZaeWKxQjGTI+pmz7cKRmMIywwMC4GA1UdEQQnMCWB
33
+ I3NhbXVlbC53aWxsaWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MC4GA1UdEgQnMCWB
34
+ I3NhbXVlbC53aWxsaWFtc0BvcmlvbnRyYW5zZmVyLmNvLm56MA0GCSqGSIb3DQEB
35
+ CwUAA4IBgQBVoM+pu3dpdUhZM1w051iw5GfiqclAr1Psypf16Tiod/ho//4oAu6T
36
+ 9fj3DPX/acWV9P/FScvqo4Qgv6g4VWO5ZU7z2JmPoTXZtYMunRAmQPFL/gSUc6aK
37
+ vszMHIyhtyzRc6DnfW2AiVOjMBjaYv8xXZc9bduniRVPrLR4J7ozmGLh4o4uJp7w
38
+ x9KCFaR8Lvn/r0oJWJOqb/DMAYI83YeN2Dlt3jpwrsmsONrtC5S3gOUle5afSGos
39
+ bYt5ocnEpKSomR9ZtnCGljds/aeO1Xgpn2r9HHcjwnH346iNrnHmMlC7BtHUFPDg
40
+ Ts92S47PTOXzwPBDsrFiq3VLbRjHSwf8rpqybQBH9MfzxGGxTaETQYOd6b4e4Ag6
41
+ y92abGna0bmIEb4+Tx9rQ10Uijh1POzvr/VTH4bbIPy9FbKrRsIQ24qDbNJRtOpE
42
+ RAOsIl+HOBTb252nx1kIRN5hqQx272AJCbCjKx8egcUQKffFVVCI0nye09v5CK+a
43
+ HiLJ8VOFx6w=
44
+ -----END CERTIFICATE-----
45
+ date: 2022-03-29 00:00:00.000000000 Z
12
46
  dependencies:
13
47
  - !ruby/object:Gem::Dependency
14
48
  name: fiber-local
@@ -105,6 +139,7 @@ files:
105
139
  - lib/console/buffer.rb
106
140
  - lib/console/capture.rb
107
141
  - lib/console/clock.rb
142
+ - lib/console/compatible/logger.rb
108
143
  - lib/console/event.rb
109
144
  - lib/console/event/failure.rb
110
145
  - lib/console/event/generic.rb
@@ -149,7 +184,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
184
  - !ruby/object:Gem::Version
150
185
  version: '0'
151
186
  requirements: []
152
- rubygems_version: 3.1.2
187
+ rubygems_version: 3.3.8
153
188
  signing_key:
154
189
  specification_version: 4
155
190
  summary: Beautiful logging for Ruby.
metadata.gz.sig ADDED
Binary file