jekyll-postcss 0.2.0 → 0.2.1

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: d3a733de925db3bbf96ab3535777f4e73e4f24fb12232c0c70ee6d8379ff8dd6
4
- data.tar.gz: 88225b5629853dece1241a3973304ca24dae4c85f9dd85bc114bd64765ccb6ff
3
+ metadata.gz: 1d24644cb78514576747cb68fb820e064d2d8a2c0bfa536c50207f771618b127
4
+ data.tar.gz: c635127fac9be4dcb76587ac4e74f5a73cacce4695a4f6f5d21f6599c79c0b40
5
5
  SHA512:
6
- metadata.gz: e78c0ff9d352295e934ae7c69d392773e5333796755182f875e6a731111c0320f6636b4248b1aad6f4195cd3cda653bb03c941bc8bded2d78f728b7b0733b35b
7
- data.tar.gz: 9dc039ca20a50b8a9ec29ba3933c11adea7ca1f9ae48247477db54e48fc2e593450ee3a35b402ac575800de7de1a49cf3efa3143163570634d9c8df2e0a3ef9e
6
+ metadata.gz: e619eff707df4d791cb3462e9974ff5ad1f356625bf251e202b16361e3e3830eca5c4577d4b7ea8c9b1abff2008310037d5e0eb0d96204298fbbad371c54cb59
7
+ data.tar.gz: '0414187afce84f987501b61148e91de68c2a69c46d270d9f47e241ec3fad569dd18079a27b809818778529c6a8c53d7db01d842d3542eb131fcbf96f87d66cc0'
data/CHANGELOG.md ADDED
@@ -0,0 +1,13 @@
1
+ # Changelog
2
+
3
+ ## 0.2.1
4
+
5
+ - Recompile when CSS imports change
6
+
7
+ ## 0.2.0
8
+
9
+ - Cache styles to avoid unnecessary rebuilds
10
+
11
+ ## 0.1.0
12
+
13
+ - Initial Release
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Jekyll
4
4
  module PostCss
5
- VERSION = "0.2.0"
5
+ VERSION = "0.2.1"
6
6
  end
7
7
  end
@@ -13,6 +13,7 @@ module Jekyll
13
13
  super
14
14
 
15
15
  @raw_cache = nil
16
+ @import_raw_cache = {}
16
17
  @converted_cache = nil
17
18
  end
18
19
 
@@ -27,9 +28,12 @@ module Jekyll
27
28
  def convert(content)
28
29
  raise PostCssNotFoundError unless File.file?("./node_modules/.bin/postcss")
29
30
 
30
- raw_digest = Digest::MD5.hexdigest content
31
- if @raw_cache != raw_digest
32
- @raw_cache = raw_digest
31
+ @raw_digest = Digest::MD5.hexdigest content
32
+ @raw_import_digests = import_digests(content)
33
+
34
+ if cache_miss.any?
35
+ @raw_cache = @raw_digest.dup
36
+ @import_raw_cache = @raw_import_digests.dup
33
37
 
34
38
  compiled_css, status =
35
39
  Open3.capture2("./node_modules/.bin/postcss", :stdin_data => content)
@@ -37,9 +41,34 @@ module Jekyll
37
41
  raise PostCssRuntimeError unless status.success?
38
42
 
39
43
  @converted_cache = compiled_css
40
- else
41
- @converted_cache
42
44
  end
45
+
46
+ reset
47
+
48
+ @converted_cache
49
+ end
50
+
51
+ private
52
+
53
+ def import_digests(content)
54
+ content
55
+ .scan(%r!^@import "(?<file>.*)";$!)
56
+ .flatten
57
+ .each_with_object({}) do |import, acc|
58
+ file = "#{import}.css"
59
+ acc[import] = Digest::MD5.hexdigest IO.read(file) if File.file?(file)
60
+ end
61
+ end
62
+
63
+ def cache_miss
64
+ @raw_import_digests
65
+ .map { |import, hash| @import_raw_cache[import] != hash }
66
+ .prepend(@raw_cache != @raw_digest)
67
+ end
68
+
69
+ def reset
70
+ @raw_digest = nil
71
+ @raw_import_digest = nil
43
72
  end
44
73
  end
45
74
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-postcss
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mitchell Hanberg
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-01-21 00:00:00.000000000 Z
11
+ date: 2019-05-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -92,6 +92,7 @@ files:
92
92
  - ".rubocop.yml"
93
93
  - ".tool-versions"
94
94
  - ".travis.yml"
95
+ - CHANGELOG.md
95
96
  - CODE_OF_CONDUCT.md
96
97
  - Gemfile
97
98
  - LICENSE.txt