apt-pkg 0.4.0 → 0.5.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
- SHA1:
3
- metadata.gz: 64ee3a45dbc30e9944967e0da58f8c2297449ff1
4
- data.tar.gz: 607e15266821d84ee6a1fd7f7c00b622c084794a
2
+ SHA256:
3
+ metadata.gz: 16cd206a5d9b3137497d05f937ef5b78fcac7aa6bd62e4177b73ef98ff0d917e
4
+ data.tar.gz: b0bcc23a93c8112321c890487ee385c7cede6da1b3179da4e5f0ebf11b723161
5
5
  SHA512:
6
- metadata.gz: bf82282038e9b15979d2e7da047eeacc2c9e81ffa245a5ff9774c527242b331dccfd20da8f453ca4f5453f99a1308fe953dcc7b733015c609ff8cac492deb69a
7
- data.tar.gz: bc89b13bafcd051b1e2a0dee36eb0faa8cc3e84a8c761a491537d1c646745c1a5d9f72e1c4f7c3091a36d9da663526781653258c733fb97a7d9213226da3ee34
6
+ metadata.gz: 3e650327a185fca89e757e30659c8c61371e7d2950e47b72e463a6ed598da4656e7fcc2f831830acea7de9e045242636077746d9f692ab5ca55dc9f62182db56
7
+ data.tar.gz: 8ab515778e66c88f8b53f10d03d65e95db89db8061f166bd4235b2dd47f18433187162b645d663a8f38bcf937d06d4a7fbdd14391b887eafadc4652b35cad80c
data/History.md CHANGED
@@ -1,4 +1,27 @@
1
1
 
2
+ 0.5.0 / 2020-07-22
3
+ ==================
4
+
5
+ * Debian::AptPkg::PkgCache.pkg_names deprecated
6
+ * Add all maintained Rubies on gitlab-ci
7
+ * Init listing packages on cache
8
+ * Quick fix gitlab ci
9
+ * Add .gitlab-ci.yml
10
+ * Rename lib/debian/apt_pkg/{version,gem_version}.rb
11
+ * Update README
12
+ * Tidy tests remove should
13
+ * Debian::AptPkg.init returns a boolean
14
+ * Fix mimitest warnings
15
+ * Remove cppcheck on CI version conflict
16
+ * Fix code lint
17
+ * Fix CI and update Rubies
18
+ * Fix libapt-pkg 2.1 compat
19
+ * Update apt-pkg deps
20
+ * Update doc Debian::AptPkg::InitError
21
+ * README: Bundler is not needed
22
+ * Use Debian::AptPkg::InitError instead of RuntimeError
23
+ * Fix rb_mDebianAptPkgCache name
24
+
2
25
  0.4.0 / 2016-10-06
3
26
  ==================
4
27
 
data/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License
2
2
 
3
- Copyright (c) 2014-2016 Laurent Arnoud <laurent@spkdev.net>
3
+ Copyright (c) 2014-2020 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
@@ -1,13 +1,13 @@
1
1
  # Ruby interface to apt-pkg
2
2
 
3
3
  Goal of this project is to have a proper Ruby binding to APT like in
4
- [Python](https://apt.alioth.debian.org/python-apt-doc/library/apt_pkg.html).
4
+ [Python](https://tracker.debian.org/pkg/python-apt).
5
5
 
6
6
  Currently install, remove packages commands are **not** implemented.
7
7
 
8
8
  ## INSTALL
9
9
 
10
- ``` console
10
+ ```
11
11
  apt install build-essential ruby-dev libapt-pkg-dev (>= 1.0)
12
12
  gem install apt-pkg
13
13
  ```
@@ -27,6 +27,12 @@ Debian::AptPkg::PkgCache.update
27
27
 
28
28
  # Search package by names
29
29
  Debian::AptPkg::PkgCache.pkg_names("vim")
30
+
31
+ # List packages stored in the cache
32
+ Debian::AptPkg::PkgCache.packages
33
+
34
+ # List installed packages
35
+ Debian::AptPkg::PkgCache.packages.select {|pkg| pkg.is_installed }
30
36
  ```
31
37
 
32
38
  [Documentation](http://www.rubydoc.info/gems/apt-pkg)
@@ -34,27 +40,24 @@ Debian::AptPkg::PkgCache.pkg_names("vim")
34
40
  ## BUILD
35
41
 
36
42
  ``` console
37
- gem install bundler
38
- bundle install
39
- bundle exec rake compile
43
+ rake compile
40
44
  ```
41
45
 
42
46
  ## TEST
43
47
 
44
48
  ``` console
45
- bundle exec rake test
49
+ rake test
46
50
  ```
47
51
 
48
52
  ## LICENSE
49
53
 
50
54
  The MIT License
51
55
 
52
- Copyright (c) 2014-2016 Laurent Arnoud <laurent@spkdev.net>
56
+ Copyright (c) 2014-2020 Laurent Arnoud <laurent@spkdev.net>
53
57
 
54
58
  ---
55
- [![Build](https://img.shields.io/travis-ci/spk/ruby-apt-pkg.svg)](https://travis-ci.org/spk/ruby-apt-pkg)
59
+ [![Build](https://img.shields.io/travis/spk/ruby-apt-pkg.svg)](https://travis-ci.org/spk/ruby-apt-pkg)
56
60
  [![Version](https://img.shields.io/gem/v/apt-pkg.svg)](https://rubygems.org/gems/apt-pkg)
57
61
  [![Documentation](https://img.shields.io/badge/doc-rubydoc-blue.svg)](http://www.rubydoc.info/gems/apt-pkg)
58
62
  [![License](https://img.shields.io/badge/license-MIT-blue.svg)](http://opensource.org/licenses/MIT "MIT")
59
- [![IRC Network](https://img.shields.io/badge/irc-oftc-blue.svg)](https://webchat.oftc.net/ "#ruby-apt-pkg")
60
- [![Project status](http://img.shields.io/status/experimental.png?color=red)](https://github.com/spk/ruby-apt-pkg)
63
+ [![Project status](https://img.shields.io/badge/status-experimental-red)](https://github.com/spk/ruby-apt-pkg)
@@ -3,19 +3,18 @@
3
3
  #include "pkgcache.h"
4
4
 
5
5
  /*
6
- * call-seq: init() -> nil
6
+ * call-seq: init() -> bool
7
7
  *
8
8
  * Shorthand for doing init_config() and init_system().
9
9
  *
10
- * Debian::AptPkg.init # => nil
10
+ * Debian::AptPkg.init # => true
11
11
  *
12
12
  **/
13
13
  static VALUE
14
14
  init(VALUE self)
15
15
  {
16
- pkgInitConfig(*_config);
17
- pkgInitSystem(*_config, _system);
18
- return Qnil;
16
+ int res = pkgInitConfig(*_config) && pkgInitSystem(*_config, _system);
17
+ return INT2BOOL(res);
19
18
  }
20
19
 
21
20
  /*
@@ -199,8 +198,6 @@ Init_apt_pkg()
199
198
  {
200
199
  VALUE rb_mDebian = rb_define_module("Debian");
201
200
  VALUE rb_mDebianAptPkg = rb_define_module_under(rb_mDebian, "AptPkg");
202
- VALUE rb_mDebianAptPkgConfiguration =
203
- rb_define_module_under(rb_mDebianAptPkg, "Configuration");
204
201
 
205
202
  rb_define_singleton_method(rb_mDebianAptPkg, "init",
206
203
  RUBY_METHOD_FUNC(init), 0);
@@ -3,6 +3,7 @@
3
3
  #include <apt-pkg/debversion.h>
4
4
  #include <apt-pkg/pkgcache.h>
5
5
  #include <apt-pkg/strutl.h>
6
+ #include <apt-pkg/pkgsystem.h>
6
7
  #include <apt-pkg/init.h>
7
8
 
8
9
  /* from '<ruby/dl.h>' */
@@ -1,5 +1,7 @@
1
1
  #include "pkgcache.h"
2
2
 
3
+ static VALUE e_mDebianAptPkgInitError, rb_cPackage, rb_cVersion;
4
+
3
5
  /*
4
6
  * private
5
7
  */
@@ -17,7 +19,8 @@ config_system_initialized()
17
19
  * call-seq: gen_caches() -> bool
18
20
  *
19
21
  * Call the main cache generator.
20
- * Return `nil` when config, system, cache is not configured.
22
+ * Raise `Debian::AptPkg::InitError` when config, system, cache is not
23
+ * configured.
21
24
  *
22
25
  * Debian::AptPkg::PkgCache.gen_caches # => false
23
26
  *
@@ -26,7 +29,7 @@ static VALUE
26
29
  gen_caches(VALUE self)
27
30
  {
28
31
  if (!config_system_initialized()) {
29
- rb_raise(rb_eRuntimeError, "System not initialized");
32
+ rb_raise(e_mDebianAptPkgInitError, "System not initialized");
30
33
  }
31
34
  pkgCacheFile CacheFile;
32
35
  int res = CacheFile.BuildCaches(NULL, true);
@@ -37,7 +40,8 @@ gen_caches(VALUE self)
37
40
  * call-seq: update() -> bool
38
41
  *
39
42
  * Update the index files used by the cache.
40
- * Return `nil` when config, system, cache is not configured.
43
+ * Raise `Debian::AptPkg::InitError` when config, system, cache is not
44
+ * configured.
41
45
  *
42
46
  * Debian::AptPkg::PkgCache.update # => false
43
47
  *
@@ -46,7 +50,7 @@ static VALUE
46
50
  update(VALUE self)
47
51
  {
48
52
  if (!config_system_initialized()) {
49
- rb_raise(rb_eRuntimeError, "System not initialized");
53
+ rb_raise(e_mDebianAptPkgInitError, "System not initialized");
50
54
  }
51
55
  pkgCacheFile CacheFile;
52
56
  // Get the source list
@@ -63,7 +67,8 @@ update(VALUE self)
63
67
  * call-seq: is_multi_arch() -> bool
64
68
  *
65
69
  * An attribute determining whether the cache supports multi-arch.
66
- * Return `nil` when config, system, cache is not configured.
70
+ * Raise `Debian::AptPkg::InitError` when config, system, cache is not
71
+ * configured.
67
72
  *
68
73
  * Debian::AptPkg::PkgCache.is_multi_arch # => false
69
74
  *
@@ -72,7 +77,7 @@ static VALUE
72
77
  is_multi_arch(VALUE self)
73
78
  {
74
79
  if (!config_system_initialized()) {
75
- rb_raise(rb_eRuntimeError, "System not initialized");
80
+ rb_raise(e_mDebianAptPkgInitError, "System not initialized");
76
81
  }
77
82
  pkgCacheFile CacheFile;
78
83
  pkgCache *Cache = CacheFile.GetPkgCache();
@@ -83,11 +88,67 @@ is_multi_arch(VALUE self)
83
88
  return INT2BOOL(res);
84
89
  }
85
90
 
91
+ /*
92
+ * call-seq: packages() -> array, nil
93
+ *
94
+ * A list of Debian::AptPkg::Package objects stored in the cache
95
+ * Raise `Debian::AptPkg::InitError` when config, system, cache is not
96
+ * configured.
97
+ *
98
+ * Debian::AptPkg::PkgCache.packages
99
+ *
100
+ **/
101
+ static VALUE
102
+ packages(int argc, VALUE *argv, VALUE self)
103
+ {
104
+ if (!config_system_initialized()) {
105
+ rb_raise(e_mDebianAptPkgInitError, "System not initialized");
106
+ }
107
+ VALUE result = rb_ary_new();
108
+ pkgCacheFile CacheFile;
109
+ if (CacheFile.GetPkgCache() == 0) {
110
+ return Qnil;
111
+ }
112
+ for (pkgCache::PkgIterator Pkg = CacheFile.GetPkgCache()->PkgBegin(); not Pkg.end(); ++Pkg) {
113
+ VALUE current_version;
114
+ if (Pkg->CurrentVer == 0) {
115
+ current_version = Qnil;
116
+ } else {
117
+ current_version = rb_struct_new(rb_cVersion,
118
+ rb_str_new2(Pkg.CurrentVer().ParentPkg().Name()),
119
+ rb_str_new2(Pkg.CurrentVer().VerStr()),
120
+ rb_str_new2(Pkg.CurrentVer().Section()),
121
+ rb_str_new2(Pkg.CurrentVer().Arch()),
122
+ INT2FIX(Pkg.CurrentVer()->Size),
123
+ INT2FIX(Pkg.CurrentVer()->InstalledSize),
124
+ INT2FIX(Pkg.CurrentVer()->Hash),
125
+ INT2FIX(Pkg.CurrentVer()->ID),
126
+ INT2FIX(Pkg.CurrentVer()->Priority)
127
+ );
128
+ }
129
+ VALUE rb_cPackage_args[7];
130
+ rb_cPackage_args[0] = INT2FIX(Pkg->ID);
131
+ rb_cPackage_args[1] = rb_str_new2(Pkg.Name());
132
+ rb_cPackage_args[2] = rb_str_new2(Pkg.FullName().c_str());
133
+ rb_cPackage_args[3] = rb_str_new2(Pkg.Arch());
134
+ rb_cPackage_args[4] = INT2BOOL((Pkg->Flags & pkgCache::Flag::Essential) != 0);
135
+ rb_cPackage_args[5] = INT2BOOL((Pkg->Flags & pkgCache::Flag::Important) != 0);
136
+ rb_cPackage_args[6] = current_version;
137
+ rb_ary_push(result, rb_class_new_instance(7,
138
+ rb_cPackage_args,
139
+ rb_cPackage
140
+ ));
141
+ }
142
+ return result;
143
+ }
144
+
86
145
  /*
87
146
  * call-seq: pkg_names() -> array, nil
88
147
  *
148
+ * Deprecated and will removed in 0.6.0
89
149
  * List the names of all packages in the system.
90
- * Return `nil` when config, system, cache is not configured.
150
+ * Raise `Debian::AptPkg::InitError` when config, system, cache is not
151
+ * configured.
91
152
  *
92
153
  * Debian::AptPkg::PkgCache.pkg_names('gcolor2') # => ["gcolor2"]
93
154
  *
@@ -95,8 +156,10 @@ is_multi_arch(VALUE self)
95
156
  static VALUE
96
157
  pkg_names(int argc, VALUE *argv, VALUE self)
97
158
  {
159
+ rb_warn("Debian::AptPkg::PkgCache.pkg_names is deprecated; " \
160
+ "use Debian::AptPkg::PkgCache.packages instead");
98
161
  if (!config_system_initialized()) {
99
- rb_raise(rb_eRuntimeError, "System not initialized");
162
+ rb_raise(e_mDebianAptPkgInitError, "System not initialized");
100
163
  }
101
164
  if (argc > 1 || argc == 0) {
102
165
  rb_raise(rb_eArgError, "You must give at least one search argument");
@@ -127,7 +190,8 @@ pkg_names(int argc, VALUE *argv, VALUE self)
127
190
  * call-seq: package_count() -> int, nil
128
191
  *
129
192
  * The total number of packages available in the cache.
130
- * Return `nil` when config, system, cache is not configured.
193
+ * Raise `Debian::AptPkg::InitError` when config, system, cache is not
194
+ * configured.
131
195
  *
132
196
  * Debian::AptPkg::PkgCache.package_count # => 69511
133
197
  *
@@ -136,7 +200,7 @@ static VALUE
136
200
  package_count(VALUE self)
137
201
  {
138
202
  if (!config_system_initialized()) {
139
- rb_raise(rb_eRuntimeError, "System not initialized");
203
+ rb_raise(e_mDebianAptPkgInitError, "System not initialized");
140
204
  }
141
205
  pkgCacheFile CacheFile;
142
206
  pkgCache *Cache = CacheFile.GetPkgCache();
@@ -150,7 +214,8 @@ package_count(VALUE self)
150
214
  * call-seq: version_count() -> int, nil
151
215
  *
152
216
  * The total number of package versions available in the cache.
153
- * Return `nil` when config, system, cache is not configured.
217
+ * Raise `Debian::AptPkg::InitError` when config, system, cache is not
218
+ * configured.
154
219
  *
155
220
  * Debian::AptPkg::PkgCache.version_count # => 84630
156
221
  *
@@ -159,7 +224,7 @@ static VALUE
159
224
  version_count(VALUE self)
160
225
  {
161
226
  if (!config_system_initialized()) {
162
- rb_raise(rb_eRuntimeError, "System not initialized");
227
+ rb_raise(e_mDebianAptPkgInitError, "System not initialized");
163
228
  }
164
229
  pkgCacheFile CacheFile;
165
230
  pkgCache *Cache = CacheFile.GetPkgCache();
@@ -173,7 +238,8 @@ version_count(VALUE self)
173
238
  * call-seq: depends_count() -> int, nil
174
239
  *
175
240
  * The total number of dependencies stored in the cache.
176
- * Return `nil` when config, system, cache is not configured.
241
+ * Raise `Debian::AptPkg::InitError` when config, system, cache is not
242
+ * configured.
177
243
  *
178
244
  * Debian::AptPkg::PkgCache.depends_count # => 551983
179
245
  *
@@ -182,7 +248,7 @@ static VALUE
182
248
  depends_count(VALUE self)
183
249
  {
184
250
  if (!config_system_initialized()) {
185
- rb_raise(rb_eRuntimeError, "System not initialized");
251
+ rb_raise(e_mDebianAptPkgInitError, "System not initialized");
186
252
  }
187
253
  pkgCacheFile CacheFile;
188
254
  pkgCache *Cache = CacheFile.GetPkgCache();
@@ -196,7 +262,8 @@ depends_count(VALUE self)
196
262
  * call-seq: package_file_count() -> int, nil
197
263
  *
198
264
  * The total number of packages files available.
199
- * Return `nil` when config, system, cache is not configured.
265
+ * Raise `Debian::AptPkg::InitError` when config, system, cache is not
266
+ * configured.
200
267
  *
201
268
  * Debian::AptPkg::PkgCache.package_file_count # => 17
202
269
  *
@@ -205,7 +272,7 @@ static VALUE
205
272
  package_file_count(VALUE self)
206
273
  {
207
274
  if (!config_system_initialized()) {
208
- rb_raise(rb_eRuntimeError, "System not initialized");
275
+ rb_raise(e_mDebianAptPkgInitError, "System not initialized");
209
276
  }
210
277
  pkgCacheFile CacheFile;
211
278
  pkgCache *Cache = CacheFile.GetPkgCache();
@@ -219,7 +286,8 @@ package_file_count(VALUE self)
219
286
  * call-seq: ver_file_count() -> int, nil
220
287
  *
221
288
  * The total number of version and package file relations stored in the cache.
222
- * Return `nil` when config, system, cache is not configured.
289
+ * Raise `Debian::AptPkg::InitError` when config, system, cache is not
290
+ * configured.
223
291
  *
224
292
  * Debian::AptPkg::PkgCache.ver_file_count # => 11274
225
293
  *
@@ -228,7 +296,7 @@ static VALUE
228
296
  ver_file_count(VALUE self)
229
297
  {
230
298
  if (!config_system_initialized()) {
231
- rb_raise(rb_eRuntimeError, "System not initialized");
299
+ rb_raise(e_mDebianAptPkgInitError, "System not initialized");
232
300
  }
233
301
  pkgCacheFile CacheFile;
234
302
  pkgCache *Cache = CacheFile.GetPkgCache();
@@ -242,7 +310,8 @@ ver_file_count(VALUE self)
242
310
  * call-seq: provides_count() -> int, nil
243
311
  *
244
312
  * The number of provided packages.
245
- * Return `nil` when config, system, cache is not configured.
313
+ * Raise `Debian::AptPkg::InitError` when config, system, cache is not
314
+ * configured.
246
315
  *
247
316
  * Debian::AptPkg::PkgCache.provides_count # => 69511
248
317
  *
@@ -251,7 +320,7 @@ static VALUE
251
320
  provides_count(VALUE self)
252
321
  {
253
322
  if (!config_system_initialized()) {
254
- rb_raise(rb_eRuntimeError, "System not initialized");
323
+ rb_raise(e_mDebianAptPkgInitError, "System not initialized");
255
324
  }
256
325
  pkgCacheFile CacheFile;
257
326
  pkgCache *Cache = CacheFile.GetPkgCache();
@@ -265,7 +334,8 @@ provides_count(VALUE self)
265
334
  * call-seq: group_count() -> int, nil
266
335
  *
267
336
  * The number of groups in the cache.
268
- * Return `nil` when config, system, cache is not configured.
337
+ * Raise `Debian::AptPkg::InitError` when config, system, cache is not
338
+ * configured.
269
339
  *
270
340
  * Debian::AptPkg::PkgCache.group_count # => 16730
271
341
  *
@@ -274,7 +344,7 @@ static VALUE
274
344
  group_count(VALUE self)
275
345
  {
276
346
  if (!config_system_initialized()) {
277
- rb_raise(rb_eRuntimeError, "System not initialized");
347
+ rb_raise(e_mDebianAptPkgInitError, "System not initialized");
278
348
  }
279
349
  pkgCacheFile CacheFile;
280
350
  pkgCache *Cache = CacheFile.GetPkgCache();
@@ -289,31 +359,48 @@ init_apt_pkg_pkgcache()
289
359
  {
290
360
  VALUE rb_mDebian = rb_define_module("Debian");
291
361
  VALUE rb_mDebianAptPkg = rb_define_module_under(rb_mDebian, "AptPkg");
292
- VALUE rb_mDebianAptPkgConfiguration = rb_define_module_under(rb_mDebianAptPkg,
362
+ VALUE rb_mDebianAptPkgCache = rb_define_module_under(rb_mDebianAptPkg,
293
363
  "PkgCache");
364
+ e_mDebianAptPkgInitError = rb_define_class_under(rb_mDebianAptPkg,
365
+ "InitError",
366
+ rb_eRuntimeError);
367
+ rb_cPackage = rb_const_get_at(rb_mDebianAptPkg, rb_intern("Package"));
368
+ rb_cVersion = rb_struct_define_under(rb_mDebianAptPkg, "Version",
369
+ "parent_package_name",
370
+ "version_string",
371
+ "section",
372
+ "arch",
373
+ "size",
374
+ "installed_size",
375
+ "hash",
376
+ "id",
377
+ "priority",
378
+ NULL);
294
379
 
295
- rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "gen_caches",
380
+ rb_define_singleton_method(rb_mDebianAptPkgCache, "gen_caches",
296
381
  RUBY_METHOD_FUNC(gen_caches), 0);
297
- rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "update",
382
+ rb_define_singleton_method(rb_mDebianAptPkgCache, "update",
298
383
  RUBY_METHOD_FUNC(update), 0);
299
- rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "is_multi_arch",
384
+ rb_define_singleton_method(rb_mDebianAptPkgCache, "is_multi_arch",
300
385
  RUBY_METHOD_FUNC(is_multi_arch), 0);
301
- rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "pkg_names",
386
+ rb_define_singleton_method(rb_mDebianAptPkgCache, "packages",
387
+ RUBY_METHOD_FUNC(packages), 0);
388
+ rb_define_singleton_method(rb_mDebianAptPkgCache, "pkg_names",
302
389
  RUBY_METHOD_FUNC(pkg_names), -1);
303
390
 
304
- rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "package_count",
391
+ rb_define_singleton_method(rb_mDebianAptPkgCache, "package_count",
305
392
  RUBY_METHOD_FUNC(package_count), 0);
306
- rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "version_count",
393
+ rb_define_singleton_method(rb_mDebianAptPkgCache, "version_count",
307
394
  RUBY_METHOD_FUNC(version_count), 0);
308
- rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "depends_count",
395
+ rb_define_singleton_method(rb_mDebianAptPkgCache, "depends_count",
309
396
  RUBY_METHOD_FUNC(depends_count), 0);
310
- rb_define_singleton_method(rb_mDebianAptPkgConfiguration,
397
+ rb_define_singleton_method(rb_mDebianAptPkgCache,
311
398
  "package_file_count",
312
399
  RUBY_METHOD_FUNC(package_file_count), 0);
313
- rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "ver_file_count",
400
+ rb_define_singleton_method(rb_mDebianAptPkgCache, "ver_file_count",
314
401
  RUBY_METHOD_FUNC(ver_file_count), 0);
315
- rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "provides_count",
402
+ rb_define_singleton_method(rb_mDebianAptPkgCache, "provides_count",
316
403
  RUBY_METHOD_FUNC(provides_count), 0);
317
- rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "group_count",
404
+ rb_define_singleton_method(rb_mDebianAptPkgCache, "group_count",
318
405
  RUBY_METHOD_FUNC(group_count), 0);
319
406
  }
@@ -1,2 +1,4 @@
1
+ # frozen_string_literal: true
2
+ require 'debian/apt_pkg/package'
1
3
  require 'apt_pkg'
2
- require 'debian/apt_pkg/version'
4
+ require 'debian/apt_pkg/gem_version'
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+ # Debian::AptPkg const VERSION file
3
+ module Debian
4
+ # AptPkg base module
5
+ module AptPkg
6
+ # Gem version
7
+ VERSION = '0.5.0'.freeze
8
+ end
9
+ end
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+ # Debian::AptPkg::Package file
3
+ module Debian
4
+ # AptPkg base module
5
+ module AptPkg
6
+ # Debian::AptPkg::Package class
7
+ # Representation of a package in a cache
8
+ class Package
9
+ attr_accessor :id, :name, :full_name, :arch, :essential, :important,
10
+ :current_version
11
+
12
+ # Initialize the Package class
13
+ # @example
14
+ # new(id, name, full_name, arch, essential, important, current_version)
15
+ # @param [Integer] The numeric ID of the package
16
+ # @param [String] The name of the package
17
+ # @param [String] Get the full name of the package, including the
18
+ # architecture
19
+ # @param [String] The architecture of the package
20
+ # @param [Boolean] Boolean value determining whether the package is
21
+ # essential
22
+ # @param [Boolean] Boolean value determining whether the package has the
23
+ # 'important' flag set
24
+ # ('Important: yes' in the Packages file)
25
+ # @param [Version,NilClass] The version of the package currently installed
26
+ # or `nil`
27
+ # @return [Package] Package instance
28
+ def initialize(id, name, full_name, arch, essential, important, current_version)
29
+ @id = id
30
+ @name = name
31
+ @full_name = full_name
32
+ @arch = arch
33
+ @essential = essential
34
+ @important = important
35
+ @current_version = current_version
36
+ end
37
+
38
+ # Return `true` if the package is installed
39
+ # @return [Boolean]
40
+ def is_installed
41
+ return false unless current_version
42
+
43
+ true
44
+ end
45
+ end
46
+ end
47
+ end
@@ -1,21 +1,22 @@
1
+ # frozen_string_literal: true
1
2
  require_relative 'test_helper'
2
3
 
3
4
  describe Debian::AptPkg::PkgCache do
4
5
  describe 'not init' do
5
6
  describe '.update' do
6
7
  it 'can be called' do
7
- lambda do
8
+ _(lambda do
8
9
  Debian::AptPkg::PkgCache.update
9
- end.must_raise RuntimeError
10
+ end).must_raise Debian::AptPkg::InitError
10
11
  end
11
12
  end
12
13
 
13
14
  %i(package version depends package_file ver_file provides group).each do |m|
14
15
  describe ".#{m}_count" do
15
16
  it 'can be called' do
16
- lambda do
17
+ _(lambda do
17
18
  Debian::AptPkg::PkgCache.public_send("#{m}_count")
18
- end.must_raise RuntimeError
19
+ end).must_raise Debian::AptPkg::InitError
19
20
  end
20
21
  end
21
22
  end
@@ -7,78 +7,72 @@ describe Debian::AptPkg::Configuration do
7
7
 
8
8
  it 'architectures return an array' do
9
9
  arches = Debian::AptPkg::Configuration.architectures
10
- arches.must_be_instance_of Array
11
- arches.wont_be_empty
10
+ _(arches).must_be_instance_of Array
11
+ _(arches).wont_be_empty
12
12
  end
13
13
 
14
14
  it 'languages return an array' do
15
15
  all_langs = Debian::AptPkg::Configuration.languages
16
- all_langs.must_be_instance_of Array
17
- all_langs.wont_be_empty
16
+ _(all_langs).must_be_instance_of Array
17
+ _(all_langs).wont_be_empty
18
18
 
19
19
  langs = Debian::AptPkg::Configuration.languages(false)
20
- langs.must_be_instance_of Array
20
+ _(langs).must_be_instance_of Array
21
21
  end
22
22
 
23
23
  it 'check_architecture' do
24
- Debian::AptPkg::Configuration.check_architecture('all').must_equal true
24
+ _(Debian::AptPkg::Configuration.check_architecture('all')).must_equal true
25
25
 
26
26
  arches = Debian::AptPkg::Configuration.architectures
27
27
  c = Debian::AptPkg::Configuration.check_architecture(arches.first)
28
- c.must_equal true
28
+ _(c).must_equal true
29
29
 
30
30
  # http://buildd.debian-ports.org/status/fetch.php?pkg=ruby2.1&arch=m68k&ver=2.1.2-2&stamp=1400604298
31
- Debian::AptPkg::Configuration.check_architecture('m68k').must_equal false
31
+ _(Debian::AptPkg::Configuration.check_architecture('m68k')).must_equal false
32
32
  end
33
33
 
34
34
  it 'check_language' do
35
- lambda do
35
+ _(lambda do
36
36
  Debian::AptPkg::Configuration.check_language
37
- end.must_raise ArgumentError
37
+ end).must_raise ArgumentError
38
38
 
39
39
  langs = Debian::AptPkg::Configuration.languages
40
- Debian::AptPkg::Configuration.check_language(langs.first).must_equal true
40
+ _(Debian::AptPkg::Configuration.check_language(langs.first)).must_equal true
41
41
 
42
42
  c = Debian::AptPkg::Configuration.check_language('gallifreyan')
43
- c.must_equal false
43
+ _(c).must_equal false
44
44
  end
45
45
 
46
46
  it 'compressors return an array' do
47
47
  cmps = Debian::AptPkg::Configuration.compressors
48
- cmps.must_be_instance_of Array
49
- cmps.wont_be_empty
50
- cmps.must_include 'gz'
48
+ _(cmps).must_be_instance_of Array
49
+ _(cmps).wont_be_empty
50
+ _(cmps).must_include 'gz'
51
51
  end
52
52
 
53
53
  it 'find configuration value' do
54
- lambda do
54
+ _(lambda do
55
55
  Debian::AptPkg::Configuration.config_find
56
- end.must_raise ArgumentError
56
+ end).must_raise ArgumentError
57
57
 
58
- Debian::AptPkg::Configuration
59
- .config_find('Dir::Etc::main')
58
+ _(Debian::AptPkg::Configuration.config_find('Dir::Etc::main'))
60
59
  .must_equal 'apt.conf'
61
- Debian::AptPkg::Configuration
62
- .config_find('Dir::Etc::netrc')
60
+ _(Debian::AptPkg::Configuration.config_find('Dir::Etc::netrc'))
63
61
  .must_equal 'auth.conf'
64
- Debian::AptPkg::Configuration
65
- .config_find('Dir::Etc::parts')
62
+ _(Debian::AptPkg::Configuration.config_find('Dir::Etc::parts'))
66
63
  .must_equal 'apt.conf.d'
67
- Debian::AptPkg::Configuration
68
- .config_find('Spk', 'DebianUser')
64
+ _(Debian::AptPkg::Configuration.config_find('Spk', 'DebianUser'))
69
65
  .must_equal 'DebianUser'
70
66
  end
71
67
 
72
68
  it 'find file' do
73
- lambda do
69
+ _(lambda do
74
70
  Debian::AptPkg::Configuration.config_find_file
75
- end.must_raise ArgumentError
71
+ end).must_raise ArgumentError
76
72
 
77
- Debian::AptPkg::Configuration
78
- .config_find_file('Dir::Etc::main')
73
+ _(Debian::AptPkg::Configuration.config_find_file('Dir::Etc::main'))
79
74
  .must_equal '/etc/apt/apt.conf'
80
- Debian::AptPkg::Configuration
81
- .config_find_file('Dir::Etc::netrc')
75
+ _(Debian::AptPkg::Configuration.config_find_file('Dir::Etc::netrc'))
82
76
  .must_equal '/etc/apt/auth.conf'
83
77
  end
84
78
  end
@@ -13,118 +13,122 @@ describe Debian::AptPkg do
13
13
  refute_nil Debian::AptPkg::LIBAPT_PKG_VERSION
14
14
  end
15
15
 
16
+ describe '.init' do
17
+ it 'returns a bool' do
18
+ _(Debian::AptPkg.init).must_equal true
19
+ end
20
+ end
21
+
16
22
  describe '.cmp_version' do
17
- it 'should compare version' do
18
- Debian::AptPkg.cmp_version('1.1', '1.0').must_be :>, 0
19
- Debian::AptPkg.cmp_version('1.0', '1.0').must_be :==, 0
20
- Debian::AptPkg.cmp_version('1.0', '1.1').must_be :<, 0
23
+ it 'compare version' do
24
+ _(Debian::AptPkg.cmp_version('1.1', '1.0')).must_be :>, 0
25
+ _(Debian::AptPkg.cmp_version('1.0', '1.0')).must_be :==, 0
26
+ _(Debian::AptPkg.cmp_version('1.0', '1.1')).must_be :<, 0
21
27
  end
22
28
  end
23
29
 
24
30
  describe '.check_dep' do
25
31
  describe 'LessEq' do
26
- it 'should compare Debian version' do
27
- Debian::AptPkg.check_dep('1', '<=', '2').must_equal true
28
- Debian::AptPkg.check_dep('2', '<=', '1').must_equal false
29
- Debian::AptPkg.check_dep('1', '<=', '1').must_equal true
32
+ it 'compare Debian version' do
33
+ _(Debian::AptPkg.check_dep('1', '<=', '2')).must_equal true
34
+ _(Debian::AptPkg.check_dep('2', '<=', '1')).must_equal false
35
+ _(Debian::AptPkg.check_dep('1', '<=', '1')).must_equal true
30
36
  end
31
37
  end
32
38
 
33
39
  describe 'GreaterEq' do
34
- it 'should compare Debian version' do
35
- Debian::AptPkg.check_dep('1', '>=', '2').must_equal false
36
- Debian::AptPkg.check_dep('2', '>=', '1').must_equal true
37
- Debian::AptPkg.check_dep('1', '>=', '1').must_equal true
40
+ it 'compare Debian version' do
41
+ _(Debian::AptPkg.check_dep('1', '>=', '2')).must_equal false
42
+ _(Debian::AptPkg.check_dep('2', '>=', '1')).must_equal true
43
+ _(Debian::AptPkg.check_dep('1', '>=', '1')).must_equal true
38
44
  end
39
45
  end
40
46
 
41
47
  describe 'Less' do
42
- it 'should compare Debian version' do
43
- Debian::AptPkg.check_dep('1', '<', '2').must_equal true
44
- Debian::AptPkg.check_dep('2', '<', '1').must_equal false
45
- Debian::AptPkg.check_dep('1', '<', '1').must_equal false
48
+ it 'compare Debian version' do
49
+ _(Debian::AptPkg.check_dep('1', '<', '2')).must_equal true
50
+ _(Debian::AptPkg.check_dep('2', '<', '1')).must_equal false
51
+ _(Debian::AptPkg.check_dep('1', '<', '1')).must_equal false
46
52
  end
47
53
  end
48
54
 
49
55
  describe 'Greater' do
50
- it 'should compare Debian version' do
51
- Debian::AptPkg.check_dep('1', '>', '2').must_equal false
52
- Debian::AptPkg.check_dep('2', '>', '1').must_equal true
53
- Debian::AptPkg.check_dep('1', '>', '1').must_equal false
56
+ it 'compare Debian version' do
57
+ _(Debian::AptPkg.check_dep('1', '>', '2')).must_equal false
58
+ _(Debian::AptPkg.check_dep('2', '>', '1')).must_equal true
59
+ _(Debian::AptPkg.check_dep('1', '>', '1')).must_equal false
54
60
  end
55
61
  end
56
62
 
57
63
  describe 'Equals' do
58
- it 'should compare Debian version' do
59
- Debian::AptPkg.check_dep('1', '=', '2').must_equal false
60
- Debian::AptPkg.check_dep('2', '=', '1').must_equal false
61
- Debian::AptPkg.check_dep('1', '=', '1').must_equal true
64
+ it 'compare Debian version' do
65
+ _(Debian::AptPkg.check_dep('1', '=', '2')).must_equal false
66
+ _(Debian::AptPkg.check_dep('2', '=', '1')).must_equal false
67
+ _(Debian::AptPkg.check_dep('1', '=', '1')).must_equal true
62
68
  end
63
69
  end
64
70
 
65
71
  describe 'NotEquals' do
66
- it 'should compare Debian version' do
67
- Debian::AptPkg
68
- .check_dep('1', Debian::AptPkg::NOT_EQUALS, '2')
72
+ it 'compare Debian version' do
73
+ _(Debian::AptPkg.check_dep('1', Debian::AptPkg::NOT_EQUALS, '2'))
69
74
  .must_equal true
70
- Debian::AptPkg
71
- .check_dep('2', Debian::AptPkg::NOT_EQUALS, '1')
75
+ _(Debian::AptPkg.check_dep('2', Debian::AptPkg::NOT_EQUALS, '1'))
72
76
  .must_equal true
73
- Debian::AptPkg
74
- .check_dep('1', Debian::AptPkg::NOT_EQUALS, '1')
77
+ _(Debian::AptPkg.check_dep('1', Debian::AptPkg::NOT_EQUALS, '1'))
75
78
  .must_equal false
76
79
  end
77
80
  end
78
81
 
79
82
  describe 'Errors' do
80
- it 'should raise argument error with bad comparison' do
81
- lambda do
83
+ it 'raise argument error with bad comparison' do
84
+ _(lambda do
82
85
  Debian::AptPkg.check_dep('1', 'bad', '2')
83
- end.must_raise ArgumentError
86
+ end).must_raise ArgumentError
84
87
  end
85
88
  end
86
89
  end
87
90
 
88
91
  describe '.uri_to_filename' do
89
- it 'should return a filename which can be used to store the file' do
90
- Debian::AptPkg
91
- .uri_to_filename('http://debian.org/index.html')
92
+ it 'return a filename which can be used to store the file' do
93
+ _(Debian::AptPkg.uri_to_filename('http://debian.org/index.html'))
92
94
  .must_equal 'debian.org_index.html'
93
95
  end
94
96
  end
95
97
 
96
98
  describe '.upstream_version' do
97
99
  it 'Return the upstream version for the Debian package version' do
98
- Debian::AptPkg.upstream_version('3.4.15-1+b1').must_equal '3.4.15'
100
+ _(Debian::AptPkg.upstream_version('3.4.15-1+b1')).must_equal '3.4.15'
99
101
  end
100
102
  end
101
103
 
102
104
  describe '.time_to_str' do
103
105
  it 'Format a given duration in human-readable manner' do
104
- Debian::AptPkg.time_to_str(3601).must_equal '1h 0min 1s'
106
+ _(Debian::AptPkg.time_to_str(3601)).must_equal '1h 0min 1s'
105
107
  end
106
108
  end
107
109
 
108
110
  describe '.size_to_str' do
109
111
  it 'Return a string describing the size in a human-readable manner' do
110
- Debian::AptPkg.size_to_str(10_000).must_equal '10.0 k'
112
+ _(Debian::AptPkg.size_to_str(10_000)).must_equal '10.0 k'
111
113
  end
112
114
  end
113
115
 
114
116
  describe '.string_to_bool' do
115
117
  it 'Parse the string input and return a boolean' do
116
- Debian::AptPkg.string_to_bool('yes').must_equal true
117
- Debian::AptPkg.string_to_bool('no').must_equal false
118
- Debian::AptPkg.string_to_bool('no-recognized').must_equal false
118
+ _(Debian::AptPkg.string_to_bool('yes')).must_equal true
119
+ _(Debian::AptPkg.string_to_bool('no')).must_equal false
120
+ _(Debian::AptPkg.string_to_bool('no-recognized')).must_equal false
119
121
  end
120
122
  end
121
123
 
122
124
  describe '.check_domain_list' do
123
125
  it 'See if the host name given by host is one of the domains given' do
124
- Debian::AptPkg.check_domain_list('alioth.debian.org',
125
- 'debian.net,debian.org').must_equal true
126
- Debian::AptPkg.check_domain_list('git.debian.org',
127
- 'spkdev.net').must_equal false
126
+ _(Debian::AptPkg.check_domain_list('alioth.debian.org',
127
+ 'debian.net,debian.org'))
128
+ .must_equal true
129
+ _(Debian::AptPkg.check_domain_list('git.debian.org',
130
+ 'spkdev.net'))
131
+ .must_equal false
128
132
  end
129
133
  end
130
134
  end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+ require_relative '../../test_helper'
3
+
4
+ describe Debian::AptPkg::Package do
5
+ let(:id) { 42 }
6
+ let(:pkg_name) { "ed" }
7
+ let(:full_name) { "ed:i386" }
8
+ let(:arch) { "i386" }
9
+ let(:essential) { false }
10
+ let(:important) { false }
11
+ let(:current_version) { nil }
12
+
13
+ describe '.new' do
14
+ describe 'with correct number of arguments' do
15
+ it 'can initialize a Package class' do
16
+ Debian::AptPkg::Package.new(id, pkg_name, full_name, arch,
17
+ essential, important, current_version)
18
+ end
19
+ end
20
+
21
+ describe 'with wrong number of arguments' do
22
+ it 'cannot initialize a Package class' do
23
+ _(lambda do
24
+ Debian::AptPkg::Package.new(id, pkg_name, full_name, arch,
25
+ essential, important)
26
+ end).must_raise ArgumentError
27
+ end
28
+ end
29
+ end
30
+
31
+ describe '#is_installed' do
32
+ subject do
33
+ Debian::AptPkg::Package.new(id, pkg_name, full_name, arch,
34
+ essential, important,
35
+ current_version).is_installed
36
+ end
37
+
38
+ describe 'when current_version is present' do
39
+ let(:current_version) do
40
+ Debian::AptPkg::Version.new("ed", "1", "editors", "i386", 0, 0, 0, 0, 4)
41
+ end
42
+
43
+ it 'returns true' do
44
+ _(subject).must_equal true
45
+ end
46
+ end
47
+
48
+ describe 'when current_version is not present' do
49
+ let(:current_version) { nil }
50
+
51
+ it 'returns false' do
52
+ _(subject).must_equal false
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,114 @@
1
+ # frozen_string_literal: true
2
+ require_relative '../../test_helper'
3
+
4
+ describe Debian::AptPkg::PkgCache do
5
+ before :all do
6
+ Debian::AptPkg.init
7
+ end
8
+
9
+ describe '.update' do
10
+ it 'can be called' do
11
+ Debian::AptPkg::PkgCache.update
12
+ end
13
+ end
14
+
15
+ describe '.gen_caches' do
16
+ it 'return boolean' do
17
+ if Process.uid == 0
18
+ _(Debian::AptPkg::PkgCache.gen_caches).must_equal true
19
+ else
20
+ _(Debian::AptPkg::PkgCache.gen_caches).must_equal false
21
+ end
22
+ end
23
+ end
24
+
25
+ describe '.is_multi_arch' do
26
+ it 'can be called' do
27
+ Debian::AptPkg::PkgCache.is_multi_arch
28
+ end
29
+ end
30
+
31
+ describe '.packages' do
32
+ it 'returns an array of Package' do
33
+ packages = Debian::AptPkg::PkgCache.packages
34
+ _(packages).must_be_kind_of Array
35
+ _(packages.first).must_be_kind_of Debian::AptPkg::Package
36
+ libapt = packages.find { |pkg| pkg.name == 'libapt-pkg-dev' }
37
+ _(libapt.id).must_be_kind_of Numeric
38
+ _(libapt.name).must_equal 'libapt-pkg-dev'
39
+ _(libapt.full_name).must_match(/libapt-pkg-dev:(\w)/)
40
+ _(libapt.arch).must_match(/(\w)/)
41
+ _([true, false]).must_include libapt.essential
42
+ _([true, false]).must_include libapt.important
43
+ _(libapt.current_version).must_be_kind_of Debian::AptPkg::Version
44
+ _(libapt.current_version.parent_package_name).must_equal libapt.name
45
+ _(libapt.current_version.version_string).must_be_kind_of String
46
+ _(libapt.current_version.section).must_equal 'libdevel'
47
+ _(libapt.current_version.arch).must_equal libapt.arch
48
+ _(libapt.current_version.size).must_be_kind_of Numeric
49
+ _(libapt.current_version.installed_size).must_be_kind_of Numeric
50
+ _(libapt.current_version.hash).must_be_kind_of Numeric
51
+ _(libapt.current_version.id).must_be_kind_of Numeric
52
+ _(libapt.current_version.priority).must_be_kind_of Numeric
53
+ end
54
+ end
55
+
56
+ describe '.pkg_names' do
57
+ it 'is deprecated' do
58
+ out, err = capture_io do
59
+ Debian::AptPkg::PkgCache.pkg_names('libapt-pkg-dev')
60
+ end
61
+ _(out).must_equal ''
62
+ regexp = /warning:\sDebian::AptPkg::PkgCache\.pkg_names\sis\sdeprecated;\s
63
+ use\sDebian::AptPkg::PkgCache\.packages\sinstead/x
64
+ _(err).must_match(regexp)
65
+ end
66
+
67
+ it 'no argument' do
68
+ _(lambda do
69
+ capture_io do
70
+ Debian::AptPkg::PkgCache.pkg_names
71
+ end
72
+ end).must_raise ArgumentError
73
+ end
74
+
75
+ it 'nil argument' do
76
+ _(lambda do
77
+ capture_io do
78
+ Debian::AptPkg::PkgCache.pkg_names(nil)
79
+ end
80
+ end).must_raise ArgumentError
81
+ end
82
+
83
+ it 'blank argument' do
84
+ _(lambda do
85
+ capture_io do
86
+ Debian::AptPkg::PkgCache.pkg_names('')
87
+ end
88
+ end).must_raise ArgumentError
89
+ end
90
+
91
+ it 'be filtered' do
92
+ capture_io do
93
+ search = Debian::AptPkg::PkgCache.pkg_names('vim')
94
+ # CI specific cache can not be present
95
+ unless search.nil? || search.empty?
96
+ _(search).must_include 'vim'
97
+ _(search).must_include 'vim-nox'
98
+ _(search).must_include 'vim-gtk'
99
+ _(search).wont_include 'emacs'
100
+ end
101
+ end
102
+ end
103
+ end
104
+
105
+ %i(package version depends package_file ver_file provides group).each do |m|
106
+ describe ".#{m}_count" do
107
+ it 'return an int' do
108
+ if Process.uid == 0
109
+ _(Debian::AptPkg::PkgCache.public_send("#{m}_count")).must_be :>=, 0
110
+ end
111
+ end
112
+ end
113
+ end
114
+ end
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.4.0
4
+ version: 0.5.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: 2016-10-06 00:00:00.000000000 Z
11
+ date: 2020-07-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -16,42 +16,42 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '10.3'
19
+ version: '13.0'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '10.3'
26
+ version: '13.0'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake-compiler
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.9'
33
+ version: '1.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.9'
40
+ version: '1.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: '5'
47
+ version: '5.13'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: '5'
54
+ version: '5.13'
55
55
  description: Ruby interface to apt-pkg
56
56
  email: laurent@spkdev.net
57
57
  executables: []
@@ -76,11 +76,13 @@ files:
76
76
  - ext/apt_pkg/pkgcache.cpp
77
77
  - ext/apt_pkg/pkgcache.h
78
78
  - lib/debian/apt_pkg.rb
79
- - lib/debian/apt_pkg/version.rb
79
+ - lib/debian/apt_pkg/gem_version.rb
80
+ - lib/debian/apt_pkg/package.rb
80
81
  - test/apt_pkg_cache_not_init_integration.rb
81
- - test/apt_pkg_cache_test.rb
82
82
  - test/apt_pkg_configuration_test.rb
83
83
  - test/apt_pkg_test.rb
84
+ - test/debian/apt_pkg/package_test.rb
85
+ - test/debian/apt_pkg/pkg_cache_test.rb
84
86
  - test/test_helper.rb
85
87
  homepage: http://github.com/spk/ruby-apt-pkg
86
88
  licenses:
@@ -102,8 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
102
104
  - !ruby/object:Gem::Version
103
105
  version: '0'
104
106
  requirements: []
105
- rubyforge_project:
106
- rubygems_version: 2.5.1
107
+ rubygems_version: 3.1.2
107
108
  signing_key:
108
109
  specification_version: 4
109
110
  summary: Ruby interface to libapt-pkg
@@ -1,8 +0,0 @@
1
- # Debian::AptPkg version file
2
- module Debian
3
- # AptPkg base module
4
- module AptPkg
5
- # Gem version
6
- VERSION = '0.4.0'.freeze
7
- end
8
- end
@@ -1,69 +0,0 @@
1
- require_relative 'test_helper'
2
-
3
- describe Debian::AptPkg::PkgCache do
4
- before :all do
5
- Debian::AptPkg.init
6
- end
7
-
8
- describe '.update' do
9
- it 'can be called' do
10
- Debian::AptPkg::PkgCache.update
11
- end
12
- end
13
-
14
- describe '.gen_caches' do
15
- it 'return boolean' do
16
- if Process.uid == 0
17
- Debian::AptPkg::PkgCache.gen_caches.must_equal true
18
- else
19
- Debian::AptPkg::PkgCache.gen_caches.must_equal false
20
- end
21
- end
22
- end
23
-
24
- describe '.is_multi_arch' do
25
- it 'can be called' do
26
- Debian::AptPkg::PkgCache.is_multi_arch
27
- end
28
- end
29
-
30
- describe '.pkg_names' do
31
- it 'no argument' do
32
- lambda do
33
- Debian::AptPkg::PkgCache.pkg_names
34
- end.must_raise ArgumentError
35
- end
36
- it 'nil argument' do
37
- lambda do
38
- Debian::AptPkg::PkgCache.pkg_names(nil)
39
- end.must_raise ArgumentError
40
- end
41
-
42
- it 'blank argument' do
43
- lambda do
44
- Debian::AptPkg::PkgCache.pkg_names('')
45
- end.must_raise ArgumentError
46
- end
47
-
48
- it 'be filtered' do
49
- search = Debian::AptPkg::PkgCache.pkg_names('vim')
50
- # CI specific cache can not be present
51
- unless search.nil? || search.empty?
52
- search.must_include 'vim'
53
- search.must_include 'vim-nox'
54
- search.must_include 'vim-gtk'
55
- search.wont_include 'emacs'
56
- end
57
- end
58
- end
59
-
60
- %i(package version depends package_file ver_file provides group).each do |m|
61
- describe ".#{m}_count" do
62
- it 'return an int' do
63
- if Process.uid == 0
64
- Debian::AptPkg::PkgCache.public_send("#{m}_count").must_be :>=, 0
65
- end
66
- end
67
- end
68
- end
69
- end