twiglet 3.5.1 → 3.6.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: 00772aa96a6be0df63c418fc7cc077cf599e9909af51e00be9992bf78d298660
4
- data.tar.gz: 479f94b2de093c797e863b66f02287e37d1b1c5aa58931553bdff269844ed792
3
+ metadata.gz: 65882a52b10620b9a6ab5ff439b9f377e135308055618474510f232d14be0ec5
4
+ data.tar.gz: 97fb56dced537bc5bf3e0ddebfc6cf2be076466241eaef4b63437a278664fe47
5
5
  SHA512:
6
- metadata.gz: 17317a0d26e6b66b573e5eeeafc7d4957c6bdb87e70f320279098cb405464e68fe29a56cbe4421663d809cf39b6e7f72d5d5b5c0261fecd59766bf420e928250
7
- data.tar.gz: 222e608e335c4a6406e08376356f1cd7e42c89ea09f7d4eba6432fc33aa26d614421f60ef123d45b2eed73ab334741b50fbf096ee17631f38dbf8930cb4c4397
6
+ metadata.gz: '09a38113c797bec07068cd08a3d2c00fceac2f1617956ce88cb775c8c2fb86344377569f0df5b75d47e93ab8bc1a6c94fadd6d2ec2190edfcefc0d648a471f67'
7
+ data.tar.gz: e37658db9af2be233a93c3f6ef7ea776a4ae51bbbbd09afb85a5e77c5b13a7172fd7ca141b87241edb1ebf7678f7a4ca1485629a6ef97c7921da7b9a33b32009
@@ -42,7 +42,7 @@ jobs:
42
42
 
43
43
  # Initializes the CodeQL tools for scanning.
44
44
  - name: Initialize CodeQL
45
- uses: github/codeql-action/init@v1
45
+ uses: github/codeql-action/init@v2
46
46
  with:
47
47
  languages: ${{ matrix.language }}
48
48
  # If you wish to specify custom queries, you can do so here or in a config file.
@@ -53,7 +53,7 @@ jobs:
53
53
  # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
54
54
  # If this step fails, then you should remove it and run the build manually (see below)
55
55
  - name: Autobuild
56
- uses: github/codeql-action/autobuild@v1
56
+ uses: github/codeql-action/autobuild@v2
57
57
 
58
58
  # ℹ️ Command-line programs to run using the OS shell.
59
59
  # 📚 https://git.io/JvXDl
@@ -67,4 +67,4 @@ jobs:
67
67
  # make release
68
68
 
69
69
  - name: Perform CodeQL Analysis
70
- uses: github/codeql-action/analyze@v1
70
+ uses: github/codeql-action/analyze@v2
@@ -0,0 +1,17 @@
1
+ name: Automatically add new Issues to Silversmith's GitHub project board
2
+ # https://github.com/orgs/simplybusiness/projects/3
3
+ # New issues in this repository will be added to the board.
4
+ on:
5
+ issues:
6
+ types: [ opened, reopened ]
7
+
8
+ jobs:
9
+ track_issues:
10
+ uses: simplybusiness/github-action-reusable-workflows/.github/workflows/project-board.yaml@master
11
+ with:
12
+ pr-id: ${{ github.event.issue.node_id }}
13
+ project-number: 3
14
+ org: simplybusiness
15
+ actor: ${{ github.actor }}
16
+ secrets:
17
+ github-token: ${{ secrets.SILVERSMITHS_PROJECT_MANAGEMENT }}
@@ -13,7 +13,7 @@ jobs:
13
13
  runs-on: ubuntu-18.04
14
14
 
15
15
  steps:
16
- - uses: simplybusiness/version-forget-me-not@V2.1.1
16
+ - uses: simplybusiness/version-forget-me-not@v2.3.0
17
17
  env:
18
18
  ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19
19
  VERSION_FILE_PATH: "lib/twiglet/version.rb"
@@ -42,17 +42,26 @@ module Twiglet
42
42
  @validator.custom_error_handler = block
43
43
  end
44
44
 
45
+ def debug(message_or_error = nil, &block)
46
+ message = message_or_error.is_a?(Exception) ? error_message(message_or_error) : message_or_error
47
+
48
+ super(message, &block)
49
+ end
50
+
51
+ def info(message_or_error = nil, &block)
52
+ message = message_or_error.is_a?(Exception) ? error_message(message_or_error) : message_or_error
53
+
54
+ super(message, &block)
55
+ end
56
+
57
+ def warn(message_or_error = nil, &block)
58
+ message = message_or_error.is_a?(Exception) ? error_message(message_or_error) : message_or_error
59
+
60
+ super(message, &block)
61
+ end
62
+
45
63
  def error(message = nil, error = nil, &block)
46
- if error
47
- error_fields = {
48
- error: {
49
- type: error.class.to_s,
50
- message: error.message
51
- }
52
- }
53
- add_stack_trace(error_fields, error)
54
- message = Message.new(message).merge(error_fields)
55
- end
64
+ message = error_message(error, message) if error
56
65
 
57
66
  super(message, &block)
58
67
  end
@@ -76,6 +85,18 @@ module Twiglet
76
85
 
77
86
  private
78
87
 
88
+ def error_message(error, message = nil)
89
+ error_fields = {
90
+ error: {
91
+ type: error.class.to_s,
92
+ message: error.message
93
+ }
94
+ }
95
+ add_stack_trace(error_fields, error)
96
+ message = error.message if message.nil? || message.empty?
97
+ Message.new(message).merge(error_fields)
98
+ end
99
+
79
100
  def add_stack_trace(hash_to_add_to, error)
80
101
  hash_to_add_to[:error][:stack_trace] = error.backtrace if error.backtrace
81
102
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Twiglet
4
- VERSION = '3.5.1'
4
+ VERSION = '3.6.0'
5
5
  end
data/test/logger_test.rb CHANGED
@@ -361,6 +361,31 @@ describe Twiglet::Logger do
361
361
 
362
362
  assert_equal 'StandardError', actual_log[:error][:type]
363
363
  end
364
+
365
+ it 'can log just an error as "error", if no message is given' do
366
+ e = StandardError.new('some error')
367
+ @logger.error(nil, e)
368
+
369
+ actual_log = read_json(@buffer)
370
+
371
+ assert_equal 'some error', actual_log[:message]
372
+ assert_equal 'StandardError', actual_log[:error][:type]
373
+ assert_equal 'some error', actual_log[:error][:message]
374
+ end
375
+
376
+ [:debug, :info, :warn].each do |level|
377
+ it "can log an error with type, error message etc.. as '#{level}'" do
378
+ error_message = "error to be logged as #{level}"
379
+ e = StandardError.new(error_message)
380
+ @logger.public_send(level, e)
381
+
382
+ actual_log = read_json(@buffer)
383
+
384
+ assert_equal error_message, actual_log[:message]
385
+ assert_equal 'StandardError', actual_log[:error][:type]
386
+ assert_equal error_message, actual_log[:error][:message]
387
+ end
388
+ end
364
389
  end
365
390
 
366
391
  describe 'text logging' do
@@ -420,6 +445,15 @@ describe Twiglet::Logger do
420
445
  assert_equal 'a block log message', actual_log[:message]
421
446
  end
422
447
  end
448
+
449
+ it 'should ignore the given progname if a block is also given' do
450
+ block = proc { 'a block log message' }
451
+ @logger.info('my-program-name', &block)
452
+ actual_log = read_json(@buffer)
453
+
454
+ assert_equal 'info', actual_log[:log][:level]
455
+ assert_equal 'a block log message', actual_log[:message]
456
+ end
423
457
  end
424
458
 
425
459
  describe 'dotted keys' do
data/twiglet.gemspec CHANGED
@@ -15,7 +15,6 @@ Gem::Specification.new do |gem|
15
15
  gem.description = 'Like a log, only smaller.'
16
16
 
17
17
  gem.files = `git ls-files`.split("\n")
18
- gem.test_files = `git ls-files -- {test}/*`.split("\n")
19
18
 
20
19
  gem.require_paths = ['lib']
21
20
  gem.required_ruby_version = '>= 2.6'
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: twiglet
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.5.1
4
+ version: 3.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simply Business
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-05-18 00:00:00.000000000 Z
11
+ date: 2022-09-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json-schema
@@ -92,6 +92,7 @@ files:
92
92
  - ".github/workflows/codeql-analysis.yml"
93
93
  - ".github/workflows/dobby-actions.yml"
94
94
  - ".github/workflows/gem-publish.yml"
95
+ - ".github/workflows/project-board.yml"
95
96
  - ".github/workflows/ruby.yml"
96
97
  - ".github/workflows/version-forget-me-not.yml"
97
98
  - ".gitignore"