content_block_tools 2.0.0 → 2.2.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 +4 -4
- data/README.md +0 -14
- data/app/components/content_block_tools/tax_component.rb +7 -7
- data/lib/content_block_tools/presenters/field_presenters/pension/amount_presenter.rb +1 -1
- data/lib/content_block_tools/renderer.rb +7 -3
- data/lib/content_block_tools/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d95412a3ec737416ecb0d2d974c2f5113d160e43d97ba8f4f506008e02da0112
|
|
4
|
+
data.tar.gz: ce284d219102d4294b4e250eedbce6be8890272bf4cfc850841e389a8e7d72ef
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bc16b47625ee69ed16aec061a8c47c1ec0e6ef4bd5f8bedac6568011c1b0ba8c92094601d0f9283e8ed004ec014662200ea6890c4611cc61eab466050b3143c8
|
|
7
|
+
data.tar.gz: ae98f4e61da8a2c05ab3b3e2c6423daa2049235ec3f436dbf5f4e4ab3008c367556f7d5260a6d68ab8d9bee105efc2441cfd5163f881b4fe70eed6accaa1efda
|
data/README.md
CHANGED
|
@@ -50,20 +50,6 @@ 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
|
-
|
|
67
53
|
## License
|
|
68
54
|
|
|
69
55
|
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
|
@@ -8,11 +8,10 @@ module ContentBlockTools
|
|
|
8
8
|
def initialize(content_block:, _block_type: nil, _block_name: nil)
|
|
9
9
|
@content_block = content_block
|
|
10
10
|
validate_format!
|
|
11
|
-
validate_presence_of_income_tax_rates! if tax_table_format?
|
|
12
11
|
end
|
|
13
12
|
|
|
14
13
|
def render
|
|
15
|
-
|
|
14
|
+
raise format_inapplicable_error unless tax_table_format? && able_to_format_as_table?
|
|
16
15
|
|
|
17
16
|
Tax::TaxTableComponent.new(rates: income_tax_rates).render
|
|
18
17
|
end
|
|
@@ -23,17 +22,18 @@ module ContentBlockTools
|
|
|
23
22
|
|
|
24
23
|
delegate :format, :details, to: :content_block
|
|
25
24
|
|
|
25
|
+
def format_inapplicable_error
|
|
26
|
+
InvalidFormatError.new("Cannot render 'tax_table' format: missing income tax rates")
|
|
27
|
+
end
|
|
28
|
+
|
|
26
29
|
def validate_format!
|
|
27
30
|
return if SUPPORTED_FORMATS.include?(format)
|
|
28
31
|
|
|
29
32
|
raise InvalidFormatError, "Unknown format '#{format}' for tax"
|
|
30
33
|
end
|
|
31
34
|
|
|
32
|
-
def
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
raise InvalidFormatError,
|
|
36
|
-
"Cannot render 'tax_table' format: missing income tax rates"
|
|
35
|
+
def able_to_format_as_table?
|
|
36
|
+
income_tax_rates&.present?
|
|
37
37
|
end
|
|
38
38
|
|
|
39
39
|
def tax_table_format?
|
|
@@ -39,14 +39,18 @@ module ContentBlockTools
|
|
|
39
39
|
|
|
40
40
|
attr_reader :content_block
|
|
41
41
|
|
|
42
|
+
def failure_message
|
|
43
|
+
"Unable to render block '#{content_block.title}' #{content_block.embed_code}"
|
|
44
|
+
end
|
|
45
|
+
|
|
42
46
|
def base_tag
|
|
43
47
|
rendering_block? ? :div : :span
|
|
44
48
|
end
|
|
45
49
|
|
|
46
50
|
def content
|
|
47
51
|
internal_content_path.present? ? field_or_block_content : component.new(content_block:).render
|
|
48
|
-
rescue UnknownComponentError
|
|
49
|
-
|
|
52
|
+
rescue UnknownComponentError, InvalidFormatError
|
|
53
|
+
failure_message
|
|
50
54
|
end
|
|
51
55
|
|
|
52
56
|
def field_or_block_content
|
|
@@ -59,7 +63,7 @@ module ContentBlockTools
|
|
|
59
63
|
render_hash_content(field_content)
|
|
60
64
|
else
|
|
61
65
|
log_content_not_found
|
|
62
|
-
|
|
66
|
+
failure_message
|
|
63
67
|
end
|
|
64
68
|
end
|
|
65
69
|
|