Class: SendSonar::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/send_sonar/configuration.rb

Constant Summary collapse

ENV_URLS =
YAML.load_file(File.expand_path('../endpoints.yml', __FILE__))
ALLOWED_ENVS =
ENV_URLS.keys

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#tokenObject



14
15
16
# File 'lib/send_sonar/configuration.rb', line 14

def token
  @token || raise(SendSonar::ConfigurationError.new('You need to set your token, see SendSonar Readme'))
end

Instance Method Details

#envObject



10
11
12
# File 'lib/send_sonar/configuration.rb', line 10

def env
  @env || :sandbox
end

#env=(env_sym) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/send_sonar/configuration.rb', line 18

def env=(env_sym)
  if ALLOWED_ENVS.include?(env_sym.to_s)
    @env = env_sym.to_s
  else
    raise SendSonar::ConfigurationError.new("You attempted to set SendSonar env to #{env_sym}. Should be one of #{env_choices}")
  end
end