# encoding: utf-8 module FFaker # Loosely based on http://html-ipsum.com/ # Requires FFaker::Lorem module module HTMLIpsum extend ModuleUtils extend self def a(word_count = 2) "#{words(word_count).capitalize!}" end def p(count = 3, options = {}) options = {fancy: false, include_breaks: false}.merge(options) if options[:fancy] s = fancy_string(count, options[:include_breaks]) else mode = options[:include_breaks] ? "paragraphs" : "paragraph" s = send(mode.to_sym, count) end "

#{s}

" end def dl(definitions = 2) s = "
" definitions.times do s << "
#{words(1).capitalize!}
#{paragraph 2}
" end s << "
" end def ul_short(items = 3) s = "" end def ul_long(items = 3) s = "" end def ol_short(items = 3) s = "
    " items.times do s << "
  1. #{sentence 2}
  2. " end s << "
" end def ol_long(items = 3) s = "
    " items.times do s << "
  1. #{paragraph 2}
  2. " end s << "
" end def ul_links(items = 3) s = "" end def table(rows = 3) s = "" rows.times do s << "" end s << "
#{word.capitalize} #{word.capitalize} #{word.capitalize} #{word.capitalize}
#{words(1).capitalize} #{words(1).capitalize} #{words(1).capitalize} #{a}
" end def body s = "

#{words(2).capitalize}

" rand(4).times do s << "

#{fancy_string}

" end s << table(rand(4)) s << "

#{words(2).capitalize}

    " rand(4).times do s << "
  1. #{paragraph 1}
  2. " end s << "

#{paragraphs 3}

#{words(2).capitalize!}


      ##{word} h1 a {
        display: block;
        width: 300px;
        height: 80px;
      }
      
" end def fancy_string(count = 3, include_breaks = false) sep = include_breaks ? "
" : " " a = k([ "#{words(2).capitalize!}.", "#{paragraph}", "#{words 2}", "#{a 2}" ] + FFaker::Lorem::paragraphs(count)) a.sample(count).join(sep) end private def word FFaker::Lorem::word end def words(word_count = 3) FFaker::Lorem::words(word_count).join(' ') end def sentence(word_count = 3) FFaker::Lorem::sentence(word_count) end def sentences(sentence_count = 3) FFaker::Lorem::sentences(sentence_count).join(' ') end def paragraph(sentence_count = 3) FFaker::Lorem::paragraph(sentence_count) end def paragraphs(paragraph_count = 3) FFaker::Lorem::paragraphs(paragraph_count).join('
') end end end