content_block_tools 1.9.0 → 1.9.2
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/app/components/content_block_tools/time_period_component.html.erb +5 -0
- data/app/components/content_block_tools/time_period_component.rb +29 -0
- data/lib/content_block_tools/presenters/field_presenters/time_period/time_presenter.rb +24 -0
- data/lib/content_block_tools/version.rb +1 -1
- data/lib/content_block_tools.rb +1 -0
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a2186a0132dec4b10c13a82dae86888e7c3b206136fccfe56d502ff875097b15
|
|
4
|
+
data.tar.gz: 5dcf3d97846ba84c1412a4291316462d71a2851bc1a4894e4d25989877505434
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 88a5a9c70e1c5a174737b040cdbaf47961126a82010ad49a7527bca9b62a7787a75a0d1b9e7b12f1f19151b2a387c567d1e79784fa246f479db95d5513674447
|
|
7
|
+
data.tar.gz: 497c6d67165fc7d80750a29e6f9fb999e5a99abc154acbcede43aac6d9db7ca82c3fa029b98ce0e95084a6fc860f683f443a9b01b5acf7e27a83204de6f53fa4
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
module ContentBlockTools
|
|
2
|
+
class TimePeriodComponent < ContentBlockTools::BaseComponent
|
|
3
|
+
def initialize(content_block:, _block_type: nil, _block_name: nil)
|
|
4
|
+
@content_block = content_block
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
def start_date
|
|
8
|
+
presented_date(
|
|
9
|
+
content_block.details.dig(:date_range, :start, :date),
|
|
10
|
+
)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def end_date
|
|
14
|
+
presented_date(
|
|
15
|
+
content_block.details.dig(:date_range, :end, :date),
|
|
16
|
+
)
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
private
|
|
20
|
+
|
|
21
|
+
attr_reader :content_block
|
|
22
|
+
|
|
23
|
+
def presented_date(date)
|
|
24
|
+
Presenters::FieldPresenters::TimePeriod::DatePresenter.new(
|
|
25
|
+
date,
|
|
26
|
+
).render
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
module ContentBlockTools
|
|
2
|
+
module Presenters
|
|
3
|
+
module FieldPresenters
|
|
4
|
+
module TimePeriod
|
|
5
|
+
class TimePresenter < BasePresenter
|
|
6
|
+
def render
|
|
7
|
+
time = Time.parse(field)
|
|
8
|
+
hour = time.strftime("%H")
|
|
9
|
+
minute = time.strftime("%M")
|
|
10
|
+
|
|
11
|
+
if minute == "00"
|
|
12
|
+
return "midday" if hour == "12"
|
|
13
|
+
return "midnight" if hour == "00"
|
|
14
|
+
|
|
15
|
+
return time.strftime("%l%P").strip
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
time.strftime("%l:%M%P").strip
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
end
|
data/lib/content_block_tools.rb
CHANGED
|
@@ -11,6 +11,7 @@ require "content_block_tools/helpers/override_classes"
|
|
|
11
11
|
require "content_block_tools/presenters/field_presenters/base_presenter"
|
|
12
12
|
require "content_block_tools/presenters/field_presenters/contact/email_presenter"
|
|
13
13
|
require "content_block_tools/presenters/field_presenters/time_period/date_presenter"
|
|
14
|
+
require "content_block_tools/presenters/field_presenters/time_period/time_presenter"
|
|
14
15
|
|
|
15
16
|
require "content_block_tools/content_block"
|
|
16
17
|
require "content_block_tools/content_block_reference"
|
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.9.
|
|
4
|
+
version: 1.9.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- GOV.UK Dev
|
|
@@ -186,6 +186,8 @@ files:
|
|
|
186
186
|
- app/components/content_block_tools/contacts/email_address_component.rb
|
|
187
187
|
- app/components/content_block_tools/contacts/telephone_component.html.erb
|
|
188
188
|
- app/components/content_block_tools/contacts/telephone_component.rb
|
|
189
|
+
- app/components/content_block_tools/time_period_component.html.erb
|
|
190
|
+
- app/components/content_block_tools/time_period_component.rb
|
|
189
191
|
- lib/content_block_tools.rb
|
|
190
192
|
- lib/content_block_tools/content_block.rb
|
|
191
193
|
- lib/content_block_tools/content_block_reference.rb
|
|
@@ -195,6 +197,7 @@ files:
|
|
|
195
197
|
- lib/content_block_tools/presenters/field_presenters/base_presenter.rb
|
|
196
198
|
- lib/content_block_tools/presenters/field_presenters/contact/email_presenter.rb
|
|
197
199
|
- lib/content_block_tools/presenters/field_presenters/time_period/date_presenter.rb
|
|
200
|
+
- lib/content_block_tools/presenters/field_presenters/time_period/time_presenter.rb
|
|
198
201
|
- lib/content_block_tools/version.rb
|
|
199
202
|
- node_modules/govuk-frontend/README.md
|
|
200
203
|
- node_modules/govuk-frontend/dist/govuk-prototype-kit/functions.js
|
|
@@ -1062,7 +1065,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
1062
1065
|
- !ruby/object:Gem::Version
|
|
1063
1066
|
version: '0'
|
|
1064
1067
|
requirements: []
|
|
1065
|
-
rubygems_version: 4.0.
|
|
1068
|
+
rubygems_version: 4.0.7
|
|
1066
1069
|
specification_version: 4
|
|
1067
1070
|
summary: A suite of tools for working with GOV.UK Content Blocks
|
|
1068
1071
|
test_files: []
|