console 1.13.1 → 1.14.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: a8c8affd2da03cdb084d7ef8af7c666409d12606c4459da493bf01a96d6b7bf3
4
- data.tar.gz: d0af1c352b7b89f91b57ea737a5069282177be325f1bae82db3cb8de2ee76f57
3
+ metadata.gz: 43a78b129f0b1f778d063513a3726aaa832390761f3987fb3b1b77286f51af1a
4
+ data.tar.gz: b790c9b840bd37bfcbd6e7f98de70e45bf2d27d049c54b2f9763070edc318a2c
5
5
  SHA512:
6
- metadata.gz: b9c453a4bfc44ac3b87c034e8854addb31d4a1c4d2cbdc9abf698f3dbf657ff99fa636d8e46dd0262e30cd195d1c3b12ba6d64c5e8b75668ec05d8b26952f494
7
- data.tar.gz: 9ca8d1ade8c3b7fc3c4dd307a27e2e67f236526bd60619cb30cc7c70af179846050bd22d0e67d1e55f3019702052ffeb593c5eed1d1522c577e73cebc2e56795
6
+ metadata.gz: f58e0e37313d0388c439c80a06e3583f57fa96271be8bd1f1e28e3f4a973ba46618143629af6474bc812b8395c51ace42af4de6a5dcc92f281eba9ce1d66d40a
7
+ data.tar.gz: b472be4850adac00472c1abfcadf3f65fc3d1ad4c180d51eb7ef15cf71831757cc411f393b40ca5b71155d9881bb83a445b3fca1ab481e2a2ae93ada1da62158
checksums.yaml.gz.sig ADDED
@@ -0,0 +1 @@
1
+ ���u��i��7k�'��È\��a�W�a�0��]:X<�Qw��J��ˈ�
@@ -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
@@ -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
@@ -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.1"
24
+ VERSION = "1.14.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
Binary file
metadata CHANGED
@@ -1,14 +1,42 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: console
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.13.1
4
+ version: 1.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
- cert_chain: []
11
- date: 2021-06-11 00:00:00.000000000 Z
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIEhDCCAuygAwIBAgIBATANBgkqhkiG9w0BAQsFADA3MTUwMwYDVQQDDCxzYW11
14
+ ZWwud2lsbGlhbXMvREM9b3Jpb250cmFuc2Zlci9EQz1jby9EQz1uejAeFw0yMTA4
15
+ MTYwNjMzNDRaFw0yMjA4MTYwNjMzNDRaMDcxNTAzBgNVBAMMLHNhbXVlbC53aWxs
16
+ aWFtcy9EQz1vcmlvbnRyYW5zZmVyL0RDPWNvL0RDPW56MIIBojANBgkqhkiG9w0B
17
+ AQEFAAOCAY8AMIIBigKCAYEAyXLSS/cw+fXJ5e7hi+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KSomR9ZtnCGljds/aeO1Xgpn2r9HHcjwnH346iNrnHmMlC7BtHUFPDg
34
+ Ts92S47PTOXzwPBDsrFiq3VLbRjHSwf8rpqybQBH9MfzxGGxTaETQYOd6b4e4Ag6
35
+ y92abGna0bmIEb4+Tx9rQ10Uijh1POzvr/VTH4bbIPy9FbKrRsIQ24qDbNJRtOpE
36
+ RAOsIl+HOBTb252nx1kIRN5hqQx272AJCbCjKx8egcUQKffFVVCI0nye09v5CK+a
37
+ HiLJ8VOFx6w=
38
+ -----END CERTIFICATE-----
39
+ date: 2021-11-19 00:00:00.000000000 Z
12
40
  dependencies:
13
41
  - !ruby/object:Gem::Dependency
14
42
  name: fiber-local
@@ -149,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
149
177
  - !ruby/object:Gem::Version
150
178
  version: '0'
151
179
  requirements: []
152
- rubygems_version: 3.3.0.dev
180
+ rubygems_version: 3.2.29
153
181
  signing_key:
154
182
  specification_version: 4
155
183
  summary: Beautiful logging for Ruby.
metadata.gz.sig ADDED
@@ -0,0 +1 @@
1
+ H�.������� �Y��Ʒ�~m�:�M�.�̄��@hu|��֊���{�#�2#�