Class: Md2site::Testdata
- Inherits:
-
Object
- Object
- Md2site::Testdata
- Defined in:
- lib/md2site/testdata.rb
Overview
テストデータクラス
Instance Method Summary collapse
-
#check_additional_conf(hash) ⇒ void
URLに応じてハッシュの内容を修正する.
-
#initialize(src_data_dir, templatedir, hash, num = 1) ⇒ Testdata
constructor
初期化.
-
#require_htmlutils(num = 1) ⇒ Array<String>
適切なHTMLファイル分割クラスの読み込み.
-
#template_dir_array ⇒ Array<String>
URLに応じたテンプレートディレクトリを得る.
-
#testdata_dir_array ⇒ Array<String>
URLに応じたテストデータディレクトリを得る.
Constructor Details
#initialize(src_data_dir, templatedir, hash, num = 1) ⇒ Testdata
初期化
12 13 14 15 16 17 18 19 |
# File 'lib/md2site/testdata.rb', line 12 def initialize(src_data_dir, templatedir, hash, num=1) @hash = hash @src_data_dir = src_data_dir @templatedir = templatedir @content_division = @hash["CONTENT_DIVISION_WAY"] check_additional_conf(@hash) require_htmlutils(num) unless defined?(HTMLUtils) end |
Instance Method Details
#check_additional_conf(hash) ⇒ void
This method returns an undefined value.
URLに応じてハッシュの内容を修正する
26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/md2site/testdata.rb', line 26 def check_additional_conf(hash) url = hash["url"] hash["functions_variable"] ||= "" hash["functions_static"] ||= %Q(ROOT_TEMPLATE_FUNCTIONS_VARIABLE=#{%q(${ABSOLUTE_PATH_ROOT_TEMPLATE}/functions_variable.erb)}) hash["contentDivisionWay"] ||= "" case url when /www\.toppers\.jp/ hash["contentDivisionWay"] = "CONTENT_DIVISION_WAY=0" hash["functions_variable"] = %Q(ROOT_TEMPLATE_FUNCTIONS_VARIABLE=#{%q(${ABSOLUTE_PATH_ROOT_TEMPLATE}/functions_variable.erb)}) hash["functions_static"] = %Q(ROOT_TEMPLATE_FUNCTIONS_STATIC=#{%q(${ABSOLUTE_PATH_ROOT_TEMPLATE}/functions_static.erb)}) end end |
#require_htmlutils(num = 1) ⇒ Array<String>
適切なHTMLファイル分割クラスの読み込み
77 78 79 80 81 82 83 84 85 86 87 88 |
# File 'lib/md2site/testdata.rb', line 77 def require_htmlutils(num=1) if @content_division num = @content_division.to_i end case num when 0 require "md2site/htmlutils0" else require "md2site/htmlutils" end end |
#template_dir_array ⇒ Array<String>
URLに応じたテンプレートディレクトリを得る
44 45 46 47 48 49 50 51 52 53 |
# File 'lib/md2site/testdata.rb', line 44 def template_dir_array array = [@templatedir] case @hash["url"] when /www\.toppers\.jp/ array << TEMPLATE_DIR2 end array end |
#testdata_dir_array ⇒ Array<String>
URLに応じたテストデータディレクトリを得る
59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/md2site/testdata.rb', line 59 def testdata_dir_array array = [] case @hash["url"] when /www\.toppers\.jp/ array << TESTDATA_DIR_TOPPERS when /northern-cross\.info/ array << TESTDATA_DIR_TOPPERS end array end |