Class: Md2site::Testx

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

Overview

全サブコマンド実行クラス

Instance Method Summary collapse

Constructor Details

#initialize(option, mes, verbose, src_data_dir, opt_struct) ⇒ Testx

初期化

Parameters:

  • option (Hash)

    オプション

  • mes (Messagex)

    Messagexクラスのインスタンス

  • verbose (Boolean)

    FileUtilsクラスのメソッドのverbose引数に与える値

  • src_data_dir (String)

    テストデータコピー元

  • opt_struct (Struct)

    オプションストラクト



13
14
15
16
17
18
19
# File 'lib/md2site/testx.rb', line 13

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

Instance Method Details

#execute_subcommand_init(option_url) ⇒ void

This method returns an undefined value.

initサブコマンド実行

Parameters:

  • option_url (Struct)

    オプションURL



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

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

#execute_subcommand_remain(env, content_path, str_variable, str_static, obj_by_yaml) ⇒ void

This method returns an undefined value.

initサブコマンド以外のサブコマンド実行



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/md2site/testx.rb', line 80

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

#init_a(option_url, tsv_filepath, test_data_dir_path) ⇒ void

This method returns an undefined value.

initサブコマンドAパターン実行



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/md2site/testx.rb', line 43

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.conf_file)
  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

#init_b(option, option_url) ⇒ void

This method returns an undefined value.

initサブコマンドBパターン実行



70
71
72
73
74
# File 'lib/md2site/testx.rb', line 70

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