class EnvChecker::Configuration
Attributes
environment[RW]
environments[RW]
logger[RW]
optional_variables[RW]
required_variables[RW]
slack_notifier[RW]
slack_webhook_url[RW]
Public Class Methods
new()
click to toggle source
Has default settings, which can be overridden in the initializer.
# File lib/env_checker/configuration.rb, line 14 def initialize @environment = ENV['RACK_ENV'] || ENV['RAILS_ENV'] @environments = [] @required_variables = [] @optional_variables = [] @slack_webhook_url = nil @slack_notifier = nil @logger = Logger.new(STDERR) end
Public Instance Methods
after_initialize()
click to toggle source
# File lib/env_checker/configuration.rb, line 24 def after_initialize valid? @slack_webhook_url && @slack_webhook_url != '' && @slack_notifier = Slack::Notifier.new(@slack_webhook_url) @required_variables && @required_variables = @required_variables.map(&:upcase) @optional_variables && @optional_variables = @optional_variables.map(&:upcase) true end
Private Instance Methods
valid?()
click to toggle source
# File lib/env_checker/configuration.rb, line 42 def valid? if required_variables && required_variables.class != Array raise ConfigurationError.new("Invalid value required_variables: #{required_variables}") end if optional_variables && optional_variables.class != Array raise ConfigurationError.new("Invalid value optional_variables: #{optional_variables}") end unless valid_url?(slack_webhook_url) raise ConfigurationError.new("Invalid value slack_webhook_url: #{slack_webhook_url}") end true end
valid_url?(uri)
click to toggle source
# File lib/env_checker/configuration.rb, line 58 def valid_url?(uri) return true unless uri valid = (uri =~ URI.regexp(%w(http https))) valid && valid.zero? end