Class: Debci::Config

Inherits:
Struct
  • Object
show all
Defined in:
lib/debci/config.rb

Overview

This class contains provides a Ruby interface to read debci configuration values.

Available configuration items:

  • data_basedir: the root directory used by debci to store test run data

There is a globally accessible instance of this class accessible from the config method of the Debci module.

>> Debci.config.data_basedir
=> "/path/to/debci/data"

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



85
86
87
88
89
90
91
92
93
94
95
# File 'lib/debci/config.rb', line 85

def initialize
  # :nodoc:
  IO.popen(['debci', 'config', *members.map(&:to_s)]) do |data|
    data.each_line.each do |line|
      key, value = line.strip.split('=', 2)
      cast = self.class.cast_for(key)
      value = cast.call(value)
      self.send("#{key}=", value)
    end
  end
end

Instance Attribute Details

#amqp_cacertObject

Returns the value of attribute amqp_cacert

Returns:

  • (Object)

    the current value of amqp_cacert



16
17
18
# File 'lib/debci/config.rb', line 16

def amqp_cacert
  @amqp_cacert
end

#amqp_certObject

Returns the value of attribute amqp_cert

Returns:

  • (Object)

    the current value of amqp_cert



16
17
18
# File 'lib/debci/config.rb', line 16

def amqp_cert
  @amqp_cert
end

#amqp_keyObject

Returns the value of attribute amqp_key

Returns:

  • (Object)

    the current value of amqp_key



16
17
18
# File 'lib/debci/config.rb', line 16

def amqp_key
  @amqp_key
end

#amqp_results_queueObject

Returns the value of attribute amqp_results_queue

Returns:

  • (Object)

    the current value of amqp_results_queue



16
17
18
# File 'lib/debci/config.rb', line 16

def amqp_results_queue
  @amqp_results_queue
end

#amqp_serverObject

Returns the value of attribute amqp_server

Returns:

  • (Object)

    the current value of amqp_server



16
17
18
# File 'lib/debci/config.rb', line 16

def amqp_server
  @amqp_server
end

#amqp_sslObject

Returns the value of attribute amqp_ssl

Returns:

  • (Object)

    the current value of amqp_ssl



16
17
18
# File 'lib/debci/config.rb', line 16

def amqp_ssl
  @amqp_ssl
end

#archObject

Returns the value of attribute arch

Returns:

  • (Object)

    the current value of arch



16
17
18
# File 'lib/debci/config.rb', line 16

def arch
  @arch
end

#arch_listObject

Returns the value of attribute arch_list

Returns:

  • (Object)

    the current value of arch_list



16
17
18
# File 'lib/debci/config.rb', line 16

def arch_list
  @arch_list
end

#artifacts_url_baseObject

Returns the value of attribute artifacts_url_base

Returns:

  • (Object)

    the current value of artifacts_url_base



16
17
18
# File 'lib/debci/config.rb', line 16

def artifacts_url_base
  @artifacts_url_base
end

#auth_fail_pageObject

Returns the value of attribute auth_fail_page

Returns:

  • (Object)

    the current value of auth_fail_page



16
17
18
# File 'lib/debci/config.rb', line 16

def auth_fail_page
  @auth_fail_page
end

#autopkgtest_basedirObject

Returns the value of attribute autopkgtest_basedir

Returns:

  • (Object)

    the current value of autopkgtest_basedir



16
17
18
# File 'lib/debci/config.rb', line 16

def autopkgtest_basedir
  @autopkgtest_basedir
end

#backendObject

Returns the value of attribute backend

Returns:

  • (Object)

    the current value of backend



16
17
18
# File 'lib/debci/config.rb', line 16

def backend
  @backend
end

#backend_listObject

Returns the value of attribute backend_list

Returns:

  • (Object)

    the current value of backend_list



16
17
18
# File 'lib/debci/config.rb', line 16

def backend_list
  @backend_list
end

#config_dirObject

Returns the value of attribute config_dir

Returns:

  • (Object)

    the current value of config_dir



16
17
18
# File 'lib/debci/config.rb', line 16

def config_dir
  @config_dir
end

#data_basedirObject

Returns the value of attribute data_basedir

Returns:

  • (Object)

    the current value of data_basedir



16
17
18
# File 'lib/debci/config.rb', line 16

def data_basedir
  @data_basedir
end

#data_retention_daysObject Also known as: data_retention

Returns the value of attribute data_retention_days

Returns:

  • (Object)

    the current value of data_retention_days



16
17
18
# File 'lib/debci/config.rb', line 16

def data_retention_days
  @data_retention_days
end

#database_urlObject

Returns the value of attribute database_url

Returns:

  • (Object)

    the current value of database_url



16
17
18
# File 'lib/debci/config.rb', line 16

def database_url
  @database_url
end

#disk_storage_limitObject

Returns the value of attribute disk_storage_limit

Returns:

  • (Object)

    the current value of disk_storage_limit



16
17
18
# File 'lib/debci/config.rb', line 16

def disk_storage_limit
  @disk_storage_limit
end

#distro_nameObject

Returns the value of attribute distro_name

Returns:

  • (Object)

    the current value of distro_name



16
17
18
# File 'lib/debci/config.rb', line 16

def distro_name
  @distro_name
end

#failing_packages_per_pageObject

Returns the value of attribute failing_packages_per_page

Returns:

  • (Object)

    the current value of failing_packages_per_page



16
17
18
# File 'lib/debci/config.rb', line 16

def failing_packages_per_page
  @failing_packages_per_page
end

#html_dirObject

Returns the value of attribute html_dir

Returns:

  • (Object)

    the current value of html_dir



16
17
18
# File 'lib/debci/config.rb', line 16

def html_dir
  @html_dir
end

#packages_dirObject

Returns the value of attribute packages_dir

Returns:

  • (Object)

    the current value of packages_dir



16
17
18
# File 'lib/debci/config.rb', line 16

def packages_dir
  @packages_dir
end

#pending_status_per_pageObject

Returns the value of attribute pending_status_per_page

Returns:

  • (Object)

    the current value of pending_status_per_page



16
17
18
# File 'lib/debci/config.rb', line 16

def pending_status_per_page
  @pending_status_per_page
end

#quietObject

Returns the value of attribute quiet

Returns:

  • (Object)

    the current value of quiet



16
17
18
# File 'lib/debci/config.rb', line 16

def quiet
  @quiet
end

#salsa_client_idObject

Returns the value of attribute salsa_client_id

Returns:

  • (Object)

    the current value of salsa_client_id



16
17
18
# File 'lib/debci/config.rb', line 16

def salsa_client_id
  @salsa_client_id
end

#salsa_client_secretObject

Returns the value of attribute salsa_client_secret

Returns:

  • (Object)

    the current value of salsa_client_secret



16
17
18
# File 'lib/debci/config.rb', line 16

def salsa_client_secret
  @salsa_client_secret
end

#secrets_dirObject

Returns the value of attribute secrets_dir

Returns:

  • (Object)

    the current value of secrets_dir



16
17
18
# File 'lib/debci/config.rb', line 16

def secrets_dir
  @secrets_dir
end

#sendmail_fromObject

Returns the value of attribute sendmail_from

Returns:

  • (Object)

    the current value of sendmail_from



16
17
18
# File 'lib/debci/config.rb', line 16

def sendmail_from
  @sendmail_from
end

#sendmail_toObject

Returns the value of attribute sendmail_to

Returns:

  • (Object)

    the current value of sendmail_to



16
17
18
# File 'lib/debci/config.rb', line 16

def sendmail_to
  @sendmail_to
end

#session_secretObject

Returns the value of attribute session_secret

Returns:

  • (Object)

    the current value of session_secret



16
17
18
# File 'lib/debci/config.rb', line 16

def session_secret
  @session_secret
end

#slow_tests_duration_minutesObject

Returns the value of attribute slow_tests_duration_minutes

Returns:

  • (Object)

    the current value of slow_tests_duration_minutes



16
17
18
# File 'lib/debci/config.rb', line 16

def slow_tests_duration_minutes
  @slow_tests_duration_minutes
end

#status_visible_daysObject

Returns the value of attribute status_visible_days

Returns:

  • (Object)

    the current value of status_visible_days



16
17
18
# File 'lib/debci/config.rb', line 16

def status_visible_days
  @status_visible_days
end

#suiteObject

Returns the value of attribute suite

Returns:

  • (Object)

    the current value of suite



16
17
18
# File 'lib/debci/config.rb', line 16

def suite
  @suite
end

#suite_listObject

Returns the value of attribute suite_list

Returns:

  • (Object)

    the current value of suite_list



16
17
18
# File 'lib/debci/config.rb', line 16

def suite_list
  @suite_list
end

#url_baseObject

Returns the value of attribute url_base

Returns:

  • (Object)

    the current value of url_base



16
17
18
# File 'lib/debci/config.rb', line 16

def url_base
  @url_base
end

Class Method Details

.cast_for(key) ⇒ Object



76
77
78
79
80
81
82
83
# File 'lib/debci/config.rb', line 76

def self.cast_for(key)
  pair = types.find { |k,v| k === key }
  if pair
    pair[1]
  else
    lambda { |x| x == "" ? nil : x }
  end
end

.typesObject



63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/debci/config.rb', line 63

def self.types
  @types ||= {
    /_list$/ => lambda { |x| x.split}, # Array
    'quiet' => lambda { |x| x == 'true' }, # boolean
    'amqp_ssl' => lambda { |x| x == 'true' }, # boolean
    'data_retention_days' => lambda { |x| x.to_i },
    'disk_storage_limit' => lambda { |x| x.to_i },
    'status_visible_days' => lambda { |x| x.to_i },
    'failing_packages_per_page' => lambda { |x| x.to_i },
    'slow_tests_duration_minutes' => lambda { |x| x.to_i }
  }
end