jekyll-zopfli 2.1.0 → 2.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5a3d94f9c2b739da1bd99584f6168c3efa2eec8f89e8be2e62f0ba76ebc0622c
4
- data.tar.gz: 1d44e3cca0978864069f10c6c629b3a5967a95f7da4f841bbd3423cc624da87a
3
+ metadata.gz: 69d64e88350322aa287a04de9c9dba6d60b1588f21973a3a1f5e40b37fd6265c
4
+ data.tar.gz: cfb0d765560b20803e39f42f8e194d3f7a5e0f68fc0290b3357947c284cb3488
5
5
  SHA512:
6
- metadata.gz: c198291793271662d43d26ba5fca15014c9ee33fdbf9676eb5711fd08a757daf6d8ff281fdb436a577059bcdf92ddbbc1a58880e7ba54bdfbb5870385d5c9940
7
- data.tar.gz: db7c122bbb10cb6ecd8d2bad9eef1ae2b2e682422b97ca3324ec157a41bd5e47b7827befffd24da1e33764a1d4a4034ec97211ce9efcd98f1d426952ec02ee10
6
+ metadata.gz: 2a5cbdf255e010eaacecf8b3795ab98c1ce2cac6cb8ef603b452632823f0988498acfd036298a876fdf5fd4b3da127153d8d581e2e2e35fe062f5523f61af1b7
7
+ data.tar.gz: 908118206b320010b26e51d399dd62eab09b571c6d97347f5417641872723b0f2766e3209a1656b72f3c4b41135691634ff5fc3b294956fc58c57d51d3eec8e5
@@ -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
@@ -11,4 +11,5 @@ Gemfile.lock
11
11
  # rspec failure tracking
12
12
  .rspec_status
13
13
 
14
- .sass-cache/
14
+ .sass-cache/
15
+ .jekyll-cache/
data/CHANGELOG.md CHANGED
@@ -1,37 +1,72 @@
1
1
  # Changelog
2
2
 
3
- ## Ongoing [☰](https://github.com/philnash/jekyll-gzip/compare/v2.1.0...master)
3
+ ## Ongoing [☰](https://github.com/philnash/jekyll-zopfli/compare/v2.4.1...main)
4
4
 
5
5
  ...
6
6
 
7
+ ## 2.5.0 (2021-02-13) [☰](https://github.com/philnash/jekyll-zopfli/compare/v2.4.1...v2.5.0)
8
+
9
+ ### Changed
10
+
11
+ - Added JSON files to compressable extensions
12
+ - Moved from Travis CI to GitHub Actions
13
+
14
+ ### Fixed
15
+
16
+ - Stop overwriting Jekyll config, which invalidates the Jekyll cache (see https://github.com/jekyll/jekyll/issues/8551)
17
+
18
+ ## 2.4.1 (2020-01-30) [☰](https://github.com/philnash/jekyll-zopfli/compare/v2.4.0...v2.4.1)
19
+
20
+ ### Changed
21
+
22
+ - Fixes the path handed to `Dir.glob` by using `File.join` instead of string concatenation
23
+
24
+ ## 2.4.0 (2019-12-31) [☰](https://github.com/philnash/jekyll-zopfli/compare/v2.3.0...v2.4.0)
25
+
26
+ ### Changed
27
+
28
+ - Doesn't regenerate files that haven't changed in incremental builds.
29
+
30
+ ## 2.3.0 (2019-10-23) [☰](https://github.com/philnash/jekyll-zopfli/compare/v2.2.0...v2.3.0)
31
+
32
+ ### Changed
33
+
34
+ - Fixed tests and actually replaces files when it is supposed to. Thanks @pat!
35
+
36
+ ## 2.2.0 (2019-08-26) [☰](https://github.com/philnash/jekyll-zopfli/compare/v2.1.0...v2.2.0)
37
+
38
+ ### Changed
39
+
40
+ - Opens up version support for Jekyll 4 (thanks [@thedanbob](https://github.com/thedanbob))
41
+
7
42
  ## 2.1.0 (2019-03-30) [☰](https://github.com/philnash/jekyll-zopfli/compare/v2.0.0...v2.1.0)
8
43
 
9
44
  ### Added
10
45
 
11
- * Adds setting to replace original files with gzipped for serving from AWS S3
46
+ - Adds setting to replace original files with gzipped for serving from AWS S3
12
47
 
13
48
  ## 2.0.0 (2018-11-24) [☰](https://github.com/philnash/jekyll-zopfli/compare/v1.1.0...v2.0.0)
14
49
 
15
50
  ### Added
16
51
 
17
- * Hooks into Jekyll::Assets if available
18
- * Adds frozen string literal comment
52
+ - Hooks into Jekyll::Assets if available
53
+ - Adds frozen string literal comment
19
54
 
20
55
  ### Changed
21
56
 
22
- * Uses built in `Jekyll.env` instead of `ENV["JEKYLL_ENV"]`
23
- * Changes `Jekyll::Zopfli::Compressor` to a module and implements a `compress_directory` method
24
- * Moves Jekyll::Zopfli::ZIPPABLE_EXTENSIONS into plugin config that can overwritten in the site config
57
+ - Uses built in `Jekyll.env` instead of `ENV["JEKYLL_ENV"]`
58
+ - Changes `Jekyll::Zopfli::Compressor` to a module and implements a `compress_directory` method
59
+ - Moves Jekyll::Zopfli::ZIPPABLE_EXTENSIONS into plugin config that can overwritten in the site config
25
60
 
26
61
  ## 1.1.0 (2018-01-03) [☰](https://github.com/philnash/jekyll-zopfli/compare/v1.0.0...v1.1.0)
27
62
 
28
63
  ### Changed
29
64
 
30
- * Only run the post write hook when the environment variable `JEKYLL_ENV` is `production`
65
+ - Only run the post write hook when the environment variable `JEKYLL_ENV` is `production`
31
66
 
32
67
  ## 1.0.0 (2018-01-02) [☰](https://github.com/philnash/jekyll-zopfli/commits/v1.0.0)
33
68
 
34
69
  ### Added
35
70
 
36
- * Methods to Gzip compress text files throughout a Jekyll site using Zopfli
37
- * Site post write hook to trigger compression
71
+ - Methods to Gzip compress text files throughout a Jekyll site using Zopfli
72
+ - Site post write hook to trigger compression
data/Gemfile CHANGED
@@ -4,3 +4,7 @@ git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
4
4
 
5
5
  # Specify your gem's dependencies in jekyll-zopfli.gemspec
6
6
  gemspec
7
+
8
+ jekyll_version = ENV["JEKYLL_VERSION"] || "~> 4.0"
9
+
10
+ gem "jekyll", jekyll_version
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Generate gzipped assets and files for your Jekyll site at build time using [Zopfli](https://github.com/google/zopfli) compression.
4
4
 
5
- [![Gem Version](https://badge.fury.io/rb/jekyll-zopfli.svg)](https://rubygems.org/gems/jekyll-zopfli) [![Build Status](https://travis-ci.org/philnash/jekyll-zopfli.svg?branch=master)](https://travis-ci.org/philnash/jekyll-zopfli) [![Maintainability](https://api.codeclimate.com/v1/badges/177f76759bc3b996e9e2/maintainability)](https://codeclimate.com/github/philnash/jekyll-zopfli/maintainability) [![Inline docs](https://inch-ci.org/github/philnash/jekyll-zopfli.svg?branch=master)](https://inch-ci.org/github/philnash/jekyll-zopfli)
5
+ [![Gem Version](https://badge.fury.io/rb/jekyll-zopfli.svg)](https://rubygems.org/gems/jekyll-zopfli) [![Build status](https://github.com/philnash/jekyll-zopfli/workflows/tests/badge.svg)](https://github.com/philnash/jekyll-zopfli/actions) [![Maintainability](https://api.codeclimate.com/v1/badges/177f76759bc3b996e9e2/maintainability)](https://codeclimate.com/github/philnash/jekyll-zopfli/maintainability) [![Inline docs](https://inch-ci.org/github/philnash/jekyll-zopfli.svg?branch=main)](https://inch-ci.org/github/philnash/jekyll-zopfli)
6
6
 
7
7
  [API docs](http://www.rubydoc.info/gems/jekyll-zopfli/) | [GitHub repo](https://github.com/philnash/jekyll-zopfli)
8
8
 
@@ -72,6 +72,7 @@ By default, `Jekyll::Zopfli` will compress all files with the following extensio
72
72
  - '.html'
73
73
  - '.css'
74
74
  - '.js'
75
+ - '.json'
75
76
  - '.txt'
76
77
  - '.ttf'
77
78
  - '.atom'
@@ -146,4 +147,4 @@ The gem is available as open source under the terms of the [MIT License](https:/
146
147
 
147
148
  ## Code of Conduct
148
149
 
149
- Everyone interacting in the Jekyll::Zopfli project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/philnash/jekyll-gzip/blob/master/CODE_OF_CONDUCT.md).
150
+ Everyone interacting in the Jekyll::Zopfli project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/philnash/jekyll-zopfli/blob/main/CODE_OF_CONDUCT.md).
@@ -21,11 +21,11 @@ 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", "~> 3.0"
24
+ spec.add_dependency "jekyll", ">= 3.0", "< 5.0"
25
25
  spec.add_dependency "zopfli", "~> 0.0.7"
26
26
 
27
27
  spec.add_development_dependency "bundler", ">= 1.16", "< 3.0"
28
- spec.add_development_dependency "rake", "~> 10.0"
28
+ spec.add_development_dependency "rake", "~> 13.0"
29
29
  spec.add_development_dependency "rspec", "~> 3.0"
30
30
  spec.add_development_dependency "simplecov", "~> 0.15.1"
31
31
  end
data/lib/jekyll/zopfli.rb CHANGED
@@ -10,11 +10,6 @@ module Jekyll
10
10
  end
11
11
  end
12
12
 
13
- Jekyll::Hooks.register :site, :after_init do |site|
14
- config = site.config['zopfli'] || {}
15
- site.config['zopfli'] = Jekyll::Zopfli::DEFAULT_CONFIG.merge(config) || {}
16
- end
17
-
18
13
  Jekyll::Hooks.register :site, :post_write do |site|
19
14
  Jekyll::Zopfli::Compressor.compress_site(site) if Jekyll.env == 'production'
20
15
  end
@@ -25,7 +25,13 @@ module Jekyll
25
25
  # @return void
26
26
  def self.compress_site(site)
27
27
  site.each_site_file do |file|
28
- compress_file(file.destination(site.dest), extensions: zippable_extensions(site))
28
+ next unless regenerate? file.destination(site.dest), site
29
+
30
+ compress_file(
31
+ file.destination(site.dest),
32
+ extensions: zippable_extensions(site),
33
+ replace_file: replace_files(site)
34
+ )
29
35
  end
30
36
  end
31
37
 
@@ -44,8 +50,16 @@ module Jekyll
44
50
  # @return void
45
51
  def self.compress_directory(dir, site)
46
52
  extensions = zippable_extensions(site).join(',')
47
- files = Dir.glob(dir + "**/*{#{extensions}}")
48
- files.each { |file| compress_file(file, extensions: zippable_extensions(site)) }
53
+ files = Dir.glob(File.join(dir, "**", "*{#{extensions}}"))
54
+ files.each do |file|
55
+ next unless regenerate? file, site
56
+
57
+ compress_file(
58
+ file,
59
+ extensions: zippable_extensions(site),
60
+ replace_file: replace_files(site)
61
+ )
62
+ end
49
63
  end
50
64
 
51
65
  ##
@@ -60,14 +74,14 @@ module Jekyll
60
74
  # @param file_name [String] The file name of the file we want to compress
61
75
  # @param extensions [Array<String>] The extensions of files that will be
62
76
  # compressed.
63
- # @param replace_file [Boolean] Whether the origina file should be
77
+ # @param replace_file [Boolean] Whether the original file should be
64
78
  # replaced or written alongside the original with a `.gz` extension
65
79
  #
66
80
  # @return void
67
81
  def self.compress_file(file_name, extensions: [], replace_file: false)
68
82
  return unless extensions.include?(File.extname(file_name))
69
83
  zipped = replace_file ? file_name : "#{file_name}.gz"
70
- contents = ::Zopfli.deflate(File.read(file_name), format: :gzip)
84
+ contents = ::Zopfli.deflate(File.binread(file_name), format: :gzip)
71
85
  File.open(zipped, "w+") do |file|
72
86
  file << contents
73
87
  end
@@ -77,8 +91,38 @@ module Jekyll
77
91
  private
78
92
 
79
93
  def self.zippable_extensions(site)
80
- site.config['zopfli'] && site.config['zopfli']['extensions'] || Jekyll::Zopfli::DEFAULT_CONFIG['extensions']
94
+ site.config.dig("zopfli", "extensions") || Jekyll::Zopfli::DEFAULT_CONFIG.fetch("extensions")
95
+ end
96
+
97
+ def self.replace_files(site)
98
+ site.config.dig("zopfli", "replace_files") || Jekyll::Zopfli::DEFAULT_CONFIG.fetch("replace_files")
99
+ end
100
+
101
+ def self.zipped(file_name, replace_file)
102
+ replace_file ? file_name : "#{file_name}.gz"
103
+ end
104
+
105
+ # Compresses the file if the site is built incrementally and the
106
+ # source was modified or the compressed file doesn't exist
107
+ def self.regenerate?(file, site)
108
+ zipped = zipped(file, replace_files(site))
109
+
110
+ # Definitely generate the file if it doesn't exist yet.
111
+ return true unless File.exist? zipped
112
+ # If we are replacing files and this file is not a gzip file, then it
113
+ # has been edited so we need to re-gzip it in place.
114
+ return !is_already_gzipped?(file) if replace_files(site)
115
+
116
+ # If the modified time of the new file is greater than the modified time
117
+ # of the old file, then we need to regenerate.
118
+ File.mtime(file) > File.mtime(zipped)
119
+ end
120
+
121
+ # First two bytes of a gzipped file are 1f and 8b. This tests for those
122
+ # bytes.
123
+ def self.is_already_gzipped?(file)
124
+ ["1f", "8b"] == File.read(file, 2).unpack("H2H2")
81
125
  end
82
126
  end
83
127
  end
84
- end
128
+ end
@@ -7,6 +7,7 @@ module Jekyll
7
7
  '.html',
8
8
  '.css',
9
9
  '.js',
10
+ '.json',
10
11
  '.txt',
11
12
  '.ttf',
12
13
  '.atom',
@@ -18,4 +19,4 @@ module Jekyll
18
19
  'replace_files' => false
19
20
  }.freeze
20
21
  end
21
- end
22
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module Zopfli
5
- VERSION = "2.1.0"
5
+ VERSION = "2.5.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,29 +1,35 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-zopfli
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
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: 2019-03-30 00:00:00.000000000 Z
11
+ date: 2021-02-13 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: zopfli
29
35
  requirement: !ruby/object:Gem::Requirement
@@ -64,14 +70,14 @@ dependencies:
64
70
  requirements:
65
71
  - - "~>"
66
72
  - !ruby/object:Gem::Version
67
- version: '10.0'
73
+ version: '13.0'
68
74
  type: :development
69
75
  prerelease: false
70
76
  version_requirements: !ruby/object:Gem::Requirement
71
77
  requirements:
72
78
  - - "~>"
73
79
  - !ruby/object:Gem::Version
74
- version: '10.0'
80
+ version: '13.0'
75
81
  - !ruby/object:Gem::Dependency
76
82
  name: rspec
77
83
  requirement: !ruby/object:Gem::Requirement
@@ -108,9 +114,10 @@ executables: []
108
114
  extensions: []
109
115
  extra_rdoc_files: []
110
116
  files:
117
+ - ".github/FUNDING.yml"
118
+ - ".github/workflows/tests.yml"
111
119
  - ".gitignore"
112
120
  - ".rspec"
113
- - ".travis.yml"
114
121
  - CHANGELOG.md
115
122
  - CODE_OF_CONDUCT.md
116
123
  - Gemfile
@@ -129,7 +136,7 @@ homepage: https://github.com/philnash/jekyll-zopfli
129
136
  licenses:
130
137
  - MIT
131
138
  metadata: {}
132
- post_install_message:
139
+ post_install_message:
133
140
  rdoc_options: []
134
141
  require_paths:
135
142
  - lib
@@ -144,8 +151,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
144
151
  - !ruby/object:Gem::Version
145
152
  version: '0'
146
153
  requirements: []
147
- rubygems_version: 3.0.3
148
- signing_key:
154
+ rubygems_version: 3.1.4
155
+ signing_key:
149
156
  specification_version: 4
150
157
  summary: Generate gzipped assets and files for your Jekyll site at build time using
151
158
  Zopfli compression.
data/.travis.yml DELETED
@@ -1,13 +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
- matrix:
10
- allow_failures:
11
- - rvm: ruby-head
12
- before_install: gem install bundler
13
- script: bundle exec rspec