slimmer 9.1.0 → 9.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
  SHA1:
3
- metadata.gz: 75ed5125f21b8ffde308600b2d649d12e45a5166
4
- data.tar.gz: 8a689fb2a310302d865d56dc9b666613360967e8
3
+ metadata.gz: 198037ca5d17fc3fc1467bde87d433ff877907e2
4
+ data.tar.gz: c1c0aaf2f5b4339c30eea89e888b8eea65bfe9af
5
5
  SHA512:
6
- metadata.gz: da744e5afa6a84e8944a05cc20ee2e5da214c1a7af671f4190e1db67e1a34d7a9e5f550c68edd3f912fecb8cc038acd515b7282ec337cde60786eda2128a9a91
7
- data.tar.gz: 24170d05c56821d21052a40aa17899ba27fbefb1e34248cb4b1193d43a10567a689bcad2ad76f60ee869c0cb6cecc5bf5885c13c76344c7aebcfe4cba08467ad
6
+ metadata.gz: bcca6785e9a96d4cf4053ee4d2c2d549390c6b23a9a85f91d6e3259a1916d3a29979ad2014c9c3ca787c70c3ee8db8a532903b418c6c17b187acb600ec691110
7
+ data.tar.gz: bfa3b5cc6ea1831bf2b040bc5a3e3be0699e060e47430e2d96931fb816db0e99df8844467a0f30851ef38bde54d59542624e9cdb7d418bcd5338da31474c8284
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 9.2.0
2
+
3
+ * Raise a custom `CouldNotRetrieveTemplate` exception when a connection to the assets server can't be made because of an SSL problem (PR #143).
4
+
1
5
  # 9.1.0
2
6
 
3
7
  * Allow applications to request components using full or partial component
data/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ # Slimmer
2
+
1
3
  Slimmer provides Rack middleware for applying a standard header and footer around pages
2
4
  returned by a Ruby (Rack) application.
3
5
 
@@ -13,9 +15,11 @@ Plek gem to look for the 'static' (previously 'assets') host for the current env
13
15
  If you want to use your own set of templates you will need to specify the appropriate host
14
16
  eg.
15
17
 
16
- YourApp::Application.configure do
17
- config.slimmer.asset_host = 'http://your.server.somewhere'
18
- end
18
+ ```rb
19
+ YourApp::Application.configure do
20
+ config.slimmer.asset_host = 'http://your.server.somewhere'
21
+ end
22
+ ```
19
23
 
20
24
  it expects to find templates in a folder called 'templates' on that host.
21
25
 
@@ -23,17 +27,23 @@ it expects to find templates in a folder called 'templates' on that host.
23
27
 
24
28
  Slimmer will work as standard rack middleware:
25
29
 
26
- use Slimmer::App
30
+ ```rb
31
+ use Slimmer::App
32
+ ```
27
33
 
28
34
  or
29
35
 
30
- use Slimmer::App, :asset_host => "http://my.alternative.host"
36
+ ```rb
37
+ use Slimmer::App, :asset_host => "http://my.alternative.host"
38
+ ```
31
39
 
32
40
  ## Asset tag helpers
33
41
 
34
42
  To get asset tag helpers to point to your external asset server, add
35
43
 
36
- config.action_controller.asset_host = "http://my.alternative.host"
44
+ ```rb
45
+ config.action_controller.asset_host = "http://my.alternative.host"
46
+ ```
37
47
 
38
48
  to `application.rb`.
39
49
 
@@ -43,23 +53,29 @@ A specific template can be requested by giving its name in the `X-Slimmer-Templa
43
53
 
44
54
  In a controller action, you can do this by calling `slimmer_template`.
45
55
 
46
- class MyController < ApplicationController
47
- def index
48
- slimmer_template 'homepage'
49
- end
50
- end
56
+ ```rb
57
+ class MyController < ApplicationController
58
+ def index
59
+ slimmer_template 'homepage'
60
+ end
61
+ end
62
+ ```
51
63
 
52
64
  There's also a macro style method which will affect all actions:
53
65
 
54
- class YourController < ApplicationController
55
- slimmer_template :admin
56
- end
66
+ ```rb
67
+ class YourController < ApplicationController
68
+ slimmer_template :admin
69
+ end
70
+ ```
57
71
 
58
72
  To get this, include Slimmer::Template in your ApplicationController:
59
73
 
60
- class ApplicationController < ActionController::Base
61
- include Slimmer::Template
62
- end
74
+ ```rb
75
+ class ApplicationController < ActionController::Base
76
+ include Slimmer::Template
77
+ end
78
+ ```
63
79
 
64
80
  ## Logging
65
81
 
@@ -67,9 +83,11 @@ Slimmer can be configured with a logger by passing in a logger instance
67
83
  (anything that quacks like an instance of `Logger`). For example, to log
68
84
  to the Rails log, put the following in an initializer:
69
85
 
70
- YourApp::Application.configure do
71
- config.slimmer.logger = Rails.logger
72
- end
86
+ ```rb
87
+ YourApp::Application.configure do
88
+ config.slimmer.logger = Rails.logger
89
+ end
90
+ ```
73
91
 
74
92
  **Note:** This can't be in `application.rb` because the Rails logger hasn't been initialized by then.
75
93
 
@@ -77,21 +95,27 @@ to the Rails log, put the following in an initializer:
77
95
 
78
96
  By default if you pass in a logger with its log level set to `debug`, slimmer will dup this logger and reduce the level to `info`. (Slimmer's debug logging is very noisy). To prevent this, set the `enable_debugging` option to true. e.g. for Rails:
79
97
 
80
- YourApp::Application.configure do
81
- config.slimmer.enable_debugging = true
82
- end
98
+ ```rb
99
+ YourApp::Application.configure do
100
+ config.slimmer.enable_debugging = true
101
+ end
102
+ ```
83
103
 
84
104
  ## Shared components
85
105
 
86
106
  To use shared template components you need to include the shared template resolver
87
107
 
88
- class ApplicationController < ActionController::Base
89
- include Slimmer::SharedTemplates
90
- end
108
+ ```rb
109
+ class ApplicationController < ActionController::Base
110
+ include Slimmer::SharedTemplates
111
+ end
112
+ ```
91
113
 
92
114
  This will make calls out to static when you try and render a partial prefixed with `govuk-component`:
93
115
 
94
- <%= render partial: 'govuk-component/example_component' %>
116
+ ```erb
117
+ <%= render partial: 'govuk-component/example_component' %>
118
+ ```
95
119
 
96
120
  You will need a copy of static running for the templates to be loaded from.
97
121
 
@@ -105,19 +129,25 @@ A test helper is included which returns a CSS selector for finding a given
105
129
  component to assert that it was used. You can make it available in your tests
106
130
  with:
107
131
 
108
- require 'slimmer/test_helpers/shared_templates'
109
- include Slimmer::TestHelpers::SharedTemplates
132
+ ```rb
133
+ require 'slimmer/test_helpers/shared_templates'
134
+ include Slimmer::TestHelpers::SharedTemplates
135
+ ```
110
136
 
111
137
  And then assert that the component has been used:
112
138
 
113
- page.should have_css(shared_component_selector('metadata'))
139
+ ```rb
140
+ page.should have_css(shared_component_selector('metadata'))
141
+ ```
114
142
 
115
143
  Or look for one of the arguments to the component which will have been
116
144
  `JSON.dump`ed inside the tag:
117
145
 
118
- within(shared_component_selector('title')) do
119
- expect(page).to have_content(expected_title_text)
120
- end
146
+ ```rb
147
+ within(shared_component_selector('title')) do
148
+ expect(page).to have_content(expected_title_text)
149
+ end
150
+ ```
121
151
 
122
152
  ## The name
123
153
 
data/lib/slimmer/skin.rb CHANGED
@@ -28,9 +28,7 @@ module Slimmer
28
28
  response.body
29
29
  rescue RestClient::Exception => e
30
30
  raise TemplateNotFoundException, "Unable to fetch: '#{template_name}' from '#{url}' because #{e}", caller
31
- rescue Errno::ECONNREFUSED => e
32
- raise CouldNotRetrieveTemplate, "Unable to fetch: '#{template_name}' from '#{url}' because #{e}", caller
33
- rescue SocketError => e
31
+ rescue Errno::ECONNREFUSED, SocketError, OpenSSL::SSL::SSLError => e
34
32
  raise CouldNotRetrieveTemplate, "Unable to fetch: '#{template_name}' from '#{url}' because #{e}", caller
35
33
  end
36
34
 
@@ -16,8 +16,8 @@
16
16
 
17
17
  <footer id="footer"></footer>
18
18
 
19
- <script src="https://assets.digital.cabinet-office.gov.uk/static/govuk-template.js" type="text/javascript"></script>
20
- <script src="https://assets.digital.cabinet-office.gov.uk/static/libs/jquery/jquery-1.7.2.js" type="text/javascript"></script>
21
- <script src="https://assets.digital.cabinet-office.gov.uk/static/header-footer-only.js" type="text/javascript"></script>
19
+ <script src="https://assets.publishing.service.gov.uk/static/govuk-template.js" type="text/javascript"></script>
20
+ <script src="https://assets.publishing.service.gov.uk/static/libs/jquery/jquery-1.7.2.js" type="text/javascript"></script>
21
+ <script src="https://assets.publishing.service.gov.uk/static/header-footer-only.js" type="text/javascript"></script>
22
22
  </body>
23
23
  </html>
@@ -16,8 +16,8 @@
16
16
 
17
17
  <footer id="footer"></footer>
18
18
 
19
- <script src="https://assets.digital.cabinet-office.gov.uk/static/govuk-template.js" type="text/javascript"></script>
20
- <script src="https://assets.digital.cabinet-office.gov.uk/static/libs/jquery/jquery-1.7.2.js" type="text/javascript"></script>
21
- <script src="https://assets.digital.cabinet-office.gov.uk/static/application.js" type="text/javascript"></script>
19
+ <script src="https://assets.publishing.service.gov.uk/static/govuk-template.js" type="text/javascript"></script>
20
+ <script src="https://assets.publishing.service.gov.uk/static/libs/jquery/jquery-1.7.2.js" type="text/javascript"></script>
21
+ <script src="https://assets.publishing.service.gov.uk/static/application.js" type="text/javascript"></script>
22
22
  </body>
23
23
  </html>
@@ -1,3 +1,3 @@
1
1
  module Slimmer
2
- VERSION = '9.1.0'
2
+ VERSION = '9.2.0'
3
3
  end
data/test/skin_test.rb CHANGED
@@ -84,6 +84,17 @@ describe Slimmer::Skin do
84
84
  skin.template 'example'
85
85
  end
86
86
  end
87
+
88
+ it "should raise appropriate exception when encountering an SSL error" do
89
+ skin = Slimmer::Skin.new asset_host: "https://bad-ssl.domain/", cache: Slimmer::Cache.instance
90
+
91
+ expected_url = "https://bad-ssl.domain/templates/example.html.erb"
92
+ stub_request(:get, expected_url).to_raise(OpenSSL::SSL::SSLError)
93
+
94
+ assert_raises(Slimmer::CouldNotRetrieveTemplate) do
95
+ skin.template 'example'
96
+ end
97
+ end
87
98
  end
88
99
 
89
100
  describe "parsing artefact from header" do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slimmer
3
3
  version: !ruby/object:Gem::Version
4
- version: 9.1.0
4
+ version: 9.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ben Griffiths
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-02-22 00:00:00.000000000 Z
12
+ date: 2016-07-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: nokogiri
@@ -336,7 +336,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
336
336
  version: '0'
337
337
  requirements: []
338
338
  rubyforge_project: slimmer
339
- rubygems_version: 2.2.5
339
+ rubygems_version: 2.5.1
340
340
  signing_key:
341
341
  specification_version: 4
342
342
  summary: Thinner than the skinner