Method: Device::Ibooks#hook_convert_txt_to_ebook_file

Defined in:
lib/device/ibooks.rb

#hook_convert_txt_to_ebook_file(&original_func) ⇒ Object

EPUBへ変換したあとiBooksが管理しているディレクトリに展開する



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/device/ibooks.rb', line 35

def hook_convert_txt_to_ebook_file(&original_func)
  ebook_file_path = original_func.call
  return ebook_file_path unless ebook_file_path
  return ebook_file_path unless @@__ibooks_container_dir
  epubdir_path = nil
  if @argument_target_type == :file
    @toc_url = nil
  else
    @toc_url = @novel_data["toc_url"]
    epubdir_path = get_epubdir_path_in_ibooks_container
  end
  if epubdir_path && File.exist?(epubdir_path)
    extract_epub(ebook_file_path, epubdir_path)
    puts "iBooksに登録してあるEPUBを更新しました"
  else
    epubdir_path = watch_ibooks_container(ebook_file_path)
    if epubdir_path
      regist_epubdir_path_to_setting(epubdir_path) if @toc_url
      puts "iBooksへの登録を確認しました"
    else
      error "EPUBの展開後のフォルダが見つかりませんでした。" \
            "iBooksがインストールされているか確認して下さい"
    end
  end
  ebook_file_path
end