content_block_tools 0.4.3 → 0.4.5

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: f5b9b36acc6265a8bd30974d57e67a9b33dfb1240e9a9e05d6cbaf2101d2bd22
4
- data.tar.gz: 4994f81c1f3339500cdcf21d84bdf9bf44f7ca19a5c0e2019b5c91e312f732b4
3
+ metadata.gz: 8dcdb3b81c3bba801688a197e2f9208ed17e8432f1d4c96215d3591bca746708
4
+ data.tar.gz: 81b3aab74207c5d64a687f4c7cff7e309b8fca6a8da68b19a74e183a09f809c3
5
5
  SHA512:
6
- metadata.gz: 268643e7647a673cbacfe74903cf592a148719a73ee1ca653078f108b904fafc7ed4cf6c6a1d2a194cfcafd8772d450bc175c1017dc638764167cc7ff39989e8
7
- data.tar.gz: ee8dead83c275f5f4125165c876bb4fbfd44e23e6f1eff584a372f6eb78b98558f88910b06d3f5e74e6fe2ccf22e9f46300584a98dd19d51ff5c385d4d7e0625
6
+ metadata.gz: 8f0169d5727462ad30dd9888a9bfc8421dac428e8c9203e7d4b00c5f3dcc093751addb500d6b1fa4d5b334e5cf3fcb118366e9615b0c1b57c95c998a082d85bf
7
+ data.tar.gz: d64fdbcef11a2de0279f01d4aca052b7aaed794669cbc24a2d8d3f8cef21e5855c3523f9e363d9db9f4376190f655fc2370debfafadb272904d83f15d51eeb10
@@ -0,0 +1,12 @@
1
+ name: Lint GitHub Actions
2
+ on:
3
+ push:
4
+ paths: ['.github/**']
5
+ jobs:
6
+ actionlint:
7
+ runs-on: ubuntu-latest
8
+ steps:
9
+ - uses: actions/checkout@v4
10
+ with:
11
+ show-progress: false
12
+ - uses: alphagov/govuk-infrastructure/.github/actions/actionlint@main
@@ -34,6 +34,15 @@ jobs:
34
34
  bundler-cache: true
35
35
  - run: bundle exec rake
36
36
 
37
+ # Branch protection rules cannot directly depend on status checks from matrix jobs.
38
+ # So instead we define `test` as a dummy job which only runs after the preceding `test_matrix` checks have passed.
39
+ # Solution inspired by: https://github.community/t/status-check-for-a-matrix-jobs/127354/3
40
+ test:
41
+ needs: test_matrix
42
+ runs-on: ubuntu-latest
43
+ steps:
44
+ - run: echo "All matrix tests have passed 🚀"
45
+
37
46
  publish:
38
47
  needs: test_matrix
39
48
  if: ${{ github.ref == 'refs/heads/main' }}
data/CHANGELOG.md CHANGED
@@ -7,40 +7,48 @@
7
7
  useful summary for people upgrading their application, not a replication
8
8
  of the commit log.
9
9
 
10
+ ## 0.4.5
11
+
12
+ - Add handling for incorrect field names and some logging ([24](https://github.com/alphagov/govuk_content_block_tools/pull/24))
13
+
14
+ ## 0.4.4
15
+
16
+ - symbolize keys in block details blob, in order to find embedded nested fields ([22](https://github.com/alphagov/govuk_content_block_tools/pull/22))
17
+
10
18
  ## 0.4.3
11
19
 
12
- * Add presenter for a pension block ([20](https://github.com/alphagov/govuk_content_block_tools/pull/20))
20
+ - Add presenter for a pension block ([20](https://github.com/alphagov/govuk_content_block_tools/pull/20))
13
21
 
14
22
  ## 0.4.2
15
23
 
16
- * Pass embed code to HTML span ([19](https://github.com/alphagov/govuk_content_block_tools/pull/19))
24
+ - Pass embed code to HTML span ([19](https://github.com/alphagov/govuk_content_block_tools/pull/19))
17
25
 
18
26
  ## 0.4.1
19
27
 
20
- * Fix field regular expression ([18](https://github.com/alphagov/govuk_content_block_tools/pull/18))
28
+ - Fix field regular expression ([18](https://github.com/alphagov/govuk_content_block_tools/pull/18))
21
29
 
22
30
  ## 0.4.0
23
31
 
24
- * BREAKING: allow support for field names in block's embed code. new ContentBlocks now require an embed code argument. (
32
+ - BREAKING: allow support for field names in block's embed code. new ContentBlocks now require an embed code argument. (
25
33
  [17]
26
34
  (https://github.com/alphagov/govuk_content_block_tools/pull/17))
27
35
 
28
36
  ## 0.3.1
29
37
 
30
- * Support any Rails version `>= 6` ([#10](https://github.com/alphagov/govuk_content_block_tools/pull/10))
38
+ - Support any Rails version `>= 6` ([#10](https://github.com/alphagov/govuk_content_block_tools/pull/10))
31
39
 
32
40
  ## 0.3.0
33
41
 
34
- * Symbolise details hash ([#8](https://github.com/alphagov/content_block_tools/pull/8))
42
+ - Symbolise details hash ([#8](https://github.com/alphagov/content_block_tools/pull/8))
35
43
 
36
44
  ## 0.2.1
37
45
 
38
- * Loosen ActionView dependency ([#7](https://github.com/alphagov/content_block_tools/pull/7))
46
+ - Loosen ActionView dependency ([#7](https://github.com/alphagov/content_block_tools/pull/7))
39
47
 
40
48
  ## 0.2.0
41
49
 
42
- * Don't `uniq` content references ([#6](https://github.com/alphagov/content_block_tools/pull/6))
50
+ - Don't `uniq` content references ([#6](https://github.com/alphagov/content_block_tools/pull/6))
43
51
 
44
52
  ## 0.1.0
45
53
 
46
- * Initial release
54
+ - Initial release
@@ -40,7 +40,9 @@ module ContentBlockTools
40
40
  #
41
41
  # @return [Array<ContentBlockReference>] An array of content block references
42
42
  def find_all_in_document(document)
43
+ ContentBlockTools.logger.info("Finding embedded content")
43
44
  document.scan(ContentBlockReference::EMBED_REGEX).map do |match|
45
+ ContentBlockTools.logger.info("Found Content Block Reference: #{match}")
44
46
  ContentBlockReference.new(document_type: match[1], content_id: match[2], embed_code: match[0])
45
47
  end
46
48
  end
@@ -44,6 +44,7 @@ module ContentBlockTools
44
44
  # @return [string] A representation of the content block to be wrapped in the base_tag in
45
45
  # {#content}
46
46
  def content
47
+ ContentBlockTools.logger.info("Getting content for content block #{content_block.content_id}")
47
48
  if field_names.present?
48
49
  content_for_fields
49
50
  else
@@ -56,7 +57,13 @@ module ContentBlockTools
56
57
  end
57
58
 
58
59
  def content_for_fields
59
- content_block.details.dig(*field_names)
60
+ content = content_block.details.deep_symbolize_keys.dig(*field_names)
61
+ if content.blank?
62
+ ContentBlockTools.logger.warn("Content not found for content block #{content_block.content_id} and fields #{field_names}")
63
+ content_block.embed_code
64
+ else
65
+ content
66
+ end
60
67
  end
61
68
 
62
69
  def field_names
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ContentBlockTools
4
- VERSION = "0.4.3"
4
+ VERSION = "0.4.5"
5
5
  end
@@ -16,4 +16,20 @@ require "content_block_tools/version"
16
16
  module ContentBlockTools
17
17
  class Error < StandardError; end
18
18
  module Presenters; end
19
+
20
+ class << self
21
+ attr_writer :logger
22
+
23
+ def logger
24
+ @logger ||= Logger.new($stdout)
25
+ end
26
+ end
27
+
28
+ if defined?(Rails::Railtie)
29
+ class Railtie < Rails::Railtie
30
+ initializer "content_block_tools.initialize_logger" do
31
+ ContentBlockTools.logger = Rails.logger
32
+ end
33
+ end
34
+ end
19
35
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: content_block_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.3
4
+ version: 0.4.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2025-02-13 00:00:00.000000000 Z
10
+ date: 2025-03-05 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: rake
@@ -73,6 +73,7 @@ extra_rdoc_files: []
73
73
  files:
74
74
  - ".github/dependabot.yml"
75
75
  - ".github/pull_request_template.md"
76
+ - ".github/workflows/actionlint.yml"
76
77
  - ".github/workflows/autorelease.yml"
77
78
  - ".github/workflows/ci.yml"
78
79
  - ".gitignore"
@@ -113,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
113
114
  - !ruby/object:Gem::Version
114
115
  version: '0'
115
116
  requirements: []
116
- rubygems_version: 3.6.3
117
+ rubygems_version: 3.6.5
117
118
  specification_version: 4
118
119
  summary: A suite of tools for working with GOV.UK Content Blocks
119
120
  test_files: []