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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2eb770ebff3f1d698f1498ae9d09f6ce70735fe4a0b4e8fb48047db6fffa9497
4
- data.tar.gz: 3b32cbac5261b3f04831b455f0bdc1e12d7579ba3006b32fedf7a0214b6c1219
3
+ metadata.gz: 52b672b4b047bc03d1b603eb57ce54e8710d2f349531b0ed7ff586dfc74ec006
4
+ data.tar.gz: 8fd5c49734e7293aa0f0331860843fd032d2728ca25b1d24747514e584b6a6b8
5
5
  SHA512:
6
- metadata.gz: e79ed58e9d0b3bbce41cc04c61ba6ffac86faee95ef257bc1be5f38c14cd9c2606c3452b13fb4f2aae5411137827aa29e70e4a2b038b8f8bf18f74dcc4f95793
7
- data.tar.gz: 9fceaf98cfc77253cf2f772367698486a250ca3659d4b5d0399ab7d18b4b95274951c1e7cda5820e3f8019e8941f34f1554208bbc5d0fdda85bd3a5ffa085547
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. As these exist on `String`, you can call them on any string such as:
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 = 'Multicoloured String'.blue.bg_red.bold
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
- | Method | Function |
92
- |---------------|--------------------------------------------------|
93
- | blue | Sets the string's colour to blue |
94
- | red | Sets the string's colour to red |
95
- | green | Sets the string's colour to green |
96
- | brown | Sets the string's colour to brown |
97
- | blue | Sets the string's colour to blue |
98
- | magenta | Sets the string's colour to magenta |
99
- | cyan | Sets the string's colour to cyan |
100
- | gray | Sets the string's colour to gray |
101
- | grey | Sets the string's colour to grey (alias of gray) |
102
- | bright_blue | Sets the string's colour to bright blue |
103
- | bright_red | Sets the string's colour to bright red |
104
- | bright_green | Sets the string's colour to bright green |
105
- | bright_yellow | Sets the string's colour to bright yellow |
106
- | bright_blue | Sets the string's colour to bright blue |
107
- | bright_magenta| Sets the string's colour to bright magenta |
108
- | bright_cyan | Sets the string's colour to bright cyan |
109
- | white | Sets the string's colour to white |
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 { |t| t.write(*args) }
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
- "\e[#{code}m#{self}\e[#{reset_code}m"
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
- alias colorize colourise
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
- alias yellow brown
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
- def bright_yellow = colourise(93)
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
- def blink = colourise(5, 25)
41
- def reverse_color = colourise(7, 27)
42
- alias reverse_colour reverse_color
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
@@ -1,5 +1,5 @@
1
1
  module DVLA
2
2
  module Herodotus
3
- VERSION = '2.2.0'.freeze
3
+ VERSION = '2.2.1'.freeze
4
4
  end
5
5
  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.0
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-08 00:00:00.000000000 Z
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