Sha256: c6632ed54027bb01e6869fc64d43ca31f93b46bc074e3ab501cfa1207c9b6a7f
Contents?: true
Size: 1.8 KB
Versions: 2
Compression:
Stored size: 1.8 KB
Contents
# frozen_string_literal: true require 'ffaker' require 'article_fixture_gen/data/article_content' require 'article_fixture_gen/data/pmtp_decorated_markup' require 'article_fixture_gen/data/smtp_decorated_markup' require 'article_fixture_gen/support/logging' # Generate blog post/article fixture data, with embedded marker tag pairs. module ArticleFixtureGen # Details of data built by the generator. module Data # Details of generated Article and internal details thereof. class Article # Reek kvetches about a :reek:ControlParameter. Too bad. def initialize(config:, base_content: nil) @config = config logger = SemanticLogger['Article#initialize'] @base_content = base_content || Default.base_content(config) logger.trace "Line #{__LINE__}", base_content: @base_content @str = nil self end def to_s return @str if @str str = add_mtps(base_content, PmtpDecoratedMarkup) @str = add_mtps(str, SmtpDecoratedMarkup) end private attr_reader :base_content, :config def add_mtps(base_markup, decorator) decorator.call(base_markup: base_markup, config: config).rstrip end # Default-value builders for #initialize parameters. module Default # FIXME: We would *prefer* `fancy: true`. However, there is the problem # of https://github.com/ffaker/ffaker/issues/298 to contend with. DEFAULT_FAKER_OPTS = { fancy: false }.freeze def self.base_content(config, faker_opts = DEFAULT_FAKER_OPTS) ArticleContent.new(config: config) do |sentence_count| FFaker::HTMLIpsum.p(sentence_count, faker_opts) end.to_s end end private_constant :Default end # class ArticleFixtureGen::Data::Article end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
article_fixture_gen-0.1.2 | lib/article_fixture_gen/data/article.rb |
article_fixture_gen-0.1.1 | lib/article_fixture_gen/data/article.rb |