dvla-herodotus 2.2.0 → 2.2.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 +4 -4
- data/CHANGELOG.md +15 -0
- data/README.md +27 -36
- data/lib/dvla/herodotus/multi_writer.rb +8 -1
- data/lib/dvla/herodotus/string.rb +58 -10
- data/lib/dvla/herodotus/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 52b672b4b047bc03d1b603eb57ce54e8710d2f349531b0ed7ff586dfc74ec006
|
4
|
+
data.tar.gz: 8fd5c49734e7293aa0f0331860843fd032d2728ca25b1d24747514e584b6a6b8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6a86fb9b81c961a73495e68068a7ea6b4b6c8aefd9c5e0b44855430b2738ddf829df971affc1a01b11a66a346b10648f62e4b538682c13efb8b8fa83ed080ac
|
7
|
+
data.tar.gz: d409d7a8f18584ac281f780c9ed94b603ed3de3af4e3a81ea15fffcfa72a95944691fd28b7642acf669f3faf1f196aabbaf7fed6742b2add922a59415fd0d290
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Changelog
|
2
|
+
All notable changes to this project will be documented in this file.
|
3
|
+
|
4
|
+
## [2.2.1] - 2025-09-15
|
5
|
+
- Fixed issue with ANSI exit codes breaking on string interpolation
|
6
|
+
- Added strip_colour method to String which we now call when sending logs to file
|
7
|
+
- Added colours/styles: yellow, bg_yellow, bg_white, bg_bright_red, bg_bright_green, bg_bright_blue, bg_bright_magenta, bg_bright_cyan, dim
|
8
|
+
- Removed colours/styles: bright_black (that's just gray), bright_yellow (that's just yellow), blink (inconsistent/unsupported)
|
9
|
+
- Added a changelog
|
10
|
+
|
11
|
+
|
12
|
+
## [2.2.0] - 2025-09-08
|
13
|
+
- Added colourise method to handle colour exist codes
|
14
|
+
- Added alias for colour/color
|
15
|
+
- Added alias for brown/yellow
|
data/README.md
CHANGED
@@ -29,7 +29,9 @@ You can get a logger by calling the following once Herodotus is installed:
|
|
29
29
|
logger = DVLA::Herodotus.logger('<system-name>')
|
30
30
|
```
|
31
31
|
|
32
|
-
You can also log out to a file. If you want all the logs in a single file, provide a string of the path to that output file and it will be logged to simultaneously with standard console logger
|
32
|
+
You can also log out to a file. If you want all the logs in a single file, provide a string of the path to that output file and it will be logged to simultaneously with standard console logger.
|
33
|
+
|
34
|
+
**Note:** Log messages are stripped of colour codes before being saved to file.
|
33
35
|
|
34
36
|
```ruby
|
35
37
|
logger = DVLA::Herodotus.logger('<system-name>', output_path: 'logs.txt')
|
@@ -82,45 +84,34 @@ logger.new_scenario('Scenario Id')
|
|
82
84
|
|
83
85
|
### Strings
|
84
86
|
|
85
|
-
Also included is a series of additional methods on `String` that allow you to modify the colour and style of logs.
|
87
|
+
Also included is a series of additional methods on `String` that allow you to modify the colour and style of logs.
|
88
|
+
You can stack multiple method calls to add additional styling and use string interpolation to style different parts of the string
|
89
|
+
|
86
90
|
|
87
91
|
```ruby
|
88
|
-
example_string = '
|
92
|
+
example_string = "#{'H'.red}#{'E'.bright_red}#{'R'.yellow}#{'O'.green}#{'D'.blue}#{'O'.bright_blue}#{'T'.magenta}#{'U'.bright_magenta}#{'S'.cyan}".bold.reverse_colour
|
89
93
|
```
|
90
94
|
|
91
|
-
|
92
|
-
|
93
|
-
|
|
94
|
-
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
102
|
-
|
103
|
-
|
|
104
|
-
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
| bg_blue | Sets the string's background colour to blue |
|
111
|
-
| bg_red | Sets the string's background colour to red |
|
112
|
-
| bg_green | Sets the string's background colour to green |
|
113
|
-
| bg_brown | Sets the string's background colour to brown |
|
114
|
-
| bg_blue | Sets the string's background colour to blue |
|
115
|
-
| bg_magenta | Sets the string's background colour to magenta |
|
116
|
-
| bg_cyan | Sets the string's background colour to cyan |
|
117
|
-
| bg_gray | Sets the string's background colour to gray |
|
118
|
-
| bold | Sets the string to be bold |
|
119
|
-
| italic | Sets the string to be italic |
|
120
|
-
| underline | Sets the string to be underline |
|
121
|
-
| blink | Sets the string to blink |
|
122
|
-
| reverse_color | Reverses the colour of the string |
|
95
|
+
#### Available String Methods
|
96
|
+
|
97
|
+
| Type | Examples |
|
98
|
+
|------|----------|
|
99
|
+
| Text Styles | **bold** <span style="opacity:0.6">dim</span> *italic* <u>underline</u> |
|
100
|
+
| Colors | <span style="color:black">black</span> <span style="color:red">red</span> <span style="color:green">green</span> <span style="color:#B8860B">brown</span> <span style="color:#ffff00">yellow</span> <span style="color:blue">blue</span> <span style="color:magenta">magenta</span> <span style="color:cyan">cyan</span> <span style="color:grey">gray</span> <span style="color:white">white</span> |
|
101
|
+
| Bright Colors | <span style="color:#ff5555">bright_red</span> <span style="color:#55ff55">bright_green</span> <span style="color:#5555ff">bright_blue</span> <span style="color:#ff55ff">bright_magenta</span> <span style="color:#55ffff">bright_cyan</span> |
|
102
|
+
| Background Colors | <span style="background:black;color:white">bg_black</span> <span style="background:red;color:white">bg_red</span> <span style="background:green;color:white">bg_green</span> <span style="background:#B8860B;color:white">bg_brown</span> <span style="background:#ffff00;color:black">bg_yellow</span> <span style="background:blue;color:white">bg_blue</span> <span style="background:magenta;color:white">bg_magenta</span> <span style="background:cyan;color:black">bg_cyan</span> <span style="background:grey;color:white">bg_gray</span> <span style="background:white;color:black">bg_white</span> |
|
103
|
+
| Bright Background Colors | <span style="background:#ff5555;color:white">bg_bright_red</span> <span style="background:#55ff55;color:black">bg_bright_green</span> <span style="background:#5555ff;color:white">bg_bright_blue</span> <span style="background:#ff55ff;color:white">bg_bright_magenta</span> <span style="background:#55ffff;color:black">bg_bright_cyan</span> |
|
104
|
+
| Utility | strip_colour reverse_colour |
|
105
|
+
|
106
|
+
#### To handle differences in spelling the following methods have been given aliases:
|
107
|
+
| Alias | Original |
|
108
|
+
|---------------|----------------|
|
109
|
+
| bg_grey | bg_gray |
|
110
|
+
| colorize | colourise |
|
111
|
+
| grey | gray |
|
112
|
+
| reverse_color | reverse_colour |
|
113
|
+
| strip_color | strip_colour |
|
123
114
|
|
124
115
|
## Development
|
125
116
|
|
126
|
-
Herodotus is very lightweight. Currently all code to generate a new logger can be found in `herodotus.rb` and the code for the logger is in `herodotus_logger.rb` so that is the best place to start with any modifications
|
117
|
+
Herodotus is very lightweight. Currently, all code to generate a new logger can be found in `herodotus.rb` and the code for the logger is in `herodotus_logger.rb` so that is the best place to start with any modifications
|
@@ -8,7 +8,14 @@ module DVLA
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def write(*args)
|
11
|
-
@targets.each
|
11
|
+
@targets.each do |target|
|
12
|
+
# If we're writing to a file we remove the colour
|
13
|
+
if target != $stdout && args[0].respond_to?(:strip_colour)
|
14
|
+
target.write(args[0].strip_colour, *args[1..])
|
15
|
+
else
|
16
|
+
target.write(*args)
|
17
|
+
end
|
18
|
+
end
|
12
19
|
end
|
13
20
|
|
14
21
|
def close
|
@@ -1,43 +1,91 @@
|
|
1
1
|
class String
|
2
2
|
def colourise(code, reset_code = 39)
|
3
|
-
|
3
|
+
# Making sure we align the correct reset codes
|
4
|
+
if self.include?("\e[#{reset_code}m")
|
5
|
+
result = self.gsub("\e[#{reset_code}m", "\e[#{reset_code}m\e[#{code}m")
|
6
|
+
"\e[#{code}m#{result}\e[#{reset_code}m"
|
7
|
+
else
|
8
|
+
"\e[#{code}m#{self}\e[#{reset_code}m"
|
9
|
+
end
|
4
10
|
end
|
5
|
-
|
11
|
+
|
12
|
+
def white = colourise(97)
|
6
13
|
|
7
14
|
def black = colourise(30)
|
15
|
+
|
8
16
|
def red = colourise(31)
|
17
|
+
|
9
18
|
def green = colourise(32)
|
19
|
+
|
10
20
|
def brown = colourise(33)
|
11
|
-
|
21
|
+
|
22
|
+
def yellow = colourise(93)
|
12
23
|
|
13
24
|
def blue = colourise(34)
|
25
|
+
|
14
26
|
def magenta = colourise(35)
|
27
|
+
|
15
28
|
def cyan = colourise(36)
|
29
|
+
|
16
30
|
def gray = colourise(37)
|
17
|
-
alias grey gray
|
18
31
|
|
19
|
-
def bright_black = colourise(90)
|
20
32
|
def bright_red = colourise(91)
|
33
|
+
|
21
34
|
def bright_green = colourise(92)
|
22
|
-
|
35
|
+
|
23
36
|
def bright_blue = colourise(94)
|
37
|
+
|
24
38
|
def bright_magenta = colourise(95)
|
39
|
+
|
25
40
|
def bright_cyan = colourise(96)
|
26
|
-
def white = colourise(97)
|
27
41
|
|
28
42
|
def bg_black = colourise(40, 49)
|
43
|
+
|
29
44
|
def bg_red = colourise(41, 49)
|
45
|
+
|
30
46
|
def bg_green = colourise(42, 49)
|
47
|
+
|
31
48
|
def bg_brown = colourise(43, 49)
|
49
|
+
|
50
|
+
def bg_yellow = colourise(103, 49)
|
51
|
+
|
32
52
|
def bg_blue = colourise(44, 49)
|
53
|
+
|
33
54
|
def bg_magenta = colourise(45, 49)
|
55
|
+
|
34
56
|
def bg_cyan = colourise(46, 49)
|
57
|
+
|
35
58
|
def bg_gray = colourise(47, 49)
|
36
59
|
|
60
|
+
def bg_white = colourise(107, 49)
|
61
|
+
|
62
|
+
def bg_bright_red = colourise(101, 49)
|
63
|
+
|
64
|
+
def bg_bright_green = colourise(102, 49)
|
65
|
+
|
66
|
+
def bg_bright_blue = colourise(104, 49)
|
67
|
+
|
68
|
+
def bg_bright_magenta = colourise(105, 49)
|
69
|
+
|
70
|
+
def bg_bright_cyan = colourise(106, 49)
|
71
|
+
|
37
72
|
def bold = colourise(1, 22)
|
73
|
+
|
74
|
+
def dim = colourise(2, 22)
|
75
|
+
|
38
76
|
def italic = colourise(3, 23)
|
77
|
+
|
39
78
|
def underline = colourise(4, 24)
|
40
|
-
|
41
|
-
def
|
42
|
-
|
79
|
+
|
80
|
+
def reverse_colour = colourise(7, 27)
|
81
|
+
|
82
|
+
def strip_colour
|
83
|
+
gsub(/\e\[[0-9;]*m/, '')
|
84
|
+
end
|
85
|
+
|
86
|
+
alias bg_grey bg_gray
|
87
|
+
alias colorize colourise
|
88
|
+
alias grey gray
|
89
|
+
alias reverse_color reverse_colour
|
90
|
+
alias strip_color strip_colour
|
43
91
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dvla-herodotus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Driver and Vehicle Licensing Agency (DVLA)
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2025-09-
|
12
|
+
date: 2025-09-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: dvla-lint
|
@@ -52,6 +52,7 @@ files:
|
|
52
52
|
- ".gitignore"
|
53
53
|
- ".rubocop.yml"
|
54
54
|
- ".ruby-version"
|
55
|
+
- CHANGELOG.md
|
55
56
|
- Gemfile
|
56
57
|
- LICENSE
|
57
58
|
- README.md
|