jekyll-gzip 2.2.0 → 2.5.0
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/.gitignore +2 -2
- data/CHANGELOG.md +29 -2
- data/Gemfile +4 -0
- data/README.md +2 -1
- data/jekyll-gzip.gemspec +2 -2
- data/lib/jekyll/gzip.rb +6 -0
- data/lib/jekyll/gzip/compressor.rb +42 -3
- data/lib/jekyll/gzip/config.rb +2 -1
- data/lib/jekyll/gzip/version.rb +1 -1
- metadata +18 -11
- data/.travis.yml +0 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3049ee54c391de6df317ecde1288f82f1224a17569644da228dd5c136eb71dd0
|
4
|
+
data.tar.gz: fe2ec6c84c347aa946ac9cd9d7c91e5c9087ded244a0b66e6a8cfc80924b3f80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37b07ec7b37fa110aeee0d36c8b96de89ed4b815bdb472f2d621863585f20cd8e3574d17b2be7c34c4a92e2c699cea4e0be203b7fadd1126b586fd55e9c68b79
|
7
|
+
data.tar.gz: 683e435482ca5be7e31e8d7149361a1cefaec9cf53c9b53418244e7b90503a39b51ff1589baa2fe50725e9ece98e06dde9be5e4eb33b8b38f75d5141e08b4b4e
|
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/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,10 +1,37 @@
|
|
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.
|
7
|
+
## 2.5.0 (2021-02-09) [☰](https://github.com/philnash/jekyll-gzip/compare/v2.4.2...v2.5.0)
|
8
|
+
|
9
|
+
### Changed
|
10
|
+
|
11
|
+
- Added JSON files to compressable extensions
|
12
|
+
- Moved from Travis CI to GitHub Actions
|
13
|
+
|
14
|
+
## 2.4.2 (2020-01-30) [☰](https://github.com/philnash/jekyll-gzip/compare/v2.4.1...v2.4.2)
|
15
|
+
|
16
|
+
### Changed
|
17
|
+
|
18
|
+
- Fixes the path handed to `Dir.glob` by using `File.join` instead of string concatenation
|
19
|
+
|
20
|
+
|
21
|
+
## 2.4.1 (2019-12-31) [☰](https://github.com/philnash/jekyll-gzip/compare/v2.4.0...v2.4.1)
|
22
|
+
|
23
|
+
### Changed
|
24
|
+
|
25
|
+
- Extends regeneration logic to files compressed by directory, not just site.
|
26
|
+
- Fixes tests that were just wrong for quite a long time.
|
27
|
+
|
28
|
+
## 2.4.0 (2019-12-31) [☰](https://github.com/philnash/jekyll-gzip/compare/v2.3.0...v2.4.0)
|
29
|
+
|
30
|
+
### Changed
|
31
|
+
|
32
|
+
- Doesn't regenerate files that haven't changed in incremental builds (thanks [@fauno](https://github.com/fauno))
|
33
|
+
|
34
|
+
## 2.3.0 (2019-08-26) [☰](https://github.com/philnash/jekyll-gzip/compare/v2.1.1...v2.3.0)
|
8
35
|
|
9
36
|
### Changed
|
10
37
|
|
data/Gemfile
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
@@ -21,10 +21,10 @@ Gem::Specification.new do |spec|
|
|
21
21
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
22
|
spec.require_paths = ["lib"]
|
23
23
|
|
24
|
-
spec.add_dependency "jekyll", "
|
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
@@ -19,6 +19,12 @@ Jekyll::Hooks.register :site, :post_write do |site|
|
|
19
19
|
Jekyll::Gzip::Compressor.compress_site(site) if Jekyll.env == 'production'
|
20
20
|
end
|
21
21
|
|
22
|
+
Jekyll::Hooks.register :clean, :on_obsolete do |obsolete|
|
23
|
+
obsolete.delete_if do |path|
|
24
|
+
path.end_with? '.gz'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
22
28
|
begin
|
23
29
|
require 'jekyll-assets'
|
24
30
|
|
@@ -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,6 +95,10 @@ 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
103
|
site.config.dig('gzip', 'extensions') || Jekyll::Gzip::DEFAULT_CONFIG['extensions']
|
87
104
|
end
|
@@ -90,6 +107,28 @@ module Jekyll
|
|
90
107
|
replace_files = site.config.dig('gzip', 'replace_files')
|
91
108
|
replace_files.nil? ? Jekyll::Gzip::DEFAULT_CONFIG['replace_files'] : replace_files
|
92
109
|
end
|
110
|
+
|
111
|
+
# Compresses the file if the site is built incrementally and the
|
112
|
+
# source was modified or the compressed file doesn't exist
|
113
|
+
def self.regenerate?(file, site)
|
114
|
+
zipped = zipped(file, replace_files(site))
|
115
|
+
|
116
|
+
# Definitely generate the file if it doesn't exist yet.
|
117
|
+
return true unless File.exist? zipped
|
118
|
+
# If we are replacing files and this file is not a gzip file, then it
|
119
|
+
# has been edited so we need to re-gzip it in place.
|
120
|
+
return !is_already_gzipped?(file) if replace_files(site)
|
121
|
+
|
122
|
+
# If the modified time of the new file is greater than the modified time
|
123
|
+
# of the old file, then we need to regenerate.
|
124
|
+
File.mtime(file) > File.mtime(zipped)
|
125
|
+
end
|
126
|
+
|
127
|
+
# First two bytes of a gzipped file are 1f and 8b. This tests for those
|
128
|
+
# bytes.
|
129
|
+
def self.is_already_gzipped?(file)
|
130
|
+
["1f", "8b"] == File.read(file, 2).unpack("H2H2")
|
131
|
+
end
|
93
132
|
end
|
94
133
|
end
|
95
134
|
end
|
data/lib/jekyll/gzip/config.rb
CHANGED
data/lib/jekyll/gzip/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,35 @@
|
|
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.0
|
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-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '3.0'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5.0'
|
20
23
|
type: :runtime
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
|
-
- - "
|
27
|
+
- - ">="
|
25
28
|
- !ruby/object:Gem::Version
|
26
29
|
version: '3.0'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5.0'
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: bundler
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,14 +56,14 @@ dependencies:
|
|
50
56
|
requirements:
|
51
57
|
- - "~>"
|
52
58
|
- !ruby/object:Gem::Version
|
53
|
-
version:
|
59
|
+
version: 13.0.3
|
54
60
|
type: :development
|
55
61
|
prerelease: false
|
56
62
|
version_requirements: !ruby/object:Gem::Requirement
|
57
63
|
requirements:
|
58
64
|
- - "~>"
|
59
65
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
66
|
+
version: 13.0.3
|
61
67
|
- !ruby/object:Gem::Dependency
|
62
68
|
name: rspec
|
63
69
|
requirement: !ruby/object:Gem::Requirement
|
@@ -93,9 +99,10 @@ executables: []
|
|
93
99
|
extensions: []
|
94
100
|
extra_rdoc_files: []
|
95
101
|
files:
|
102
|
+
- ".github/FUNDING.yml"
|
103
|
+
- ".github/workflows/tests.yml"
|
96
104
|
- ".gitignore"
|
97
105
|
- ".rspec"
|
98
|
-
- ".travis.yml"
|
99
106
|
- CHANGELOG.md
|
100
107
|
- CODE_OF_CONDUCT.md
|
101
108
|
- Gemfile
|
@@ -114,7 +121,7 @@ homepage: https://github.com/philnash/jekyll-gzip
|
|
114
121
|
licenses:
|
115
122
|
- MIT
|
116
123
|
metadata: {}
|
117
|
-
post_install_message:
|
124
|
+
post_install_message:
|
118
125
|
rdoc_options: []
|
119
126
|
require_paths:
|
120
127
|
- lib
|
@@ -129,8 +136,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
129
136
|
- !ruby/object:Gem::Version
|
130
137
|
version: '0'
|
131
138
|
requirements: []
|
132
|
-
rubygems_version: 3.
|
133
|
-
signing_key:
|
139
|
+
rubygems_version: 3.1.4
|
140
|
+
signing_key:
|
134
141
|
specification_version: 4
|
135
142
|
summary: Generate gzipped assets and files for your Jekyll site at build time
|
136
143
|
test_files: []
|