module Md2site class Testx def initialize(option, mes, verbose, src_data_dir, opt_struct) @option = option @mes = mes @verbose = verbose @src_data_dir = src_data_dir @opt_struct = opt_struct end def execute_subcommand_init(option_url) case option_url.value when /northern\-cross\.info/ init_a(option_url, %q(/testdata/site.tsv), "testdata/*") when /www\.toppers\.jp/ init_a(option_url, %q(/testdata/site.tsv), "testdata0/*") when /example\.com/ init_b(@option, option_url) else init_b(@option, option_url) end end def init_a(option_url, tsv_filepath, test_data_dir_path) root_path = @option.value optionx = @opt_struct.new("init", root_path) init = Init.new(@src_data_dir, @mes, @verbose) init.execute_subcommand(optionx, option_url) conf_dir = File.join(root_path, init.hs["conf_dir"]) conf_path = File.join(conf_dir, init.confFile) dir = File.dirname(root_path) base = File.basename(root_path) content_path = File.join(dir, %Q(#{base}-contents)) @mes.exc_make_directory(content_path) { FileUtils.mkdir_p(content_path) } src_path = File.join(@src_data_dir, tsv_filepath) dest_path = conf_dir @mes.exc_file_copy(src_path, dest_path) { FileUtils.copy(src_path, dest_path) } Dir[File.join(@src_data_dir, test_data_dir_path)].each do |x| next if File.directory?(x) @mes.exc_file_copy(x, conf_dir) { FileUtils.cp(x, conf_dir) } end [conf_path, content_path] end def init_b(option, option_url) @mes.output_warn(%Q(option=#{option.value})) @mes.output_warn(%Q(optionUrl=#{option_url.value})) exit(@mes.ec("EXIT_CODE_NORMAL_EXIT")) end def execute_subcommand_remain(env, content_path, str_variable, str_static, obj_by_yaml) setup = Setup.new(env, @mes) optionx = @opt_struct.new("zcontents", content_path) setup.execute_subcommand(optionx) optionx = @opt_struct.new("getfiles", content_path) setup.execute_subcommand(optionx) optionx = @opt_struct.new("contentUpdate") setup.execute_subcommand(optionx) info = Info.new(env) optionx = @opt_struct.new("zlist") info.execute_subcommand(optionx) optionx = @opt_struct.new("zindex") info.execute_subcommand(optionx) make = Make.new(env, @mes, @verbose, str_variable, str_static, obj_by_yaml) env.commands.map {|x| make.do_multiple_commands(x[0]) } end end end