Class: VivlioStarter::CLI::PdfCommands::PdfCompressor

Inherits:
Object
  • Object
show all
Defined in:
lib/vivlio_starter/cli/pdf.rb

Overview

Ghostscript を利用して PDF を圧縮する

動作モード(options):

- false(既定): vs pdf:compress の単体実行。利用者の明示要求のため、
gs 不在・圧縮失敗は 🔴 エラー + exit 1 で報告する
- true: vs build の Step 12 から呼ばれる。PDF は生成済みのため、
gs 不在・圧縮失敗でもビルドを止めず 🟡 でスキップを案内して続行する

Instance Method Summary collapse

Constructor Details

#initialize(options, cli_input = nil, cli_output = nil) ⇒ PdfCompressor

Returns a new instance of PdfCompressor.



173
174
175
176
177
178
179
180
181
# File 'lib/vivlio_starter/cli/pdf.rb', line 173

def initialize(options, cli_input = nil, cli_output = nil)
  @options = options || {}
  @cli_input = cli_input
  @cli_output = cli_output
  @input_pdf = nil
  @output_pdf = nil
  @compression_success = false
  @skipped = false
end

Instance Method Details

#callObject



183
184
185
186
187
188
189
190
# File 'lib/vivlio_starter/cli/pdf.rb', line 183

def call
  apply_verbose
  determine_paths
  ensure_input_exists
  Common.log_action("PDFを圧縮しています…(入力: #{input_pdf} → 出力: #{output_pdf}")
  compress_pdf
  report_result
end