Sha256: e5eaa46a13ca46b1f0c70d476f0e7a0edba156d20440070f06fe3efa05cab511
Contents?: true
Size: 909 Bytes
Versions: 16
Compression:
Stored size: 909 Bytes
Contents
module JsTestDriver # This is a class that given a directory name, puts all its *.html children # into a javascript file, so that they can later be used in the tests class HtmlFixture attr_reader :name, :namespace def initialize(directory_name, name = nil, namespace = nil) @name = name || "all" @namespace = namespace || "htmlFixtures" @data = {} load_data(directory_name) end def to_h @data end def to_s <<JS if (typeof(#{namespace}) === 'undefined') { #{namespace} = {}; } #{namespace}.#{name} = #{self.to_h.to_json}; JS end private def load_data(directory_name) full_path = File.expand_path(directory_name) files = Dir["#{full_path}/**/*.html"] files.each do |file| name = file.gsub(/^#{full_path}\//, '').gsub(/\.html$/, '') @data[name] = File.read(file) end end end end
Version data entries
16 entries across 16 versions & 2 rubygems