From a2c9e774af26df7ff2f6d810ea54b755879c141c Mon Sep 17 00:00:00 2001 From: 0x1eef <0x1eef@protonmail.com> Date: Sat, 12 Nov 2022 13:28:26 -0300 Subject: [PATCH] replace lib/filters/gzip.rb with nanoc-gunzip.rb --- Gemfile | 1 + Gemfile.lock | 2 ++ Rules | 1 + lib/filters/gzip.rb | 44 -------------------------------------------- 4 files changed, 4 insertions(+), 44 deletions(-) delete mode 100644 lib/filters/gzip.rb diff --git a/Gemfile b/Gemfile index 15df9df9e..d896f751a 100644 --- a/Gemfile +++ b/Gemfile @@ -3,6 +3,7 @@ source "https://rubygems.org" gem "nanoc", "~> 4.12" gem "nanoc-live", "~> 1.0" +gem "nanoc-gunzip.rb", "~> 0.1" gem "rainpress", "~> 1.0" gem "sass" gem "standardrb" diff --git a/Gemfile.lock b/Gemfile.lock index b64d30877..a9c854da5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -66,6 +66,7 @@ GEM nanoc-checking (~> 1.0) nanoc-cli (~> 4.11, >= 4.11.15) nanoc-core (~> 4.11, >= 4.11.15) + nanoc-gunzip.rb (0.1.2) nanoc-live (1.0.0) adsf-live (~> 1.4) listen (~> 3.0) @@ -138,6 +139,7 @@ DEPENDENCIES adsf dotenv nanoc (~> 4.12) + nanoc-gunzip.rb (= 0.1.2) nanoc-live (~> 1.0) paint puma diff --git a/Rules b/Rules index 0240b3ad9..84aaa1b09 100644 --- a/Rules +++ b/Rules @@ -1,6 +1,7 @@ #!/usr/bin/env ruby # frozen_string_literal: true require "ryo" +require "nanoc-gunzip" LOCALES = %w[ar en] SURAH_ID_TO_SLUG = Ryo.from( diff --git a/lib/filters/gzip.rb b/lib/filters/gzip.rb deleted file mode 100644 index b9e3bd815..000000000 --- a/lib/filters/gzip.rb +++ /dev/null @@ -1,44 +0,0 @@ -# frozen_string_literal: true - -module GZip - require "zlib" - include Zlib - - private - - def gzip(content, level, strategy) - level ||= Zlib::BEST_COMPRESSION - strategy ||= Zlib::DEFAULT_STRATEGY - GzipWriter.open(output_filename, level, strategy) do - _1.write(content) - end - end -end - -class Nanoc::Filter::GZipText < Nanoc::Filter - include GZip - identifier :gzip_text - type text: :binary - - def run(content, options = {}) - gzip( - content, - options[:delete], - options[:strategy] - ) - end -end - -class Nanoc::Filter::GZipBinary < Nanoc::Filter - include GZip - identifier :gzip_binary - type binary: :binary - - def run(file, options = {}) - gzip( - File.binread(file), - options[:delete], - options[:strategy] - ) - end -end