Module: Debian::AptPkg::Configuration

Defined in:
ext/apt_pkg/configuration.cpp

Class Method Summary collapse

Class Method Details

.architecturesArray

Return the list of architectures supported on this system.

Debian::AptPkg::Configuration.architectures # => ["amd64"]

11
12
13
14
15
16
17
18
19
20
21
# File 'ext/apt_pkg/configuration.cpp', line 11

static VALUE
architectures(VALUE self)
{
  VALUE result = rb_ary_new();
  std::vector < std::string > arches = APT::Configuration::getArchitectures();
  std::vector < std::string >::const_iterator I;
  for (I = arches.begin(); I != arches.end(); ++I) {
    rb_ary_push(result, rb_str_new2((*I).c_str()));
  }
  return result;
}

.check_architecture(arch) ⇒ Boolean

Are we interested in the given Architecture.

Debian::AptPkg::Configuration.check_architecture("all") # => true

31
32
33
34
35
36
# File 'ext/apt_pkg/configuration.cpp', line 31

static VALUE
check_architecture(VALUE self, VALUE arch)
{
  int res = APT::Configuration::checkArchitecture(StringValuePtr(arch));
  return INT2BOOL(res);
}

.check_language(lang, all) ⇒ Boolean

Are we interested in the given language.

Debian::AptPkg::Configuration.check_language("fr") # => true

74
75
76
77
78
79
80
81
82
83
84
# File 'ext/apt_pkg/configuration.cpp', line 74

static VALUE
check_language(int argc, VALUE *argv, VALUE self)
{
  if (argc > 2 || argc == 0) {
    rb_raise(rb_eArgError, "wrong number of arguments");
  }
  VALUE lang, all;
  rb_scan_args(argc, argv, "11", &lang, &all);
  int res = APT::Configuration::checkLanguage(StringValuePtr(lang), all);
  return INT2BOOL(res);
}

.compressorsArray

Return the list of compressors supported on this system.

Debian::AptPkg::Configuration.compressors # => ["gz"]

94
95
96
97
98
99
100
101
102
103
104
# File 'ext/apt_pkg/configuration.cpp', line 94

static VALUE
compressors(VALUE self)
{
  VALUE result = rb_ary_new();
  std::vector < std::string > cmps = APT::Configuration::getCompressionTypes();
  std::vector < std::string >::const_iterator I;
  for (I = cmps.begin(); I != cmps.end(); ++I) {
    rb_ary_push(result, rb_str_new2((*I).c_str()));
  }
  return result;
}

.config_find(name, default_key = '') ⇒ String

Return the value stored at the option named key, or the value given by the string default if the option in question is not set.

Params:

name

Key name.

default_key

Default key when config option not set.

Debian::AptPkg::Configuration.config_find('Dir::Etc::main') # => "apt.conf"

120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'ext/apt_pkg/configuration.cpp', line 120

static VALUE
config_find(int argc, VALUE *argv, VALUE self)
{
  if (argc > 2 || argc == 0) {
    rb_raise(rb_eArgError, "wrong number of arguments");
  }
  VALUE name, default_key;
  rb_scan_args(argc, argv, "11", &name, &default_key);
  if (NIL_P(default_key))
    default_key = rb_str_new2("");
  return rb_str_new2(_config->Find(StringValuePtr(name),
                                   StringValuePtr(default_key)).c_str());
}

.config_find_file(name, default_key = '') ⇒ String

Locate the given key using find() and return the path to the file/directory. This uses a special algorithms which moves upwards in the configuration space and prepends the values of the options to the result. These methods are generally used for the options stored in the ‘Dir’ section of the configuration.

Params:

name

Key name.

default_key

Default key when config option not set.

Debian::AptPkg::Configuration.config_find_file('Dir::Etc::main') # => "/etc/apt/apt.conf"

151
152
153
154
155
156
157
158
159
160
161
162
163
# File 'ext/apt_pkg/configuration.cpp', line 151

static VALUE
config_find_file(int argc, VALUE *argv, VALUE self)
{
  if (argc > 2 || argc == 0) {
    rb_raise(rb_eArgError, "wrong number of arguments");
  }
  VALUE name, default_key;
  rb_scan_args(argc, argv, "11", &name, &default_key);
  if (NIL_P(default_key))
    default_key = rb_str_new2("");
  return rb_str_new2(_config->FindFile(StringValuePtr(name),
                                       StringValuePtr(default_key)).c_str());
}

.languagesArray

Return the list of languages code.

Params:

all

All languages code or short for false.

Debian::AptPkg::Configuration.languages # => ["en", "none", "fr"]
Debian::AptPkg::Configuration.languages(false) # => ["en"]

51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'ext/apt_pkg/configuration.cpp', line 51

static VALUE
languages(int argc, VALUE *argv, VALUE self)
{
  VALUE all;
  rb_scan_args(argc, argv, "01", &all);
  VALUE result = rb_ary_new();
  std::vector < std::string > const langs =
    APT::Configuration::getLanguages(all);
  std::vector < std::string >::const_iterator I;
  for (I = langs.begin(); I != langs.end(); ++I) {
    rb_ary_push(result, rb_str_new2((*I).c_str()));
  }
  return result;
}