slimmer 13.0.0 → 13.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +30 -0
- data/Rakefile +4 -4
- data/bin/render_slimmer_error +13 -14
- data/lib/slimmer.rb +26 -26
- data/lib/slimmer/app.rb +34 -26
- data/lib/slimmer/cucumber.rb +2 -2
- data/lib/slimmer/headers.rb +20 -13
- data/lib/slimmer/processors/body_class_copier.rb +4 -4
- data/lib/slimmer/processors/body_inserter.rb +4 -4
- data/lib/slimmer/processors/conditional_comment_mover.rb +2 -4
- data/lib/slimmer/processors/footer_remover.rb +1 -1
- data/lib/slimmer/processors/header_context_inserter.rb +3 -3
- data/lib/slimmer/processors/inside_header_inserter.rb +2 -2
- data/lib/slimmer/processors/metadata_inserter.rb +10 -10
- data/lib/slimmer/processors/navigation_mover.rb +4 -5
- data/lib/slimmer/processors/search_parameter_inserter.rb +7 -7
- data/lib/slimmer/processors/search_path_setter.rb +3 -3
- data/lib/slimmer/processors/search_remover.rb +1 -1
- data/lib/slimmer/processors/tag_mover.rb +11 -9
- data/lib/slimmer/processors/title_inserter.rb +6 -6
- data/lib/slimmer/railtie.rb +11 -2
- data/lib/slimmer/rspec.rb +3 -3
- data/lib/slimmer/skin.rb +16 -16
- data/lib/slimmer/test.rb +3 -3
- data/lib/slimmer/test_templates/header_footer_only.html +2 -0
- data/lib/slimmer/test_templates/wrapper.html +2 -0
- data/lib/slimmer/version.rb +1 -1
- data/lib/tasks/slimmer.rake +2 -2
- metadata +61 -49
- data/lib/tasks/lint.rake +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 29c95c6ec5fcb3d786e88628da00aa44018de1a338e49359d19088db092ea025
|
4
|
+
data.tar.gz: 5c2f32ef832e751dc5812af7cb9d388fd4a36c8bde03d9525f58b7a46b5f0e87
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 111d7b5964863534428a2a6b9f46252f49624cb226c524e6c048cbff155c2a37d96cf14f85ade73d71b9b8bbeef1065596f9e795682f7f4fe913529fb0225116
|
7
|
+
data.tar.gz: 182cab20358b7ae4b69b17c11b19ddb6697e54bd94cd66575478bdc0fa11d6a03597d9788ec4c03b6da22f6ccbb5a4156042aaecb433b1c7ddc907c2e3b7934f
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,33 @@
|
|
1
|
+
# 13.3.0
|
2
|
+
|
3
|
+
* Add X-Slimmer-Ignore-Error header flag to prevent overriding non-200 status responses
|
4
|
+
|
5
|
+
# 13.2.2
|
6
|
+
|
7
|
+
* Fix bug where parent_name was called without app
|
8
|
+
|
9
|
+
# 13.2.1
|
10
|
+
|
11
|
+
* Fix deprecation warning: `Module#parent_name` has been renamed to
|
12
|
+
`module_parent_name`. `parent_name` is deprecated and will be removed in
|
13
|
+
Rails 6.1. (#237)
|
14
|
+
* Migrate from govuk-lint to rubocop-govuk (#237)
|
15
|
+
* Remove lint rake task (#237)
|
16
|
+
* Fix linting issues (#237)
|
17
|
+
* Fix deprecation warning: Mocha deprecation warning at
|
18
|
+
/my/local/path/to/test/test_helper.rb:6:in 'require': Require
|
19
|
+
'mocha/test_unit', 'mocha/minitest' or 'mocha/api' instead of 'mocha/setup'.
|
20
|
+
(#237)
|
21
|
+
|
22
|
+
# 13.2.0
|
23
|
+
|
24
|
+
* Upgrade Ruby version to 2.6.5. (#234)
|
25
|
+
* Fix linting issues. (#234)
|
26
|
+
|
27
|
+
# 13.1.0
|
28
|
+
|
29
|
+
* Add `js-enabled` to body tag of test templates. (#226)
|
30
|
+
|
1
31
|
# 13.0.0
|
2
32
|
|
3
33
|
* Drop cache TTL to 60 seconds.
|
data/Rakefile
CHANGED
@@ -2,9 +2,9 @@
|
|
2
2
|
|
3
3
|
require "bundler/gem_tasks"
|
4
4
|
require "rdoc/task"
|
5
|
-
require
|
5
|
+
require "rake/testtask"
|
6
6
|
|
7
|
-
Dir.glob(
|
7
|
+
Dir.glob("lib/tasks/*.rake").each { |r| import r }
|
8
8
|
|
9
9
|
RDoc::Task.new do |rd|
|
10
10
|
rd.rdoc_files.include("lib/**/*.rb")
|
@@ -12,10 +12,10 @@ RDoc::Task.new do |rd|
|
|
12
12
|
end
|
13
13
|
|
14
14
|
Rake::TestTask.new("test") do |t|
|
15
|
-
t.ruby_opts << "-
|
15
|
+
t.ruby_opts << "-rrubygems"
|
16
16
|
t.libs << "test"
|
17
17
|
t.test_files = FileList["test/**/*_test.rb"]
|
18
18
|
t.verbose = true
|
19
19
|
end
|
20
20
|
|
21
|
-
task :
|
21
|
+
task default: %i[test]
|
data/bin/render_slimmer_error
CHANGED
@@ -1,26 +1,25 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require "optparse"
|
4
|
+
require "slimmer"
|
5
|
+
require "logger"
|
6
6
|
|
7
7
|
options = {}
|
8
|
-
OptionParser.new do |opts|
|
9
|
-
opts.on
|
10
|
-
'Template to render' do |v|
|
8
|
+
option_parser = OptionParser.new do |opts|
|
9
|
+
opts.on "-t", "--template=TEMPLATE", "Template to render" do |v|
|
11
10
|
options[:template] = v
|
12
11
|
end
|
13
12
|
|
14
|
-
opts.on
|
15
|
-
'Host that serves assets used in the template' do |v|
|
13
|
+
opts.on "-h", "--asset-host=HOST", "Host that serves assets used in the template" do |v|
|
16
14
|
options[:asset_host] = v
|
17
15
|
end
|
18
16
|
|
19
|
-
opts.on
|
20
|
-
'File to write static error page to' do |v|
|
17
|
+
opts.on "-o", "--output-file=FILE", "File to write static error page to" do |v|
|
21
18
|
options[:file] = v
|
22
19
|
end
|
23
|
-
end
|
20
|
+
end
|
21
|
+
|
22
|
+
option_parser.parse!
|
24
23
|
|
25
24
|
raise "Please specify a template" unless options[:template]
|
26
25
|
raise "Please specify an asset host" unless options[:asset_host]
|
@@ -28,13 +27,13 @@ raise "Please specify an output file" unless options[:file]
|
|
28
27
|
|
29
28
|
logger = Logger.new STDOUT
|
30
29
|
logger.level = Logger::DEBUG
|
31
|
-
skin = Slimmer::Skin.new options[:asset_host], false, :
|
30
|
+
skin = Slimmer::Skin.new options[:asset_host], false, logger: logger
|
32
31
|
static_error = skin.error nil, options[:template], Nokogiri::HTML("").to_html
|
33
32
|
|
34
|
-
if options[:file] ==
|
33
|
+
if options[:file] == "-"
|
35
34
|
STDOUT.print static_error
|
36
35
|
else
|
37
|
-
File.open options[:file],
|
36
|
+
File.open options[:file], "w" do |f|
|
38
37
|
f.print static_error
|
39
38
|
end
|
40
39
|
end
|
data/lib/slimmer.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
require
|
1
|
+
require "nokogiri"
|
2
|
+
require "erb"
|
3
|
+
require "plek"
|
4
|
+
require "null_logger"
|
5
5
|
|
6
|
-
require
|
7
|
-
require
|
6
|
+
require "slimmer/version"
|
7
|
+
require "slimmer/railtie" if defined? Rails
|
8
8
|
|
9
9
|
module Slimmer
|
10
10
|
CACHE_TTL = 60
|
@@ -19,29 +19,29 @@ module Slimmer
|
|
19
19
|
end
|
20
20
|
end
|
21
21
|
|
22
|
-
autoload :Railtie,
|
23
|
-
autoload :Skin,
|
22
|
+
autoload :Railtie, "slimmer/railtie"
|
23
|
+
autoload :Skin, "slimmer/skin"
|
24
24
|
|
25
|
-
autoload :Template,
|
26
|
-
autoload :App,
|
27
|
-
autoload :Headers,
|
28
|
-
autoload :HTTPClient,
|
25
|
+
autoload :Template, "slimmer/template"
|
26
|
+
autoload :App, "slimmer/app"
|
27
|
+
autoload :Headers, "slimmer/headers"
|
28
|
+
autoload :HTTPClient, "slimmer/http_client"
|
29
29
|
|
30
30
|
module Processors
|
31
|
-
autoload :BodyClassCopier,
|
32
|
-
autoload :BodyInserter,
|
33
|
-
autoload :ConditionalCommentMover,
|
34
|
-
autoload :FooterRemover,
|
35
|
-
autoload :MetadataInserter,
|
36
|
-
autoload :HeaderContextInserter,
|
37
|
-
autoload :InsideHeaderInserter,
|
38
|
-
autoload :NavigationMover,
|
39
|
-
autoload :SearchIndexSetter,
|
40
|
-
autoload :SearchPathSetter,
|
41
|
-
autoload :SearchParameterInserter,
|
42
|
-
autoload :SearchRemover,
|
43
|
-
autoload :TagMover,
|
44
|
-
autoload :TitleInserter,
|
31
|
+
autoload :BodyClassCopier, "slimmer/processors/body_class_copier"
|
32
|
+
autoload :BodyInserter, "slimmer/processors/body_inserter"
|
33
|
+
autoload :ConditionalCommentMover, "slimmer/processors/conditional_comment_mover"
|
34
|
+
autoload :FooterRemover, "slimmer/processors/footer_remover"
|
35
|
+
autoload :MetadataInserter, "slimmer/processors/metadata_inserter"
|
36
|
+
autoload :HeaderContextInserter, "slimmer/processors/header_context_inserter"
|
37
|
+
autoload :InsideHeaderInserter, "slimmer/processors/inside_header_inserter"
|
38
|
+
autoload :NavigationMover, "slimmer/processors/navigation_mover"
|
39
|
+
autoload :SearchIndexSetter, "slimmer/processors/search_index_setter"
|
40
|
+
autoload :SearchPathSetter, "slimmer/processors/search_path_setter"
|
41
|
+
autoload :SearchParameterInserter, "slimmer/processors/search_parameter_inserter"
|
42
|
+
autoload :SearchRemover, "slimmer/processors/search_remover"
|
43
|
+
autoload :TagMover, "slimmer/processors/tag_mover"
|
44
|
+
autoload :TitleInserter, "slimmer/processors/title_inserter"
|
45
45
|
end
|
46
46
|
|
47
47
|
class TemplateNotFoundException < StandardError; end
|
data/lib/slimmer/app.rb
CHANGED
@@ -1,23 +1,20 @@
|
|
1
|
-
require
|
1
|
+
require "slimmer/govuk_request_id"
|
2
2
|
|
3
3
|
module Slimmer
|
4
4
|
class App
|
5
5
|
attr_accessor :logger
|
6
6
|
|
7
|
-
def initialize(app, *args
|
7
|
+
def initialize(app, *args)
|
8
8
|
options = args.first || {}
|
9
9
|
@app = app
|
10
10
|
|
11
11
|
logger = options[:logger] || NullLogger.instance
|
12
12
|
self.logger = logger
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
self.logger.level = 1 # info
|
18
|
-
end
|
13
|
+
if logger&.level&.zero? # Log set to debug level
|
14
|
+
unless options[:enable_debugging]
|
15
|
+
self.logger = logger.dup
|
16
|
+
self.logger.level = 1 # info
|
19
17
|
end
|
20
|
-
rescue NoMethodError # In case logger doesn't respond_to? :level
|
21
18
|
end
|
22
19
|
|
23
20
|
if options.key? :template_path
|
@@ -55,22 +52,27 @@ module Slimmer
|
|
55
52
|
end
|
56
53
|
|
57
54
|
def in_development?
|
58
|
-
ENV[
|
55
|
+
ENV["RAILS_ENV"] == "development"
|
59
56
|
end
|
60
57
|
|
61
58
|
def skip_slimmer_param?(env)
|
62
|
-
skip = Rack::Request.new(env).params[
|
63
|
-
skip
|
59
|
+
skip = Rack::Request.new(env).params["skip_slimmer"]
|
60
|
+
skip && skip.to_i.positive?
|
64
61
|
end
|
65
62
|
|
66
63
|
def skip_slimmer_header?(response)
|
67
64
|
!!response.headers[Headers::SKIP_HEADER]
|
68
65
|
end
|
69
66
|
|
67
|
+
def ignore_error_header?(response)
|
68
|
+
!!response.headers[Headers::IGNORE_ERROR_HEADER]
|
69
|
+
end
|
70
|
+
|
70
71
|
def s(body)
|
71
72
|
return body.to_s unless body.respond_to?(:each)
|
73
|
+
|
72
74
|
b = ""
|
73
|
-
body.each {|a| b << a }
|
75
|
+
body.each { |a| b << a }
|
74
76
|
b
|
75
77
|
end
|
76
78
|
|
@@ -84,30 +86,36 @@ module Slimmer
|
|
84
86
|
request = Rack::Request.new(env)
|
85
87
|
|
86
88
|
# Store the request id so it can be passed on with any template requests
|
87
|
-
GovukRequestId.value = env[
|
89
|
+
GovukRequestId.value = env["HTTP_GOVUK_REQUEST_ID"]
|
90
|
+
|
91
|
+
body = rewritten_body(request, response)
|
92
|
+
|
93
|
+
body = [body] unless body.respond_to?(:each)
|
94
|
+
response.body = body
|
95
|
+
response.headers["Content-Length"] = content_length(response.body)
|
96
|
+
|
97
|
+
response.finish
|
98
|
+
end
|
99
|
+
|
100
|
+
def rewritten_body(request, response)
|
101
|
+
return @skin.success request, response, s(response.body) if ignore_error_header?(response)
|
88
102
|
|
89
|
-
|
103
|
+
case response.status
|
90
104
|
when 200
|
91
105
|
@skin.success request, response, s(response.body)
|
92
106
|
when 403
|
93
|
-
@skin.error
|
107
|
+
@skin.error "403", s(response.body), request.env
|
94
108
|
when 404
|
95
|
-
@skin.error
|
109
|
+
@skin.error "404", s(response.body), request.env
|
96
110
|
when 410
|
97
|
-
@skin.error
|
111
|
+
@skin.error "410", s(response.body), request.env
|
98
112
|
else
|
99
|
-
@skin.error
|
113
|
+
@skin.error "500", s(response.body), request.env
|
100
114
|
end
|
101
|
-
|
102
|
-
rewritten_body = [rewritten_body] unless rewritten_body.respond_to?(:each)
|
103
|
-
response.body = rewritten_body
|
104
|
-
response.headers['Content-Length'] = content_length(response.body)
|
105
|
-
|
106
|
-
response.finish
|
107
115
|
end
|
108
116
|
|
109
117
|
def strip_slimmer_headers(headers)
|
110
|
-
headers.reject {|k,
|
118
|
+
headers.reject { |k, _v| k =~ /\A#{Headers::HEADER_PREFIX}/ }
|
111
119
|
end
|
112
120
|
end
|
113
121
|
end
|
data/lib/slimmer/cucumber.rb
CHANGED
@@ -1,3 +1,3 @@
|
|
1
|
-
require
|
1
|
+
require "cucumber"
|
2
2
|
|
3
|
-
require
|
3
|
+
require "slimmer/test"
|
data/lib/slimmer/headers.rb
CHANGED
@@ -5,7 +5,7 @@ module Slimmer
|
|
5
5
|
InvalidHeader = Class.new(RuntimeError)
|
6
6
|
|
7
7
|
# @private
|
8
|
-
HEADER_PREFIX = "X-Slimmer"
|
8
|
+
HEADER_PREFIX = "X-Slimmer".freeze
|
9
9
|
|
10
10
|
# @private
|
11
11
|
SLIMMER_HEADER_MAPPING = {
|
@@ -20,45 +20,51 @@ module Slimmer
|
|
20
20
|
skip: "Skip",
|
21
21
|
template: "Template",
|
22
22
|
remove_search: "Remove-Search",
|
23
|
-
|
23
|
+
ignore_error: "Ignore-Error",
|
24
|
+
}.freeze
|
24
25
|
|
25
26
|
# @private
|
26
|
-
APPLICATION_NAME_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:application_name]}"
|
27
|
+
APPLICATION_NAME_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:application_name]}".freeze
|
27
28
|
|
28
29
|
# @private
|
29
|
-
FORMAT_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:format]}"
|
30
|
+
FORMAT_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:format]}".freeze
|
30
31
|
|
31
32
|
# @private
|
32
|
-
ORGANISATIONS_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:organisations]}"
|
33
|
+
ORGANISATIONS_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:organisations]}".freeze
|
33
34
|
|
34
35
|
# @private
|
35
|
-
WORLD_LOCATIONS_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:world_locations]}"
|
36
|
+
WORLD_LOCATIONS_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:world_locations]}".freeze
|
36
37
|
|
37
38
|
# @private
|
38
|
-
PAGE_OWNER_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:page_owner]}"
|
39
|
+
PAGE_OWNER_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:page_owner]}".freeze
|
39
40
|
|
40
41
|
# @private
|
41
|
-
RESULT_COUNT_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:result_count]}"
|
42
|
+
RESULT_COUNT_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:result_count]}".freeze
|
42
43
|
|
43
44
|
# @private
|
44
|
-
SEARCH_PATH_HEADER = "#{HEADER_PREFIX}-Search-Path"
|
45
|
+
SEARCH_PATH_HEADER = "#{HEADER_PREFIX}-Search-Path".freeze
|
45
46
|
|
46
47
|
# @private
|
47
|
-
SEARCH_PARAMETERS_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:search_parameters]}"
|
48
|
+
SEARCH_PARAMETERS_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:search_parameters]}".freeze
|
48
49
|
|
49
50
|
# @private
|
50
|
-
SKIP_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:skip]}"
|
51
|
+
SKIP_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:skip]}".freeze
|
51
52
|
|
52
53
|
# @private
|
53
|
-
TEMPLATE_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:template]}"
|
54
|
+
TEMPLATE_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:template]}".freeze
|
54
55
|
|
55
56
|
# @private
|
56
|
-
REMOVE_SEARCH_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:remove_search]}"
|
57
|
+
REMOVE_SEARCH_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:remove_search]}".freeze
|
58
|
+
|
59
|
+
# @private
|
60
|
+
IGNORE_ERROR_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:ignore_error]}".freeze
|
61
|
+
|
57
62
|
|
58
63
|
# Set the "slimmer headers" to configure the page
|
59
64
|
#
|
60
65
|
# @param hash [Hash] the options
|
61
66
|
# @option hash [String] application_name
|
67
|
+
# @option hash [String] ignore_error
|
62
68
|
# @option hash [String] format
|
63
69
|
# @option hash [String] organisations
|
64
70
|
# @option hash [String] page_owner
|
@@ -71,6 +77,7 @@ module Slimmer
|
|
71
77
|
# @option hash [String] world_locations
|
72
78
|
def set_slimmer_headers(hash)
|
73
79
|
raise InvalidHeader if (hash.keys - SLIMMER_HEADER_MAPPING.keys).any?
|
80
|
+
|
74
81
|
SLIMMER_HEADER_MAPPING.each do |hash_key, header_suffix|
|
75
82
|
value = hash[hash_key]
|
76
83
|
headers["#{HEADER_PREFIX}-#{header_suffix}"] = value.to_s if value
|
@@ -2,11 +2,11 @@ module Slimmer::Processors
|
|
2
2
|
class BodyClassCopier
|
3
3
|
def filter(src, dest)
|
4
4
|
src_body_tag = src.at_css("body")
|
5
|
-
dest_body_tag = dest.at_css(
|
5
|
+
dest_body_tag = dest.at_css("body")
|
6
6
|
if src_body_tag.has_attribute?("class")
|
7
|
-
combinded_classes = dest_body_tag.attr(
|
8
|
-
combinded_classes << src_body_tag.attr(
|
9
|
-
dest_body_tag.set_attribute("class", combinded_classes.join(
|
7
|
+
combinded_classes = dest_body_tag.attr("class").to_s.split(/ +/)
|
8
|
+
combinded_classes << src_body_tag.attr("class").to_s.split(/ +/)
|
9
|
+
dest_body_tag.set_attribute("class", combinded_classes.join(" "))
|
10
10
|
end
|
11
11
|
end
|
12
12
|
end
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module Slimmer::Processors
|
2
2
|
class BodyInserter
|
3
|
-
def initialize(source_id=
|
4
|
-
@source_selector =
|
5
|
-
@destination_selector =
|
3
|
+
def initialize(source_id = "wrapper", destination_id = "wrapper")
|
4
|
+
@source_selector = "#" + source_id
|
5
|
+
@destination_selector = "#" + destination_id
|
6
6
|
end
|
7
7
|
|
8
|
-
def filter(src,dest)
|
8
|
+
def filter(src, dest)
|
9
9
|
body = Nokogiri::HTML.fragment(src.at_css(@source_selector).to_html)
|
10
10
|
dest.at_css(@destination_selector).replace(body)
|
11
11
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Slimmer::Processors
|
2
2
|
class ConditionalCommentMover
|
3
3
|
def filter(src, dest)
|
4
|
-
src.xpath(
|
4
|
+
src.xpath("//comment()").each do |comment|
|
5
5
|
if match_conditional_comments(comment)
|
6
|
-
dest.at_xpath(
|
6
|
+
dest.at_xpath("/html/head") << comment
|
7
7
|
end
|
8
8
|
end
|
9
9
|
end
|
@@ -13,5 +13,3 @@ module Slimmer::Processors
|
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
16
|
-
|
17
|
-
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module Slimmer::Processors
|
2
2
|
class HeaderContextInserter
|
3
|
-
def initialize(path=
|
3
|
+
def initialize(path = ".header-context")
|
4
4
|
@path = path
|
5
5
|
end
|
6
6
|
|
7
|
-
def filter(src,dest)
|
8
|
-
if dest.at_css(@path) && replacement = src.at_css(@path)
|
7
|
+
def filter(src, dest)
|
8
|
+
if dest.at_css(@path) && (replacement = src.at_css(@path))
|
9
9
|
header_context = src.fragment(replacement)
|
10
10
|
dest.at_css(@path).replace(header_context)
|
11
11
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Slimmer::Processors
|
2
2
|
class InsideHeaderInserter
|
3
3
|
def filter(src, dest)
|
4
|
-
insertion = src.at_css(
|
4
|
+
insertion = src.at_css(".slimmer-inside-header")
|
5
5
|
|
6
6
|
if insertion
|
7
|
-
logo = dest.at_css(
|
7
|
+
logo = dest.at_css(".header-logo")
|
8
8
|
logo.add_next_sibling(insertion.inner_html) unless logo.nil?
|
9
9
|
end
|
10
10
|
end
|
@@ -5,23 +5,23 @@ module Slimmer::Processors
|
|
5
5
|
@app_name = app_name
|
6
6
|
end
|
7
7
|
|
8
|
-
def filter(
|
9
|
-
head = dest.at_css(
|
8
|
+
def filter(_src, dest)
|
9
|
+
head = dest.at_css("head")
|
10
10
|
|
11
|
-
add_meta_tag(
|
12
|
-
add_meta_tag(
|
13
|
-
add_meta_tag(
|
14
|
-
add_meta_tag(
|
15
|
-
add_meta_tag(
|
11
|
+
add_meta_tag("analytics:organisations", @headers[Slimmer::Headers::ORGANISATIONS_HEADER], head)
|
12
|
+
add_meta_tag("analytics:world-locations", @headers[Slimmer::Headers::WORLD_LOCATIONS_HEADER], head)
|
13
|
+
add_meta_tag("format", @headers[Slimmer::Headers::FORMAT_HEADER], head)
|
14
|
+
add_meta_tag("search-result-count", @headers[Slimmer::Headers::RESULT_COUNT_HEADER], head)
|
15
|
+
add_meta_tag("rendering-application", @app_name, head)
|
16
16
|
end
|
17
17
|
|
18
18
|
private
|
19
19
|
|
20
20
|
def add_meta_tag(name, content, head)
|
21
21
|
if content
|
22
|
-
meta_node = Nokogiri::XML::Node.new(
|
23
|
-
meta_node[
|
24
|
-
meta_node[
|
22
|
+
meta_node = Nokogiri::XML::Node.new("meta", head)
|
23
|
+
meta_node["name"] = "govuk:#{name}"
|
24
|
+
meta_node["content"] = content
|
25
25
|
|
26
26
|
head.add_child(meta_node)
|
27
27
|
end
|
@@ -1,5 +1,4 @@
|
|
1
1
|
class Slimmer::Processors::NavigationMover
|
2
|
-
|
3
2
|
def initialize(skin)
|
4
3
|
@skin = skin
|
5
4
|
end
|
@@ -10,16 +9,16 @@ class Slimmer::Processors::NavigationMover
|
|
10
9
|
if proposition_header && global_header
|
11
10
|
proposition_header.remove
|
12
11
|
|
13
|
-
global_header[
|
12
|
+
global_header["class"] = [global_header["class"], "with-proposition"].compact.join(" ")
|
14
13
|
|
15
14
|
header_block = Nokogiri::HTML.fragment(proposition_header_block)
|
16
|
-
header_block.at_css(
|
15
|
+
header_block.at_css(".content") << proposition_header
|
17
16
|
|
18
|
-
global_header.at_css(
|
17
|
+
global_header.at_css(".header-wrapper") << header_block
|
19
18
|
end
|
20
19
|
end
|
21
20
|
|
22
21
|
def proposition_header_block
|
23
|
-
@proposition_header_block ||= @skin.template(
|
22
|
+
@proposition_header_block ||= @skin.template("proposition_menu")
|
24
23
|
end
|
25
24
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "json"
|
2
2
|
|
3
3
|
module Slimmer::Processors
|
4
4
|
class SearchParameterInserter
|
@@ -6,8 +6,8 @@ module Slimmer::Processors
|
|
6
6
|
@response = response
|
7
7
|
end
|
8
8
|
|
9
|
-
def filter(
|
10
|
-
search_form = page_template.at_css(
|
9
|
+
def filter(_content_document, page_template)
|
10
|
+
search_form = page_template.at_css("form#search")
|
11
11
|
if search_parameters && search_form
|
12
12
|
search_parameters.each_pair do |name, value|
|
13
13
|
# Value can either be a string or an array of values
|
@@ -24,10 +24,10 @@ module Slimmer::Processors
|
|
24
24
|
end
|
25
25
|
|
26
26
|
def add_hidden_input(search_form, name, value)
|
27
|
-
element = Nokogiri::XML::Node.new(
|
28
|
-
element[
|
29
|
-
element[
|
30
|
-
element[
|
27
|
+
element = Nokogiri::XML::Node.new("input", search_form)
|
28
|
+
element["type"] = "hidden"
|
29
|
+
element["name"] = name
|
30
|
+
element["value"] = value.to_s
|
31
31
|
search_form.add_child(element)
|
32
32
|
end
|
33
33
|
|
@@ -4,9 +4,9 @@ module Slimmer::Processors
|
|
4
4
|
@response = response
|
5
5
|
end
|
6
6
|
|
7
|
-
def filter(
|
8
|
-
if search_scope && page_template.at_css(
|
9
|
-
page_template.at_css(
|
7
|
+
def filter(_content_document, page_template)
|
8
|
+
if search_scope && page_template.at_css("form#search")
|
9
|
+
page_template.at_css("form#search").attributes["action"].value = search_scope
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -1,10 +1,10 @@
|
|
1
1
|
module Slimmer::Processors
|
2
2
|
class TagMover
|
3
3
|
def filter(src, dest)
|
4
|
-
move_tags(src, dest,
|
5
|
-
move_tags(src, dest,
|
6
|
-
move_tags(src, dest,
|
7
|
-
move_tags(src, dest,
|
4
|
+
move_tags(src, dest, "script", dest_node: "body", keys: %w(src inner_html))
|
5
|
+
move_tags(src, dest, "link", must_have: %w[href])
|
6
|
+
move_tags(src, dest, "meta", must_have: %w(name content), keys: %w[name content http-equiv], insertion_location: :top)
|
7
|
+
move_tags(src, dest, "meta", must_have: %w(property content), keys: %w(property content), insertion_location: :top)
|
8
8
|
end
|
9
9
|
|
10
10
|
def include_tag?(node, min_attrs)
|
@@ -12,17 +12,19 @@ module Slimmer::Processors
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def tag_fingerprint(node, attrs)
|
15
|
-
attrs.collect do |attr_name|
|
16
|
-
if attr_name ==
|
15
|
+
collected_attrs = attrs.collect do |attr_name|
|
16
|
+
if attr_name == "inner_html"
|
17
17
|
node.content
|
18
18
|
else
|
19
19
|
node.has_attribute?(attr_name) ? node.attr(attr_name) : nil
|
20
20
|
end
|
21
|
-
end
|
21
|
+
end
|
22
|
+
|
23
|
+
collected_attrs.compact.sort
|
22
24
|
end
|
23
25
|
|
24
26
|
def wrap_node(src, node)
|
25
|
-
if node.previous_sibling.to_s =~ /<!--\[if[^\]]+\]><!-->/ && node.next_sibling.to_s ==
|
27
|
+
if node.previous_sibling.to_s =~ /<!--\[if[^\]]+\]><!-->/ && node.next_sibling.to_s == "<!--<![endif]-->"
|
26
28
|
node = Nokogiri::XML::NodeSet.new(src, [node.previous_sibling, node, node.next_sibling])
|
27
29
|
end
|
28
30
|
node
|
@@ -34,7 +36,7 @@ module Slimmer::Processors
|
|
34
36
|
already_there = dest.css(type).map { |node|
|
35
37
|
tag_fingerprint(node, comparison_attrs)
|
36
38
|
}.compact
|
37
|
-
dest_node = opts[:dest_node] ||
|
39
|
+
dest_node = opts[:dest_node] || "head"
|
38
40
|
|
39
41
|
src.css(type).each do |node|
|
40
42
|
if include_tag?(node, min_attrs) && !already_there.include?(tag_fingerprint(node, comparison_attrs))
|
@@ -1,18 +1,18 @@
|
|
1
1
|
module Slimmer::Processors
|
2
2
|
class TitleInserter
|
3
|
-
def filter(src,dest)
|
4
|
-
title = src.at_css(
|
5
|
-
head = dest.at_xpath(
|
3
|
+
def filter(src, dest)
|
4
|
+
title = src.at_css("head title")
|
5
|
+
head = dest.at_xpath("/html/head")
|
6
6
|
if head && title
|
7
|
-
insert_title(title,head)
|
7
|
+
insert_title(title, head)
|
8
8
|
end
|
9
9
|
end
|
10
10
|
|
11
11
|
def insert_title(title, head)
|
12
|
-
if head.at_css(
|
12
|
+
if head.at_css("title").nil?
|
13
13
|
head.first_element_child.nil? ? head << title : head.first_element_child.before(title)
|
14
14
|
else
|
15
|
-
head.at_css(
|
15
|
+
head.at_css("title").replace(title)
|
16
16
|
end
|
17
17
|
end
|
18
18
|
end
|
data/lib/slimmer/railtie.rb
CHANGED
@@ -4,11 +4,20 @@ module Slimmer
|
|
4
4
|
|
5
5
|
initializer "slimmer.configure" do |app|
|
6
6
|
slimmer_config = app.config.slimmer.to_hash
|
7
|
-
|
8
|
-
app_name = ENV['GOVUK_APP_NAME'] || app.class.parent_name
|
7
|
+
app_name = ENV["GOVUK_APP_NAME"] || Slimmer::Railtie.parent_name(app)
|
9
8
|
slimmer_config = slimmer_config.reverse_merge(app_name: app_name)
|
10
9
|
|
11
10
|
app.middleware.use Slimmer::App, slimmer_config
|
12
11
|
end
|
12
|
+
|
13
|
+
# TODO: remove this method when all our apps are in rails 6 and substitute
|
14
|
+
# it with: app_name = ENV['GOVUK_APP_NAME'] || app.class.module_parent_name
|
15
|
+
def self.parent_name(app)
|
16
|
+
if app.class.respond_to?(:module_parent_name)
|
17
|
+
app.class.module_parent_name
|
18
|
+
else
|
19
|
+
app.class.parent_name
|
20
|
+
end
|
21
|
+
end
|
13
22
|
end
|
14
23
|
end
|
data/lib/slimmer/rspec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "rspec/core"
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
3
|
+
require "slimmer"
|
4
|
+
require "slimmer/test"
|
data/lib/slimmer/skin.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
require
|
2
|
-
require
|
1
|
+
require "rest_client"
|
2
|
+
require "slimmer/govuk_request_id"
|
3
3
|
|
4
4
|
module Slimmer
|
5
5
|
class Skin
|
@@ -10,7 +10,7 @@ module Slimmer
|
|
10
10
|
@asset_host = options[:asset_host]
|
11
11
|
|
12
12
|
@logger = options[:logger] || NullLogger.instance
|
13
|
-
@strict = options[:strict] ||
|
13
|
+
@strict = options[:strict] || %w{development test}.include?(ENV["RACK_ENV"])
|
14
14
|
end
|
15
15
|
|
16
16
|
def template(template_name)
|
@@ -30,19 +30,19 @@ module Slimmer
|
|
30
30
|
|
31
31
|
def template_url(template_name)
|
32
32
|
host = asset_host.dup
|
33
|
-
host +=
|
33
|
+
host += "/" unless host =~ /\/$/
|
34
34
|
"#{host}templates/#{template_name}.html.erb"
|
35
35
|
end
|
36
36
|
|
37
|
-
def report_parse_errors_if_strict!(nokogiri_doc,
|
37
|
+
def report_parse_errors_if_strict!(nokogiri_doc, _description_for_error_message)
|
38
38
|
nokogiri_doc
|
39
39
|
end
|
40
40
|
|
41
41
|
def parse_html(html, description_for_error_message)
|
42
42
|
doc = Nokogiri::HTML.parse(html)
|
43
43
|
if strict
|
44
|
-
errors = doc.errors.select
|
45
|
-
if errors.
|
44
|
+
errors = doc.errors.select(&:error?).reject { |e| ignorable?(e) }
|
45
|
+
if !errors.empty?
|
46
46
|
error = errors.first
|
47
47
|
message = "In #{description_for_error_message}: '#{error.message}' at line #{error.line} col #{error.column} (code #{error.code}).\n"
|
48
48
|
message << "Add ?skip_slimmer=1 to the url to show the raw backend request.\n\n"
|
@@ -59,7 +59,7 @@ module Slimmer
|
|
59
59
|
lines = [""] + html.split("\n")
|
60
60
|
from = [1, error.line - context_size].max
|
61
61
|
to = [lines.size - 1, error.line + context_size].min
|
62
|
-
context = (from..to).zip(lines[from..to]).map {|lineno, line| "%4d: %s" % [lineno, line] }
|
62
|
+
context = (from..to).zip(lines[from..to]).map { |lineno, line| "%4d: %s" % [lineno, line] }
|
63
63
|
marker = " " * (error.column - 1) + "-----v"
|
64
64
|
context.insert(context_size, marker)
|
65
65
|
context.join("\n")
|
@@ -70,7 +70,7 @@ module Slimmer
|
|
70
70
|
ignorable_codes.include?(error.code) || error.message.match(/Element script embeds close tag/) || error.message.match(/Unexpected end tag : noscript/)
|
71
71
|
end
|
72
72
|
|
73
|
-
def process(processors,body,template,
|
73
|
+
def process(processors, body, template, _rack_env)
|
74
74
|
logger.debug "Slimmer: starting skinning process"
|
75
75
|
src = parse_html(body.to_s, "backend response")
|
76
76
|
dest = parse_html(template, "template")
|
@@ -92,30 +92,30 @@ module Slimmer
|
|
92
92
|
end
|
93
93
|
|
94
94
|
def success(source_request, response, body)
|
95
|
-
wrapper_id = options[:wrapper_id] ||
|
95
|
+
wrapper_id = options[:wrapper_id] || "wrapper"
|
96
96
|
|
97
97
|
processors = [
|
98
|
-
Processors::TitleInserter.new
|
99
|
-
Processors::TagMover.new
|
98
|
+
Processors::TitleInserter.new,
|
99
|
+
Processors::TagMover.new,
|
100
100
|
Processors::NavigationMover.new(self),
|
101
|
-
Processors::ConditionalCommentMover.new
|
101
|
+
Processors::ConditionalCommentMover.new,
|
102
102
|
Processors::BodyInserter.new(wrapper_id),
|
103
103
|
Processors::BodyClassCopier.new,
|
104
104
|
Processors::InsideHeaderInserter.new,
|
105
|
-
Processors::HeaderContextInserter.new
|
105
|
+
Processors::HeaderContextInserter.new,
|
106
106
|
Processors::MetadataInserter.new(response, options[:app_name]),
|
107
107
|
Processors::SearchParameterInserter.new(response),
|
108
108
|
Processors::SearchPathSetter.new(response),
|
109
109
|
Processors::SearchRemover.new(response.headers),
|
110
110
|
]
|
111
111
|
|
112
|
-
template_name = response.headers[Headers::TEMPLATE_HEADER] ||
|
112
|
+
template_name = response.headers[Headers::TEMPLATE_HEADER] || "core_layout"
|
113
113
|
process(processors, body, template(template_name), source_request.env)
|
114
114
|
end
|
115
115
|
|
116
116
|
def error(template_name, body, rack_env)
|
117
117
|
processors = [
|
118
|
-
Processors::TitleInserter.new
|
118
|
+
Processors::TitleInserter.new,
|
119
119
|
]
|
120
120
|
process(processors, body, template(template_name), rack_env)
|
121
121
|
end
|
data/lib/slimmer/test.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "slimmer/skin"
|
2
2
|
|
3
3
|
module Slimmer
|
4
4
|
class Skin
|
@@ -6,10 +6,10 @@ module Slimmer
|
|
6
6
|
logger.debug "Slimmer: TEST MODE - Loading fixture template from #{__FILE__}"
|
7
7
|
if name =~ /\A(.*)\.raw\z/
|
8
8
|
%{<div id="test-#{$1}"></div>}
|
9
|
-
elsif File.exist?(template_path = File.join(File.dirname(__FILE__),
|
9
|
+
elsif File.exist?(template_path = File.join(File.dirname(__FILE__), "test_templates", "#{name}.html"))
|
10
10
|
File.read(template_path)
|
11
11
|
else
|
12
|
-
File.read(File.join(File.dirname(__FILE__),
|
12
|
+
File.read(File.join(File.dirname(__FILE__), "test_templates", "wrapper.html"))
|
13
13
|
end
|
14
14
|
end
|
15
15
|
end
|
data/lib/slimmer/version.rb
CHANGED
data/lib/tasks/slimmer.rake
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require
|
1
|
+
require "rake"
|
2
2
|
|
3
3
|
namespace :slimmer do
|
4
4
|
desc "Symlink from public directory to static directory"
|
@@ -6,7 +6,7 @@ namespace :slimmer do
|
|
6
6
|
path_to_static = "../static/public"
|
7
7
|
path_to_public = "public"
|
8
8
|
commands = ["cd #{path_to_public}"]
|
9
|
-
|
9
|
+
Dir.glob("../static/public/*") { |f|
|
10
10
|
commands << "ln -s #{path_to_static}/#{f}"
|
11
11
|
}
|
12
12
|
commands << ["cd .."]
|
metadata
CHANGED
@@ -1,31 +1,31 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: slimmer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 13.
|
4
|
+
version: 13.3.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:
|
11
|
+
date: 2020-04-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name:
|
14
|
+
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: json
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
@@ -39,21 +39,21 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: nokogiri
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.
|
47
|
+
version: '1.7'
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 1.
|
54
|
+
version: '1.7'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: null_logger
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -67,21 +67,21 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: plek
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version:
|
75
|
+
version: 1.1.0
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version:
|
82
|
+
version: 1.1.0
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: rack
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - ">="
|
@@ -95,7 +95,7 @@ dependencies:
|
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '0'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
98
|
+
name: rest-client
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
100
100
|
requirements:
|
101
101
|
- - ">="
|
@@ -109,89 +109,89 @@ dependencies:
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
- !ruby/object:Gem::Dependency
|
112
|
-
name:
|
112
|
+
name: minitest
|
113
113
|
requirement: !ruby/object:Gem::Requirement
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - "~>"
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version:
|
117
|
+
version: '5.4'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
requirements:
|
122
|
-
- -
|
122
|
+
- - "~>"
|
123
123
|
- !ruby/object:Gem::Version
|
124
|
-
version:
|
124
|
+
version: '5.4'
|
125
125
|
- !ruby/object:Gem::Dependency
|
126
|
-
name:
|
126
|
+
name: mocha
|
127
127
|
requirement: !ruby/object:Gem::Requirement
|
128
128
|
requirements:
|
129
129
|
- - "~>"
|
130
130
|
- !ruby/object:Gem::Version
|
131
|
-
version: '
|
131
|
+
version: '1.1'
|
132
132
|
type: :development
|
133
133
|
prerelease: false
|
134
134
|
version_requirements: !ruby/object:Gem::Requirement
|
135
135
|
requirements:
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
|
-
version: '
|
138
|
+
version: '1.1'
|
139
139
|
- !ruby/object:Gem::Dependency
|
140
|
-
name:
|
140
|
+
name: rack-test
|
141
141
|
requirement: !ruby/object:Gem::Requirement
|
142
142
|
requirements:
|
143
143
|
- - "~>"
|
144
144
|
- !ruby/object:Gem::Version
|
145
|
-
version: 0.
|
145
|
+
version: 0.6.1
|
146
146
|
type: :development
|
147
147
|
prerelease: false
|
148
148
|
version_requirements: !ruby/object:Gem::Requirement
|
149
149
|
requirements:
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
|
-
version: 0.
|
152
|
+
version: 0.6.1
|
153
153
|
- !ruby/object:Gem::Dependency
|
154
|
-
name:
|
154
|
+
name: rails
|
155
155
|
requirement: !ruby/object:Gem::Requirement
|
156
156
|
requirements:
|
157
157
|
- - "~>"
|
158
158
|
- !ruby/object:Gem::Version
|
159
|
-
version: 0.
|
159
|
+
version: 6.0.2
|
160
160
|
type: :development
|
161
161
|
prerelease: false
|
162
162
|
version_requirements: !ruby/object:Gem::Requirement
|
163
163
|
requirements:
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
|
-
version: 0.
|
166
|
+
version: 6.0.2
|
167
167
|
- !ruby/object:Gem::Dependency
|
168
|
-
name:
|
168
|
+
name: rake
|
169
169
|
requirement: !ruby/object:Gem::Requirement
|
170
170
|
requirements:
|
171
171
|
- - "~>"
|
172
172
|
- !ruby/object:Gem::Version
|
173
|
-
version:
|
173
|
+
version: 0.9.2.2
|
174
174
|
type: :development
|
175
175
|
prerelease: false
|
176
176
|
version_requirements: !ruby/object:Gem::Requirement
|
177
177
|
requirements:
|
178
178
|
- - "~>"
|
179
179
|
- !ruby/object:Gem::Version
|
180
|
-
version:
|
180
|
+
version: 0.9.2.2
|
181
181
|
- !ruby/object:Gem::Dependency
|
182
|
-
name:
|
182
|
+
name: rubocop-govuk
|
183
183
|
requirement: !ruby/object:Gem::Requirement
|
184
184
|
requirements:
|
185
|
-
- -
|
185
|
+
- - "~>"
|
186
186
|
- !ruby/object:Gem::Version
|
187
|
-
version:
|
187
|
+
version: 2.0.0
|
188
188
|
type: :development
|
189
189
|
prerelease: false
|
190
190
|
version_requirements: !ruby/object:Gem::Requirement
|
191
191
|
requirements:
|
192
|
-
- -
|
192
|
+
- - "~>"
|
193
193
|
- !ruby/object:Gem::Version
|
194
|
-
version:
|
194
|
+
version: 2.0.0
|
195
195
|
- !ruby/object:Gem::Dependency
|
196
196
|
name: timecop
|
197
197
|
requirement: !ruby/object:Gem::Requirement
|
@@ -207,19 +207,33 @@ dependencies:
|
|
207
207
|
- !ruby/object:Gem::Version
|
208
208
|
version: 0.5.1
|
209
209
|
- !ruby/object:Gem::Dependency
|
210
|
-
name:
|
210
|
+
name: webmock
|
211
211
|
requirement: !ruby/object:Gem::Requirement
|
212
212
|
requirements:
|
213
|
-
- -
|
213
|
+
- - '='
|
214
214
|
- !ruby/object:Gem::Version
|
215
|
-
version:
|
215
|
+
version: 3.5.0
|
216
216
|
type: :development
|
217
217
|
prerelease: false
|
218
218
|
version_requirements: !ruby/object:Gem::Requirement
|
219
219
|
requirements:
|
220
|
-
- -
|
220
|
+
- - '='
|
221
221
|
- !ruby/object:Gem::Version
|
222
|
-
version:
|
222
|
+
version: 3.5.0
|
223
|
+
- !ruby/object:Gem::Dependency
|
224
|
+
name: yard
|
225
|
+
requirement: !ruby/object:Gem::Requirement
|
226
|
+
requirements:
|
227
|
+
- - '='
|
228
|
+
- !ruby/object:Gem::Version
|
229
|
+
version: 0.8.7.6
|
230
|
+
type: :development
|
231
|
+
prerelease: false
|
232
|
+
version_requirements: !ruby/object:Gem::Requirement
|
233
|
+
requirements:
|
234
|
+
- - '='
|
235
|
+
- !ruby/object:Gem::Version
|
236
|
+
version: 0.8.7.6
|
223
237
|
description: Rack middleware for skinning pages using a specific template
|
224
238
|
email:
|
225
239
|
- govuk-dev@digital.cabinet-office.gov.uk
|
@@ -260,7 +274,6 @@ files:
|
|
260
274
|
- lib/slimmer/test_templates/proposition_menu.html
|
261
275
|
- lib/slimmer/test_templates/wrapper.html
|
262
276
|
- lib/slimmer/version.rb
|
263
|
-
- lib/tasks/lint.rake
|
264
277
|
- lib/tasks/slimmer.rake
|
265
278
|
homepage: http://github.com/alphagov/slimmer
|
266
279
|
licenses:
|
@@ -281,8 +294,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
281
294
|
- !ruby/object:Gem::Version
|
282
295
|
version: '0'
|
283
296
|
requirements: []
|
284
|
-
|
285
|
-
rubygems_version: 2.5.1
|
297
|
+
rubygems_version: 3.0.3
|
286
298
|
signing_key:
|
287
299
|
specification_version: 4
|
288
300
|
summary: Thinner than the skinner
|
data/lib/tasks/lint.rake
DELETED