Sha256: 724e14d85c31e86b6d117ee227b19fa0524030aff0971157ec679d85dfc5a8c9

Contents?: true

Size: 1.36 KB

Versions: 5

Compression:

Stored size: 1.36 KB

Contents

# frozen_string_literal: true

require 'singleton'
require 'fileutils'
require 'yaml'

# GovFakeNotify module
module GovFakeNotify
  # Central configuration singleton
  class Config
    include Singleton

    attr_accessor :smtp_address, :smtp_port, :smtp_user_name, :smtp_password,
                  :smtp_authentication, :smtp_enable_starttls_auto,
                  :base_url, :database_file, :attachments_path, :include_templates,
                  :include_api_keys, :delivery_method, :port

    def from(hash)
      hash.each_pair do |key, value|
        next unless respond_to?(:"#{key}=")

        send(:"#{key}=", value)
      end
    end
  end

  Config.instance.tap do |c| # rubocop:disable Metrics/BlockLength
    c.smtp_address = ENV.fetch('GOV_FAKE_NOTIFY_SMTP_HOSTNAME', 'localhost')
    c.smtp_port = ENV.fetch('GOV_FAKE_NOTIFY_SMTP_PORT', '1025').to_i
    c.smtp_user_name = ENV['GOV_FAKE_NOTIFY_SMTP_USERNAME']
    c.smtp_password = ENV['GOV_FAKE_NOTIFY_SMTP_PASSWORD']
    c.base_url = ENV.fetch('GOV_FAKE_NOTIFY_BASE_URL', 'http://localhost:8080')
    c.smtp_authentication = nil
    c.smtp_enable_starttls_auto = false
    c.database_file = "#{ENV['HOME']}/.gov_fake_notify/store"
    c.attachments_path = "#{ENV['HOME']}/.gov_fake_notify/attachments"
    c.include_templates = []
    c.include_api_keys = []
    c.delivery_method = 'smtp'
    c.port = 8080
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
gov_fake_notify-2.0.0 lib/gov_fake_notify/config.rb
gov_fake_notify-1.2.0 lib/gov_fake_notify/config.rb
gov_fake_notify-1.1.3 lib/gov_fake_notify/config.rb
gov_fake_notify-1.1.2 lib/gov_fake_notify/config.rb
gov_fake_notify-1.1.1 lib/gov_fake_notify/config.rb