jekyll-gzip 2.4.0 → 2.4.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 67e75bf1b039238497db31bdb5b2eadfe5ad1e8ab4e9bb081d5306d0218dcd9b
4
- data.tar.gz: a87207df53e3341bd540518fd1e75da2f1c1cd8fc47165d8116f27e10c3e5e61
3
+ metadata.gz: 20a0d5baaba7091074b3acf89006d8ebd2d7d057ca722b6283066cb9c829614f
4
+ data.tar.gz: 11af52cb88ada9cb60aba27e21d048df49d5f4c9f8161aadc52bd8925b5289cb
5
5
  SHA512:
6
- metadata.gz: b237fb2c934762fd8ece504eaf6d370cbc3190d0cf0f11e4179f833015e24b9de8111f1ee98bbc8e8bfc0751c59360c1343e1c339fdc2a30deb3cc9349320f1e
7
- data.tar.gz: 3a0d6fcad32e2751c6d4ed9d66d83180c1023abc94a521028ee90e87127836771e15b0220633a8fae799e9e29d076d160763fa709b0fa5ca9412234a2fcd7aec
6
+ metadata.gz: 21fc14003d2c4d4b2b5dc6ae97e48efc824e1c1d7bd5832c228b4d984a85d68366d7e6c2d41ed94bb6dd6fb59cf8cb3d0284ed95590bbb012860c39039dcf89d
7
+ data.tar.gz: dbacb25224a0d5adf71c41c437ed48a3a509854d2263036d209a9cb3b1d55a93ff245af9df14a345ed07ddb9ded99b1343e54475cde2495f7b31f2d394ed31b3
@@ -1,9 +1,20 @@
1
1
  # Changelog
2
2
 
3
- ## Ongoing [☰](https://github.com/philnash/jekyll-gzip/compare/v2.4.0...master)
3
+ ## Ongoing [☰](https://github.com/philnash/jekyll-gzip/compare/v2.4.1...master)
4
+
5
+ ...
6
+
7
+ ## 2.4.1 (2019-12-31) [☰](https://github.com/philnash/jekyll-gzip/compare/v2.4.0...v2.4.1)
8
+
9
+ ### Changed
10
+
11
+ - Extends regeneration logic to files compressed by directory, not just site.
12
+ - Fixes tests that were just wrong for quite a long time.
4
13
 
5
14
  ## 2.4.0 (2019-12-31) [☰](https://github.com/philnash/jekyll-gzip/compare/v2.3.0...v2.4.0)
6
15
 
16
+ ### Changed
17
+
7
18
  - Doesn't regenerate files that haven't changed in incremental builds (thanks [@fauno](https://github.com/fauno))
8
19
 
9
20
  ## 2.3.0 (2019-08-26) [☰](https://github.com/philnash/jekyll-gzip/compare/v2.1.1...v2.3.0)
@@ -25,7 +25,7 @@ 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
28
+ next unless regenerate? file.destination(site.dest), site
29
29
 
30
30
  compress_file(
31
31
  file.destination(site.dest),
@@ -51,8 +51,16 @@ module Jekyll
51
51
  def self.compress_directory(dir, site)
52
52
  extensions = zippable_extensions(site).join(',')
53
53
  replace_file = replace_files(site)
54
- files = Dir.glob(dir + "**/*{#{extensions}}")
55
- files.each { |file| compress_file(file, extensions: extensions, replace_file: replace_file) }
54
+ files = Dir.glob(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
56
64
  end
57
65
 
58
66
  ##
@@ -103,12 +111,23 @@ module Jekyll
103
111
  # Compresses the file if the site is built incrementally and the
104
112
  # source was modified or the compressed file doesn't exist
105
113
  def self.regenerate?(file, site)
106
- orig = file.destination(site.dest)
107
- zipped = zipped(orig, replace_files(site))
114
+ zipped = zipped(file, replace_files(site))
108
115
 
116
+ # Definitely generate the file if it doesn't exist yet.
109
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
110
126
 
111
- File.mtime(orig) > File.mtime(zipped)
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")
112
131
  end
113
132
  end
114
133
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module Gzip
5
- VERSION = "2.4.0"
5
+ VERSION = "2.4.1"
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.4.0
4
+ version: 2.4.1
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-12-30 00:00:00.000000000 Z
11
+ date: 2019-12-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: jekyll