content_block_tools 1.14.1 → 2.0.0

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: 838582c2538bbe70c10178123a0d45012cc374f311ab2c201248315bdc4a75ca
4
- data.tar.gz: 6df681c851529b676a3c99e9102eb650d14cb4264e6a19c9af090457f6f84faa
3
+ metadata.gz: 99811790c4d8143e24ce25e8363e24daa1f1357abe68e4774e80762540a7a99e
4
+ data.tar.gz: 25d492eae3b951462342163d5d05388556d190e469215ff8e2dd4fb8a8083f21
5
5
  SHA512:
6
- metadata.gz: 2811f4de394ea44cdad0a0b780b8933c6748d65a21b183f33134d1a94e3b8ab3ab1e423ac116ebda8cd84541abdf5487a73101e03612c5ba9b7e834570da592a
7
- data.tar.gz: 4e43661c293351a6e00038116ee6da74e51b43fe9ad6db0c1e5cf1f8b2e758439e537c5c8b73466490f219cdaf76083bcfb7f70aefa9561f78f9909a024dca47
6
+ metadata.gz: 62056453f1c35fb2c14016cb6f514e473f8d6f49208cf7355917086cd0b80b3fd58e5f3e66fc5addd8fc26fcb515e91fc1b9c24e4ce2d975d584c817feaac872
7
+ data.tar.gz: 961d83d5c8bf96dd0699dc58c8f4f60e69b17e9707bd6e9c205dec1b3c981641c6db1431ae068ed389cc4bcac8daf4d362f594ae28c8ef2273ef6e2f3a20c2ff
data/README.md CHANGED
@@ -50,6 +50,20 @@ content_block.render
50
50
 
51
51
  For more information, see the [Documentation](https://www.rubydoc.info/github/alphagov/content_block_tools)
52
52
 
53
+ ## Development
54
+
55
+ ### Running the test suites
56
+
57
+ To run the unit tests:
58
+ ```
59
+ bundle exec rspec
60
+ ```
61
+
62
+ To run the feature tests:
63
+ ```
64
+ bundle exec cucumber
65
+ ```
66
+
53
67
  ## License
54
68
 
55
69
  The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -49,38 +49,6 @@ module ContentBlockTools
49
49
 
50
50
  attr_reader :content_id, :title, :embed_code
51
51
 
52
- # Creates a ContentBlock instance from an embed code string by fetching
53
- # the content item data from the Content Store API.
54
- #
55
- # @param embed_code [String] The embed code string to parse and fetch content for
56
- # @example
57
- # ContentBlock.from_embed_code("{{embed:content_block_pension:2b92cade-549c-4449-9796-e7a3957f3a86}}")
58
- #
59
- # @return [ContentBlock] A new ContentBlock instance populated with data from the Content Store
60
- #
61
- # @raise [ContentBlockTools::InvalidEmbedCodeError] if the embed code format is invalid
62
- # @raise [GdsApi::HTTPErrorResponse] if the API request fails
63
- #
64
- # @example Create a ContentBlock from an embed code
65
- # embed_code = "{{embed:content_block_email:123e4567-e89b-12d3-a456-426614174000}}"
66
- # content_block = ContentBlock.from_embed_code(embed_code)
67
- # content_block.title #=> "Contact Email"
68
- # content_block.document_type #=> "email"
69
- #
70
- # @see ContentBlockReference.from_string
71
- # @see GdsApi.content_store
72
- def self.from_embed_code(embed_code)
73
- reference = ContentBlockReference.from_string(embed_code)
74
- api_response = GdsApi.content_store.content_item(reference.content_store_identifier)
75
- new(
76
- content_id: api_response["content_id"],
77
- title: api_response["title"],
78
- document_type: api_response["document_type"],
79
- details: api_response["details"],
80
- embed_code:,
81
- )
82
- end
83
-
84
52
  def initialize(content_id:, title:, document_type:, details:, embed_code:)
85
53
  @content_id = content_id
86
54
  @title = title
@@ -52,21 +52,6 @@ module ContentBlockTools
52
52
  !identifier.match?(UUID_REGEX)
53
53
  end
54
54
 
55
- # Returns the content store path for this content block reference
56
- #
57
- # Constructs a path used to identify and retrieve the content block from the content store.
58
- # The path follows the format `/content-blocks/{document_type}/{identifier}`.
59
- #
60
- # @example
61
- # reference = ContentBlockReference.new(document_type: "content_block_contact", identifier: "some-slug", embed_code: "...")
62
- # reference.content_store_identifier
63
- # #=> "/content-blocks/content_block_contact/some-slug"
64
- #
65
- # @return [String] the content store path for this content block
66
- def content_store_identifier
67
- "/content-blocks/#{document_type}/#{identifier}"
68
- end
69
-
70
55
  class << self
71
56
  # Finds all content block references within a document, using `ContentBlockReference::EMBED_REGEX`
72
57
  # to scan through the document
@@ -5,8 +5,8 @@ module ContentBlockTools
5
5
  # fields to render. The format is:
6
6
  # {{embed:block_type:identifier}}
7
7
  # {{embed:block_type:identifier/field1/nested_field2}}
8
- # {{embed:block_type:identifier|format}}
9
- # {{embed:block_type:identifier/field1|format}}
8
+ # {{embed:block_type:identifier#format}}
9
+ # {{embed:block_type:identifier/field1#format}}
10
10
  #
11
11
  # @example Basic embed code
12
12
  # embed_code = EmbedCode.new("{{embed:content_block_contact:main-office}}")
@@ -4,7 +4,7 @@ module ContentBlockTools
4
4
  module Pension
5
5
  class AmountPresenter < BasePresenter
6
6
  def render
7
- field.start_with?("£") ? field : "£#{field}"
7
+ "£#{field}"
8
8
  end
9
9
  end
10
10
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ContentBlockTools
4
- VERSION = "1.14.1"
4
+ VERSION = "2.0.0"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: content_block_tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.14.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
@@ -1117,14 +1117,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
1117
1117
  requirements:
1118
1118
  - - ">="
1119
1119
  - !ruby/object:Gem::Version
1120
- version: '3.2'
1120
+ version: '3.3'
1121
1121
  required_rubygems_version: !ruby/object:Gem::Requirement
1122
1122
  requirements:
1123
1123
  - - ">="
1124
1124
  - !ruby/object:Gem::Version
1125
1125
  version: '0'
1126
1126
  requirements: []
1127
- rubygems_version: 4.0.12
1127
+ rubygems_version: 4.0.18
1128
1128
  specification_version: 4
1129
1129
  summary: A suite of tools for working with GOV.UK Content Blocks
1130
1130
  test_files: []