jekyll-gzip 2.3.0 → 2.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/FUNDING.yml +1 -0
- data/.github/workflows/tests.yml +25 -0
- data/CHANGELOG.md +34 -1
- data/README.md +2 -1
- data/jekyll-gzip.gemspec +1 -1
- data/lib/jekyll/gzip.rb +6 -5
- data/lib/jekyll/gzip/compressor.rb +44 -6
- data/lib/jekyll/gzip/config.rb +2 -1
- data/lib/jekyll/gzip/version.rb +1 -1
- metadata +10 -9
- data/.travis.yml +0 -19
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 28d480574a2998a3dae5cdfd7f41d0071f9f50989b40b8fdab9cc5a4c8ee780f
|
4
|
+
data.tar.gz: c897d7e9c325aa0780e817525b11d2aea99103590501a30a7e717b79add8dc95
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d60611ffcf9f0143c5ce1a85d8c3941386b39d323b819da6589ed0878979d6ef5c611789f54d86894cca57e8a611d83ad073f2641983356196ed7104a881152
|
7
|
+
data.tar.gz: a2506fb3379771e481fef97acf9354304fba61dc6a45e59286ed46d6b58a4b86372af74d1843395719875edab8280fe4db8b1dc94314020231d727afbd1b6f79
|
data/.github/FUNDING.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
github: philnash
|
@@ -0,0 +1,25 @@
|
|
1
|
+
name: tests
|
2
|
+
|
3
|
+
on: [push, pull_request]
|
4
|
+
|
5
|
+
jobs:
|
6
|
+
test:
|
7
|
+
runs-on: ubuntu-latest
|
8
|
+
strategy:
|
9
|
+
fail-fast: false
|
10
|
+
matrix:
|
11
|
+
ruby: [2.5, 2.6, 2.7, 3.0, head]
|
12
|
+
jekyll: ["3.0", "4.0"]
|
13
|
+
continue-on-error: ${{ endsWith(matrix.ruby, 'head') }}
|
14
|
+
env:
|
15
|
+
JEKYLL_VERSION: ~> ${{ matrix.jekyll }}
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@v2
|
18
|
+
- name: Set up Ruby ${{ matrix.ruby }}
|
19
|
+
uses: ruby/setup-ruby@v1
|
20
|
+
with:
|
21
|
+
ruby-version: ${{ matrix.ruby }}
|
22
|
+
- name: "Install dependencies"
|
23
|
+
run: bundle install
|
24
|
+
- name: Run tests
|
25
|
+
run: bundle exec rspec
|
data/CHANGELOG.md
CHANGED
@@ -1,9 +1,42 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## Ongoing [☰](https://github.com/philnash/jekyll-gzip/compare/v2.
|
3
|
+
## Ongoing [☰](https://github.com/philnash/jekyll-gzip/compare/v2.5.0...master)
|
4
4
|
|
5
5
|
...
|
6
6
|
|
7
|
+
## 2.5.1 (2021-02-13) [☰](https://github.com/philnash/jekyll-gzip/compare/v2.5.0...v2.5.1)
|
8
|
+
|
9
|
+
### Fixed
|
10
|
+
|
11
|
+
- Stop overwriting Jekyll config, which invalidates the Jekyll cache (see https://github.com/jekyll/jekyll/issues/8551)
|
12
|
+
|
13
|
+
## 2.5.0 (2021-02-09) [☰](https://github.com/philnash/jekyll-gzip/compare/v2.4.2...v2.5.0)
|
14
|
+
|
15
|
+
### Changed
|
16
|
+
|
17
|
+
- Added JSON files to compressable extensions
|
18
|
+
- Moved from Travis CI to GitHub Actions
|
19
|
+
|
20
|
+
## 2.4.2 (2020-01-30) [☰](https://github.com/philnash/jekyll-gzip/compare/v2.4.1...v2.4.2)
|
21
|
+
|
22
|
+
### Changed
|
23
|
+
|
24
|
+
- Fixes the path handed to `Dir.glob` by using `File.join` instead of string concatenation
|
25
|
+
|
26
|
+
|
27
|
+
## 2.4.1 (2019-12-31) [☰](https://github.com/philnash/jekyll-gzip/compare/v2.4.0...v2.4.1)
|
28
|
+
|
29
|
+
### Changed
|
30
|
+
|
31
|
+
- Extends regeneration logic to files compressed by directory, not just site.
|
32
|
+
- Fixes tests that were just wrong for quite a long time.
|
33
|
+
|
34
|
+
## 2.4.0 (2019-12-31) [☰](https://github.com/philnash/jekyll-gzip/compare/v2.3.0...v2.4.0)
|
35
|
+
|
36
|
+
### Changed
|
37
|
+
|
38
|
+
- Doesn't regenerate files that haven't changed in incremental builds (thanks [@fauno](https://github.com/fauno))
|
39
|
+
|
7
40
|
## 2.3.0 (2019-08-26) [☰](https://github.com/philnash/jekyll-gzip/compare/v2.1.1...v2.3.0)
|
8
41
|
|
9
42
|
### Changed
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
Generate gzipped assets and files for your Jekyll site at build time.
|
4
4
|
|
5
|
-
[![Gem Version](https://badge.fury.io/rb/jekyll-gzip.svg)](https://rubygems.org/gems/jekyll-gzip) [![Build
|
5
|
+
[![Gem Version](https://badge.fury.io/rb/jekyll-gzip.svg)](https://rubygems.org/gems/jekyll-gzip) [![Build status](https://github.com/philnash/jekyll-gzip/workflows/tests/badge.svg)](https://github.com/philnash/jekyll-gzip/actions) [![Maintainability](https://api.codeclimate.com/v1/badges/895369c1c7a17f879b00/maintainability)](https://codeclimate.com/github/philnash/jekyll-gzip/maintainability) [![Inline docs](https://inch-ci.org/github/philnash/jekyll-gzip.svg?branch=master)](https://inch-ci.org/github/philnash/jekyll-gzip)
|
6
6
|
|
7
7
|
[API docs](http://www.rubydoc.info/gems/jekyll-gzip/) | [GitHub repo](https://github.com/philnash/jekyll-gzip)
|
8
8
|
|
@@ -70,6 +70,7 @@ By default, `Jekyll::Gzip` will compress all files with the following extensions
|
|
70
70
|
- '.html'
|
71
71
|
- '.css'
|
72
72
|
- '.js'
|
73
|
+
- '.json'
|
73
74
|
- '.txt'
|
74
75
|
- '.ttf'
|
75
76
|
- '.atom'
|
data/jekyll-gzip.gemspec
CHANGED
@@ -24,7 +24,7 @@ Gem::Specification.new do |spec|
|
|
24
24
|
spec.add_dependency "jekyll", ">= 3.0", "< 5.0"
|
25
25
|
|
26
26
|
spec.add_development_dependency "bundler", ">= 1.16", "< 3.0"
|
27
|
-
spec.add_development_dependency "rake", "~>
|
27
|
+
spec.add_development_dependency "rake", "~> 13.0.3"
|
28
28
|
spec.add_development_dependency "rspec", "~> 3.0"
|
29
29
|
spec.add_development_dependency "simplecov", "~> 0.15.1"
|
30
30
|
end
|
data/lib/jekyll/gzip.rb
CHANGED
@@ -10,15 +10,16 @@ module Jekyll
|
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
13
|
-
Jekyll::Hooks.register :site, :after_init do |site|
|
14
|
-
config = site.config['gzip'] || {}
|
15
|
-
site.config['gzip'] = Jekyll::Gzip::DEFAULT_CONFIG.merge(config) || {}
|
16
|
-
end
|
17
|
-
|
18
13
|
Jekyll::Hooks.register :site, :post_write do |site|
|
19
14
|
Jekyll::Gzip::Compressor.compress_site(site) if Jekyll.env == 'production'
|
20
15
|
end
|
21
16
|
|
17
|
+
Jekyll::Hooks.register :clean, :on_obsolete do |obsolete|
|
18
|
+
obsolete.delete_if do |path|
|
19
|
+
path.end_with? '.gz'
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
22
23
|
begin
|
23
24
|
require 'jekyll-assets'
|
24
25
|
|
@@ -25,6 +25,8 @@ module Jekyll
|
|
25
25
|
# @return void
|
26
26
|
def self.compress_site(site)
|
27
27
|
site.each_site_file do |file|
|
28
|
+
next unless regenerate? file.destination(site.dest), site
|
29
|
+
|
28
30
|
compress_file(
|
29
31
|
file.destination(site.dest),
|
30
32
|
extensions: zippable_extensions(site),
|
@@ -49,8 +51,16 @@ module Jekyll
|
|
49
51
|
def self.compress_directory(dir, site)
|
50
52
|
extensions = zippable_extensions(site).join(',')
|
51
53
|
replace_file = replace_files(site)
|
52
|
-
files = Dir.glob(dir
|
53
|
-
files.each
|
54
|
+
files = Dir.glob(File.join(dir, "**", "*{#{extensions}}"))
|
55
|
+
files.each do |file|
|
56
|
+
next unless regenerate?(file, site)
|
57
|
+
|
58
|
+
compress_file(
|
59
|
+
file,
|
60
|
+
extensions: extensions,
|
61
|
+
replace_file: replace_file
|
62
|
+
)
|
63
|
+
end
|
54
64
|
end
|
55
65
|
|
56
66
|
##
|
@@ -71,8 +81,11 @@ module Jekyll
|
|
71
81
|
# @return void
|
72
82
|
def self.compress_file(file_name, extensions: [], replace_file: false)
|
73
83
|
return unless extensions.include?(File.extname(file_name))
|
74
|
-
zipped =
|
84
|
+
zipped = zipped(file_name, replace_file)
|
75
85
|
file_content = IO.binread(file_name)
|
86
|
+
|
87
|
+
Jekyll.logger.debug "Gzip: #{zipped}"
|
88
|
+
|
76
89
|
Zlib::GzipWriter.open(zipped, Zlib::BEST_COMPRESSION) do |gz|
|
77
90
|
gz.mtime = File.mtime(file_name)
|
78
91
|
gz.orig_name = file_name
|
@@ -82,13 +95,38 @@ module Jekyll
|
|
82
95
|
|
83
96
|
private
|
84
97
|
|
98
|
+
def self.zipped(file_name, replace_file)
|
99
|
+
replace_file ? file_name : "#{file_name}.gz"
|
100
|
+
end
|
101
|
+
|
85
102
|
def self.zippable_extensions(site)
|
86
|
-
site.config.dig(
|
103
|
+
site.config.dig("gzip", "extensions") || Jekyll::Gzip::DEFAULT_CONFIG.fetch("extensions")
|
87
104
|
end
|
88
105
|
|
89
106
|
def self.replace_files(site)
|
90
|
-
|
91
|
-
|
107
|
+
site.config.dig("gzip", "replace_files") || Jekyll::Gzip::DEFAULT_CONFIG.fetch("replace_files")
|
108
|
+
end
|
109
|
+
|
110
|
+
# Compresses the file if the site is built incrementally and the
|
111
|
+
# source was modified or the compressed file doesn't exist
|
112
|
+
def self.regenerate?(file, site)
|
113
|
+
zipped = zipped(file, replace_files(site))
|
114
|
+
|
115
|
+
# Definitely generate the file if it doesn't exist yet.
|
116
|
+
return true unless File.exist? zipped
|
117
|
+
# If we are replacing files and this file is not a gzip file, then it
|
118
|
+
# has been edited so we need to re-gzip it in place.
|
119
|
+
return !is_already_gzipped?(file) if replace_files(site)
|
120
|
+
|
121
|
+
# If the modified time of the new file is greater than the modified time
|
122
|
+
# of the old file, then we need to regenerate.
|
123
|
+
File.mtime(file) > File.mtime(zipped)
|
124
|
+
end
|
125
|
+
|
126
|
+
# First two bytes of a gzipped file are 1f and 8b. This tests for those
|
127
|
+
# bytes.
|
128
|
+
def self.is_already_gzipped?(file)
|
129
|
+
["1f", "8b"] == File.read(file, 2).unpack("H2H2")
|
92
130
|
end
|
93
131
|
end
|
94
132
|
end
|
data/lib/jekyll/gzip/config.rb
CHANGED
data/lib/jekyll/gzip/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-gzip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Phil Nash
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -56,14 +56,14 @@ dependencies:
|
|
56
56
|
requirements:
|
57
57
|
- - "~>"
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
version:
|
59
|
+
version: 13.0.3
|
60
60
|
type: :development
|
61
61
|
prerelease: false
|
62
62
|
version_requirements: !ruby/object:Gem::Requirement
|
63
63
|
requirements:
|
64
64
|
- - "~>"
|
65
65
|
- !ruby/object:Gem::Version
|
66
|
-
version:
|
66
|
+
version: 13.0.3
|
67
67
|
- !ruby/object:Gem::Dependency
|
68
68
|
name: rspec
|
69
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -99,9 +99,10 @@ executables: []
|
|
99
99
|
extensions: []
|
100
100
|
extra_rdoc_files: []
|
101
101
|
files:
|
102
|
+
- ".github/FUNDING.yml"
|
103
|
+
- ".github/workflows/tests.yml"
|
102
104
|
- ".gitignore"
|
103
105
|
- ".rspec"
|
104
|
-
- ".travis.yml"
|
105
106
|
- CHANGELOG.md
|
106
107
|
- CODE_OF_CONDUCT.md
|
107
108
|
- Gemfile
|
@@ -120,7 +121,7 @@ homepage: https://github.com/philnash/jekyll-gzip
|
|
120
121
|
licenses:
|
121
122
|
- MIT
|
122
123
|
metadata: {}
|
123
|
-
post_install_message:
|
124
|
+
post_install_message:
|
124
125
|
rdoc_options: []
|
125
126
|
require_paths:
|
126
127
|
- lib
|
@@ -135,8 +136,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
135
136
|
- !ruby/object:Gem::Version
|
136
137
|
version: '0'
|
137
138
|
requirements: []
|
138
|
-
rubygems_version: 3.
|
139
|
-
signing_key:
|
139
|
+
rubygems_version: 3.1.4
|
140
|
+
signing_key:
|
140
141
|
specification_version: 4
|
141
142
|
summary: Generate gzipped assets and files for your Jekyll site at build time
|
142
143
|
test_files: []
|
data/.travis.yml
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
sudo: false
|
2
|
-
language: ruby
|
3
|
-
rvm:
|
4
|
-
- 2.6
|
5
|
-
- 2.5
|
6
|
-
- 2.4
|
7
|
-
- 2.3
|
8
|
-
- ruby-head
|
9
|
-
env:
|
10
|
-
- 'JEKYLL_VERSION="~> 3.0"'
|
11
|
-
- 'JEKYLL_VERSION="~> 4.0"'
|
12
|
-
matrix:
|
13
|
-
allow_failures:
|
14
|
-
- rvm: ruby-head
|
15
|
-
exclude:
|
16
|
-
- rvm: 2.3
|
17
|
-
env: 'JEKYLL_VERSION="~> 4.0"'
|
18
|
-
before_install: gem install bundler
|
19
|
-
script: bundle exec rspec
|