# 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 = "#{word.capitalize} | #{word.capitalize} | #{word.capitalize} | #{word.capitalize} |
---|---|---|---|
#{words(1).capitalize} | #{words(1).capitalize} | #{words(1).capitalize} | #{a} |
#{fancy_string}
" end s << table(rand(4)) s << "#{paragraphs 3}
##{word} h1 a {
display: block;
width: 300px;
height: 80px;
}
"
end
def fancy_string(count = 3, include_breaks = false)
sep = include_breaks ? "#{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('