replace lib/filters/gzip.rb with nanoc-gunzip.rb

This commit is contained in:
0x1eef 2022-11-12 13:28:26 -03:00 committed by Robert
parent be79f36d2d
commit a2c9e774af
4 changed files with 4 additions and 44 deletions

View file

@ -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"

View file

@ -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

1
Rules
View file

@ -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(

View file

@ -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