class ReqresRspec::Configuration

Constants

DEFAULT_FORMATTERS

Attributes

amazon_s3[R]
formatters[RW]
output_path[RW]
root[R]
templates_path[RW]
title[RW]

Public Class Methods

new() click to toggle source
# File lib/reqres_rspec/configuration.rb, line 28
def initialize
  ReqresRspec.logger.level = Logger::INFO
  @root = if defined?(Rails)
    Rails.root.to_s
  else
    raise 'REQRES_RSPEC_ROOT is not defined' if ENV['REQRES_RSPEC_ROOT'].blank?
    ENV['REQRES_RSPEC_ROOT']
  end

  @templates_path = File.expand_path('../templates', __FILE__)
  @output_path = File.join(@root, '/doc/reqres')
  FileUtils.mkdir_p @output_path

  requested_formats = (ENV['REQRES_RSPEC_FORMATTERS'].to_s).split(',')
  requested_formats.sort_by!{|fmt| [DEFAULT_FORMATTERS.index(fmt), fmt]}
  @formatters = requested_formats.empty? ? %w(html) : requested_formats

  @amazon_s3 = {
    credentials: {
      access_key_id: ENV['AWS_ACCESS_KEY_ID'],
      secret_access_key: ENV['AWS_SECRET_ACCESS_KEY'],
      region: (ENV['AWS_REGION'] || 'us-east-1'),
    },
    bucket: ENV['AWS_REQRES_BUCKET'],
    enabled: false
  }

  @title = 'API Docs'
end

Public Instance Methods

amazon_s3=(config={}) click to toggle source
# File lib/reqres_rspec/configuration.rb, line 65
def amazon_s3=(config={})
  @amazon_s3.deep_merge!(config)
end