twiglet 3.12.0 → 3.13.4

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: 7f7f408c7f0546be8ef926a307e70a58af7a7ff3427b1744bdbb4cfbc4653189
4
- data.tar.gz: aaf5bce57110c3accb2353250c528a525b0948fbfda377f3b6fc6308e50030ba
3
+ metadata.gz: d45efd0e55e70aa841d869e74651ae6aa4e63e687cac76636259d73b14b3a004
4
+ data.tar.gz: 6a9c30a7e7e1b8ee44b40e7e39ccf7c531dee71771566bff485de87837a3f387
5
5
  SHA512:
6
- metadata.gz: 830da1bdf6311f12b6a92cab29c8e25453d8ee0bd0007d3b41e211a628983ea20c3956dc6cab9b6d991901ebb7cfb718f0296b11b82e89c20deee187a4f6ae87
7
- data.tar.gz: 140e91a61d0883769aea1e0828022ae0662750a571fc35531f3604d1708a24efbfc2b229624faef3855234d59048134c8f29700505d8ca674f7a9a830e5d1465
6
+ metadata.gz: e25f3123db091b89be3d0fa6802a322700ff3f13d0c564b6010adabe8c44a0a0d82d75b4fd9775fc959ce9963dffcae7afc194db1820d8bcd42969b8ee75e1bf
7
+ data.tar.gz: 18604a8d18ff0fb9d2da01afc0f3c4e2811bed972ed8a58105a5a997948f185a6012229e57a1aa99523e5f1069c5e2e1507a3f295c400cb15314c881f2ea4316
@@ -38,11 +38,11 @@ jobs:
38
38
 
39
39
  steps:
40
40
  - name: Checkout repository
41
- uses: actions/checkout@v3
41
+ uses: actions/checkout@v4
42
42
 
43
43
  # Initializes the CodeQL tools for scanning.
44
44
  - name: Initialize CodeQL
45
- uses: github/codeql-action/init@v2
45
+ uses: github/codeql-action/init@v3
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@v2
56
+ uses: github/codeql-action/autobuild@v3
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@v2
70
+ uses: github/codeql-action/analyze@v3
@@ -13,7 +13,7 @@ jobs:
13
13
  BUNDLE_WITHOUT: "development:test"
14
14
  steps:
15
15
  - name: Chekcout action
16
- uses: actions/checkout@v3
16
+ uses: actions/checkout@v4
17
17
  with:
18
18
  repository: 'simplybusiness/dobby'
19
19
  ref: 'v3.0.0'
@@ -22,7 +22,7 @@ jobs:
22
22
  with:
23
23
  bundler-cache: true
24
24
  - name: Bump version
25
- uses: simplybusiness/dobby@v3.1.1
25
+ uses: simplybusiness/dobby@v3
26
26
  env:
27
27
  DOBBY_APP_ID: ${{ secrets.DOBBY_APP_ID }}
28
28
  DOBBY_PRIVATE_KEY: ${{ secrets.DOBBY_PRIVATE_KEY }}
@@ -12,7 +12,7 @@ jobs:
12
12
  name: Build and Publish
13
13
  runs-on: ubuntu-latest
14
14
  steps:
15
- - uses: actions/checkout@v3
15
+ - uses: actions/checkout@v4
16
16
  - name: Set up Ruby
17
17
  uses: ruby/setup-ruby@v1
18
18
  with:
@@ -31,7 +31,7 @@ jobs:
31
31
  id: get-gem-version
32
32
  run: echo "GEM_VERSION=$(bundle exec ruby -e 'puts Twiglet::VERSION')" >> $GITHUB_OUTPUT
33
33
  - name: Create Release
34
- uses: actions/github-script@v6
34
+ uses: actions/github-script@v7
35
35
  env:
36
36
  GEM_VERSION: ${{ steps.get-gem-version.outputs.GEM_VERSION }}
37
37
  with:
@@ -18,10 +18,10 @@ jobs:
18
18
 
19
19
  strategy:
20
20
  matrix:
21
- ruby-version: [3.0, 3.1, 3.2]
21
+ ruby-version: [3.0, 3.1, 3.2, 3.3]
22
22
 
23
23
  steps:
24
- - uses: actions/checkout@v3
24
+ - uses: actions/checkout@v4
25
25
  - name: Set up Ruby
26
26
  uses: ruby/setup-ruby@v1
27
27
  with:
@@ -13,7 +13,7 @@ jobs:
13
13
  runs-on: ubuntu-latest
14
14
 
15
15
  steps:
16
- - uses: simplybusiness/version-forget-me-not@v2.3.0
16
+ - uses: simplybusiness/version-forget-me-not@v2
17
17
  env:
18
18
  ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
19
19
  VERSION_FILE_PATH: "lib/twiglet/version.rb"
@@ -81,6 +81,13 @@ module Twiglet
81
81
  )
82
82
  end
83
83
 
84
+ def validation_schema(validation_schema)
85
+ self.class.new(
86
+ @service_name,
87
+ **@args.merge(validation_schema: validation_schema)
88
+ )
89
+ end
90
+
84
91
  def context_provider(&blk)
85
92
  new_context_providers = Array(@args[:context_providers])
86
93
  new_context_providers << blk
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Twiglet
4
- VERSION = '3.12.0'
4
+ VERSION = '3.13.4'
5
5
  end
data/test/logger_test.rb CHANGED
@@ -681,11 +681,71 @@ describe Twiglet::Logger do
681
681
  end
682
682
  end
683
683
 
684
+ describe '#validation_schema' do
685
+ it 'allows for reconfiguring the validation_schema on new logger instances' do
686
+ validation_schema = <<-JSON
687
+ {
688
+ "type": "object",
689
+ "required": ["pet"],
690
+ "properties": {
691
+ "pet": {
692
+ "type": "object",
693
+ "required": ["name", "best_boy_or_girl?"],
694
+ "properties": {
695
+ "name": {
696
+ "type": "string",
697
+ "minLength": 1
698
+ },
699
+ "best_boy_or_girl?": {
700
+ "type": "boolean"
701
+ }
702
+ }
703
+ }
704
+ }
705
+ }
706
+ JSON
707
+
708
+ logger = Twiglet::Logger.new(
709
+ 'petshop',
710
+ now: @now,
711
+ output: @buffer
712
+ )
713
+
714
+ message = { message: 'hi' }
715
+
716
+ pet_message = {
717
+ pet: { name: 'Davis', best_boy_or_girl?: true, species: 'dog' }
718
+ }
719
+
720
+ logger.info(message)
721
+ log = read_json(@buffer)
722
+ assert_equal 'hi', log[:message]
723
+
724
+ error = assert_raises JSON::Schema::ValidationError do
725
+ logger.info(pet_message)
726
+ end
727
+ assert_equal "The property '#/' did not contain a required property of 'message'", error.message
728
+
729
+ logger = logger.validation_schema(validation_schema)
730
+
731
+ error = assert_raises JSON::Schema::ValidationError do
732
+ logger.info(message)
733
+ end
734
+ assert_equal "The property '#/' did not contain a required property of 'pet'", error.message
735
+
736
+ logger.info(pet_message)
737
+ log = read_json(@buffer)
738
+ assert_equal 'Davis', log[:pet][:name]
739
+ end
740
+ end
741
+
684
742
  private
685
743
 
686
744
  def read_json(buffer)
687
745
  buffer.rewind
688
- JSON.parse(buffer.read, symbolize_names: true)
746
+ string = buffer.read
747
+ buffer.rewind
748
+ JSON.parse(string, symbolize_names: true)
689
749
  end
690
750
  end
691
751
  # rubocop:enable Metrics/BlockLength
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.12.0
4
+ version: 3.13.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simply Business
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-08-09 00:00:00.000000000 Z
11
+ date: 2024-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json-schema
@@ -92,16 +92,13 @@ 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"
96
95
  - ".github/workflows/ruby.yml"
97
96
  - ".github/workflows/version-forget-me-not.yml"
98
97
  - ".gitignore"
99
98
  - ".rubocop.yml"
100
99
  - ".ruby-version"
101
- - Dockerfile
102
100
  - Gemfile
103
101
  - LICENSE
104
- - Makefile
105
102
  - README.md
106
103
  - Rakefile
107
104
  - catalog-info.yaml
@@ -120,7 +117,6 @@ files:
120
117
  - lib/twiglet/validation_schema.json
121
118
  - lib/twiglet/validator.rb
122
119
  - lib/twiglet/version.rb
123
- - mkdocs.yml
124
120
  - test/error_serialiser_test.rb
125
121
  - test/formatter_test.rb
126
122
  - test/hash_extensions_test.rb
@@ -1,17 +0,0 @@
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 }}
data/Dockerfile DELETED
@@ -1,7 +0,0 @@
1
- FROM ruby:2.6.5
2
-
3
- WORKDIR /var/app
4
- COPY Gemfile .
5
- RUN bundle install
6
-
7
- CMD ["bash"]
data/Makefile DELETED
@@ -1,21 +0,0 @@
1
- .PHONY: all build clean shell test
2
-
3
- all: clean build test
4
-
5
- build:
6
- docker build -t simplybusiness/ruby-dev:2.6.5 .
7
-
8
- clean:
9
- rm -f *~
10
-
11
- shell:
12
- docker run -it \
13
- -v `pwd`:/var/app \
14
- simplybusiness/ruby-dev:2.6.5 \
15
- bash
16
-
17
- test:
18
- docker run -it \
19
- -v `pwd`:/var/app \
20
- simplybusiness/ruby-dev:2.6.5 \
21
- bundle exec rake test
data/mkdocs.yml DELETED
@@ -1,8 +0,0 @@
1
- site_name: 'Twiglet Docs'
2
- nav:
3
- - Home: index.md
4
- - Code of Conduct: CODE_OF_CONDUCT.md
5
- - "Why Twiglet?": RATIONALE.md
6
-
7
- plugins:
8
- - techdocs-core