Sha256: b664e3de7907e1291b14612e2e8810bbd380112b2551400ec0f0b61f811c2967
Contents?: true
Size: 1.29 KB
Versions: 2
Compression:
Stored size: 1.29 KB
Contents
# frozen_string_literal: true require 'forwardable' require_relative './config/builder' require_relative './config/constants' require_relative './config/data' require_relative './config/option_validator' # Generate blog post/article fixture data, with embedded marker tag pairs. module ArticleFixtureGen # Maintain configuration information for app. class Config # Error raised when validating one or more attributes fails. class ValidationError < RuntimeError end # class ArticleFixtureGen::Config::ValidationError extend Forwardable def initialize(options_hash) data = Builder.call(options_hash) validate(data) # will raise if not valid @values = Data.new data self end def self.defaults new Constants::DEFAULTS end def_delegators :@values, :article_count, :config, :config_given, :generate_config, :generate_config_given, :para_count_max, :para_count_min, :pmtp_count, :pmtp_text, :sent_count_max, :sent_count_min, :smtp_count, :smtp_text, :to_hash private def validate(data) errors = OptionValidator.call options: data return self if errors.empty? raise ValidationError, errors.first end end # class ArticleFixtureGen::Config end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
article_fixture_gen-0.1.2 | lib/article_fixture_gen/config.rb |
article_fixture_gen-0.1.1 | lib/article_fixture_gen/config.rb |