Sha256: ca69d483db4a3171034dc618f9a7d7b06a04cbfff3a6dcbaa7c20401cd38b16e

Contents?: true

Size: 1.41 KB

Versions: 1

Compression:

Stored size: 1.41 KB

Contents

module Md2site
  class Testdata
    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

    def check_additional_conf(hash)
      url = hash["url"]
      hash["functions_variable"] ||= ""
      hash["functions_static"]   ||= %Q(ROOT_TEMPLATE_FUNCTIONS_VARIABLE=#{File.join(@src_data_dir, %q(/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=#{File.join(@src_data_dir, %q(/template/functions_variable.erb))})
        hash["functions_static"]   = %Q(ROOT_TEMPLATE_FUNCTIONS_STATIC=#{File.join(@src_data_dir, %q(/template/functions_static.erb))})
      end
    end

    def template_dir_array
      array = [@templatedir]

      case @hash["url"]
      when /www\.toppers\.jp/
        array << TEMPLATE_DIR2
      end

      array
    end

    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
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
md2site-0.1.2 lib/md2site/testdata.rb