Class: OxTenderAbstract::Configuration

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

Overview

Configuration for the library

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/oxtenderabstract/configuration.rb', line 12

def initialize
  @token = nil
  @timeout_open = 30
  @timeout_read = 120
  @ssl_verify = false
  @wsdl_url = nil  # Will be set later
  @logger = nil    # Will be set later
  @auto_wait_on_block = true  # Автоматически ждать при блокировке
  @block_wait_time = 610      # Время ожидания при блокировке (10 мин + 10 сек)
  @max_wait_time = 900        # Максимальное время ожидания (15 мин)
end

Instance Attribute Details

#auto_wait_on_blockObject

Returns the value of attribute auto_wait_on_block.



8
9
10
# File 'lib/oxtenderabstract/configuration.rb', line 8

def auto_wait_on_block
  @auto_wait_on_block
end

#block_wait_timeObject

Returns the value of attribute block_wait_time.



8
9
10
# File 'lib/oxtenderabstract/configuration.rb', line 8

def block_wait_time
  @block_wait_time
end

#loggerObject



28
29
30
31
32
33
34
35
# File 'lib/oxtenderabstract/configuration.rb', line 28

def logger
  @logger ||= Logger.new($stdout).tap do |log|
    log.level = Logger::INFO
    log.formatter = proc do |severity, datetime, progname, msg|
      "[#{datetime.strftime('%Y-%m-%d %H:%M:%S')}] #{severity}: #{msg}\n"
    end
  end
end

#max_wait_timeObject

Returns the value of attribute max_wait_time.



8
9
10
# File 'lib/oxtenderabstract/configuration.rb', line 8

def max_wait_time
  @max_wait_time
end

#ssl_verifyObject

Returns the value of attribute ssl_verify.



8
9
10
# File 'lib/oxtenderabstract/configuration.rb', line 8

def ssl_verify
  @ssl_verify
end

#timeout_openObject

Returns the value of attribute timeout_open.



8
9
10
# File 'lib/oxtenderabstract/configuration.rb', line 8

def timeout_open
  @timeout_open
end

#timeout_readObject

Returns the value of attribute timeout_read.



8
9
10
# File 'lib/oxtenderabstract/configuration.rb', line 8

def timeout_read
  @timeout_read
end

#tokenObject

Returns the value of attribute token.



8
9
10
# File 'lib/oxtenderabstract/configuration.rb', line 8

def token
  @token
end

#wsdl_urlObject



24
25
26
# File 'lib/oxtenderabstract/configuration.rb', line 24

def wsdl_url
  @wsdl_url ||= DocumentTypes::API_CONFIG[:wsdl]
end

Instance Method Details

#token_from_file(file_path) ⇒ Object



41
42
43
44
45
46
# File 'lib/oxtenderabstract/configuration.rb', line 41

def token_from_file(file_path)
  return nil unless File.exist?(file_path)

  content = File.read(file_path).strip
  content.empty? ? nil : content
end

#valid?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/oxtenderabstract/configuration.rb', line 37

def valid?
  !token.nil? && !token.empty?
end