govuk_publishing_components 23.10.1 → 23.10.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: d2f681b78ca039b8a55b58be79b935acbb1f8c1ca30e010d8cbc26eaaf1b26b4
4
- data.tar.gz: 0f7fdd2c05953ec4a4ccc73e7335d11195923a62fd959a1f99eebc5a944a0bc1
3
+ metadata.gz: 737265f42ca1a81cb1a854d9858c053b36da1dd49096d4ab271880e40a0d265a
4
+ data.tar.gz: 53e08f6b824be9665c54eb1e421463d63d8a761cc0aa8b432fdea43025fe173f
5
5
  SHA512:
6
- metadata.gz: 070cf7a1d723b8d4aaddb9cfc366ab2f8b25445316efa000f8eacc4ea4c852aa764da637714ff29073fa016f2056b9a6083e1ed35b75629aea3156068f051232
7
- data.tar.gz: e5632bc51e2307471d9b48dd668f8b76ff3c1f52f138e4efd07f09580887d6df510153e13d3aa4bfe5f18396d3d7fedd7ab9067f73297752c950a2c2dd989098
6
+ metadata.gz: d668236b7496da22426217927da594ff3dc3da9a903fafe647ca9ab47cc7877d779aef7dd841dde4b1f514571155a149a8d81bc40ff0b4e506ec8d90eeb6b80b
7
+ data.tar.gz: 5ea78e25ed6a8ca39346ce90b46262b96c793ebd0fcc84a83715378099f029aa2c72bc29f758ba1b414d81fc7a73a3b21e7bd35603313d621d8c7fb112b1364f
@@ -37,15 +37,17 @@ require "govuk_publishing_components/app_helpers/brand_helper"
37
37
  require "govuk_publishing_components/app_helpers/countdown_helper"
38
38
  require "govuk_publishing_components/app_helpers/environment"
39
39
 
40
- # Add view and i18n paths for usage outside of a Rails app
41
- ActionController::Base.append_view_path(
42
- File.expand_path("app/views", GovukPublishingComponents::Config.gem_directory),
43
- )
44
-
40
+ # Add i18n paths and views for usage outside of a Rails app
45
41
  I18n.load_path.unshift(
46
42
  *Dir.glob(File.expand_path("config/locales/*.yml", GovukPublishingComponents::Config.gem_directory)),
47
43
  )
48
44
 
45
+ ActiveSupport.on_load(:action_controller) do
46
+ ActionController::Base.append_view_path(
47
+ File.expand_path("app/views", GovukPublishingComponents::Config.gem_directory),
48
+ )
49
+ end
50
+
49
51
  module GovukPublishingComponents
50
52
  def self.render(component, options = {})
51
53
  I18n.with_locale(options.fetch(:locale, "en")) do
@@ -1,18 +1,18 @@
1
1
  module GovukPublishingComponents
2
2
  module AppHelpers
3
3
  class CountdownHelper
4
- END_OF_TRANSITION_PERIOD = Date.new(2021, 1, 1)
4
+ DEADLINE = Time.new(2020, 12, 31, 23, 59)
5
5
 
6
6
  def days_left
7
- sprintf "%02d", days_left_integer
7
+ sprintf "%02d", days_left_until_deadline
8
8
  end
9
9
 
10
10
  def show?
11
- days_left_integer.positive?
11
+ minutes_left_until_deadline >= 30
12
12
  end
13
13
 
14
14
  def days_text
15
- if days_left_integer == 1
15
+ if days_left_until_deadline == 1
16
16
  I18n.t!("components.transition_countdown.day_to_go")
17
17
  else
18
18
  I18n.t!("components.transition_countdown.days_to_go")
@@ -21,12 +21,28 @@ module GovukPublishingComponents
21
21
 
22
22
  private
23
23
 
24
- def days_left_integer
25
- (END_OF_TRANSITION_PERIOD - today_in_london).to_i
24
+ def days_left_until_deadline
25
+ (minutes_left_until_deadline / 60 / 24).ceil
26
26
  end
27
27
 
28
- def today_in_london
29
- Time.find_zone("Europe/London").today
28
+ def minutes_left_until_deadline
29
+ (seconds_left_until_deadline / 60)
30
+ end
31
+
32
+ def seconds_left_until_deadline
33
+ end_of_transition_period - now_in_london
34
+ end
35
+
36
+ def end_of_transition_period
37
+ london_time_zone(DEADLINE)
38
+ end
39
+
40
+ def now_in_london
41
+ london_time_zone(Time.now)
42
+ end
43
+
44
+ def london_time_zone(time)
45
+ time.in_time_zone("Europe/London")
30
46
  end
31
47
  end
32
48
  end
@@ -1,3 +1,3 @@
1
1
  module GovukPublishingComponents
2
- VERSION = "23.10.1".freeze
2
+ VERSION = "23.10.2".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: govuk_publishing_components
3
3
  version: !ruby/object:Gem::Version
4
- version: 23.10.1
4
+ version: 23.10.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-12-17 00:00:00.000000000 Z
11
+ date: 2020-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: govuk_app_config