jekyll-gzip 2.3.0 → 2.4.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: 43dc2c3b2573c028bb17d1c303f763a5d244927ceeecde3427359c5144b5bdf4
4
- data.tar.gz: 2eee8cc5df31a3e26657bcb48ed8612e0581dfe5025a37ebfb3b2715d604f5c2
3
+ metadata.gz: 67e75bf1b039238497db31bdb5b2eadfe5ad1e8ab4e9bb081d5306d0218dcd9b
4
+ data.tar.gz: a87207df53e3341bd540518fd1e75da2f1c1cd8fc47165d8116f27e10c3e5e61
5
5
  SHA512:
6
- metadata.gz: 2ed3483c621dc9b32d30f41e2a7144685468634fa9680aac2580837c2e0de1e28f8300b755aa64b9a5a8954d51ec0afa929b594a1c9bb636a3ad746888ca9546
7
- data.tar.gz: 9e749685bc29ef1833783096ee70d882506acdf7dc5a4a92d9fe46a635657470a4c7d68c73d53f843a4d425ded15ef5eebeb366fcd3b35075dadea0bead8fdb1
6
+ metadata.gz: b237fb2c934762fd8ece504eaf6d370cbc3190d0cf0f11e4179f833015e24b9de8111f1ee98bbc8e8bfc0751c59360c1343e1c339fdc2a30deb3cc9349320f1e
7
+ data.tar.gz: 3a0d6fcad32e2751c6d4ed9d66d83180c1023abc94a521028ee90e87127836771e15b0220633a8fae799e9e29d076d160763fa709b0fa5ca9412234a2fcd7aec
data/CHANGELOG.md CHANGED
@@ -1,8 +1,10 @@
1
1
  # Changelog
2
2
 
3
- ## Ongoing [☰](https://github.com/philnash/jekyll-gzip/compare/v2.1.1...master)
3
+ ## Ongoing [☰](https://github.com/philnash/jekyll-gzip/compare/v2.4.0...master)
4
4
 
5
- ...
5
+ ## 2.4.0 (2019-12-31) [☰](https://github.com/philnash/jekyll-gzip/compare/v2.3.0...v2.4.0)
6
+
7
+ - Doesn't regenerate files that haven't changed in incremental builds (thanks [@fauno](https://github.com/fauno))
6
8
 
7
9
  ## 2.3.0 (2019-08-26) [☰](https://github.com/philnash/jekyll-gzip/compare/v2.1.1...v2.3.0)
8
10
 
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, site
29
+
28
30
  compress_file(
29
31
  file.destination(site.dest),
30
32
  extensions: zippable_extensions(site),
@@ -71,8 +73,11 @@ module Jekyll
71
73
  # @return void
72
74
  def self.compress_file(file_name, extensions: [], replace_file: false)
73
75
  return unless extensions.include?(File.extname(file_name))
74
- zipped = replace_file ? file_name : "#{file_name}.gz"
76
+ zipped = zipped(file_name, replace_file)
75
77
  file_content = IO.binread(file_name)
78
+
79
+ Jekyll.logger.debug "Gzip: #{zipped}"
80
+
76
81
  Zlib::GzipWriter.open(zipped, Zlib::BEST_COMPRESSION) do |gz|
77
82
  gz.mtime = File.mtime(file_name)
78
83
  gz.orig_name = file_name
@@ -82,6 +87,10 @@ module Jekyll
82
87
 
83
88
  private
84
89
 
90
+ def self.zipped(file_name, replace_file)
91
+ replace_file ? file_name : "#{file_name}.gz"
92
+ end
93
+
85
94
  def self.zippable_extensions(site)
86
95
  site.config.dig('gzip', 'extensions') || Jekyll::Gzip::DEFAULT_CONFIG['extensions']
87
96
  end
@@ -90,6 +99,17 @@ module Jekyll
90
99
  replace_files = site.config.dig('gzip', 'replace_files')
91
100
  replace_files.nil? ? Jekyll::Gzip::DEFAULT_CONFIG['replace_files'] : replace_files
92
101
  end
102
+
103
+ # Compresses the file if the site is built incrementally and the
104
+ # source was modified or the compressed file doesn't exist
105
+ def self.regenerate?(file, site)
106
+ orig = file.destination(site.dest)
107
+ zipped = zipped(orig, replace_files(site))
108
+
109
+ return true unless File.exist? zipped
110
+
111
+ File.mtime(orig) > File.mtime(zipped)
112
+ end
93
113
  end
94
114
  end
95
115
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module Gzip
5
- VERSION = "2.3.0"
5
+ VERSION = "2.4.0"
6
6
  end
7
7
  end
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.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Phil Nash
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-08-26 00:00:00.000000000 Z
11
+ date: 2019-12-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll
@@ -135,7 +135,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
135
  - !ruby/object:Gem::Version
136
136
  version: '0'
137
137
  requirements: []
138
- rubygems_version: 3.0.3
138
+ rubygems_version: 3.0.1
139
139
  signing_key:
140
140
  specification_version: 4
141
141
  summary: Generate gzipped assets and files for your Jekyll site at build time