heroku-deflater 0.6.3 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +11 -0
- data/Gemfile +8 -5
- data/Gemfile.lock +144 -140
- data/README.md +16 -12
- data/Rakefile +7 -32
- data/heroku-deflater.gemspec +17 -65
- data/lib/heroku-deflater/cache_control_manager.rb +5 -19
- data/lib/heroku-deflater/railtie.rb +20 -8
- data/lib/heroku-deflater/serve_zipped_assets.rb +10 -11
- data/lib/heroku-deflater/skip_binary.rb +1 -1
- data/lib/heroku-deflater/version.rb +5 -0
- data/lib/heroku-deflater.rb +6 -0
- metadata +12 -88
- data/spec/cache_control_manager_spec.rb +0 -68
- data/spec/fixtures/assets/spec.js +0 -6
- data/spec/fixtures/assets/spec.js.gz +0 -0
- data/spec/fixtures/assets/spec2.js +0 -4
- data/spec/fixtures/non-assets/spec.js.gz +0 -0
- data/spec/serve_zipped_assets_spec.rb +0 -80
- data/spec/skip_binary_spec.rb +0 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: bc43fb6e8ecff5ba8ba4a374e79dfd2353c049830026161cb57cfdea433a37dd
|
4
|
+
data.tar.gz: cb450b53c9d7b8cb46f9bdedccbec4b5d88d0eab53cbdc5ab4d7d8318e2ba40e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 80c79692c6397ea1c49c63c0a7054ad6de941b5484e2928b0c5724c7aa48b59d1251316b4278a7608edd4e1e89646d1820000f2495b532263c7b2048923e2540
|
7
|
+
data.tar.gz: e3e1738333089af3c793573c091471d825f59dab1803e84acdd2e5390fb4307d7cc25ccae327972e0b767ef86a44f3dd1a20d01ae0c3905c7e73e2291c7dc687
|
data/.gitignore
ADDED
data/Gemfile
CHANGED
@@ -1,10 +1,13 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source 'https://rubygems.org'
|
4
|
+
|
5
|
+
gemspec
|
2
6
|
|
3
7
|
gem 'rack', '>=1.4.5'
|
4
8
|
|
5
9
|
group :development do
|
6
|
-
gem
|
7
|
-
gem
|
8
|
-
gem
|
9
|
-
gem "rails"
|
10
|
+
gem 'bundler'
|
11
|
+
gem 'rspec'
|
12
|
+
gem 'rails', '~>6.0.3.1'
|
10
13
|
end
|
data/Gemfile.lock
CHANGED
@@ -1,170 +1,174 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
heroku-deflater (0.7.0)
|
5
|
+
|
1
6
|
GEM
|
2
|
-
remote:
|
7
|
+
remote: https://rubygems.org/
|
3
8
|
specs:
|
4
|
-
actioncable (
|
5
|
-
actionpack (=
|
6
|
-
nio4r (~>
|
7
|
-
websocket-driver (
|
8
|
-
|
9
|
-
actionpack (=
|
10
|
-
|
11
|
-
|
9
|
+
actioncable (6.0.3.7)
|
10
|
+
actionpack (= 6.0.3.7)
|
11
|
+
nio4r (~> 2.0)
|
12
|
+
websocket-driver (>= 0.6.1)
|
13
|
+
actionmailbox (6.0.3.7)
|
14
|
+
actionpack (= 6.0.3.7)
|
15
|
+
activejob (= 6.0.3.7)
|
16
|
+
activerecord (= 6.0.3.7)
|
17
|
+
activestorage (= 6.0.3.7)
|
18
|
+
activesupport (= 6.0.3.7)
|
19
|
+
mail (>= 2.7.1)
|
20
|
+
actionmailer (6.0.3.7)
|
21
|
+
actionpack (= 6.0.3.7)
|
22
|
+
actionview (= 6.0.3.7)
|
23
|
+
activejob (= 6.0.3.7)
|
12
24
|
mail (~> 2.5, >= 2.5.4)
|
13
25
|
rails-dom-testing (~> 2.0)
|
14
|
-
actionpack (
|
15
|
-
actionview (=
|
16
|
-
activesupport (=
|
17
|
-
rack (~> 2.0)
|
18
|
-
rack-test (
|
26
|
+
actionpack (6.0.3.7)
|
27
|
+
actionview (= 6.0.3.7)
|
28
|
+
activesupport (= 6.0.3.7)
|
29
|
+
rack (~> 2.0, >= 2.0.8)
|
30
|
+
rack-test (>= 0.6.3)
|
19
31
|
rails-dom-testing (~> 2.0)
|
20
|
-
rails-html-sanitizer (~> 1.0, >= 1.0
|
21
|
-
|
22
|
-
|
32
|
+
rails-html-sanitizer (~> 1.0, >= 1.2.0)
|
33
|
+
actiontext (6.0.3.7)
|
34
|
+
actionpack (= 6.0.3.7)
|
35
|
+
activerecord (= 6.0.3.7)
|
36
|
+
activestorage (= 6.0.3.7)
|
37
|
+
activesupport (= 6.0.3.7)
|
38
|
+
nokogiri (>= 1.8.5)
|
39
|
+
actionview (6.0.3.7)
|
40
|
+
activesupport (= 6.0.3.7)
|
23
41
|
builder (~> 3.1)
|
24
|
-
|
42
|
+
erubi (~> 1.4)
|
25
43
|
rails-dom-testing (~> 2.0)
|
26
|
-
rails-html-sanitizer (~> 1.
|
27
|
-
activejob (
|
28
|
-
activesupport (=
|
44
|
+
rails-html-sanitizer (~> 1.1, >= 1.2.0)
|
45
|
+
activejob (6.0.3.7)
|
46
|
+
activesupport (= 6.0.3.7)
|
29
47
|
globalid (>= 0.3.6)
|
30
|
-
activemodel (
|
31
|
-
activesupport (=
|
32
|
-
activerecord (
|
33
|
-
activemodel (=
|
34
|
-
activesupport (=
|
35
|
-
|
36
|
-
|
48
|
+
activemodel (6.0.3.7)
|
49
|
+
activesupport (= 6.0.3.7)
|
50
|
+
activerecord (6.0.3.7)
|
51
|
+
activemodel (= 6.0.3.7)
|
52
|
+
activesupport (= 6.0.3.7)
|
53
|
+
activestorage (6.0.3.7)
|
54
|
+
actionpack (= 6.0.3.7)
|
55
|
+
activejob (= 6.0.3.7)
|
56
|
+
activerecord (= 6.0.3.7)
|
57
|
+
marcel (~> 1.0.0)
|
58
|
+
activesupport (6.0.3.7)
|
37
59
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
38
|
-
i18n (
|
60
|
+
i18n (>= 0.7, < 2)
|
39
61
|
minitest (~> 5.1)
|
40
62
|
tzinfo (~> 1.1)
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
jwt (~> 1.0)
|
97
|
-
multi_json (~> 1.3)
|
98
|
-
multi_xml (~> 0.5)
|
99
|
-
rack (>= 1.2, < 3)
|
100
|
-
psych (2.2.2)
|
101
|
-
public_suffix (2.0.5)
|
102
|
-
rack (2.0.1)
|
103
|
-
rack-test (0.6.3)
|
104
|
-
rack (>= 1.0)
|
105
|
-
rails (5.0.1)
|
106
|
-
actioncable (= 5.0.1)
|
107
|
-
actionmailer (= 5.0.1)
|
108
|
-
actionpack (= 5.0.1)
|
109
|
-
actionview (= 5.0.1)
|
110
|
-
activejob (= 5.0.1)
|
111
|
-
activemodel (= 5.0.1)
|
112
|
-
activerecord (= 5.0.1)
|
113
|
-
activesupport (= 5.0.1)
|
114
|
-
bundler (>= 1.3.0, < 2.0)
|
115
|
-
railties (= 5.0.1)
|
63
|
+
zeitwerk (~> 2.2, >= 2.2.2)
|
64
|
+
builder (3.2.4)
|
65
|
+
concurrent-ruby (1.2.2)
|
66
|
+
crass (1.0.6)
|
67
|
+
date (3.3.3)
|
68
|
+
diff-lcs (1.5.0)
|
69
|
+
erubi (1.12.0)
|
70
|
+
globalid (1.1.0)
|
71
|
+
activesupport (>= 5.0)
|
72
|
+
i18n (1.14.1)
|
73
|
+
concurrent-ruby (~> 1.0)
|
74
|
+
loofah (2.21.4)
|
75
|
+
crass (~> 1.0.2)
|
76
|
+
nokogiri (>= 1.12.0)
|
77
|
+
mail (2.8.1)
|
78
|
+
mini_mime (>= 0.1.1)
|
79
|
+
net-imap
|
80
|
+
net-pop
|
81
|
+
net-smtp
|
82
|
+
marcel (1.0.2)
|
83
|
+
method_source (1.0.0)
|
84
|
+
mini_mime (1.1.5)
|
85
|
+
mini_portile2 (2.8.4)
|
86
|
+
minitest (5.20.0)
|
87
|
+
net-imap (0.4.1)
|
88
|
+
date
|
89
|
+
net-protocol
|
90
|
+
net-pop (0.1.2)
|
91
|
+
net-protocol
|
92
|
+
net-protocol (0.2.1)
|
93
|
+
timeout
|
94
|
+
net-smtp (0.4.0)
|
95
|
+
net-protocol
|
96
|
+
nio4r (2.5.9)
|
97
|
+
nokogiri (1.15.4)
|
98
|
+
mini_portile2 (~> 2.8.2)
|
99
|
+
racc (~> 1.4)
|
100
|
+
racc (1.7.1)
|
101
|
+
rack (2.2.8)
|
102
|
+
rack-test (2.1.0)
|
103
|
+
rack (>= 1.3)
|
104
|
+
rails (6.0.3.7)
|
105
|
+
actioncable (= 6.0.3.7)
|
106
|
+
actionmailbox (= 6.0.3.7)
|
107
|
+
actionmailer (= 6.0.3.7)
|
108
|
+
actionpack (= 6.0.3.7)
|
109
|
+
actiontext (= 6.0.3.7)
|
110
|
+
actionview (= 6.0.3.7)
|
111
|
+
activejob (= 6.0.3.7)
|
112
|
+
activemodel (= 6.0.3.7)
|
113
|
+
activerecord (= 6.0.3.7)
|
114
|
+
activestorage (= 6.0.3.7)
|
115
|
+
activesupport (= 6.0.3.7)
|
116
|
+
bundler (>= 1.3.0)
|
117
|
+
railties (= 6.0.3.7)
|
116
118
|
sprockets-rails (>= 2.0.0)
|
117
|
-
rails-dom-testing (2.0
|
118
|
-
activesupport (>=
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
119
|
+
rails-dom-testing (2.2.0)
|
120
|
+
activesupport (>= 5.0.0)
|
121
|
+
minitest
|
122
|
+
nokogiri (>= 1.6)
|
123
|
+
rails-html-sanitizer (1.6.0)
|
124
|
+
loofah (~> 2.21)
|
125
|
+
nokogiri (~> 1.14)
|
126
|
+
railties (6.0.3.7)
|
127
|
+
actionpack (= 6.0.3.7)
|
128
|
+
activesupport (= 6.0.3.7)
|
125
129
|
method_source
|
126
130
|
rake (>= 0.8.7)
|
127
|
-
thor (>= 0.
|
128
|
-
rake (
|
129
|
-
|
130
|
-
|
131
|
-
rspec-
|
132
|
-
rspec-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
rspec-expectations (3.5.0)
|
131
|
+
thor (>= 0.20.3, < 2.0)
|
132
|
+
rake (13.0.6)
|
133
|
+
rspec (3.12.0)
|
134
|
+
rspec-core (~> 3.12.0)
|
135
|
+
rspec-expectations (~> 3.12.0)
|
136
|
+
rspec-mocks (~> 3.12.0)
|
137
|
+
rspec-core (3.12.2)
|
138
|
+
rspec-support (~> 3.12.0)
|
139
|
+
rspec-expectations (3.12.3)
|
137
140
|
diff-lcs (>= 1.2.0, < 2.0)
|
138
|
-
rspec-support (~> 3.
|
139
|
-
rspec-mocks (3.
|
141
|
+
rspec-support (~> 3.12.0)
|
142
|
+
rspec-mocks (3.12.6)
|
140
143
|
diff-lcs (>= 1.2.0, < 2.0)
|
141
|
-
rspec-support (~> 3.
|
142
|
-
rspec-support (3.
|
143
|
-
|
144
|
-
sprockets (3.7.1)
|
144
|
+
rspec-support (~> 3.12.0)
|
145
|
+
rspec-support (3.12.1)
|
146
|
+
sprockets (4.2.1)
|
145
147
|
concurrent-ruby (~> 1.0)
|
146
|
-
rack (
|
147
|
-
sprockets-rails (3.2
|
148
|
-
actionpack (>=
|
149
|
-
activesupport (>=
|
148
|
+
rack (>= 2.2.4, < 4)
|
149
|
+
sprockets-rails (3.4.2)
|
150
|
+
actionpack (>= 5.2)
|
151
|
+
activesupport (>= 5.2)
|
150
152
|
sprockets (>= 3.0.0)
|
151
|
-
thor (
|
152
|
-
thread_safe (0.3.
|
153
|
-
|
153
|
+
thor (1.3.0)
|
154
|
+
thread_safe (0.3.6)
|
155
|
+
timeout (0.4.0)
|
156
|
+
tzinfo (1.2.11)
|
154
157
|
thread_safe (~> 0.1)
|
155
|
-
websocket-driver (0.6
|
158
|
+
websocket-driver (0.7.6)
|
156
159
|
websocket-extensions (>= 0.1.0)
|
157
|
-
websocket-extensions (0.1.
|
160
|
+
websocket-extensions (0.1.5)
|
161
|
+
zeitwerk (2.6.12)
|
158
162
|
|
159
163
|
PLATFORMS
|
160
164
|
ruby
|
161
165
|
|
162
166
|
DEPENDENCIES
|
163
167
|
bundler
|
164
|
-
|
168
|
+
heroku-deflater!
|
165
169
|
rack (>= 1.4.5)
|
166
|
-
rails
|
170
|
+
rails (~> 6.0.3.1)
|
167
171
|
rspec
|
168
172
|
|
169
173
|
BUNDLED WITH
|
170
|
-
|
174
|
+
2.2.33
|
data/README.md
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# heroku-deflater
|
2
2
|
|
3
|
-
A simple rack middleware that enables compressing of your
|
4
|
-
responses on Heroku, while not wasting CPU
|
5
|
-
and other binary responses.
|
3
|
+
A simple rack middleware that enables compressing of your sprockets and
|
4
|
+
webpacker assets and application responses on Heroku, while not wasting CPU
|
5
|
+
cycles on pointlessly compressing images and other binary responses.
|
6
6
|
|
7
7
|
It also includes code from https://github.com/mattolson/heroku_rails_deflate
|
8
8
|
|
9
|
-
Before serving a file from disk to a gzip-enabled client, it will look for
|
10
|
-
|
11
|
-
|
9
|
+
Before serving a file from disk to a gzip-enabled client, it will look for a
|
10
|
+
precompressed file in the same location that ends in ".gz". The purpose is to
|
11
|
+
avoid compressing the same file each time it is requested.
|
12
12
|
|
13
13
|
## Installing
|
14
14
|
|
@@ -19,17 +19,21 @@ Add to your Gemfile:
|
|
19
19
|
|
20
20
|
## Contributing to heroku-deflater
|
21
21
|
|
22
|
-
* Check out the latest master to make sure the feature hasn't been implemented
|
23
|
-
|
22
|
+
* Check out the latest master to make sure the feature hasn't been implemented
|
23
|
+
or the bug hasn't been fixed yet.
|
24
|
+
* Check out the issue tracker to make sure someone already hasn't requested it
|
25
|
+
and/or contributed it.
|
24
26
|
* Fork the project.
|
25
27
|
* Start a feature/bugfix branch.
|
26
28
|
* Commit and push until you are happy with your contribution.
|
27
|
-
* Make sure to add tests for it. This is important so I don't break it in a
|
28
|
-
|
29
|
+
* Make sure to add tests for it. This is important so I don't break it in a
|
30
|
+
future version unintentionally.
|
31
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to
|
32
|
+
have your own version, or is otherwise necessary, that is fine, but please
|
33
|
+
isolate to its own commit so I can cherry-pick around it.
|
29
34
|
|
30
35
|
## Copyright
|
31
36
|
|
32
|
-
Copyright (c) 2012 Roman Shterenzon. See LICENSE.txt for
|
33
|
-
further details.
|
37
|
+
Copyright (c) 2012 Roman Shterenzon. See LICENSE.txt for further details.
|
34
38
|
|
35
39
|
[1]: https://github.com/rack/rack/issues/349
|
data/Rakefile
CHANGED
@@ -1,42 +1,17 @@
|
|
1
|
-
#
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require '
|
4
|
-
require 'bundler'
|
3
|
+
require 'bundler/gem_tasks'
|
5
4
|
begin
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
-
exit e.status_code
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
RSpec::Core::RakeTask.new(:spec)
|
7
|
+
rescue LoadError
|
11
8
|
end
|
12
|
-
require 'rake'
|
13
9
|
|
14
|
-
|
15
|
-
Jeweler::Tasks.new do |gem|
|
16
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
-
gem.name = "heroku-deflater"
|
18
|
-
gem.homepage = "http://github.com/romanbsd/heroku-deflater"
|
19
|
-
gem.license = "MIT"
|
20
|
-
gem.summary = %Q{Deflate assets on heroku}
|
21
|
-
gem.description = gem.summary
|
22
|
-
gem.email = "romanbsd@yahoo.com"
|
23
|
-
gem.authors = ["Roman Shterenzon"]
|
24
|
-
# dependencies defined in Gemfile
|
25
|
-
end
|
26
|
-
Jeweler::RubygemsDotOrgTasks.new
|
27
|
-
|
28
|
-
require 'rake/testtask'
|
29
|
-
Rake::TestTask.new(:test) do |test|
|
30
|
-
test.libs << 'lib' << 'test'
|
31
|
-
test.pattern = 'test/**/test_*.rb'
|
32
|
-
test.verbose = true
|
33
|
-
end
|
34
|
-
|
35
|
-
task :default => :test
|
10
|
+
task default: :spec
|
36
11
|
|
37
12
|
require 'rdoc/task'
|
38
13
|
Rake::RDocTask.new do |rdoc|
|
39
|
-
version = File.exist?('VERSION') ? File.read('VERSION') :
|
14
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ''
|
40
15
|
|
41
16
|
rdoc.rdoc_dir = 'rdoc'
|
42
17
|
rdoc.title = "heroku-deflater #{version}"
|
data/heroku-deflater.gemspec
CHANGED
@@ -1,72 +1,24 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: heroku-deflater 0.6.3 ruby lib
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'lib/heroku-deflater/version'
|
6
4
|
|
7
5
|
Gem::Specification.new do |s|
|
8
|
-
s.name =
|
9
|
-
s.version =
|
6
|
+
s.name = 'heroku-deflater'
|
7
|
+
s.version = HerokuDeflater::VERSION
|
8
|
+
s.authors = ['Roman Shterenzon']
|
9
|
+
s.email = 'romanbsd@yahoo.com'
|
10
10
|
|
11
|
-
s.
|
12
|
-
s.
|
13
|
-
s.
|
14
|
-
s.
|
15
|
-
s.
|
16
|
-
s.email = "romanbsd@yahoo.com".freeze
|
11
|
+
s.summary = 'Deflate assets on heroku'
|
12
|
+
s.description = 'Deflate assets on Heroku'
|
13
|
+
s.homepage = 'https://github.com/romanbsd/heroku-deflater'
|
14
|
+
s.required_ruby_version = Gem::Requirement.new('>= 2.3.0')
|
15
|
+
s.require_paths = ['lib']
|
17
16
|
s.extra_rdoc_files = [
|
18
|
-
|
19
|
-
|
20
|
-
]
|
21
|
-
s.files = [
|
22
|
-
".rspec",
|
23
|
-
"Gemfile",
|
24
|
-
"Gemfile.lock",
|
25
|
-
"LICENSE.txt",
|
26
|
-
"README.md",
|
27
|
-
"Rakefile",
|
28
|
-
"VERSION",
|
29
|
-
"heroku-deflater.gemspec",
|
30
|
-
"lib/heroku-deflater.rb",
|
31
|
-
"lib/heroku-deflater/cache_control_manager.rb",
|
32
|
-
"lib/heroku-deflater/railtie.rb",
|
33
|
-
"lib/heroku-deflater/serve_zipped_assets.rb",
|
34
|
-
"lib/heroku-deflater/skip_binary.rb",
|
35
|
-
"spec/cache_control_manager_spec.rb",
|
36
|
-
"spec/fixtures/assets/spec.js",
|
37
|
-
"spec/fixtures/assets/spec.js.gz",
|
38
|
-
"spec/fixtures/assets/spec2.js",
|
39
|
-
"spec/fixtures/non-assets/spec.js.gz",
|
40
|
-
"spec/serve_zipped_assets_spec.rb",
|
41
|
-
"spec/skip_binary_spec.rb"
|
17
|
+
'LICENSE.txt',
|
18
|
+
'README.md'
|
42
19
|
]
|
43
|
-
s.
|
44
|
-
s.
|
45
|
-
|
46
|
-
s.summary = "Deflate assets on heroku".freeze
|
47
|
-
|
48
|
-
if s.respond_to? :specification_version then
|
49
|
-
s.specification_version = 4
|
50
|
-
|
51
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
52
|
-
s.add_runtime_dependency(%q<rack>.freeze, [">= 1.4.5"])
|
53
|
-
s.add_development_dependency(%q<bundler>.freeze, [">= 0"])
|
54
|
-
s.add_development_dependency(%q<jeweler>.freeze, [">= 0"])
|
55
|
-
s.add_development_dependency(%q<rspec>.freeze, [">= 0"])
|
56
|
-
s.add_development_dependency(%q<rails>.freeze, [">= 0"])
|
57
|
-
else
|
58
|
-
s.add_dependency(%q<rack>.freeze, [">= 1.4.5"])
|
59
|
-
s.add_dependency(%q<bundler>.freeze, [">= 0"])
|
60
|
-
s.add_dependency(%q<jeweler>.freeze, [">= 0"])
|
61
|
-
s.add_dependency(%q<rspec>.freeze, [">= 0"])
|
62
|
-
s.add_dependency(%q<rails>.freeze, [">= 0"])
|
63
|
-
end
|
64
|
-
else
|
65
|
-
s.add_dependency(%q<rack>.freeze, [">= 1.4.5"])
|
66
|
-
s.add_dependency(%q<bundler>.freeze, [">= 0"])
|
67
|
-
s.add_dependency(%q<jeweler>.freeze, [">= 0"])
|
68
|
-
s.add_dependency(%q<rspec>.freeze, [">= 0"])
|
69
|
-
s.add_dependency(%q<rails>.freeze, [">= 0"])
|
20
|
+
s.licenses = ['MIT']
|
21
|
+
s.files = Dir.chdir(File.expand_path(__dir__)) do
|
22
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
70
23
|
end
|
71
24
|
end
|
72
|
-
|
@@ -10,30 +10,16 @@ module HerokuDeflater
|
|
10
10
|
|
11
11
|
def setup_max_age(max_age)
|
12
12
|
@max_age = max_age
|
13
|
-
if rails_version_5?
|
14
|
-
app.config.public_file_server.headers ||= {}
|
15
|
-
app.config.public_file_server.headers['Cache-Control'] = cache_control
|
16
|
-
else
|
17
|
-
app.config.static_cache_control = cache_control
|
18
|
-
end
|
19
13
|
end
|
20
14
|
|
21
15
|
def cache_control_headers
|
22
|
-
if rails_version_5?
|
23
|
-
|
16
|
+
if HerokuDeflater.rails_version_5?
|
17
|
+
headers = app.config.public_file_server.headers ||= {}
|
18
|
+
headers['Cache-Control'] ||= "public, max-age=#{max_age}"
|
19
|
+
headers
|
24
20
|
else
|
25
|
-
|
21
|
+
app.config.static_cache_control ||= "public, max-age=#{max_age}"
|
26
22
|
end
|
27
23
|
end
|
28
|
-
|
29
|
-
private
|
30
|
-
|
31
|
-
def rails_version_5?
|
32
|
-
Rails::VERSION::MAJOR >= 5
|
33
|
-
end
|
34
|
-
|
35
|
-
def cache_control
|
36
|
-
@_cache_control ||= "public, max-age=#{max_age}"
|
37
|
-
end
|
38
24
|
end
|
39
25
|
end
|
@@ -8,19 +8,31 @@ module HerokuDeflater
|
|
8
8
|
initializer 'heroku_deflater.configure_rails_initialization' do |app|
|
9
9
|
app.middleware.insert_before ActionDispatch::Static, Rack::Deflater
|
10
10
|
app.middleware.insert_before ActionDispatch::Static, HerokuDeflater::SkipBinary
|
11
|
-
app.middleware.insert_before Rack::Deflater, HerokuDeflater::ServeZippedAssets,
|
12
|
-
app.paths['public'].first, app.config.assets.prefix, self.class.cache_control_manager(app)
|
13
|
-
end
|
14
11
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
12
|
+
assets_prefix = app.config.assets.prefix if app.config.respond_to?(:assets)
|
13
|
+
|
14
|
+
if Object.const_defined?(:Webpacker)
|
15
|
+
public_path = Webpacker.config.public_path.to_s
|
16
|
+
public_output_path = Webpacker.config.public_output_path.to_s
|
17
|
+
webpacker_prefix = public_output_path.split(public_path).last
|
18
|
+
end
|
19
|
+
|
20
|
+
if assets_prefix || webpacker_prefix
|
21
|
+
paths = [assets_prefix, webpacker_prefix].compact
|
22
|
+
app.middleware.insert_before Rack::Deflater, HerokuDeflater::ServeZippedAssets,
|
23
|
+
app.paths['public'].first, paths, self.class.cache_control_manager(app)
|
24
|
+
end
|
20
25
|
end
|
21
26
|
|
22
27
|
def self.cache_control_manager(app)
|
23
28
|
@_cache_control_manager ||= CacheControlManager.new(app)
|
24
29
|
end
|
30
|
+
|
31
|
+
# Set default Cache-Control headers to 24 hours.
|
32
|
+
# The configuration block in config/application.rb overrides this.
|
33
|
+
config.before_initialize do |app|
|
34
|
+
cache_control = cache_control_manager(app)
|
35
|
+
cache_control.setup_max_age(86400)
|
36
|
+
end
|
25
37
|
end
|
26
38
|
end
|
@@ -1,18 +1,22 @@
|
|
1
1
|
require 'action_controller'
|
2
|
-
require 'active_support/core_ext/uri'
|
3
2
|
require 'action_dispatch/middleware/static'
|
4
3
|
|
4
|
+
if Rails::VERSION::MAJOR < 7
|
5
|
+
# Deprecated in Rails 7.0, and removed in 7.1
|
6
|
+
require 'active_support/core_ext/uri'
|
7
|
+
end
|
8
|
+
|
5
9
|
# Adapted from https://gist.github.com/guyboltonking/2152663
|
6
10
|
#
|
7
11
|
# Taken from: https://github.com/mattolson/heroku_rails_deflate
|
8
12
|
#
|
9
|
-
|
10
13
|
module HerokuDeflater
|
11
14
|
class ServeZippedAssets
|
12
|
-
def initialize(app, root,
|
15
|
+
def initialize(app, root, paths, cache_control_manager)
|
13
16
|
@app = app
|
14
|
-
@
|
15
|
-
|
17
|
+
@paths = paths.map { |p| p.chomp('/') + '/' }
|
18
|
+
|
19
|
+
if HerokuDeflater.rails_version_5?
|
16
20
|
@file_handler = ActionDispatch::FileHandler.new(root, headers: cache_control_manager.cache_control_headers)
|
17
21
|
else
|
18
22
|
@file_handler = ActionDispatch::FileHandler.new(root, cache_control_manager.cache_control_headers)
|
@@ -28,7 +32,7 @@ module HerokuDeflater
|
|
28
32
|
# See if gzipped version exists in assets directory
|
29
33
|
compressed_path = env['PATH_INFO'] + '.gz'
|
30
34
|
|
31
|
-
if compressed_path.start_with?(
|
35
|
+
if compressed_path.start_with?(*@paths) && (match = @file_handler.match?(compressed_path))
|
32
36
|
# Get the FileHandler to serve up the gzipped file, then strip the .gz suffix
|
33
37
|
env['PATH_INFO'] = match
|
34
38
|
status, headers, body = @file_handler.call(env)
|
@@ -53,10 +57,5 @@ module HerokuDeflater
|
|
53
57
|
|
54
58
|
@app.call(env)
|
55
59
|
end
|
56
|
-
|
57
|
-
private
|
58
|
-
def rails_version_5?
|
59
|
-
Rails::VERSION::MAJOR >= 5
|
60
|
-
end
|
61
60
|
end
|
62
61
|
end
|
data/lib/heroku-deflater.rb
CHANGED
metadata
CHANGED
@@ -1,86 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: heroku-deflater
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Roman Shterenzon
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
12
|
-
dependencies:
|
13
|
-
|
14
|
-
name: rack
|
15
|
-
requirement: !ruby/object:Gem::Requirement
|
16
|
-
requirements:
|
17
|
-
- - ">="
|
18
|
-
- !ruby/object:Gem::Version
|
19
|
-
version: 1.4.5
|
20
|
-
type: :runtime
|
21
|
-
prerelease: false
|
22
|
-
version_requirements: !ruby/object:Gem::Requirement
|
23
|
-
requirements:
|
24
|
-
- - ">="
|
25
|
-
- !ruby/object:Gem::Version
|
26
|
-
version: 1.4.5
|
27
|
-
- !ruby/object:Gem::Dependency
|
28
|
-
name: bundler
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: jeweler
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
48
|
-
type: :development
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
- !ruby/object:Gem::Dependency
|
56
|
-
name: rspec
|
57
|
-
requirement: !ruby/object:Gem::Requirement
|
58
|
-
requirements:
|
59
|
-
- - ">="
|
60
|
-
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
62
|
-
type: :development
|
63
|
-
prerelease: false
|
64
|
-
version_requirements: !ruby/object:Gem::Requirement
|
65
|
-
requirements:
|
66
|
-
- - ">="
|
67
|
-
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: rails
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :development
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
83
|
-
description: Deflate assets on heroku
|
11
|
+
date: 2023-10-19 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: Deflate assets on Heroku
|
84
14
|
email: romanbsd@yahoo.com
|
85
15
|
executables: []
|
86
16
|
extensions: []
|
@@ -88,6 +18,7 @@ extra_rdoc_files:
|
|
88
18
|
- LICENSE.txt
|
89
19
|
- README.md
|
90
20
|
files:
|
21
|
+
- ".gitignore"
|
91
22
|
- ".rspec"
|
92
23
|
- Gemfile
|
93
24
|
- Gemfile.lock
|
@@ -101,18 +32,12 @@ files:
|
|
101
32
|
- lib/heroku-deflater/railtie.rb
|
102
33
|
- lib/heroku-deflater/serve_zipped_assets.rb
|
103
34
|
- lib/heroku-deflater/skip_binary.rb
|
104
|
-
-
|
105
|
-
|
106
|
-
- spec/fixtures/assets/spec.js.gz
|
107
|
-
- spec/fixtures/assets/spec2.js
|
108
|
-
- spec/fixtures/non-assets/spec.js.gz
|
109
|
-
- spec/serve_zipped_assets_spec.rb
|
110
|
-
- spec/skip_binary_spec.rb
|
111
|
-
homepage: http://github.com/romanbsd/heroku-deflater
|
35
|
+
- lib/heroku-deflater/version.rb
|
36
|
+
homepage: https://github.com/romanbsd/heroku-deflater
|
112
37
|
licenses:
|
113
38
|
- MIT
|
114
39
|
metadata: {}
|
115
|
-
post_install_message:
|
40
|
+
post_install_message:
|
116
41
|
rdoc_options: []
|
117
42
|
require_paths:
|
118
43
|
- lib
|
@@ -120,16 +45,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
120
45
|
requirements:
|
121
46
|
- - ">="
|
122
47
|
- !ruby/object:Gem::Version
|
123
|
-
version:
|
48
|
+
version: 2.3.0
|
124
49
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
125
50
|
requirements:
|
126
51
|
- - ">="
|
127
52
|
- !ruby/object:Gem::Version
|
128
53
|
version: '0'
|
129
54
|
requirements: []
|
130
|
-
|
131
|
-
|
132
|
-
signing_key:
|
55
|
+
rubygems_version: 3.2.33
|
56
|
+
signing_key:
|
133
57
|
specification_version: 4
|
134
58
|
summary: Deflate assets on heroku
|
135
59
|
test_files: []
|
@@ -1,68 +0,0 @@
|
|
1
|
-
require 'heroku-deflater/cache_control_manager'
|
2
|
-
require 'rails'
|
3
|
-
|
4
|
-
describe HerokuDeflater::CacheControlManager do
|
5
|
-
class Rails5App
|
6
|
-
def config
|
7
|
-
@_config ||= Config.new
|
8
|
-
end
|
9
|
-
|
10
|
-
class Config
|
11
|
-
attr_accessor :headers
|
12
|
-
|
13
|
-
def initialize
|
14
|
-
@headers = {}
|
15
|
-
end
|
16
|
-
|
17
|
-
def public_file_server
|
18
|
-
self
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
class Rails4App
|
24
|
-
def config
|
25
|
-
@_config ||= Config.new
|
26
|
-
end
|
27
|
-
|
28
|
-
class Config
|
29
|
-
attr_accessor :static_cache_control
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'Rails 4.x and below' do
|
34
|
-
let(:app) { Rails4App.new }
|
35
|
-
|
36
|
-
subject { described_class.new(app) }
|
37
|
-
before do
|
38
|
-
allow(subject).to receive(:rails_version_5?).and_return(false)
|
39
|
-
subject.setup_max_age(86400)
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'sets max age for static_cache_control config option' do
|
43
|
-
expect(app.config.static_cache_control).to eq('public, max-age=86400')
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'cache_control_headers returns cache control option' do
|
47
|
-
expect(subject.cache_control_headers).to eq('public, max-age=86400')
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
context 'Rails 5' do
|
52
|
-
let(:app) { Rails5App.new }
|
53
|
-
|
54
|
-
subject { described_class.new(app) }
|
55
|
-
before do
|
56
|
-
allow(subject).to receive(:rails_version_5?).and_return(true)
|
57
|
-
subject.setup_max_age(86400)
|
58
|
-
end
|
59
|
-
|
60
|
-
it 'sets max age for public_file_server config option' do
|
61
|
-
expect(app.config.public_file_server.headers['Cache-Control']).to eq('public, max-age=86400')
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'cache_control_headers returns hash cache control headers' do
|
65
|
-
expect(subject.cache_control_headers).to eq({'Cache-Control' =>'public, max-age=86400'})
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
Binary file
|
Binary file
|
@@ -1,80 +0,0 @@
|
|
1
|
-
require 'rack/mock'
|
2
|
-
require 'rack/static'
|
3
|
-
require 'heroku-deflater/serve_zipped_assets'
|
4
|
-
require 'heroku-deflater/cache_control_manager'
|
5
|
-
|
6
|
-
describe HerokuDeflater::ServeZippedAssets do
|
7
|
-
def process(path, accept_encoding = 'compress, gzip, deflate')
|
8
|
-
env = Rack::MockRequest.env_for(path)
|
9
|
-
env['HTTP_ACCEPT_ENCODING'] = accept_encoding
|
10
|
-
app.call(env)
|
11
|
-
end
|
12
|
-
|
13
|
-
def app
|
14
|
-
@app ||= begin
|
15
|
-
root_path = File.expand_path('../fixtures', __FILE__)
|
16
|
-
cache_control_manager = HerokuDeflater::CacheControlManager.new(nil)
|
17
|
-
mock = lambda { |env| [404, {'X-Cascade' => 'pass'}, []] }
|
18
|
-
described_class.new(mock, root_path, '/assets', cache_control_manager)
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
shared_examples_for 'ServeZippedAssets' do
|
23
|
-
|
24
|
-
it 'does nothing for clients which do not want gzip' do
|
25
|
-
status, headers, body = process('/assets/spec.js', nil)
|
26
|
-
expect(status).to eq(404)
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'handles the pre-gzipped assets' do
|
30
|
-
status, headers, body = process('/assets/spec.js')
|
31
|
-
expect(status).to eq(200)
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'has correct content type' do
|
35
|
-
status, headers, body = process('/assets/spec.js')
|
36
|
-
expect(headers['Content-Type']).to eq('application/javascript')
|
37
|
-
end
|
38
|
-
|
39
|
-
it 'has correct content encoding' do
|
40
|
-
status, headers, body = process('/assets/spec.js')
|
41
|
-
expect(headers['Content-Encoding']).to eq('gzip')
|
42
|
-
end
|
43
|
-
|
44
|
-
it 'has correct content length' do
|
45
|
-
status, headers, body = process('/assets/spec.js')
|
46
|
-
expect(headers['Content-Length']).to eq('86')
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'has correct cache control' do
|
50
|
-
status, headers, body = process('/assets/spec.js')
|
51
|
-
expect(headers['Cache-Control']).to eq('public, max-age=86400')
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'does not serve non-gzipped assets' do
|
55
|
-
status, headers, body = process('/assets/spec2.js')
|
56
|
-
expect(status).to eq(404)
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'does not serve anything from non-asset directories' do
|
60
|
-
status, headers, body = process('/non-assets/spec.js')
|
61
|
-
expect(status).to eq(404)
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
describe 'Rais 4.x' do
|
66
|
-
before do
|
67
|
-
allow(app).to receive(:rails_version_5?) { false }
|
68
|
-
end
|
69
|
-
|
70
|
-
it_behaves_like 'ServeZippedAssets'
|
71
|
-
end
|
72
|
-
|
73
|
-
describe 'Rais 5.x' do
|
74
|
-
before do
|
75
|
-
allow(app).to receive(:rails_version_5?) { true }
|
76
|
-
end
|
77
|
-
|
78
|
-
it_behaves_like 'ServeZippedAssets'
|
79
|
-
end
|
80
|
-
end
|
data/spec/skip_binary_spec.rb
DELETED
@@ -1,40 +0,0 @@
|
|
1
|
-
require 'rack/mock'
|
2
|
-
require 'heroku-deflater/skip_binary'
|
3
|
-
|
4
|
-
describe HerokuDeflater::SkipBinary do
|
5
|
-
let(:env) { Rack::MockRequest.env_for('/') }
|
6
|
-
|
7
|
-
def app_returning_type(type, headers = {})
|
8
|
-
lambda { |env| [200, {'Content-Type' => type}.merge(headers), ['']] }
|
9
|
-
end
|
10
|
-
|
11
|
-
def process(type, headers = {})
|
12
|
-
described_class.new(app_returning_type(type, headers)).call(env)[1]
|
13
|
-
end
|
14
|
-
|
15
|
-
it "forbids compressing of binary types" do
|
16
|
-
%w[application/gzip application/pdf image/jpeg].each do |type|
|
17
|
-
headers = process(type)
|
18
|
-
expect(headers['Cache-Control'].to_s).to include('no-transform')
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
it "allows compressing of text types" do
|
23
|
-
%w[text/plain text/html application/json application/javascript
|
24
|
-
application/rss+xml].each do |type|
|
25
|
-
headers = process(type)
|
26
|
-
expect(headers['Cache-Control'].to_s).not_to include('no-transform')
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
it "adds to existing headers" do
|
31
|
-
headers = process('image/gif', 'Cache-Control' => 'public')
|
32
|
-
expect(headers['Cache-Control']).to eq('public, no-transform')
|
33
|
-
end
|
34
|
-
|
35
|
-
it "doesn't add 'no-transform' if it's already present" do
|
36
|
-
headers = process('image/gif', 'Cache-Control' => 'public, no-transform')
|
37
|
-
expect(headers['Cache-Control']).to eq('public, no-transform')
|
38
|
-
end
|
39
|
-
|
40
|
-
end
|