class Md2site::EnvCheck
環境検査クラス
Public Class Methods
new(mes, conf_path)
click to toggle source
初期化
@param mes [Messagex] Messagexクラスのインスタンス @param conf_path [String] 構成ファイルのパス @param verbose [Boolean] FileUtilsクラスのメソッドのverbose引数に与える値
# File lib/md2site/envcheck.rb, line 12 def initialize(mes, conf_path) @mes = mes @conf_path = conf_path end
Public Instance Methods
check_conf_hs(conf_hs, absolutepath_root, root_output_dir)
click to toggle source
構成ファイルから変換したハッシュに有効な値が指定されているか調べる(無効であればexitする)
@param conf_hs [Hash] 構成ハッシュ @param absolutepath_root [String] プロジェクトルートへの絶対パス @param root_output_dir [String] ルート出力ディレクトリ @return [void]
# 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)
click to toggle source
構成ファイルから変換したハッシュに指定されている値が有効であれば、インスタンス変数で参照できるようにする(無効であればexitする)
@param conf_hs [Hash] 構成ハッシュ @return [void]
# 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)
click to toggle source
Envクラスのattributeとして有効な値が構成ファイル中に指定されているか調べる(無効であればexitする)
@param conf_hs [Hash] 構成ハッシュ @return [void]
# 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()
click to toggle source
有効な構成ファイルへのパスであるか調べる(無効であればexitする)
@return [void]
# 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