lib/jekyll/converters/postcss.rb in jekyll-postcss-0.4.1 vs lib/jekyll/converters/postcss.rb in jekyll-postcss-0.5.0

- old
+ new

@@ -10,10 +10,11 @@ priority :normal def initialize(config = {}) super + @cache_enabled = config.fetch("postcss", {}).fetch("cache", true) @socket = config.fetch("socket") { ::PostCss::Socket.new } @raw_cache = nil @import_raw_cache = {} @converted_cache = nil end @@ -30,11 +31,11 @@ raise PostCssNotFoundError unless Dir.exist?("./node_modules/postcss") @raw_digest = Digest::MD5.hexdigest content @raw_import_digests = import_digests(content) - if cache_miss.any? + if cache_disabled? || cache_miss? @raw_cache = @raw_digest.dup @import_raw_cache = @raw_import_digests.dup @socket.write content @@ -56,13 +57,18 @@ file = "#{import}.css" acc[import] = Digest::MD5.hexdigest IO.read(file) if File.file?(file) end end - def cache_miss + def cache_disabled? + @cache_enabled == false + end + + def cache_miss? @raw_import_digests .map { |import, hash| @import_raw_cache[import] != hash } .unshift(@raw_cache != @raw_digest) + .any? end def reset @raw_digest = nil @raw_import_digest = nil