Class: TriannonClient::Configuration
- Inherits:
-
Object
- Object
- TriannonClient::Configuration
- Defined in:
- lib/triannon-client/configuration.rb
Instance Attribute Summary collapse
-
#client_id ⇒ Object
Parameters for triannon client authentication.
-
#client_pass ⇒ Object
Returns the value of attribute client_pass.
-
#container ⇒ Object
Parameters for triannon container.
-
#container_user ⇒ Object
Returns the value of attribute container_user.
-
#container_workgroups ⇒ Object
Returns the value of attribute container_workgroups.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#host ⇒ Object
Parameters for triannon server.
-
#log_file ⇒ Object
readonly
Returns the value of attribute log_file.
-
#logger ⇒ Object
Returns the value of attribute logger.
Instance Method Summary collapse
- #env_boolean(var) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/triannon-client/configuration.rb', line 24 def initialize @debug = env_boolean('DEBUG') @host = ENV['TRIANNON_HOST'] || 'http://localhost:3000' # @user = ENV['TRIANNON_USER'] || '' # triannon doesn't support basic auth # @pass = ENV['TRIANNON_PASS'] || '' # triannon doesn't support basic auth # Parameters for triannon client authentication @client_id = ENV['TRIANNON_CLIENT_ID'] || '' @client_pass = ENV['TRIANNON_CLIENT_PASS'] || '' # Parameters for triannon container @container = ENV['TRIANNON_CONTAINER'] || '' @container += '/' unless(@container.empty? || @container.end_with?('/')) @container_user = ENV['TRIANNON_CONTAINER_USER'] || '' @container_workgroups = ENV['TRIANNON_CONTAINER_WORKGROUPS'] || '' # logger begin log_file = ENV['TRIANNON_LOG_FILE'] || 'log/triannon_client.log' @log_file = File.absolute_path log_file FileUtils.mkdir_p File.dirname(@log_file) rescue nil log_dev = File.new(@log_file, 'w+') rescue log_dev = $stderr @log_file = 'STDERR' end log_dev.sync = true if @debug # skip IO buffering in debug mode @logger = Logger.new(log_dev, 'weekly') @logger.level = @debug ? Logger::DEBUG : Logger::INFO end |
Instance Attribute Details
#client_id ⇒ Object
Parameters for triannon client authentication
21 22 23 |
# File 'lib/triannon-client/configuration.rb', line 21 def client_id @client_id end |
#client_pass ⇒ Object
Returns the value of attribute client_pass.
22 23 24 |
# File 'lib/triannon-client/configuration.rb', line 22 def client_pass @client_pass end |
#container ⇒ Object
Parameters for triannon container
16 17 18 |
# File 'lib/triannon-client/configuration.rb', line 16 def container @container end |
#container_user ⇒ Object
Returns the value of attribute container_user.
17 18 19 |
# File 'lib/triannon-client/configuration.rb', line 17 def container_user @container_user end |
#container_workgroups ⇒ Object
Returns the value of attribute container_workgroups.
18 19 20 |
# File 'lib/triannon-client/configuration.rb', line 18 def container_workgroups @container_workgroups end |
#debug ⇒ Object
Returns the value of attribute debug.
6 7 8 |
# File 'lib/triannon-client/configuration.rb', line 6 def debug @debug end |
#host ⇒ Object
Parameters for triannon server
11 12 13 |
# File 'lib/triannon-client/configuration.rb', line 11 def host @host end |
#log_file ⇒ Object (readonly)
Returns the value of attribute log_file.
8 9 10 |
# File 'lib/triannon-client/configuration.rb', line 8 def log_file @log_file end |
#logger ⇒ Object
Returns the value of attribute logger.
7 8 9 |
# File 'lib/triannon-client/configuration.rb', line 7 def logger @logger end |
Instance Method Details
#env_boolean(var) ⇒ Object
56 57 58 59 |
# File 'lib/triannon-client/configuration.rb', line 56 def env_boolean(var) # check if an ENV variable is true, use false as default ENV[var].to_s.upcase == 'TRUE' rescue false end |