Module: Vivlio::Starter::CLI::Build::PdfFinalizer

Defined in:
lib/vivlio/starter/cli/build/pdf_finalizer.rb

Overview

PDF 圧縮・リネームモジュール

Class Method Summary collapse

Class Method Details

.compress_pdf!Object

Step 12: 生成PDFを圧縮



33
34
35
36
# File 'lib/vivlio/starter/cli/build/pdf_finalizer.rb', line 33

def compress_pdf!
  Common.log_action('[Step 12] 生成PDFを圧縮します…')
  PdfCommands.execute_pdf_compress({})
end

.rename_compressed_pdfObject

output_compressed.pdf を動的生成されたファイル名にリネーム



57
58
59
60
61
62
63
64
# File 'lib/vivlio/starter/cli/build/pdf_finalizer.rb', line 57

def rename_compressed_pdf
  target_name = Common.generate_compressed_pdf_filename('pdf')
  return if target_name == 'output_compressed.pdf'

  FileUtils.rm_f(target_name)
  FileUtils.mv('output_compressed.pdf', target_name)
  Common.log_success("圧縮PDFをリネームしました: output_compressed.pdf → #{target_name}")
end

.rename_main_pdfObject

output.pdf を動的生成されたファイル名にリネーム



45
46
47
48
49
50
51
52
53
54
# File 'lib/vivlio/starter/cli/build/pdf_finalizer.rb', line 45

def rename_main_pdf
  return unless File.exist?('output.pdf')

  target_name = Common.generate_output_filename('pdf')
  return if target_name == 'output.pdf'

  FileUtils.rm_f(target_name)
  FileUtils.mv('output.pdf', target_name)
  Common.log_success("出力PDFをリネームしました: output.pdf → #{target_name}")
end

.rename_output_pdfs!Object

Step 13: 出力PDFを最終ファイル名にリネーム



39
40
41
42
# File 'lib/vivlio/starter/cli/build/pdf_finalizer.rb', line 39

def rename_output_pdfs!
  rename_main_pdf
  rename_compressed_pdf if File.exist?('output_compressed.pdf')
end