class Nuncium::Configuration
Constants
- ALLOWED_PRODUCTION_SYNTAX
Attributes
api_url[W]
cert_file[W]
data_box[W]
env[W]
key_file[W]
pass_phrase[RW]
password[W]
username[W]
Public Class Methods
new()
click to toggle source
# File lib/nuncium/configuration.rb, line 9 def initialize @username = nil @password = nil @data_box = nil @env = nil @cert_file = nil @key_file = nil @pass_phrase = nil end
Public Instance Methods
api_domain()
click to toggle source
# File lib/nuncium/configuration.rb, line 63 def api_domain if production? return 'https://ws1c.mojedatovaschranka.cz/cert' if @cert_file 'https://ws1.mojedatovaschranka.cz' else return 'https://ws1c.czebox.cz/hspis' if @cert_file 'https://ws1.czebox.cz' end end
cert_file()
click to toggle source
# File lib/nuncium/configuration.rb, line 34 def cert_file if @cert_file && (!@key_file && !@pass_phrase) raise ConfigNotSet, 'pass_phrase and key_file' end return unless @cert_file OpenSSL::X509::Certificate.new(File.read(@cert_file)) end
data_box()
click to toggle source
# File lib/nuncium/configuration.rb, line 19 def data_box raise ConfigNotSet, 'data_box' unless @data_box @data_box end
env()
click to toggle source
env values:
:development (default) :production
# File lib/nuncium/configuration.rb, line 58 def env return :development unless @env @env end
key_file()
click to toggle source
# File lib/nuncium/configuration.rb, line 42 def key_file return nil unless @key_file File.read(@key_file) end
password()
click to toggle source
# File lib/nuncium/configuration.rb, line 29 def password raise ConfigNotSet, 'password' unless @password @password end
private_key()
click to toggle source
# File lib/nuncium/configuration.rb, line 47 def private_key raise ConfigNotSet, 'pass_phrase' if @key_file && !@pass_phrase raise ConfigNotSet, 'key_file' if !@key_file && @pass_phrase OpenSSL::PKey::RSA.new(File.read(@key_file), @pass_phrase) end
production?()
click to toggle source
# File lib/nuncium/configuration.rb, line 78 def production? ALLOWED_PRODUCTION_SYNTAX.include?(@env) end
username()
click to toggle source
# File lib/nuncium/configuration.rb, line 24 def username raise ConfigNotSet, 'username' unless @username @username end
xml_url()
click to toggle source
# File lib/nuncium/configuration.rb, line 73 def xml_url return 'mojedatovaschranka.cz' if production? 'czechpoint.cz' end