Class: Md2site::EnvCheck
- Inherits:
-
Object
- Object
- Md2site::EnvCheck
- Defined in:
- lib/md2site/envcheck.rb
Overview
環境検査クラス
Instance Method Summary collapse
-
#check_conf_hs(conf_hs, absolutepath_root, root_output_dir) ⇒ void
構成ファイルから変換したハッシュに有効な値が指定されているか調べる(無効であればexitする).
-
#check_conf_hs_and_set(conf_hs) ⇒ void
構成ファイルから変換したハッシュに指定されている値が有効であれば、インスタンス変数で参照できるようにする(無効であればexitする).
-
#check_conf_hs_for_attribute(conf_hs) ⇒ void
Envクラスのattributeとして有効な値が構成ファイル中に指定されているか調べる(無効であればexitする).
-
#check_conf_path ⇒ void
有効な構成ファイルへのパスであるか調べる(無効であればexitする).
-
#initialize(mes, conf_path) ⇒ EnvCheck
constructor
初期化.
Constructor Details
#initialize(mes, conf_path) ⇒ EnvCheck
初期化
12 13 14 15 |
# File 'lib/md2site/envcheck.rb', line 12 def initialize(mes, conf_path) @mes = mes @conf_path = conf_path end |
Instance Method Details
#check_conf_hs(conf_hs, absolutepath_root, root_output_dir) ⇒ void
This method returns an undefined value.
構成ファイルから変換したハッシュに有効な値が指定されているか調べる(無効であればexitする)
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
# File 'lib/md2site/envcheck.rb', line 64 def check_conf_hs(conf_hs, absolutepath_root, root_output_dir) # rubocop:disable Metrics/MethodLength default_table_template = conf_hs["DEFAULT_TABLE_TEMPLATE"] # 5col_no_attr_b.erb unless default_table_template || !FileTest.exist?(default_table_template) @mes.output_fatal("Cannot find valid DEFAULT_TABLE_TEMPLATE(=#{default_table_template}) in #{@conf_path}") exit(@mes.ec("EXIT_CODE_CANNOT_FIND_DEFAULT_TABLE_TEMPLATE")) end sitefile_path = conf_hs["ABSOLUTE_PATH_SITE_FILE"] unless sitefile_path || !FileTest.exist?(sitefile_path) @mes.output_error("Can't get valid ABSOLUTE_PATH_SITE_FILE in #{@conf_path}") exit(@mes.ec("EXIT_CODE_CANNOT_GET_ABSOLUTE_PATH_SITE_FILE")) end absolute_path_status_file = conf_hs["ABSOLUTE_PATH_STATUS_FILE"] unless absolute_path_status_file || !FileTest.exist?(absolute_path_status_file) @mes.output_error("Can't find valid ABSOLUTE_PATH_STATUS_FILE in #{@conf_path}") exit(@mes.ec("EXIT_CODE_CANNOT_GET_ABSOLUTE_PATH_STATUS_FILE")) end unless conf_hs["TEMPLELATE_DIR"] @mes.output_error("Can't get TEPLATE_DIR in #{@conf_path}") exit(@mes.ec("EXIT_CODE_CANNOT_GET_TEPLATE_DIR")) end unless conf_hs["CONF_DIR"] @mes.output_error("Can't get CONF_DIR in #{@conf_path}") exit(@mes.ec("EXIT_CODE_CANNOT_GET_CONF_DIR")) end unless conf_hs["URL"] @mes.output_error("Can't get URL in #{@conf_path}") exit(@mes.ec("EXIT_CODE_CANNOT_GET_URL")) end unless conf_hs["ROOT_TEMPLATE_FUNCTIONS_VARIABLE"] @mes.output_fatal("Cannot get value by ROOT_TEMPLATE_FUNCTIONS_VARIABLE from #{@conf_path}") exit(@mes.ec("EXIT_CODE_CANNOT_GET_ROOT_TEMPLATE_FUNCTIONS_VARIABLE")) end root_output_path = File.join(absolutepath_root, root_output_dir) unless File.exist?(root_output_path) @mes.output_error("Can't find root_output_dir(=#{root_output_dir})") exit(@mes.ec("EXIT_CODE_CANNOT_FIND_ROOTOUTPUTDIR")) end sitefile_path end |
#check_conf_hs_and_set(conf_hs) ⇒ void
This method returns an undefined value.
構成ファイルから変換したハッシュに指定されている値が有効であれば、インスタンス変数で参照できるようにする(無効であればexitする)
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 |
# File 'lib/md2site/envcheck.rb', line 116 def check_conf_hs_and_set(conf_hs) # rubocop:disable Metrics/MethodLength @category_conf_prefix = conf_hs["CATEGORY_CONF_PREFIX"] unless @category_conf_prefix @mes.output_fatal("Cannot get category conf prefix from #{@conf_path}") exit(@mes.ec("EXIT_CODE_CANNOT_GET_CATEGORY_CONF_PREFIX")) end @root_output_dir = conf_hs["OUTPUT_DIR"] unless @root_output_dir @mes.output_fatal("Cannot get rootOutputDir from #{@conf_path}") exit(@mes.ec("EXIT_CODE_CANNOT_GET_ROOTOUTPUTDIR")) end @src_dir = conf_hs["SRC_DIR"] unless @src_dir @mes.output_error("Can't get SRC_DIR in #{@conf_path}") exit(@mes.ec("EXIT_CODE_CANNOT_GET_SRC_DIR")) end @data_dir = conf_hs["DATA_DIR"] unless @data_dir @mes.output_fatal("Cannot get DATA_DIR in #{@conf_path}") exit(@mes.ec("EXIT_CODE_CANNOT_GET_DATA_DIR")) end @work_dir = conf_hs["WORK_DIR"] unless @work_dir @mes.output_fatal("Cannot get WORK_DIR in #{@conf_path}") exit(@mes.ec("EXIT_CODE_CANNOT_GET_WORK_DIR")) end @material_dir = conf_hs["MATERIAL_DIR"] unless @material_dir @mes.output_fatal("Cannot get MATERIAL_DIR in #{@conf_path}") exit(@mes.ec("EXIT_CODE_CANNOT_GET_MATERIAL_DIR")) end @target_command_index = conf_hs["TARGET_COMMAND_INDEX"].to_i unless @target_command_index @mes.output_fatal("Cannot get targetCommandIndex from #{@conf_path}") exit(@mes.ec("EXIT_CODE_CANNOT_CANNOT_GET_TARGET_COMMAND_INDEX")) end @subtarget_command_index = conf_hs["SUBTARGET_COMMAND_INDEX"].to_i unless @subtarget_command_index @mes.output_fatal("Cannot get subTargetCommandIndex from #{@conf_path}") exit(@mes.ec("EXIT_CODE_CANNOT_GET_SUBTARGET_COMMAND_INDEX")) end @key_index = conf_hs["KEY_INDEX"].to_i unless @key_index @mes.output_fatal("Cannot get keyIndex from #{@conf_path}") exit(@mes.ec("EXIT_CODE_CANNOT_GET_KEY_INDEX")) end @htmlfile_index = conf_hs["HTMLFILE_INDEX"].to_i unless @htmlfile_index @mes.output_fatal("Cannot get htmlfileIndex from #{@conf_path}") exit(@mes.ec("EXIT_CODE_CANNOT_GET_HTMLFILE_INDEX")) end @alias_htmlfile_index = conf_hs["ALIAS_HTMLFILE_INDEX"].to_i unless @alias_htmlfile_index @mes.output_fatal("Cannot get aliasHtmlfileIndex from #{@conf_path}") exit(@mes.ec("EXIT_CODE_CANNOT_GET_ALIAS_HTMLFILE_INDEX")) end [@category_conf_prefix, @root_output_dir, @src_dir, @data_dir, @work_dir, @material_dir, @target_command_index, @subtarget_command_index, @key_index, @htmlfile_index, @alias_htmlfile_index] end |
#check_conf_hs_for_attribute(conf_hs) ⇒ void
This method returns an undefined value.
Envクラスのattributeとして有効な値が構成ファイル中に指定されているか調べる(無効であればexitする)
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/md2site/envcheck.rb', line 38 def check_conf_hs_for_attribute(conf_hs) @absolute_path_root_conf = conf_hs["ABSOLUTE_PATH_ROOT_CONF"] unless @absolute_path_root_conf @mes.output_fatal("Cannot get ABSOLUTE_PATH_ROOT_CONF in #{@conf_path}") exit(@mes.ec("EXIT_CODE_CANNOT_GET_ABSOLUTE_PATH_ROOT_CONF")) end unless File.exist?(@absolute_path_root_conf) @mes.output_fatal("Cannot find root conf dir(#{@absolute_path_root_conf})") exit(@mes.ec("EXIT_CODE_CANNOT_FIND_ROOTCONFFILE")) end @absolutepath_root_settingfile = conf_hs["ABSOLUTE_PATH_ROOT_SETTINGFILE"] unless @absolutepath_root_settingfile @mes.output_error("Can't get ABSOLUTE_PATH_ROOT_SETTINGFILE in #{@conf_path}") exit(@mes.ec("EXIT_CODE_CANNOT_GET_ABSOLUTE_PATH_ROOT_SETTINGFILE")) end [@absolute_path_root_conf, @absolutepath_root_settingfile] end |
#check_conf_path ⇒ void
This method returns an undefined value.
有効な構成ファイルへのパスであるか調べる(無効であればexitする)
21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/md2site/envcheck.rb', line 21 def check_conf_path unless @conf_path @mes.output_error("Not specified conf file") exit(@mes.ec("EXIT_CODE_NOT_SPECIFIED_CONFFILE")) end unless File.exist?(@conf_path) @mes.output_fatal("Cannot find conf file(#{confPath})") exit(@mes.ec("EXIT_CODE_CANNOT_FIND_CONFFILE")) end end |