bankrupt 2.1.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/default.yml +23 -0
- data/.github/workflows/publish.yml +33 -0
- data/.rubocop.yml +12 -2
- data/.ruby-version +1 -0
- data/CHANGELOG.md +5 -0
- data/README.md +2 -4
- data/bankrupt.gemspec +2 -1
- data/lib/bankrupt.rb +7 -6
- data/lib/bankrupt/tasks.rb +9 -9
- data/lib/bankrupt/util.rb +4 -4
- data/lib/bankrupt/version.rb +2 -2
- metadata +21 -5
- data/.travis.yml +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7605a8034097043298a51ba0cea61725c7befef7e7c1456c5dfa80cdeb500a6
|
4
|
+
data.tar.gz: cde2061f0af7b265d5d7cf347318598c2ea8145d566d9fcfed48b4cf4814f492
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d392a244a8aebfbd509e9af128b14795aaf241d6c75b10db9794579f5bb2cbd18e6664b248ac82b39f77d972503438dbbe9d56285e10adbc42c01df5ac2f48c4
|
7
|
+
data.tar.gz: bfba6c8fd639df3b8a5f9dcf3a80f3e62893a1dea003e0087ebda7ed7feff1b308935880ade03de7a859e5f6964587058c9c2f48b2c31eaddc789dfc8b391afa
|
@@ -0,0 +1,23 @@
|
|
1
|
+
---
|
2
|
+
name: CI
|
3
|
+
on: push
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
main:
|
7
|
+
name: ${{ matrix.ruby }}
|
8
|
+
runs-on: ubuntu-latest
|
9
|
+
strategy:
|
10
|
+
fail-fast: false
|
11
|
+
matrix:
|
12
|
+
ruby: [2.5, 2.6, 2.7, 3.0]
|
13
|
+
|
14
|
+
steps:
|
15
|
+
- uses: actions/checkout@v2
|
16
|
+
- uses: ruby/setup-ruby@v1
|
17
|
+
with:
|
18
|
+
ruby-version: ${{ matrix.ruby }}
|
19
|
+
- run: bundle install
|
20
|
+
- run: bundle exec rubocop
|
21
|
+
- run: bundle exec rspec
|
22
|
+
- run: bundle exec yard
|
23
|
+
- run: gem build bankrupt.gemspec
|
@@ -0,0 +1,33 @@
|
|
1
|
+
---
|
2
|
+
name: Publish Rubygem
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
tags:
|
6
|
+
- 'v*'
|
7
|
+
|
8
|
+
jobs:
|
9
|
+
main:
|
10
|
+
name: Release
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
steps:
|
13
|
+
- uses: actions/checkout@v2
|
14
|
+
- uses: ruby/setup-ruby@v1
|
15
|
+
- run: gem build bankrupt.gemspec
|
16
|
+
|
17
|
+
- name: setup credentials
|
18
|
+
run: |
|
19
|
+
mkdir -p $HOME/.gem
|
20
|
+
touch $HOME/.gem/credentials
|
21
|
+
chmod 0600 $HOME/.gem/credentials
|
22
|
+
printf -- "---\n:github: ${GH_API_KEY}\n" > $HOME/.gem/credentials
|
23
|
+
printf -- ":rubygems_api_key: ${RUBYGEMS_API_KEY}\n" >> $HOME/.gem/credentials
|
24
|
+
env:
|
25
|
+
GH_API_KEY: Bearer ${{ secrets.GITHUB_TOKEN }}
|
26
|
+
RUBYGEMS_API_KEY: ${{ secrets.RUBYGEMS_API_KEY }}
|
27
|
+
|
28
|
+
- name: publish to rubygems
|
29
|
+
run: |
|
30
|
+
gem push *.gem
|
31
|
+
- name: publish to github packages
|
32
|
+
run: |
|
33
|
+
gem push --key github --host https://rubygems.pkg.github.com/${{ github.repository_owner }} *.gem
|
data/.rubocop.yml
CHANGED
@@ -1,12 +1,18 @@
|
|
1
1
|
---
|
2
|
-
require:
|
2
|
+
require:
|
3
|
+
- rubocop-rake
|
4
|
+
- rubocop-rspec
|
3
5
|
|
4
6
|
AllCops:
|
5
|
-
|
7
|
+
NewCops: enable
|
8
|
+
TargetRubyVersion: 2.5.0
|
6
9
|
|
7
10
|
Layout/ExtraSpacing:
|
8
11
|
AllowForAlignment: false
|
9
12
|
|
13
|
+
Layout/LineLength:
|
14
|
+
Max: 80
|
15
|
+
|
10
16
|
Metrics/AbcSize:
|
11
17
|
Max: 20
|
12
18
|
|
@@ -23,6 +29,7 @@ RSpec/DescribeClass:
|
|
23
29
|
- 'spec/bankrupt/tasks_spec.rb'
|
24
30
|
|
25
31
|
RSpec/ExampleLength:
|
32
|
+
Max: 6
|
26
33
|
Exclude:
|
27
34
|
- 'spec/bankrupt/tasks_spec.rb'
|
28
35
|
|
@@ -35,3 +42,6 @@ RSpec/MultipleExpectations:
|
|
35
42
|
|
36
43
|
RSpec/NestedGroups:
|
37
44
|
Max: 6
|
45
|
+
|
46
|
+
RSpec/StubbedMock:
|
47
|
+
Enabled: false
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.0.2
|
data/CHANGELOG.md
CHANGED
@@ -3,6 +3,11 @@
|
|
3
3
|
This file keeps track of changes between releases for the bankrupt project
|
4
4
|
which adheres to [semantic versioning](https://semver.org).
|
5
5
|
|
6
|
+
## v3.0.0 2021-08-21
|
7
|
+
|
8
|
+
* Drop support for ruby 2.4.x.
|
9
|
+
* Mark uploaded assets as `immutable` in the `Cache-Control` header.
|
10
|
+
|
6
11
|
## v2.1.2 2020-01-20
|
7
12
|
|
8
13
|
Take options into account to ensure unique asset lookups.
|
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
# Bankrupt
|
2
2
|
|
3
3
|
[](https://rubygems.org/gems/bankrupt)
|
4
|
-
|
4
|
+

|
5
5
|
[](https://coveralls.io/github/mfinelli/bankrupt?branch=master)
|
6
6
|
[](https://codeclimate.com/github/mfinelli/bankrupt/maintainability)
|
7
7
|
[](http://inch-ci.org/github/mfinelli/bankrupt)
|
@@ -156,7 +156,7 @@ end
|
|
156
156
|
## License
|
157
157
|
|
158
158
|
```
|
159
|
-
Copyright 2018-
|
159
|
+
Copyright 2018-2021 Mario Finelli
|
160
160
|
|
161
161
|
Licensed under the Apache License, Version 2.0 (the "License");
|
162
162
|
you may not use this file except in compliance with the License.
|
@@ -170,5 +170,3 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
170
170
|
See the License for the specific language governing permissions and
|
171
171
|
limitations under the License.
|
172
172
|
```
|
173
|
-
|
174
|
-
TODO: tests to ensure the lookups are separate
|
data/bankrupt.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.description = 'Load files from local disk or from a CDN in production.'
|
15
15
|
spec.homepage = 'https://github.com/mfinelli/bankrupt'
|
16
16
|
spec.license = 'Apache-2.0'
|
17
|
-
spec.required_ruby_version = '>= 2.
|
17
|
+
spec.required_ruby_version = '>= 2.5.0'
|
18
18
|
|
19
19
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
20
20
|
f.match(%r{^(test|spec|features)/})
|
@@ -33,6 +33,7 @@ Gem::Specification.new do |spec|
|
|
33
33
|
spec.add_development_dependency 'redcarpet'
|
34
34
|
spec.add_development_dependency 'rspec'
|
35
35
|
spec.add_development_dependency 'rubocop'
|
36
|
+
spec.add_development_dependency 'rubocop-rake'
|
36
37
|
spec.add_development_dependency 'rubocop-rspec'
|
37
38
|
spec.add_development_dependency 'simplecov'
|
38
39
|
spec.add_development_dependency 'yard'
|
data/lib/bankrupt.rb
CHANGED
@@ -82,7 +82,7 @@ module Bankrupt
|
|
82
82
|
# @return [String] full path to the asset
|
83
83
|
def raw(path)
|
84
84
|
details = ASSETS.fetch(path)
|
85
|
-
create_fullpath(path, details[:md5], details[:hashless])
|
85
|
+
create_fullpath(path, details[:md5], hashless: details[:hashless])
|
86
86
|
rescue KeyError
|
87
87
|
"/#{path}"
|
88
88
|
end
|
@@ -92,7 +92,7 @@ module Bankrupt
|
|
92
92
|
# Return a precomputed asset path if it exists
|
93
93
|
#
|
94
94
|
# @param path [String] asset on which to perform the lookup
|
95
|
-
# @
|
95
|
+
# @param options [String] the options string to use in the lookup
|
96
96
|
# @return [String] the rendered slim template with the asset in place
|
97
97
|
def lookup(path, options = nil)
|
98
98
|
if actual_options?(options)
|
@@ -111,7 +111,7 @@ module Bankrupt
|
|
111
111
|
# @param hashless [Boolean] if the file doesn't have the hash appended
|
112
112
|
# @return [String] filename with digest e.g, style-123.css (style.css if
|
113
113
|
# hashless)
|
114
|
-
def append_md5(file, digest, hashless
|
114
|
+
def append_md5(file, digest, hashless: false)
|
115
115
|
return file if hashless
|
116
116
|
|
117
117
|
[[file.split(ex = File.extname(file)).first, digest].join('-'), ex].join
|
@@ -123,10 +123,10 @@ module Bankrupt
|
|
123
123
|
# @param md5 [String] md5 hash of the asset
|
124
124
|
# @param hashless [Boolean] if the files doesn't have the hash appended
|
125
125
|
# @return [String] new, full path to the asset
|
126
|
-
def create_fullpath(path, md5, hashless
|
126
|
+
def create_fullpath(path, md5, hashless: false)
|
127
127
|
return "/#{path}" if CDN.empty?
|
128
128
|
|
129
|
-
[CDN, append_md5(path, md5, hashless)].join('/')
|
129
|
+
[CDN, append_md5(path, md5, hashless: hashless)].join('/')
|
130
130
|
end
|
131
131
|
|
132
132
|
# Generate the asset HTML. If the asset exists in the lookup hash then
|
@@ -149,7 +149,8 @@ module Bankrupt
|
|
149
149
|
begin
|
150
150
|
details = ASSETS.fetch(path)
|
151
151
|
|
152
|
-
fullpath = create_fullpath(path, details[:md5],
|
152
|
+
fullpath = create_fullpath(path, details[:md5],
|
153
|
+
hashless: details[:hashless])
|
153
154
|
|
154
155
|
@_assets[lookup_path] = Slim::Template.new { cdn }.render(
|
155
156
|
ASSET.new(fullpath, details[:sri])
|
data/lib/bankrupt/tasks.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright 2018-
|
3
|
+
# Copyright 2018-2021 Mario Finelli
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
# you may not use this file except in compliance with the License.
|
@@ -47,7 +47,7 @@ namespace :bankrupt do
|
|
47
47
|
# content_md5: Base64.strict_encode64(asset[:md5]),
|
48
48
|
content_length: File.size(f),
|
49
49
|
content_type: MiniMime.lookup_by_filename(f).content_type,
|
50
|
-
cache_control: 'public, max-age=31536000',
|
50
|
+
cache_control: 'public, max-age=31536000, immutable',
|
51
51
|
server_side_encryption: 'AES256',
|
52
52
|
storage_class: 'STANDARD',
|
53
53
|
metadata: {
|
@@ -102,11 +102,11 @@ namespace :bankrupt do
|
|
102
102
|
file_glob = '*.{css,jpg,js,pdf,png,svg,eot,ttf,woff,woff2}'
|
103
103
|
|
104
104
|
config = begin
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
105
|
+
YAML.safe_load(File.read(File.join(APP_ROOT, '.bankrupt.yml')),
|
106
|
+
[], [], true, symbolize_names: true)
|
107
|
+
rescue Errno::ENOENT
|
108
|
+
{}
|
109
|
+
end
|
110
110
|
|
111
111
|
Dir.glob(File.join(APP_ROOT, 'public', file_glob)).sort.each do |file|
|
112
112
|
md5 = Digest::MD5.file(file).to_s
|
@@ -114,7 +114,7 @@ namespace :bankrupt do
|
|
114
114
|
|
115
115
|
# undo the hash that we have webpack insert (but is important so the
|
116
116
|
# final css uses the correct path)
|
117
|
-
if basename.match?(
|
117
|
+
if basename.match?(/-#{md5}\.#{File.extname(file).delete('.')}$/)
|
118
118
|
File.rename(file,
|
119
119
|
(file = File.join(
|
120
120
|
File.dirname(file),
|
@@ -126,7 +126,7 @@ namespace :bankrupt do
|
|
126
126
|
filename: basename,
|
127
127
|
md5: md5,
|
128
128
|
babble: Digest::MD5.file(file).bubblebabble,
|
129
|
-
sri:
|
129
|
+
sri: "sha384-#{Digest::SHA384.file(file).base64digest}"
|
130
130
|
}
|
131
131
|
|
132
132
|
Array(config[:hashless]).each do |match|
|
data/lib/bankrupt/util.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright 2018 Mario Finelli
|
3
|
+
# Copyright 2018-2021 Mario Finelli
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
# you may not use this file except in compliance with the License.
|
@@ -22,9 +22,9 @@ module Bankrupt
|
|
22
22
|
# @param path [String] path to the manifest
|
23
23
|
# @return [Hash] parsed manifest or empty hash on error
|
24
24
|
def self.parse_manifest(path)
|
25
|
-
|
26
|
-
[k.freeze,
|
27
|
-
end
|
25
|
+
JSON.parse(File.read(path)).map do |k, v|
|
26
|
+
[k.freeze, v.map { |l, b| [l.to_sym, b.freeze] }.to_h.freeze]
|
27
|
+
end.to_h.freeze
|
28
28
|
rescue StandardError
|
29
29
|
{}
|
30
30
|
end
|
data/lib/bankrupt/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# Copyright 2018-
|
3
|
+
# Copyright 2018-2021 Mario Finelli
|
4
4
|
#
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
6
6
|
# you may not use this file except in compliance with the License.
|
@@ -15,5 +15,5 @@
|
|
15
15
|
# limitations under the License.
|
16
16
|
|
17
17
|
module Bankrupt
|
18
|
-
VERSION = '
|
18
|
+
VERSION = '3.0.0'
|
19
19
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bankrupt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Mario Finelli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: slim
|
@@ -156,6 +156,20 @@ dependencies:
|
|
156
156
|
- - ">="
|
157
157
|
- !ruby/object:Gem::Version
|
158
158
|
version: '0'
|
159
|
+
- !ruby/object:Gem::Dependency
|
160
|
+
name: rubocop-rake
|
161
|
+
requirement: !ruby/object:Gem::Requirement
|
162
|
+
requirements:
|
163
|
+
- - ">="
|
164
|
+
- !ruby/object:Gem::Version
|
165
|
+
version: '0'
|
166
|
+
type: :development
|
167
|
+
prerelease: false
|
168
|
+
version_requirements: !ruby/object:Gem::Requirement
|
169
|
+
requirements:
|
170
|
+
- - ">="
|
171
|
+
- !ruby/object:Gem::Version
|
172
|
+
version: '0'
|
159
173
|
- !ruby/object:Gem::Dependency
|
160
174
|
name: rubocop-rspec
|
161
175
|
requirement: !ruby/object:Gem::Requirement
|
@@ -206,10 +220,12 @@ extensions: []
|
|
206
220
|
extra_rdoc_files: []
|
207
221
|
files:
|
208
222
|
- ".editorconfig"
|
223
|
+
- ".github/workflows/default.yml"
|
224
|
+
- ".github/workflows/publish.yml"
|
209
225
|
- ".gitignore"
|
210
226
|
- ".rspec"
|
211
227
|
- ".rubocop.yml"
|
212
|
-
- ".
|
228
|
+
- ".ruby-version"
|
213
229
|
- CHANGELOG.md
|
214
230
|
- Gemfile
|
215
231
|
- LICENSE
|
@@ -231,14 +247,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
231
247
|
requirements:
|
232
248
|
- - ">="
|
233
249
|
- !ruby/object:Gem::Version
|
234
|
-
version: 2.
|
250
|
+
version: 2.5.0
|
235
251
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
236
252
|
requirements:
|
237
253
|
- - ">="
|
238
254
|
- !ruby/object:Gem::Version
|
239
255
|
version: '0'
|
240
256
|
requirements: []
|
241
|
-
rubygems_version: 3.
|
257
|
+
rubygems_version: 3.2.22
|
242
258
|
signing_key:
|
243
259
|
specification_version: 4
|
244
260
|
summary: A sinatra helper to load assets locally and production.
|
data/.travis.yml
DELETED
@@ -1,21 +0,0 @@
|
|
1
|
-
---
|
2
|
-
sudo: false
|
3
|
-
|
4
|
-
language: ruby
|
5
|
-
rvm:
|
6
|
-
- 2.4
|
7
|
-
- 2.5
|
8
|
-
- 2.6
|
9
|
-
- 2.7
|
10
|
-
|
11
|
-
before_install:
|
12
|
-
- gem update --system
|
13
|
-
- gem --version
|
14
|
-
|
15
|
-
script:
|
16
|
-
- bundle exec rubocop
|
17
|
-
- bundle exec rspec
|
18
|
-
- bundle exec yard
|
19
|
-
|
20
|
-
notifications:
|
21
|
-
email: false
|