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 +4 -4
- data/.github/workflows/actionlint.yml +12 -0
- data/.github/workflows/ci.yml +9 -0
- data/CHANGELOG.md +17 -9
- data/lib/content_block_tools/content_block_reference.rb +2 -0
- data/lib/content_block_tools/presenters/base_presenter.rb +8 -1
- data/lib/content_block_tools/version.rb +1 -1
- data/lib/content_block_tools.rb +16 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8dcdb3b81c3bba801688a197e2f9208ed17e8432f1d4c96215d3591bca746708
|
4
|
+
data.tar.gz: 81b3aab74207c5d64a687f4c7cff7e309b8fca6a8da68b19a74e183a09f809c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f0169d5727462ad30dd9888a9bfc8421dac428e8c9203e7d4b00c5f3dcc093751addb500d6b1fa4d5b334e5cf3fcb118366e9615b0c1b57c95c998a082d85bf
|
7
|
+
data.tar.gz: d64fdbcef11a2de0279f01d4aca052b7aaed794669cbc24a2d8d3f8cef21e5855c3523f9e363d9db9f4376190f655fc2370debfafadb272904d83f15d51eeb10
|
data/.github/workflows/ci.yml
CHANGED
@@ -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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
42
|
+
- Symbolise details hash ([#8](https://github.com/alphagov/content_block_tools/pull/8))
|
35
43
|
|
36
44
|
## 0.2.1
|
37
45
|
|
38
|
-
|
46
|
+
- Loosen ActionView dependency ([#7](https://github.com/alphagov/content_block_tools/pull/7))
|
39
47
|
|
40
48
|
## 0.2.0
|
41
49
|
|
42
|
-
|
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
|
-
|
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
|
data/lib/content_block_tools.rb
CHANGED
@@ -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.
|
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-
|
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.
|
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: []
|