console 1.19.0 → 1.21.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: e68f107945b1831b98497a3a7d6a251b030788dfb0f85e212af7da334816f791
4
- data.tar.gz: 0460616df8b87571a01eba8d41cdfa2c30ae2efb4c7847c322273cc1de8d74fd
3
+ metadata.gz: 36a5fff3c1cafc8686f77440fc2dcb09d3a94d1399b15b9bf6967e4b21e6a511
4
+ data.tar.gz: 3c7e6218667002f2a0f745bcfddbeec1dc8b126fdd1b81cec71fa03c53c3eba5
5
5
  SHA512:
6
- metadata.gz: 9d7f4c0af841a44c643e24dec336bb1a71642fe292fe204382282e6ef1766a6fe6ec4390486c6e9b3bc6d841b5d603739711ed14848fc4024f6d9c2b169e2e09
7
- data.tar.gz: 65399cb6f4c81c5bbe67a746797fa37a96d8a01f1b540abdb01cccad73ea174439a2c27131db84fa2ee80b6860a69150ed77a19e9d3a298cc22dc1e6ed4a97bf
6
+ metadata.gz: b4d6ebc41b6ea36a711f5f054a30a81ff4a29d06e0f4a2ef6a6554f6c94fd874439428df40e7a098f4bec25a8605452c2380987d1e275e38e6cf522254fdc3b8
7
+ data.tar.gz: 693ed3f6a7d6786a87aef0ff42d238a3cbd1fc267c0cafb1683b8236e0f878bb7a8dc316822f00ab84cdba7e6f58212e8474d0e85109d67ff59a65b3003548f3
checksums.yaml.gz.sig CHANGED
Binary file
@@ -29,7 +29,7 @@ module Console
29
29
  end
30
30
  end
31
31
 
32
- def initialize(subject, output)
32
+ def initialize(subject, output = Console)
33
33
  super(nil)
34
34
 
35
35
  @progname = subject
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2022, by Samuel Williams.
4
+ # Copyright, 2019-2023, by Samuel Williams.
5
5
  # Copyright, 2019, by Bryan Powell.
6
6
  # Copyright, 2020, by Michael Adams.
7
7
  # Copyright, 2021, by Robert Schulze.
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Released under the MIT License.
4
+ # Copyright, 2023, by Samuel Williams.
5
+
6
+ module Console
7
+ module Output
8
+ class Encoder
9
+ def initialize(output, encoding = ::Encoding::UTF_8)
10
+ @output = output
11
+ @encoding = encoding
12
+ end
13
+
14
+ attr :output
15
+
16
+ attr :encoding
17
+
18
+ def call(subject = nil, *arguments, **options, &block)
19
+ subject = encode(subject)
20
+ arguments = encode(arguments)
21
+ options = encode(options)
22
+
23
+ @output.call(subject, *arguments, **options, &block)
24
+ end
25
+
26
+ def encode(value)
27
+ case value
28
+ when String
29
+ value.encode(@encoding, invalid: :replace, undef: :replace)
30
+ when Array
31
+ value.map{|item| encode(item)}
32
+ when Hash
33
+ value.transform_values{|item| encode(item)}
34
+ else
35
+ value
36
+ end
37
+ end
38
+ end
39
+ end
40
+ end
@@ -4,12 +4,16 @@
4
4
  # Copyright, 2021-2022, by Samuel Williams.
5
5
 
6
6
  require_relative '../serialized/logger'
7
+ require_relative 'encoder'
7
8
 
8
9
  module Console
9
10
  module Output
10
11
  module JSON
11
12
  def self.new(output, **options)
12
- Serialized::Logger.new(output, format: ::JSON, **options)
13
+ # The output encoder can prevent encoding issues (e.g. invalid UTF-8):
14
+ Output::Encoder.new(
15
+ Serialized::Logger.new(output, format: ::JSON, **options)
16
+ )
13
17
  end
14
18
  end
15
19
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2022, by Samuel Williams.
4
+ # Copyright, 2022-2023, by Samuel Williams.
5
5
 
6
6
  module Console
7
7
  module Output
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2021-2022, by Samuel Williams.
4
+ # Copyright, 2021-2023, by Samuel Williams.
5
5
 
6
6
  require_relative 'output/default'
7
7
  require_relative 'output/json'
@@ -1,7 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2020-2022, by Samuel Williams.
4
+ # Copyright, 2020-2023, by Samuel Williams.
5
+ # Copyright, 2022, by Anton Sozontov.
5
6
 
6
7
  require_relative 'event/progress'
7
8
  require_relative 'clock'
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2022, by Samuel Williams.
4
+ # Copyright, 2019-2023, by Samuel Williams.
5
5
 
6
6
  require_relative '../buffer'
7
7
  require_relative '../filter'
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2022, by Samuel Williams.
4
+ # Copyright, 2019-2023, by Samuel Williams.
5
5
  # Copyright, 2021, by Robert Schulze.
6
6
 
7
7
  require_relative '../buffer'
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2022, by Samuel Williams.
4
+ # Copyright, 2019-2023, by Samuel Williams.
5
5
 
6
6
  require 'io/console'
7
7
 
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2022, by Samuel Williams.
4
+ # Copyright, 2019-2023, by Samuel Williams.
5
5
 
6
6
  module Console
7
- VERSION = "1.19.0"
7
+ VERSION = "1.21.0"
8
8
  end
data/lib/console.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  # Released under the MIT License.
4
- # Copyright, 2019-2022, by Samuel Williams.
4
+ # Copyright, 2019-2023, by Samuel Williams.
5
5
  # Copyright, 2019, by Bryan Powell.
6
6
  # Copyright, 2020, by Michael Adams.
7
7
  # Copyright, 2021, by Cédric Boutillier.
@@ -10,23 +10,45 @@ require_relative 'console/version'
10
10
  require_relative 'console/logger'
11
11
 
12
12
  module Console
13
- def self.logger
14
- Logger.instance
15
- end
16
-
17
- def self.logger= instance
18
- Logger.instance= instance
13
+ class << self
14
+ def logger
15
+ Logger.instance
16
+ end
17
+
18
+ def logger= instance
19
+ Logger.instance= instance
20
+ end
21
+
22
+ def debug(...)
23
+ Logger.instance.debug(...)
24
+ end
25
+
26
+ def info(...)
27
+ Logger.instance.info(...)
28
+ end
29
+
30
+ def warn(...)
31
+ Logger.instance.warn(...)
32
+ end
33
+
34
+ def error(...)
35
+ Logger.instance.error(...)
36
+ end
37
+
38
+ def fatal(...)
39
+ Logger.instance.fatal(...)
40
+ end
41
+
42
+ def call(...)
43
+ Logger.instance.call(...)
44
+ end
19
45
  end
20
46
 
21
47
  def logger= logger
22
- @logger = logger
48
+ warn "Setting logger on #{self} is deprecated. Use Console.logger= instead.", uplevel: 1
23
49
  end
24
50
 
25
51
  def logger
26
- @logger || Logger.instance
27
- end
28
-
29
- def self.extended(klass)
30
- klass.instance_variable_set(:@logger, nil)
52
+ Logger.instance
31
53
  end
32
54
  end
data/license.md CHANGED
@@ -1,12 +1,15 @@
1
1
  # MIT License
2
2
 
3
- Copyright, 2019-2022, by Samuel Williams.
3
+ Copyright, 2019-2023, by Samuel Williams.
4
4
  Copyright, 2019-2021, by Bryan Powell.
5
5
  Copyright, 2019, by Cyril Roelandt.
6
6
  Copyright, 2020, by Olle Jonsson.
7
7
  Copyright, 2020, by Michael Adams.
8
8
  Copyright, 2021, by Cédric Boutillier.
9
9
  Copyright, 2021, by Robert Schulze.
10
+ Copyright, 2022, by Anton Sozontov.
11
+ Copyright, 2022, by William T. Nelson.
12
+ Copyright, 2023, by Felix Yan.
10
13
 
11
14
  Permission is hereby granted, free of charge, to any person obtaining a copy
12
15
  of this software and associated documentation files (the "Software"), to deal
data/readme.md CHANGED
@@ -6,7 +6,7 @@ Provides beautiful console logging for Ruby applications. Implements fast, buffe
6
6
 
7
7
  ## Motivation
8
8
 
9
- When Ruby decided to reverse the order of exception backtraces, I finally gave up using the built in logging and decided restore sanity to the output of my programs once and for all!
9
+ When Ruby decided to reverse the order of exception backtraces, I finally gave up using the built in logging and decided restore sanity to the output of my programs once and for all\!
10
10
 
11
11
  ## Features
12
12
 
@@ -29,3 +29,11 @@ We welcome contributions to this project.
29
29
  3. Commit your changes (`git commit -am 'Add some feature'`).
30
30
  4. Push to the branch (`git push origin my-new-feature`).
31
31
  5. Create new Pull Request.
32
+
33
+ ### Developer Certificate of Origin
34
+
35
+ This project uses the [Developer Certificate of Origin](https://developercertificate.org/). All contributors to this project must agree to this document to have their contributions accepted.
36
+
37
+ ### Contributor Covenant
38
+
39
+ This project is governed by [Contributor Covenant](https://www.contributor-covenant.org/). All contributors and participants agree to abide by its terms.
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,16 +1,19 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: console
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.19.0
4
+ version: 1.21.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  - Robert Schulze
9
9
  - Bryan Powell
10
10
  - Michael Adams
11
+ - Anton Sozontov
11
12
  - Cyril Roelandt
12
13
  - Cédric Boutillier
14
+ - Felix Yan
13
15
  - Olle Jonsson
16
+ - William T. Nelson
14
17
  autorequire:
15
18
  bindir: bin
16
19
  cert_chain:
@@ -43,22 +46,8 @@ cert_chain:
43
46
  Q2K9NVun/S785AP05vKkXZEFYxqG6EW012U4oLcFl5MySFajYXRYbuUpH6AY+HP8
44
47
  voD0MPg1DssDLKwXyt1eKD/+Fq0bFWhwVM/1XiAXL7lyYUyOq24KHgQ2Csg=
45
48
  -----END CERTIFICATE-----
46
- date: 2023-08-02 00:00:00.000000000 Z
49
+ date: 2023-08-07 00:00:00.000000000 Z
47
50
  dependencies:
48
- - !ruby/object:Gem::Dependency
49
- name: fiber-local
50
- requirement: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- type: :runtime
56
- prerelease: false
57
- version_requirements: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
51
  - !ruby/object:Gem::Dependency
63
52
  name: fiber-annotation
64
53
  requirement: !ruby/object:Gem::Requirement
@@ -74,89 +63,19 @@ dependencies:
74
63
  - !ruby/object:Gem::Version
75
64
  version: '0'
76
65
  - !ruby/object:Gem::Dependency
77
- name: bake
78
- requirement: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- type: :development
84
- prerelease: false
85
- version_requirements: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- - !ruby/object:Gem::Dependency
91
- name: bake-test
92
- requirement: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- type: :development
98
- prerelease: false
99
- version_requirements: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- - !ruby/object:Gem::Dependency
105
- name: bake-test-external
106
- requirement: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
- type: :development
112
- prerelease: false
113
- version_requirements: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - ">="
116
- - !ruby/object:Gem::Version
117
- version: '0'
118
- - !ruby/object:Gem::Dependency
119
- name: bundler
66
+ name: fiber-local
120
67
  requirement: !ruby/object:Gem::Requirement
121
68
  requirements:
122
69
  - - ">="
123
70
  - !ruby/object:Gem::Version
124
71
  version: '0'
125
- type: :development
72
+ type: :runtime
126
73
  prerelease: false
127
74
  version_requirements: !ruby/object:Gem::Requirement
128
75
  requirements:
129
76
  - - ">="
130
77
  - !ruby/object:Gem::Version
131
78
  version: '0'
132
- - !ruby/object:Gem::Dependency
133
- name: covered
134
- requirement: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: 0.18.1
139
- type: :development
140
- prerelease: false
141
- version_requirements: !ruby/object:Gem::Requirement
142
- requirements:
143
- - - "~>"
144
- - !ruby/object:Gem::Version
145
- version: 0.18.1
146
- - !ruby/object:Gem::Dependency
147
- name: sus
148
- requirement: !ruby/object:Gem::Requirement
149
- requirements:
150
- - - "~>"
151
- - !ruby/object:Gem::Version
152
- version: '0.14'
153
- type: :development
154
- prerelease: false
155
- version_requirements: !ruby/object:Gem::Requirement
156
- requirements:
157
- - - "~>"
158
- - !ruby/object:Gem::Version
159
- version: '0.14'
160
79
  description:
161
80
  email:
162
81
  executables: []
@@ -179,6 +98,7 @@ files:
179
98
  - lib/console/logger.rb
180
99
  - lib/console/output.rb
181
100
  - lib/console/output/default.rb
101
+ - lib/console/output/encoder.rb
182
102
  - lib/console/output/json.rb
183
103
  - lib/console/output/null.rb
184
104
  - lib/console/output/sensitive.rb
@@ -208,7 +128,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
208
128
  requirements:
209
129
  - - ">="
210
130
  - !ruby/object:Gem::Version
211
- version: 2.7.3
131
+ version: '3.0'
212
132
  required_rubygems_version: !ruby/object:Gem::Requirement
213
133
  requirements:
214
134
  - - ">="
metadata.gz.sig CHANGED
Binary file