Class: Md2site::Setup

Inherits:
Object
  • Object
show all
Defined in:
lib/md2site/setup.rb

Overview

setupサブコマンドクラス

Constant Summary collapse

ACCESS_WAIT_SEC =

WEBサイトへのアクセス待ち時間(秒単位)

10

Instance Method Summary collapse

Constructor Details

#initialize(env, mes) ⇒ Setup

初期化

Parameters:

  • env (Env)

    環境クラスのメソッド

  • mes (Messagex)

    Messagexクラスのインスタンス



26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/md2site/setup.rb', line 26

def initialize(env, mes)
  @env = env
  @mes = mes
  @category_target = @env.category_target
  absolute_path_status_file = env.conf_hs["ABSOLUTE_PATH_STATUS_FILE"]
  @url = @env.conf_hs["URL"]
  @res = {}

  @mes.add_exitcode("EXIT_CODE_BY_EXCEPTION")
  @mes.add_exitcode("EXIT_CODE_EXECUTE_SETUP_BEFORE_UPDATE_HTMLFILES")
  @mes.add_exitcode("EXIT_CODE_CANNOT_FIND_DEST_DIR")
  @mes.add_exitcode("EXIT_CODE_CANNOT_CONVERT_FROM_HTML_TO_MD")
  @mes.add_exitcode("EXIT_CODE_PANDOC_EXIT_ABNORMALLY")
  @status_file = StatusFile.new(absolute_path_status_file, @env.absolutepath_root, @url, @mes)
end

Instance Method Details

#execute_subcommand(option) ⇒ void

This method returns an undefined value.

サブコマンド実行

Parameters:

  • option (String)

    サブコマンドのオプション



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/md2site/setup.rb', line 47

def execute_subcommand(option)
  case option.name
  when "contentUpdate"
    update_htmlfiles
  when "zcontents"
    dir = @env.get_filepath(option.value)
    unless dir
      @mes.exc_make_directory(option.value) { FileUtils.mkdir_p(option.value) }
      dir = @env.get_filepath(option.value)
    end
    unless dir || FileTest.directory?(dir)
      @mes.output_fatal("Can't find drectory(=#{dir}")
      exit(@mes.ec("EXIT_CODE_CANNOT_FIND_DIRECTORY"))
    end
    get_remote_contents(dir)
  when "getfiles"
    dir = @env.get_filepath(option.value)
    get_remote_file_headers(dir)
  end
end