<commit_before># frozen_string_literal: true

require 'pathname'
require 'rghost'
require 'rghost/gs_alone'
require 'tmpdir'

RGhost::GSAlone.prepend (Module.new do
  WindowsRx = /win|ming/

  def initialize params, debug = false
    (@params = params.dup).push(*(@params.pop.split File::PATH_SEPARATOR))
    @debug = debug
  end

  def run
    RGhost::Config.config_platform unless File.exist? RGhost::Config::GS[:path].to_s
    (cmd = @params.slice 1, @params.length).unshift RGhost::Config::GS[:path].to_s
    puts cmd.join ' ' if @debug
    system(*cmd)
  end
end)

RGhost::Engine.prepend (Module.new do
  def shellescape str
    str
  end
end)

module Asciidoctor
  module PDF
    class Optimizer
      (QUALITY_NAMES = {
        'default' => :default,
        'screen' => :screen,
        'ebook' => :ebook,
        'printer' => :printer,
        'prepress' => :prepress,
      }).default = :default

      attr_reader :quality<commit_msg>ignore debug parameter in patched GSAlone class<commit_after># frozen_string_literal: true

require 'pathname'
require 'rghost'
require 'rghost/gs_alone'
require 'tmpdir'

RGhost::GSAlone.prepend (Module.new do
  WindowsRx = /win|ming/

  def initialize params, debug
    (@params = params.dup).push(*(@params.pop.split File::PATH_SEPARATOR))
    @debug = debug
  end

  def run
    RGhost::Config.config_platform unless File.exist? RGhost::Config::GS[:path].to_s
    (cmd = @params.slice 1, @params.length).unshift RGhost::Config::GS[:path].to_s
    #puts cmd if @debug
    system(*cmd)
  end
end)

RGhost::Engine.prepend (Module.new do
  def shellescape str
    str
  end
end)

module Asciidoctor
  module PDF
    class Optimizer
      (QUALITY_NAMES = {
        'default' => :default,
        'screen' => :screen,
        'ebook' => :ebook,
        'printer' => :printer,
        'prepress' => :prepress,
      }).default = :default

      attr_reader :quality
{'fraction_non_alphanumeric': 0.13050314465408805, 'fraction_numerical': 0.0010482180293501049, 'mean_word_length': 3.280269058295964, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4100778', 'n_tokens_mistral': 659, 'n_tokens_neox': 642, 'n_words': 154}