slimmer 15.1.1 → 15.2.0

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: 4146598de4151ad771c4b288b7556ab2a8e6ef88378870a11e108188b8ff248a
4
- data.tar.gz: 06377c22b246a77ac2faad4abed3e10b9cc8ed5d16c6515088ce949a2ea748df
3
+ metadata.gz: adfdc8dd1fa7b69450bbbae9daf9cbd352704a621947aad067fc5aabad239132
4
+ data.tar.gz: ef11b30a4f27806579d0a7e690f9e71b08210d10625722de29b6a320d5cf1840
5
5
  SHA512:
6
- metadata.gz: 8a5d1c2d0f54b7cbdf75c2e82ab4dacf27086786b505a1b63983d97751f64439927bcc81aabf24aa5deeeb0e179616edb246f756a15328d659fdc6a3df218538
7
- data.tar.gz: 3543e2879ef471c1cf87012661c18199c094d4467b5af95aad6979dc68c678a1c1746028faa299eda135b58617c1655e3f73ded277aa98808a5a2173dd8194b3
6
+ metadata.gz: 75bba48992276cc1d656c72271dd6ecb192af0467205cfc12411a8b53b26d65d534f25801b5e70b4a0304fbf08fa6202440891956bd36547f03dc488ec1aee64
7
+ data.tar.gz: '038f855917b3f9fe4d66c0e15737efadd8b4724e23b47dab25573f18962e0b525449780566421f8b07759d17bda1947bdbc1e75ef032752645126fda9a3378d3'
@@ -1,3 +1,9 @@
1
+ # 15.2.0
2
+
3
+ * Add X-Slimmer-Show-Accounts header to choose between accounts
4
+ header components. (#255)
5
+ * Update to Ruby 2.7.2. (#254)
6
+
1
7
  # 15.1.1
2
8
 
3
9
  * Amend toggle button selector (#251)
@@ -28,6 +28,7 @@ module Slimmer
28
28
  autoload :HTTPClient, "slimmer/http_client"
29
29
 
30
30
  module Processors
31
+ autoload :AccountsShower, "slimmer/processors/accounts_shower"
31
32
  autoload :BodyClassCopier, "slimmer/processors/body_class_copier"
32
33
  autoload :BodyInserter, "slimmer/processors/body_inserter"
33
34
  autoload :ConditionalCommentMover, "slimmer/processors/conditional_comment_mover"
@@ -20,6 +20,7 @@ module Slimmer
20
20
  skip: "Skip",
21
21
  template: "Template",
22
22
  remove_search: "Remove-Search",
23
+ show_accounts: "Show-Accounts",
23
24
  }.freeze
24
25
 
25
26
  # @private
@@ -55,6 +56,9 @@ module Slimmer
55
56
  # @private
56
57
  REMOVE_SEARCH_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:remove_search]}".freeze
57
58
 
59
+ # @private
60
+ SHOW_ACCOUNTS_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:show_accounts]}".freeze
61
+
58
62
  # Set the "slimmer headers" to configure the page
59
63
  #
60
64
  # @param hash [Hash] the options
@@ -66,6 +70,7 @@ module Slimmer
66
70
  # @option hash [String] result_count
67
71
  # @option hash [String] search_parameters
68
72
  # @option hash [String] section
73
+ # @option hash [String] show_accounts
69
74
  # @option hash [String] skip
70
75
  # @option hash [String] template
71
76
  # @option hash [String] world_locations
@@ -0,0 +1,29 @@
1
+ module Slimmer::Processors
2
+ class AccountsShower
3
+ def initialize(headers)
4
+ @headers = headers
5
+ end
6
+
7
+ def filter(_src, dest)
8
+ header_value = @headers[Slimmer::Headers::SHOW_ACCOUNTS_HEADER]
9
+ if header_value == "signed-in"
10
+ remove_signed_out(dest)
11
+ elsif header_value == "signed-out"
12
+ remove_signed_in(dest)
13
+ else
14
+ remove_signed_out(dest)
15
+ remove_signed_in(dest)
16
+ end
17
+ end
18
+
19
+ def remove_signed_out(dest)
20
+ signed_out = dest.at_css("#global-header #accounts-signed-out")
21
+ signed_out.remove if signed_out
22
+ end
23
+
24
+ def remove_signed_in(dest)
25
+ signed_in = dest.at_css("#global-header #accounts-signed-in")
26
+ signed_in.remove if signed_in
27
+ end
28
+ end
29
+ end
@@ -107,6 +107,7 @@ module Slimmer
107
107
  Processors::SearchParameterInserter.new(response),
108
108
  Processors::SearchPathSetter.new(response),
109
109
  Processors::SearchRemover.new(response.headers),
110
+ Processors::AccountsShower.new(response.headers),
110
111
  ]
111
112
 
112
113
  template_name = response.headers[Headers::TEMPLATE_HEADER] || "core_layout"
@@ -1,3 +1,3 @@
1
1
  module Slimmer
2
- VERSION = "15.1.1".freeze
2
+ VERSION = "15.2.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slimmer
3
3
  version: !ruby/object:Gem::Version
4
- version: 15.1.1
4
+ version: 15.2.0
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-09-17 00:00:00.000000000 Z
11
+ date: 2020-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -252,6 +252,7 @@ files:
252
252
  - lib/slimmer/govuk_request_id.rb
253
253
  - lib/slimmer/headers.rb
254
254
  - lib/slimmer/http_client.rb
255
+ - lib/slimmer/processors/accounts_shower.rb
255
256
  - lib/slimmer/processors/body_class_copier.rb
256
257
  - lib/slimmer/processors/body_inserter.rb
257
258
  - lib/slimmer/processors/conditional_comment_mover.rb
@@ -294,7 +295,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
294
295
  - !ruby/object:Gem::Version
295
296
  version: '0'
296
297
  requirements: []
297
- rubygems_version: 3.0.3
298
+ rubygems_version: 3.1.4
298
299
  signing_key:
299
300
  specification_version: 4
300
301
  summary: Thinner than the skinner