apt-pkg 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f84dc3e1846ba85b0b390fab4f2bc79df60be2f8
4
- data.tar.gz: 8a01ee86fb7e14569a3ddca653f65c6a57fa38de
3
+ metadata.gz: dca5749e8aeefa1455545b78ee74c606a0980c3a
4
+ data.tar.gz: c55db57c265cc70b03951e4fe1d2512a1df11d8c
5
5
  SHA512:
6
- metadata.gz: 0351a2ebd626836792954809677e899c6b2bb4689088583421ba63efb6d723e7395967f614a37f0fa25c441bf22b28f2210540842e3c6d0585aee7aea2284c56
7
- data.tar.gz: 6791a8180fa9a6abe2da1f071a0c7ce76aa320bf641893e2a3d86dc07a14bd681b05db6d1364fb94ddab6af5ddade6a8ace3388e4c102283f598baaed2cf502f
6
+ metadata.gz: 309b619137c40692dda14b015640a608570d47f3bf80ff1b578718f757c8cde0c07f81efbb8f3e3d383457dd462972a1dfbe2a0b76a6f9b9a3771a19c18f6c02
7
+ data.tar.gz: c8a6b47d0fb7f87d74e830632c21a782070a600aa6daead1c00b8769b70529f6628f61a6c00e7f31e1714429b6ed75fc2170dbcd3ee8ebf680db08ce6a943961
data/History.md CHANGED
@@ -1,4 +1,11 @@
1
1
 
2
+ 0.2.0 / 2016-01-04
3
+ ==================
4
+
5
+ * Fix cache count methods when not init
6
+ * Add init, init_{config,system}
7
+ * Add PkgCache.is_multi_arch method
8
+
2
9
  0.1.0 / 2015-12-20
3
10
  ==================
4
11
 
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2014-2015 Laurent Arnoud <laurent@spkdev.net>
3
+ Copyright (c) 2014-2016 Laurent Arnoud <laurent@spkdev.net>
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining
6
6
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -7,44 +7,45 @@ Currently install, remove packages commands are **not** implemented.
7
7
 
8
8
  ## INSTALL
9
9
 
10
- ~~~ console
11
- aptitude install build-essential ruby-dev libapt-pkg-dev (~> 1.0)
10
+ ``` console
11
+ apt install build-essential ruby-dev libapt-pkg-dev (>= 1.0)
12
12
  gem install apt-pkg
13
- ~~~
13
+ ```
14
14
 
15
15
  ## USING
16
16
 
17
17
  Simple search is implemented with:
18
18
 
19
- ~~~ ruby
19
+ ``` ruby
20
20
  require 'debian/apt_pkg'
21
+ Debian::AptPkg.init
21
22
  Debian::AptPkg::PkgCache.pkg_names("vim")
22
- ~~~
23
+ ```
23
24
 
24
25
  [Documentation](https://spk.github.io/ruby-apt-pkg/)
25
26
 
26
27
  ## BUILD
27
28
 
28
- ~~~ console
29
+ ``` console
29
30
  gem install bundler
30
31
  bundle install
31
32
  bundle exec rake compile
32
- ~~~
33
+ ```
33
34
 
34
35
  ## TEST
35
36
 
36
- ~~~ console
37
+ ``` console
37
38
  bundle exec rake test
38
- ~~~
39
+ ```
39
40
 
40
41
  ## LICENSE
41
42
 
42
43
  The MIT License
43
44
 
44
- Copyright (c) 2014-2015 Laurent Arnoud <laurent@spkdev.net>
45
+ Copyright (c) 2014-2016 Laurent Arnoud <laurent@spkdev.net>
45
46
 
46
47
  ---
47
- [![Gem Version](https://badge.fury.io/rb/apt-pkg.svg)](https://rubygems.org/gems/apt-pkg)
48
- [![Build Status](https://secure.travis-ci.org/spk/ruby-apt-pkg.svg?branch=master)](https://travis-ci.org/spk/ruby-apt-pkg)
49
- [![License](https://img.shields.io/github/license/spk/ruby-apt-pkg.svg)](http://opensource.org/licenses/MIT "MIT")
48
+ [![Build](https://img.shields.io/travis-ci/spk/ruby-apt-pkg.svg)](https://travis-ci.org/spk/ruby-apt-pkg)
49
+ [![Version](https://img.shields.io/gem/v/apt-pkg.svg)](https://rubygems.org/gems/apt-pkg)
50
+ [![License](https://img.shields.io/badge/license-MIT-blue.svg)](http://opensource.org/licenses/MIT "MIT")
50
51
  [![IRC Network](https://img.shields.io/badge/irc-oftc-blue.svg)](https://webchat.oftc.net/ "#ruby-apt-pkg")
@@ -2,6 +2,52 @@
2
2
  #include "configuration.h"
3
3
  #include "pkgcache.h"
4
4
 
5
+ /*
6
+ * call-seq: init() -> nil
7
+ *
8
+ * Shorthand for doing init_config() and init_system().
9
+ *
10
+ * Debian::AptPkg.init # => nil
11
+ *
12
+ **/
13
+ static VALUE
14
+ init(VALUE self)
15
+ {
16
+ pkgInitConfig(*_config);
17
+ pkgInitSystem(*_config, _system);
18
+ return Qnil;
19
+ }
20
+
21
+ /*
22
+ * call-seq: init_config() -> bool
23
+ *
24
+ * Load the default configuration and the config file.
25
+ *
26
+ * Debian::AptPkg.init_config # => false
27
+ *
28
+ **/
29
+ static VALUE
30
+ init_config(VALUE self)
31
+ {
32
+ int res = pkgInitConfig(*_config);
33
+ return INT2BOOL(res);
34
+ }
35
+
36
+ /*
37
+ * call-seq: init_system() -> bool
38
+ *
39
+ * Construct the apt_pkg system.
40
+ *
41
+ * Debian::AptPkg.init_system # => false
42
+ *
43
+ **/
44
+ static VALUE
45
+ init_system(VALUE self)
46
+ {
47
+ int res = pkgInitSystem(*_config, _system);
48
+ return INT2BOOL(res);
49
+ }
50
+
5
51
  /*
6
52
  * call-seq: cmp_version(pkg_version_a, pkg_version_b) -> int
7
53
  *
@@ -15,11 +61,12 @@
15
61
  * Debian::AptPkg.cmp_version('1.0', '1.1') # => -1
16
62
  *
17
63
  **/
18
- static
19
- VALUE cmp_version(VALUE self, VALUE pkg_version_a, VALUE pkg_version_b) {
20
- int res = debVS.CmpVersion(StringValuePtr(pkg_version_a),
21
- StringValuePtr(pkg_version_b));
22
- return INT2FIX(res);
64
+ static VALUE
65
+ cmp_version(VALUE self, VALUE pkg_version_a, VALUE pkg_version_b)
66
+ {
67
+ int res = debVS.CmpVersion(StringValuePtr(pkg_version_a),
68
+ StringValuePtr(pkg_version_b));
69
+ return INT2FIX(res);
23
70
  }
24
71
 
25
72
  /*
@@ -37,24 +84,26 @@ VALUE cmp_version(VALUE self, VALUE pkg_version_a, VALUE pkg_version_b) {
37
84
  * Debian::AptPkg.check_dep('1', Debian::AptPkg::NOT_EQUALS, '2') # => true
38
85
  *
39
86
  **/
40
- static
41
- VALUE check_dep(VALUE self, VALUE pkg_version_a, VALUE cmp_type, VALUE pkg_version_b) {
42
- unsigned int op = 0;
43
- if (TYPE(cmp_type) == T_FIXNUM) {
44
- op = NUM2INT(cmp_type);
45
- } else {
46
- const char *op_str = StringValuePtr(cmp_type);
47
- if (strcmp(op_str, ">") == 0) op_str = ">>";
48
- if (strcmp(op_str, "<") == 0) op_str = "<<";
49
- if (*debListParser::ConvertRelation(op_str, op) != 0)
50
- {
51
- rb_raise(rb_eArgError, "Bad comparison operation");
52
- return 0;
53
- }
87
+ static VALUE
88
+ check_dep(VALUE self, VALUE pkg_version_a, VALUE cmp_type, VALUE pkg_version_b)
89
+ {
90
+ unsigned int op = 0;
91
+ if (TYPE(cmp_type) == T_FIXNUM) {
92
+ op = NUM2INT(cmp_type);
93
+ } else {
94
+ const char *op_str = StringValuePtr(cmp_type);
95
+ if (strcmp(op_str, ">") == 0)
96
+ op_str = ">>";
97
+ if (strcmp(op_str, "<") == 0)
98
+ op_str = "<<";
99
+ if (*debListParser::ConvertRelation(op_str, op) != 0) {
100
+ rb_raise(rb_eArgError, "Bad comparison operation");
101
+ return 0;
54
102
  }
55
- int res = debVS.CheckDep(StringValuePtr(pkg_version_a), op,
56
- StringValuePtr(pkg_version_b));
57
- return INT2BOOL(res);
103
+ }
104
+ int res = debVS.CheckDep(StringValuePtr(pkg_version_a), op,
105
+ StringValuePtr(pkg_version_b));
106
+ return INT2BOOL(res);
58
107
  }
59
108
 
60
109
  /*
@@ -65,9 +114,10 @@ VALUE check_dep(VALUE self, VALUE pkg_version_a, VALUE cmp_type, VALUE pkg_versi
65
114
  * Debian::AptPkg.uri_to_filename('http://debian.org/index.html') # => 'debian.org_index.html'
66
115
  *
67
116
  **/
68
- static
69
- VALUE uri_to_filename(VALUE self, VALUE uri) {
70
- return rb_str_new2(URItoFileName(StringValuePtr(uri)).c_str());
117
+ static VALUE
118
+ uri_to_filename(VALUE self, VALUE uri)
119
+ {
120
+ return rb_str_new2(URItoFileName(StringValuePtr(uri)).c_str());
71
121
  }
72
122
 
73
123
  /*
@@ -78,9 +128,10 @@ VALUE uri_to_filename(VALUE self, VALUE uri) {
78
128
  * Debian::AptPkg.upstream_version('3.4.15-1+b1') # => '3.4.15'
79
129
  *
80
130
  **/
81
- static
82
- VALUE upstream_version(VALUE self, VALUE ver) {
83
- return rb_str_new2(debVS.UpstreamVersion(StringValuePtr(ver)).c_str());
131
+ static VALUE
132
+ upstream_version(VALUE self, VALUE ver)
133
+ {
134
+ return rb_str_new2(debVS.UpstreamVersion(StringValuePtr(ver)).c_str());
84
135
  }
85
136
 
86
137
  /*
@@ -91,9 +142,10 @@ VALUE upstream_version(VALUE self, VALUE ver) {
91
142
  * Debian::AptPkg.time_to_str(3601) # => '1h 0min 1s'
92
143
  *
93
144
  **/
94
- static
95
- VALUE time_to_str(VALUE self, VALUE secondes) {
96
- return rb_str_new2(TimeToStr(NUM2INT(secondes)).c_str());
145
+ static VALUE
146
+ time_to_str(VALUE self, VALUE secondes)
147
+ {
148
+ return rb_str_new2(TimeToStr(NUM2INT(secondes)).c_str());
97
149
  }
98
150
 
99
151
  /*
@@ -104,9 +156,10 @@ VALUE time_to_str(VALUE self, VALUE secondes) {
104
156
  * Debian::AptPkg.size_to_str(10000) # => '10.0 k'
105
157
  *
106
158
  **/
107
- static
108
- VALUE size_to_str(VALUE self, VALUE size) {
109
- return rb_str_new2(SizeToStr(NUM2INT(size)).c_str());
159
+ static VALUE
160
+ size_to_str(VALUE self, VALUE size)
161
+ {
162
+ return rb_str_new2(SizeToStr(NUM2INT(size)).c_str());
110
163
  }
111
164
 
112
165
  /*
@@ -119,9 +172,10 @@ VALUE size_to_str(VALUE self, VALUE size) {
119
172
  * Debian::AptPkg.string_to_bool('no-recognized') # => false
120
173
  *
121
174
  **/
122
- static
123
- VALUE string_to_bool(VALUE self, VALUE text) {
124
- return INT2BOOL(StringToBool(StringValuePtr(text)) == 1);
175
+ static VALUE
176
+ string_to_bool(VALUE self, VALUE text)
177
+ {
178
+ return INT2BOOL(StringToBool(StringValuePtr(text)) == 1);
125
179
  }
126
180
 
127
181
  /*
@@ -132,59 +186,66 @@ VALUE string_to_bool(VALUE self, VALUE text) {
132
186
  * Debian::AptPkg.check_domain_list("alioth.debian.org", "debian.net,debian.org") # => true
133
187
  *
134
188
  **/
135
- static
136
- VALUE check_domain_list(VALUE self, VALUE host, VALUE list) {
137
- int res = CheckDomainList(StringValuePtr(host), StringValuePtr(list));
138
- return INT2BOOL(res);
189
+ static VALUE
190
+ check_domain_list(VALUE self, VALUE host, VALUE list)
191
+ {
192
+ int res = CheckDomainList(StringValuePtr(host), StringValuePtr(list));
193
+ return INT2BOOL(res);
139
194
  }
140
195
 
141
196
  void
142
- Init_apt_pkg() {
143
- pkgInitConfig(*_config);
144
- pkgInitSystem(*_config, _system);
145
-
146
- /* Base module */
147
- VALUE rb_mDebian = rb_define_module("Debian");
148
- VALUE rb_mDebianAptPkg = rb_define_module_under(rb_mDebian, "AptPkg");
149
- VALUE rb_mDebianAptPkgConfiguration
150
- = rb_define_module_under(rb_mDebianAptPkg, "Configuration");
151
-
152
- rb_define_singleton_method(rb_mDebianAptPkg, "uri_to_filename",
153
- RUBY_METHOD_FUNC(uri_to_filename), 1);
154
- rb_define_singleton_method(rb_mDebianAptPkg, "time_to_str",
155
- RUBY_METHOD_FUNC(time_to_str), 1);
156
- rb_define_singleton_method(rb_mDebianAptPkg, "size_to_str",
157
- RUBY_METHOD_FUNC(size_to_str), 1);
158
- rb_define_singleton_method(rb_mDebianAptPkg, "string_to_bool",
159
- RUBY_METHOD_FUNC(string_to_bool), 1);
160
- rb_define_singleton_method(rb_mDebianAptPkg, "check_domain_list",
161
- RUBY_METHOD_FUNC(check_domain_list), 2);
162
- rb_define_singleton_method(rb_mDebianAptPkg, "cmp_version",
163
- RUBY_METHOD_FUNC(cmp_version), 2);
164
- rb_define_singleton_method(rb_mDebianAptPkg, "check_dep",
165
- RUBY_METHOD_FUNC(check_dep), 3);
166
- rb_define_singleton_method(rb_mDebianAptPkg, "upstream_version",
167
- RUBY_METHOD_FUNC(upstream_version), 1);
168
-
169
- /* Represents less equal operator. */
170
- rb_define_const(rb_mDebianAptPkg, "LESS_EQ", INT2FIX(pkgCache::Dep::LessEq));
171
- /* Represents greater equal operator. */
172
- rb_define_const(rb_mDebianAptPkg, "GREATER_EQ", INT2FIX(pkgCache::Dep::GreaterEq));
173
- /* Represents less operator. */
174
- rb_define_const(rb_mDebianAptPkg, "LESS", INT2FIX(pkgCache::Dep::Less));
175
- /* Represents greater operator. */
176
- rb_define_const(rb_mDebianAptPkg, "GREATER", INT2FIX(pkgCache::Dep::Greater));
177
- /* Represents equals operator. */
178
- rb_define_const(rb_mDebianAptPkg, "EQUALS", INT2FIX(pkgCache::Dep::Equals));
179
- /* Represents not equals operator. */
180
- rb_define_const(rb_mDebianAptPkg, "NOT_EQUALS", INT2FIX(pkgCache::Dep::NotEquals));
181
-
182
- /* Represents the version of apt. */
183
- rb_define_const(rb_mDebianAptPkg, "APT_VERSION", rb_str_new2(pkgVersion));
184
- /* Represents the version of apt_pkg library. */
185
- rb_define_const(rb_mDebianAptPkg, "LIBAPT_PKG_VERSION",
186
- rb_str_new2(pkgLibVersion));
187
-
188
- init_apt_pkg_configuration();
189
- init_apt_pkg_pkgcache();
197
+ Init_apt_pkg()
198
+ {
199
+ VALUE rb_mDebian = rb_define_module("Debian");
200
+ VALUE rb_mDebianAptPkg = rb_define_module_under(rb_mDebian, "AptPkg");
201
+ VALUE rb_mDebianAptPkgConfiguration =
202
+ rb_define_module_under(rb_mDebianAptPkg, "Configuration");
203
+
204
+ rb_define_singleton_method(rb_mDebianAptPkg, "init",
205
+ RUBY_METHOD_FUNC(init), 0);
206
+ rb_define_singleton_method(rb_mDebianAptPkg, "init_config",
207
+ RUBY_METHOD_FUNC(init_config), 0);
208
+ rb_define_singleton_method(rb_mDebianAptPkg, "init_system",
209
+ RUBY_METHOD_FUNC(init_system), 0);
210
+
211
+ rb_define_singleton_method(rb_mDebianAptPkg, "uri_to_filename",
212
+ RUBY_METHOD_FUNC(uri_to_filename), 1);
213
+ rb_define_singleton_method(rb_mDebianAptPkg, "time_to_str",
214
+ RUBY_METHOD_FUNC(time_to_str), 1);
215
+ rb_define_singleton_method(rb_mDebianAptPkg, "size_to_str",
216
+ RUBY_METHOD_FUNC(size_to_str), 1);
217
+ rb_define_singleton_method(rb_mDebianAptPkg, "string_to_bool",
218
+ RUBY_METHOD_FUNC(string_to_bool), 1);
219
+ rb_define_singleton_method(rb_mDebianAptPkg, "check_domain_list",
220
+ RUBY_METHOD_FUNC(check_domain_list), 2);
221
+ rb_define_singleton_method(rb_mDebianAptPkg, "cmp_version",
222
+ RUBY_METHOD_FUNC(cmp_version), 2);
223
+ rb_define_singleton_method(rb_mDebianAptPkg, "check_dep",
224
+ RUBY_METHOD_FUNC(check_dep), 3);
225
+ rb_define_singleton_method(rb_mDebianAptPkg, "upstream_version",
226
+ RUBY_METHOD_FUNC(upstream_version), 1);
227
+
228
+ /* Represents less equal operator. */
229
+ rb_define_const(rb_mDebianAptPkg, "LESS_EQ", INT2FIX(pkgCache::Dep::LessEq));
230
+ /* Represents greater equal operator. */
231
+ rb_define_const(rb_mDebianAptPkg, "GREATER_EQ",
232
+ INT2FIX(pkgCache::Dep::GreaterEq));
233
+ /* Represents less operator. */
234
+ rb_define_const(rb_mDebianAptPkg, "LESS", INT2FIX(pkgCache::Dep::Less));
235
+ /* Represents greater operator. */
236
+ rb_define_const(rb_mDebianAptPkg, "GREATER", INT2FIX(pkgCache::Dep::Greater));
237
+ /* Represents equals operator. */
238
+ rb_define_const(rb_mDebianAptPkg, "EQUALS", INT2FIX(pkgCache::Dep::Equals));
239
+ /* Represents not equals operator. */
240
+ rb_define_const(rb_mDebianAptPkg, "NOT_EQUALS",
241
+ INT2FIX(pkgCache::Dep::NotEquals));
242
+
243
+ /* Represents the version of apt. */
244
+ rb_define_const(rb_mDebianAptPkg, "APT_VERSION", rb_str_new2(pkgVersion));
245
+ /* Represents the version of apt_pkg library. */
246
+ rb_define_const(rb_mDebianAptPkg, "LIBAPT_PKG_VERSION",
247
+ rb_str_new2(pkgLibVersion));
248
+
249
+ init_apt_pkg_configuration();
250
+ init_apt_pkg_pkgcache();
190
251
  }
@@ -20,5 +20,6 @@ static VALUE string_to_bool(VALUE self, VALUE text);
20
20
  static VALUE check_domain_list(VALUE self, VALUE host, VALUE list);
21
21
  /* Versioning */
22
22
  static VALUE cmp_version(VALUE self, VALUE pkg_version_a, VALUE pkg_version_b);
23
- static VALUE check_dep(VALUE self, VALUE pkg_version_a, VALUE cmp_type, VALUE pkg_version_b);
23
+ static VALUE check_dep(VALUE self, VALUE pkg_version_a, VALUE cmp_type,
24
+ VALUE pkg_version_b);
24
25
  static VALUE upstream_version(VALUE self, VALUE ver);
@@ -8,16 +8,16 @@
8
8
  * Debian::AptPkg::Configuration.architectures # => ["amd64"]
9
9
  *
10
10
  **/
11
- static
12
- VALUE architectures(VALUE self) {
13
- VALUE result = rb_ary_new();
14
- std::vector<std::string> arches = APT::Configuration::getArchitectures();
15
- std::vector<std::string>::const_iterator I;
16
- for (I = arches.begin(); I != arches.end(); I++)
17
- {
18
- rb_ary_push(result, rb_str_new2((*I).c_str()));
19
- }
20
- return result;
11
+ static VALUE
12
+ architectures(VALUE self)
13
+ {
14
+ VALUE result = rb_ary_new();
15
+ std::vector < std::string > arches = APT::Configuration::getArchitectures();
16
+ std::vector < std::string >::const_iterator I;
17
+ for (I = arches.begin(); I != arches.end(); I++) {
18
+ rb_ary_push(result, rb_str_new2((*I).c_str()));
19
+ }
20
+ return result;
21
21
  }
22
22
 
23
23
  /*
@@ -28,10 +28,11 @@ VALUE architectures(VALUE self) {
28
28
  * Debian::AptPkg::Configuration.check_architecture("all") # => true
29
29
  *
30
30
  **/
31
- static
32
- VALUE check_architecture(VALUE self, VALUE arch) {
33
- int res = APT::Configuration::checkArchitecture(StringValuePtr(arch));
34
- return INT2BOOL(res);
31
+ static VALUE
32
+ check_architecture(VALUE self, VALUE arch)
33
+ {
34
+ int res = APT::Configuration::checkArchitecture(StringValuePtr(arch));
35
+ return INT2BOOL(res);
35
36
  }
36
37
 
37
38
  /*
@@ -47,18 +48,19 @@ VALUE check_architecture(VALUE self, VALUE arch) {
47
48
  * Debian::AptPkg::Configuration.languages(false) # => ["en"]
48
49
  *
49
50
  **/
50
- static
51
- VALUE languages(int argc, VALUE* argv, VALUE self) {
52
- VALUE all;
53
- rb_scan_args(argc, argv, "01", &all);
54
- VALUE result = rb_ary_new();
55
- std::vector<std::string> const langs = APT::Configuration::getLanguages(all);
56
- std::vector<std::string>::const_iterator I;
57
- for (I = langs.begin(); I != langs.end(); I++)
58
- {
59
- rb_ary_push(result, rb_str_new2((*I).c_str()));
60
- }
61
- return result;
51
+ static VALUE
52
+ languages(int argc, VALUE *argv, VALUE self)
53
+ {
54
+ VALUE all;
55
+ rb_scan_args(argc, argv, "01", &all);
56
+ VALUE result = rb_ary_new();
57
+ std::vector < std::string > const langs =
58
+ APT::Configuration::getLanguages(all);
59
+ std::vector < std::string >::const_iterator I;
60
+ for (I = langs.begin(); I != langs.end(); I++) {
61
+ rb_ary_push(result, rb_str_new2((*I).c_str()));
62
+ }
63
+ return result;
62
64
  }
63
65
 
64
66
  /*
@@ -69,15 +71,16 @@ VALUE languages(int argc, VALUE* argv, VALUE self) {
69
71
  * Debian::AptPkg::Configuration.check_language("fr") # => true
70
72
  *
71
73
  **/
72
- static
73
- VALUE check_language(int argc, VALUE* argv, VALUE self) {
74
- if (argc > 2 || argc == 0) {
75
- rb_raise(rb_eArgError, "wrong number of arguments");
76
- }
77
- VALUE lang, all;
78
- rb_scan_args(argc, argv, "11", &lang, &all);
79
- int res = APT::Configuration::checkLanguage(StringValuePtr(lang), all);
80
- return INT2BOOL(res);
74
+ static VALUE
75
+ check_language(int argc, VALUE *argv, VALUE self)
76
+ {
77
+ if (argc > 2 || argc == 0) {
78
+ rb_raise(rb_eArgError, "wrong number of arguments");
79
+ }
80
+ VALUE lang, all;
81
+ rb_scan_args(argc, argv, "11", &lang, &all);
82
+ int res = APT::Configuration::checkLanguage(StringValuePtr(lang), all);
83
+ return INT2BOOL(res);
81
84
  }
82
85
 
83
86
  /*
@@ -88,16 +91,16 @@ VALUE check_language(int argc, VALUE* argv, VALUE self) {
88
91
  * Debian::AptPkg::Configuration.compressors # => ["gz"]
89
92
  *
90
93
  **/
91
- static
92
- VALUE compressors(VALUE self) {
93
- VALUE result = rb_ary_new();
94
- std::vector<std::string> cmps = APT::Configuration::getCompressionTypes();
95
- std::vector<std::string>::const_iterator I;
96
- for (I = cmps.begin(); I != cmps.end(); I++)
97
- {
98
- rb_ary_push(result, rb_str_new2((*I).c_str()));
99
- }
100
- return result;
94
+ static VALUE
95
+ compressors(VALUE self)
96
+ {
97
+ VALUE result = rb_ary_new();
98
+ std::vector < std::string > cmps = APT::Configuration::getCompressionTypes();
99
+ std::vector < std::string >::const_iterator I;
100
+ for (I = cmps.begin(); I != cmps.end(); I++) {
101
+ rb_ary_push(result, rb_str_new2((*I).c_str()));
102
+ }
103
+ return result;
101
104
  }
102
105
 
103
106
  /*
@@ -114,17 +117,18 @@ VALUE compressors(VALUE self) {
114
117
  * Debian::AptPkg::Configuration.config_find('Dir::Etc::main') # => "apt.conf"
115
118
  *
116
119
  **/
117
- static
118
- VALUE config_find(int argc, VALUE* argv, VALUE self) {
119
- if (argc > 2 || argc == 0) {
120
- rb_raise(rb_eArgError, "wrong number of arguments");
121
- }
122
- VALUE name, default_key;
123
- rb_scan_args(argc, argv, "11", &name, &default_key);
124
- if (NIL_P(default_key))
125
- default_key = rb_str_new2("");
126
- return rb_str_new2(_config->Find(StringValuePtr(name),
127
- StringValuePtr(default_key)).c_str());
120
+ static VALUE
121
+ config_find(int argc, VALUE *argv, VALUE self)
122
+ {
123
+ if (argc > 2 || argc == 0) {
124
+ rb_raise(rb_eArgError, "wrong number of arguments");
125
+ }
126
+ VALUE name, default_key;
127
+ rb_scan_args(argc, argv, "11", &name, &default_key);
128
+ if (NIL_P(default_key))
129
+ default_key = rb_str_new2("");
130
+ return rb_str_new2(_config->Find(StringValuePtr(name),
131
+ StringValuePtr(default_key)).c_str());
128
132
  }
129
133
 
130
134
  /*
@@ -144,39 +148,43 @@ VALUE config_find(int argc, VALUE* argv, VALUE self) {
144
148
  * Debian::AptPkg::Configuration.config_find_file('Dir::Etc::main') # => "/etc/apt/apt.conf"
145
149
  *
146
150
  **/
147
- static
148
- VALUE config_find_file(int argc, VALUE* argv, VALUE self) {
149
- if (argc > 2 || argc == 0) {
150
- rb_raise(rb_eArgError, "wrong number of arguments");
151
- }
152
- VALUE name, default_key;
153
- rb_scan_args(argc, argv, "11", &name, &default_key);
154
- if (NIL_P(default_key))
155
- default_key = rb_str_new2("");
156
- return rb_str_new2(_config->FindFile(StringValuePtr(name),
157
- StringValuePtr(default_key)).c_str());
151
+ static VALUE
152
+ config_find_file(int argc, VALUE *argv, VALUE self)
153
+ {
154
+ if (argc > 2 || argc == 0) {
155
+ rb_raise(rb_eArgError, "wrong number of arguments");
156
+ }
157
+ VALUE name, default_key;
158
+ rb_scan_args(argc, argv, "11", &name, &default_key);
159
+ if (NIL_P(default_key))
160
+ default_key = rb_str_new2("");
161
+ return rb_str_new2(_config->FindFile(StringValuePtr(name),
162
+ StringValuePtr(default_key)).c_str());
158
163
  }
159
164
 
160
165
  void
161
- init_apt_pkg_configuration() {
162
- VALUE rb_mDebian = rb_define_module("Debian");
163
- VALUE rb_mDebianAptPkg = rb_define_module_under(rb_mDebian, "AptPkg");
164
- VALUE rb_mDebianAptPkgConfiguration =
165
- rb_define_module_under(rb_mDebianAptPkg, "Configuration");
166
+ init_apt_pkg_configuration()
167
+ {
168
+ VALUE rb_mDebian = rb_define_module("Debian");
169
+ VALUE rb_mDebianAptPkg = rb_define_module_under(rb_mDebian, "AptPkg");
170
+ VALUE rb_mDebianAptPkgConfiguration =
171
+ rb_define_module_under(rb_mDebianAptPkg, "Configuration");
166
172
 
167
- rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "architectures",
168
- RUBY_METHOD_FUNC(architectures), 0);
169
- rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "check_architecture",
170
- RUBY_METHOD_FUNC(check_architecture), 1);
171
- rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "languages",
172
- RUBY_METHOD_FUNC(languages), -1);
173
- rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "check_language",
174
- RUBY_METHOD_FUNC(check_language), -1);
175
- rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "compressors",
176
- RUBY_METHOD_FUNC(compressors), 0);
173
+ rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "architectures",
174
+ RUBY_METHOD_FUNC(architectures), 0);
175
+ rb_define_singleton_method(rb_mDebianAptPkgConfiguration,
176
+ "check_architecture",
177
+ RUBY_METHOD_FUNC(check_architecture), 1);
178
+ rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "languages",
179
+ RUBY_METHOD_FUNC(languages), -1);
180
+ rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "check_language",
181
+ RUBY_METHOD_FUNC(check_language), -1);
182
+ rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "compressors",
183
+ RUBY_METHOD_FUNC(compressors), 0);
177
184
 
178
- rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "config_find",
179
- RUBY_METHOD_FUNC(config_find), -1);
180
- rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "config_find_file",
181
- RUBY_METHOD_FUNC(config_find_file), -1);
185
+ rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "config_find",
186
+ RUBY_METHOD_FUNC(config_find), -1);
187
+ rb_define_singleton_method(rb_mDebianAptPkgConfiguration,
188
+ "config_find_file",
189
+ RUBY_METHOD_FUNC(config_find_file), -1);
182
190
  }
@@ -1,8 +1,5 @@
1
1
  require 'mkmf'
2
-
3
2
  have_library('stdc++')
4
3
  have_library('apt-pkg')
5
-
6
4
  dir_config('apt_pkg')
7
-
8
5
  create_makefile('apt_pkg')
@@ -1,213 +1,291 @@
1
1
  #include "pkgcache.h"
2
2
 
3
+ /*
4
+ * private
5
+ */
6
+ bool
7
+ config_system_initialized()
8
+ {
9
+ string const arch = _config->Find("APT::Architecture");
10
+ if (arch.empty()) {
11
+ return false;
12
+ }
13
+ return true;
14
+ }
15
+
3
16
  /*
4
17
  * call-seq: gen_caches() -> bool
5
18
  *
6
19
  * Call the main cache generator.
20
+ * Return `nil` when config, system, cache is not configured.
7
21
  *
8
22
  * Debian::AptPkg::PkgCache.gen_caches # => false
9
23
  *
10
24
  **/
11
- static
12
- VALUE gen_caches(VALUE self) {
13
- pkgCacheFile CacheFile;
14
- int res = CacheFile.BuildCaches(NULL, true);
15
- return INT2BOOL(res);
25
+ static VALUE
26
+ gen_caches(VALUE self)
27
+ {
28
+ if (!config_system_initialized()) {
29
+ return Qnil;
30
+ }
31
+ pkgCacheFile CacheFile;
32
+ int res = CacheFile.BuildCaches(NULL, true);
33
+ return INT2BOOL(res);
34
+ }
35
+
36
+ /*
37
+ * call-seq: is_multi_arch() -> bool
38
+ *
39
+ * An attribute determining whether the cache supports multi-arch.
40
+ * Return `nil` when config, system, cache is not configured.
41
+ *
42
+ * Debian::AptPkg::PkgCache.is_multi_arch # => false
43
+ *
44
+ **/
45
+ static VALUE
46
+ is_multi_arch(VALUE self)
47
+ {
48
+ if (!config_system_initialized()) {
49
+ return Qnil;
50
+ }
51
+ pkgCacheFile CacheFile;
52
+ pkgCache *Cache = CacheFile.GetPkgCache();
53
+ if (Cache == NULL) {
54
+ return Qnil;
55
+ }
56
+ int res = Cache->MultiArchCache();
57
+ return INT2BOOL(res);
16
58
  }
17
59
 
18
60
  /*
19
61
  * call-seq: pkg_names() -> array, nil
20
62
  *
21
63
  * List the names of all packages in the system.
22
- * Return `nil` when cache is not generated.
64
+ * Return `nil` when config, system, cache is not configured.
23
65
  *
24
66
  * Debian::AptPkg::PkgCache.pkg_names('gcolor2') # => ["gcolor2"]
25
67
  *
26
68
  **/
27
- static
28
- VALUE pkg_names(int argc, VALUE* argv, VALUE self) {
29
- if (argc > 1 || argc == 0) {
30
- rb_raise(rb_eArgError, "You must give at least one search argument");
31
- }
32
- VALUE name;
33
- rb_scan_args(argc, argv, "01", &name);
34
- if (NIL_P(name) || RSTRING_LEN(name) < 1) {
35
- rb_raise(rb_eArgError, "You must give at least one search pattern");
36
- }
37
- VALUE result = rb_ary_new();
69
+ static VALUE
70
+ pkg_names(int argc, VALUE *argv, VALUE self)
71
+ {
72
+ if (!config_system_initialized()) {
73
+ return Qnil;
74
+ }
75
+ if (argc > 1 || argc == 0) {
76
+ rb_raise(rb_eArgError, "You must give at least one search argument");
77
+ }
78
+ VALUE name;
79
+ rb_scan_args(argc, argv, "01", &name);
80
+ if (NIL_P(name) || RSTRING_LEN(name) < 1) {
81
+ rb_raise(rb_eArgError, "You must give at least one search pattern");
82
+ }
83
+ VALUE result = rb_ary_new();
38
84
 
39
- pkgCacheFile CacheFile;
40
- if (CacheFile.GetPkgCache() == 0) {
41
- return Qnil;
42
- }
43
- pkgCache::GrpIterator I = CacheFile.GetPkgCache()->GrpBegin();
85
+ pkgCacheFile CacheFile;
86
+ if (CacheFile.GetPkgCache() == 0) {
87
+ return Qnil;
88
+ }
89
+ pkgCache::GrpIterator I = CacheFile.GetPkgCache()->GrpBegin();
44
90
 
45
- const char *pkgname = StringValuePtr(name);
46
- for (;I.end() != true; ++I) {
47
- if (strncmp(I.Name(), pkgname, strlen(pkgname)) == 0) {
48
- rb_ary_push(result, rb_str_new2(I.Name()));
49
- }
91
+ const char *pkgname = StringValuePtr(name);
92
+ for (; I.end() != true; ++I) {
93
+ if (strncmp(I.Name(), pkgname, strlen(pkgname)) == 0) {
94
+ rb_ary_push(result, rb_str_new2(I.Name()));
50
95
  }
51
- return result;
96
+ }
97
+ return result;
52
98
  }
53
99
 
54
100
  /*
55
101
  * call-seq: package_count() -> int, nil
56
102
  *
57
103
  * The total number of packages available in the cache.
58
- * Return `nil` when cache is not generated.
104
+ * Return `nil` when config, system, cache is not configured.
59
105
  *
60
106
  * Debian::AptPkg::PkgCache.package_count # => 69511
61
107
  *
62
108
  **/
63
- static
64
- VALUE package_count(VALUE self) {
65
- pkgCacheFile CacheFile;
66
- pkgCache *Cache = CacheFile.GetPkgCache();
67
- if (Cache == NULL) {
68
- return Qnil;
69
- }
70
- return INT2FIX(Cache->HeaderP->PackageCount);
109
+ static VALUE
110
+ package_count(VALUE self)
111
+ {
112
+ if (!config_system_initialized()) {
113
+ return Qnil;
114
+ }
115
+ pkgCacheFile CacheFile;
116
+ pkgCache *Cache = CacheFile.GetPkgCache();
117
+ if (Cache == NULL) {
118
+ return Qnil;
119
+ }
120
+ return INT2FIX(Cache->HeaderP->PackageCount);
71
121
  }
72
122
 
73
123
  /*
74
124
  * call-seq: version_count() -> int, nil
75
125
  *
76
126
  * The total number of package versions available in the cache.
77
- * Return `nil` when cache is not generated.
127
+ * Return `nil` when config, system, cache is not configured.
78
128
  *
79
129
  * Debian::AptPkg::PkgCache.version_count # => 84630
80
130
  *
81
131
  **/
82
- static
83
- VALUE version_count(VALUE self) {
84
- pkgCacheFile CacheFile;
85
- pkgCache *Cache = CacheFile.GetPkgCache();
86
- if (Cache == NULL) {
87
- return Qnil;
88
- }
89
- return INT2FIX(Cache->HeaderP->VersionCount);
132
+ static VALUE
133
+ version_count(VALUE self)
134
+ {
135
+ if (!config_system_initialized()) {
136
+ return Qnil;
137
+ }
138
+ pkgCacheFile CacheFile;
139
+ pkgCache *Cache = CacheFile.GetPkgCache();
140
+ if (Cache == NULL) {
141
+ return Qnil;
142
+ }
143
+ return INT2FIX(Cache->HeaderP->VersionCount);
90
144
  }
91
145
 
92
146
  /*
93
147
  * call-seq: depends_count() -> int, nil
94
148
  *
95
149
  * The total number of dependencies stored in the cache.
96
- * Return `nil` when cache is not generated.
150
+ * Return `nil` when config, system, cache is not configured.
97
151
  *
98
152
  * Debian::AptPkg::PkgCache.depends_count # => 551983
99
153
  *
100
154
  **/
101
- static
102
- VALUE depends_count(VALUE self) {
103
- pkgCacheFile CacheFile;
104
- pkgCache *Cache = CacheFile.GetPkgCache();
105
- if (Cache == NULL) {
106
- return Qnil;
107
- }
108
- return INT2FIX(Cache->HeaderP->DependsCount);
155
+ static VALUE
156
+ depends_count(VALUE self)
157
+ {
158
+ if (!config_system_initialized()) {
159
+ return Qnil;
160
+ }
161
+ pkgCacheFile CacheFile;
162
+ pkgCache *Cache = CacheFile.GetPkgCache();
163
+ if (Cache == NULL) {
164
+ return Qnil;
165
+ }
166
+ return INT2FIX(Cache->HeaderP->DependsCount);
109
167
  }
110
168
 
111
169
  /*
112
170
  * call-seq: package_file_count() -> int, nil
113
171
  *
114
172
  * The total number of packages files available.
115
- * Return `nil` when cache is not generated.
173
+ * Return `nil` when config, system, cache is not configured.
116
174
  *
117
175
  * Debian::AptPkg::PkgCache.package_file_count # => 17
118
176
  *
119
177
  **/
120
- static
121
- VALUE package_file_count(VALUE self) {
122
- pkgCacheFile CacheFile;
123
- pkgCache *Cache = CacheFile.GetPkgCache();
124
- if (Cache == NULL) {
125
- return Qnil;
126
- }
127
- return INT2FIX(Cache->HeaderP->PackageFileCount);
178
+ static VALUE
179
+ package_file_count(VALUE self)
180
+ {
181
+ if (!config_system_initialized()) {
182
+ return Qnil;
183
+ }
184
+ pkgCacheFile CacheFile;
185
+ pkgCache *Cache = CacheFile.GetPkgCache();
186
+ if (Cache == NULL) {
187
+ return Qnil;
188
+ }
189
+ return INT2FIX(Cache->HeaderP->PackageFileCount);
128
190
  }
129
191
 
130
192
  /*
131
193
  * call-seq: ver_file_count() -> int, nil
132
194
  *
133
195
  * The total number of version and package file relations stored in the cache.
134
- * Return `nil` when cache is not generated.
196
+ * Return `nil` when config, system, cache is not configured.
135
197
  *
136
198
  * Debian::AptPkg::PkgCache.ver_file_count # => 11274
137
199
  *
138
200
  **/
139
- static
140
- VALUE ver_file_count(VALUE self) {
141
- pkgCacheFile CacheFile;
142
- pkgCache *Cache = CacheFile.GetPkgCache();
143
- if (Cache == NULL) {
144
- return Qnil;
145
- }
146
- return INT2FIX(Cache->HeaderP->VerFileCount);
201
+ static VALUE
202
+ ver_file_count(VALUE self)
203
+ {
204
+ if (!config_system_initialized()) {
205
+ return Qnil;
206
+ }
207
+ pkgCacheFile CacheFile;
208
+ pkgCache *Cache = CacheFile.GetPkgCache();
209
+ if (Cache == NULL) {
210
+ return Qnil;
211
+ }
212
+ return INT2FIX(Cache->HeaderP->VerFileCount);
147
213
  }
148
214
 
149
215
  /*
150
216
  * call-seq: provides_count() -> int, nil
151
217
  *
152
218
  * The number of provided packages.
153
- * Return `nil` when cache is not generated.
219
+ * Return `nil` when config, system, cache is not configured.
154
220
  *
155
221
  * Debian::AptPkg::PkgCache.provides_count # => 69511
156
222
  *
157
223
  **/
158
- static
159
- VALUE provides_count(VALUE self) {
160
- pkgCacheFile CacheFile;
161
- pkgCache *Cache = CacheFile.GetPkgCache();
162
- if (Cache == NULL) {
163
- return Qnil;
164
- }
165
- return INT2FIX(Cache->HeaderP->ProvidesCount);
224
+ static VALUE
225
+ provides_count(VALUE self)
226
+ {
227
+ if (!config_system_initialized()) {
228
+ return Qnil;
229
+ }
230
+ pkgCacheFile CacheFile;
231
+ pkgCache *Cache = CacheFile.GetPkgCache();
232
+ if (Cache == NULL) {
233
+ return Qnil;
234
+ }
235
+ return INT2FIX(Cache->HeaderP->ProvidesCount);
166
236
  }
167
237
 
168
238
  /*
169
239
  * call-seq: group_count() -> int, nil
170
240
  *
171
241
  * The number of groups in the cache.
172
- * Return `nil` when cache is not generated.
242
+ * Return `nil` when config, system, cache is not configured.
173
243
  *
174
244
  * Debian::AptPkg::PkgCache.group_count # => 16730
175
245
  *
176
246
  **/
177
- static
178
- VALUE group_count(VALUE self) {
179
- pkgCacheFile CacheFile;
180
- pkgCache *Cache = CacheFile.GetPkgCache();
181
- if (Cache == NULL) {
182
- return Qnil;
183
- }
184
- return INT2FIX(Cache->HeaderP->GroupCount);
247
+ static VALUE
248
+ group_count(VALUE self)
249
+ {
250
+ if (!config_system_initialized()) {
251
+ return Qnil;
252
+ }
253
+ pkgCacheFile CacheFile;
254
+ pkgCache *Cache = CacheFile.GetPkgCache();
255
+ if (Cache == NULL) {
256
+ return Qnil;
257
+ }
258
+ return INT2FIX(Cache->HeaderP->GroupCount);
185
259
  }
186
260
 
187
261
  void
188
- init_apt_pkg_pkgcache() {
189
- VALUE rb_mDebian = rb_define_module("Debian");
190
- VALUE rb_mDebianAptPkg = rb_define_module_under(rb_mDebian, "AptPkg");
191
- VALUE rb_mDebianAptPkgConfiguration = rb_define_module_under(rb_mDebianAptPkg,
192
- "PkgCache");
193
-
194
- rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "gen_caches",
195
- RUBY_METHOD_FUNC(gen_caches), 0);
196
- rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "pkg_names",
197
- RUBY_METHOD_FUNC(pkg_names), -1);
198
-
199
- rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "package_count",
200
- RUBY_METHOD_FUNC(package_count), 0);
201
- rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "version_count",
202
- RUBY_METHOD_FUNC(version_count), 0);
203
- rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "depends_count",
204
- RUBY_METHOD_FUNC(depends_count), 0);
205
- rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "package_file_count",
206
- RUBY_METHOD_FUNC(package_file_count), 0);
207
- rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "ver_file_count",
208
- RUBY_METHOD_FUNC(ver_file_count), 0);
209
- rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "provides_count",
210
- RUBY_METHOD_FUNC(provides_count), 0);
211
- rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "group_count",
212
- RUBY_METHOD_FUNC(group_count), 0);
262
+ init_apt_pkg_pkgcache()
263
+ {
264
+ VALUE rb_mDebian = rb_define_module("Debian");
265
+ VALUE rb_mDebianAptPkg = rb_define_module_under(rb_mDebian, "AptPkg");
266
+ VALUE rb_mDebianAptPkgConfiguration = rb_define_module_under(rb_mDebianAptPkg,
267
+ "PkgCache");
268
+
269
+ rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "gen_caches",
270
+ RUBY_METHOD_FUNC(gen_caches), 0);
271
+ rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "is_multi_arch",
272
+ RUBY_METHOD_FUNC(is_multi_arch), 0);
273
+ rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "pkg_names",
274
+ RUBY_METHOD_FUNC(pkg_names), -1);
275
+
276
+ rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "package_count",
277
+ RUBY_METHOD_FUNC(package_count), 0);
278
+ rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "version_count",
279
+ RUBY_METHOD_FUNC(version_count), 0);
280
+ rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "depends_count",
281
+ RUBY_METHOD_FUNC(depends_count), 0);
282
+ rb_define_singleton_method(rb_mDebianAptPkgConfiguration,
283
+ "package_file_count",
284
+ RUBY_METHOD_FUNC(package_file_count), 0);
285
+ rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "ver_file_count",
286
+ RUBY_METHOD_FUNC(ver_file_count), 0);
287
+ rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "provides_count",
288
+ RUBY_METHOD_FUNC(provides_count), 0);
289
+ rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "group_count",
290
+ RUBY_METHOD_FUNC(group_count), 0);
213
291
  }
@@ -3,6 +3,6 @@ module Debian
3
3
  # AptPkg base module
4
4
  module AptPkg
5
5
  # Gem version
6
- VERSION = '0.1.0'.freeze
6
+ VERSION = '0.2.0'.freeze
7
7
  end
8
8
  end
@@ -0,0 +1,13 @@
1
+ require_relative 'test_helper'
2
+
3
+ describe Debian::AptPkg::PkgCache do
4
+ describe 'not init' do
5
+ %i(package version depends package_file ver_file provides group).each do |m|
6
+ describe ".#{m}_count" do
7
+ it 'can be called' do
8
+ Debian::AptPkg::PkgCache.public_send("#{m}_count")
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,6 +1,10 @@
1
1
  require_relative 'test_helper'
2
2
 
3
3
  describe Debian::AptPkg::PkgCache do
4
+ before :all do
5
+ Debian::AptPkg.init
6
+ end
7
+
4
8
  describe '.gen_caches' do
5
9
  it 'return boolean' do
6
10
  if Process.uid == 0
@@ -11,6 +15,12 @@ describe Debian::AptPkg::PkgCache do
11
15
  end
12
16
  end
13
17
 
18
+ describe '.is_multi_arch' do
19
+ it 'can be called' do
20
+ Debian::AptPkg::PkgCache.is_multi_arch
21
+ end
22
+ end
23
+
14
24
  describe '.pkg_names' do
15
25
  it 'no argument' do
16
26
  lambda do
@@ -1,6 +1,10 @@
1
1
  require_relative 'test_helper'
2
2
 
3
3
  describe Debian::AptPkg::Configuration do
4
+ before :all do
5
+ Debian::AptPkg.init
6
+ end
7
+
4
8
  it 'architectures return an array' do
5
9
  arches = Debian::AptPkg::Configuration.architectures
6
10
  arches.must_be_instance_of Array
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: apt-pkg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Laurent Arnoud
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-20 00:00:00.000000000 Z
11
+ date: 2016-01-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -77,6 +77,7 @@ files:
77
77
  - ext/apt_pkg/pkgcache.h
78
78
  - lib/debian/apt_pkg.rb
79
79
  - lib/debian/apt_pkg/version.rb
80
+ - test/apt_pkg_cache_not_init_test.rb
80
81
  - test/apt_pkg_cache_test.rb
81
82
  - test/apt_pkg_configuration_test.rb
82
83
  - test/apt_pkg_test.rb
@@ -107,3 +108,4 @@ signing_key:
107
108
  specification_version: 4
108
109
  summary: Ruby interface to libapt-pkg
109
110
  test_files: []
111
+ has_rdoc: