Sha256: 17e53e536ac05526704c2f311da430d9658c9230429e58b732d02cb8b9005b28
Contents?: true
Size: 950 Bytes
Versions: 5
Compression:
Stored size: 950 Bytes
Contents
module TempFileHelper TEMP_DIR = File.expand_path('content', File.dirname(__FILE__)) def create_temp_directory FileUtils.mkdir_p(TempFileHelper::TEMP_DIR) end def remove_temp_directory FileUtils.rm_r(TempFileHelper::TEMP_DIR, :force => true) end def temp_path(base) File.join(TempFileHelper::TEMP_DIR, base) end end module PageFactory include TempFileHelper def create_file(name, metadata = {}) full_name = File.join(TEMP_DIR, name) metatext = metadata .select { |key, value| key != :content} .map { |key, value| "#{key}: #{value}" }.join("\n") content = metadata[:content] ? metadata[:content] : "Some stuff" contents =<<-EOF #{metatext} #{content} EOF File.open(full_name, 'w') { |file| file.write(contents) } full_name end def create_page(name, metadata = {}) full_name = create_file(name, metadata) Spandex::Page.from_filename(full_name, TEMP_DIR) end end
Version data entries
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
spandex-0.0.7 | spec/spec_helper.rb |
spandex-0.0.6 | spec/spec_helper.rb |
spandex-0.0.5 | spec/spec_helper.rb |
spandex-0.0.4 | spec/spec_helper.rb |
spandex-0.0.3 | spec/spec_helper.rb |