class Md2site::Testdata

テストデータクラス

Public Class Methods

new(src_data_dir, templatedir, hash, num=1) click to toggle source

初期化

@param src_data_dir [String] テストデータのコピー元ディレクトリ @param templatedir [String] テストデータのテンプレートディレクトリ @param hash [Hash] 修正対象ハッシュ @param num [Integer]

# 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

Public Instance Methods

check_additional_conf(hash) click to toggle source

URLに応じてハッシュの内容を修正する

@param hash [Hash] 修正対象ハッシュ @return [void]

# 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) click to toggle source

適切なHTMLファイル分割クラスの読み込み

@param num [Integer] @return [Array<String>] URLに応じた適切なHTMLファイル分割クラスの読み込み

# 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() click to toggle source

URLに応じたテンプレートディレクトリを得る

@return [Array<String>] URLに応じたテンプレートディレクトリの配列

# 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() click to toggle source

URLに応じたテストデータディレクトリを得る

@return [Array<String>] URLに応じたテストデータディレクトリの配列

# 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