apt-pkg 0.2.0 → 0.3.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: dca5749e8aeefa1455545b78ee74c606a0980c3a
4
- data.tar.gz: c55db57c265cc70b03951e4fe1d2512a1df11d8c
3
+ metadata.gz: d4ad2f07af4117ef4391ccac21f05f0aa7b7d5f2
4
+ data.tar.gz: 841edb14b431b6b07c0362b06f6b1f0fa250bf97
5
5
  SHA512:
6
- metadata.gz: 309b619137c40692dda14b015640a608570d47f3bf80ff1b578718f757c8cde0c07f81efbb8f3e3d383457dd462972a1dfbe2a0b76a6f9b9a3771a19c18f6c02
7
- data.tar.gz: c8a6b47d0fb7f87d74e830632c21a782070a600aa6daead1c00b8769b70529f6628f61a6c00e7f31e1714429b6ed75fc2170dbcd3ee8ebf680db08ce6a943961
6
+ metadata.gz: 3c90cc55dd8670bc11f0eb3085c0c9f65bd9aa1424365f1eca496c2cf02a218f3aaf5dd5ea4e5d7399106d4a44e68db6d43d003157e3b7ab61cb815d488103ad
7
+ data.tar.gz: 449d404c254233e5a9c2628b834d15f61e27e0012f7f1d9edb440da5a03591a0fff43e712cbdf82be237abbda26892ba7edd69b79897002faf55c221a5676ad2
data/History.md CHANGED
@@ -1,4 +1,10 @@
1
1
 
2
+ 0.3.0 / 2016-01-23
3
+ ==================
4
+
5
+ * Prefer prefix ++/-- operators for non-primitive types
6
+ * Add Debian::AptPkg::PkgCache.update
7
+
2
8
  0.2.0 / 2016-01-04
3
9
  ==================
4
10
 
data/README.md CHANGED
@@ -14,15 +14,22 @@ gem install apt-pkg
14
14
 
15
15
  ## USING
16
16
 
17
- Simple search is implemented with:
17
+ Basic usage:
18
18
 
19
19
  ``` ruby
20
20
  require 'debian/apt_pkg'
21
+
22
+ # Initialize the configuration and system of apt
21
23
  Debian::AptPkg.init
24
+
25
+ # Update the index files used by the cache
26
+ Debian::AptPkg::PkgCache.update
27
+
28
+ # Search package by names
22
29
  Debian::AptPkg::PkgCache.pkg_names("vim")
23
30
  ```
24
31
 
25
- [Documentation](https://spk.github.io/ruby-apt-pkg/)
32
+ [Documentation](http://www.rubydoc.info/gems/apt-pkg)
26
33
 
27
34
  ## BUILD
28
35
 
@@ -47,5 +54,7 @@ Copyright (c) 2014-2016 Laurent Arnoud <laurent@spkdev.net>
47
54
  ---
48
55
  [![Build](https://img.shields.io/travis-ci/spk/ruby-apt-pkg.svg)](https://travis-ci.org/spk/ruby-apt-pkg)
49
56
  [![Version](https://img.shields.io/gem/v/apt-pkg.svg)](https://rubygems.org/gems/apt-pkg)
57
+ [![Documentation](https://img.shields.io/badge/doc-rubydoc-blue.svg)](http://www.rubydoc.info/gems/apt-pkg)
50
58
  [![License](https://img.shields.io/badge/license-MIT-blue.svg)](http://opensource.org/licenses/MIT "MIT")
51
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)
@@ -194,6 +194,7 @@ check_domain_list(VALUE self, VALUE host, VALUE list)
194
194
  }
195
195
 
196
196
  void
197
+ // cppcheck-suppress unusedFunction
197
198
  Init_apt_pkg()
198
199
  {
199
200
  VALUE rb_mDebian = rb_define_module("Debian");
@@ -14,7 +14,7 @@ architectures(VALUE self)
14
14
  VALUE result = rb_ary_new();
15
15
  std::vector < std::string > arches = APT::Configuration::getArchitectures();
16
16
  std::vector < std::string >::const_iterator I;
17
- for (I = arches.begin(); I != arches.end(); I++) {
17
+ for (I = arches.begin(); I != arches.end(); ++I) {
18
18
  rb_ary_push(result, rb_str_new2((*I).c_str()));
19
19
  }
20
20
  return result;
@@ -57,7 +57,7 @@ languages(int argc, VALUE *argv, VALUE self)
57
57
  std::vector < std::string > const langs =
58
58
  APT::Configuration::getLanguages(all);
59
59
  std::vector < std::string >::const_iterator I;
60
- for (I = langs.begin(); I != langs.end(); I++) {
60
+ for (I = langs.begin(); I != langs.end(); ++I) {
61
61
  rb_ary_push(result, rb_str_new2((*I).c_str()));
62
62
  }
63
63
  return result;
@@ -97,7 +97,7 @@ compressors(VALUE self)
97
97
  VALUE result = rb_ary_new();
98
98
  std::vector < std::string > cmps = APT::Configuration::getCompressionTypes();
99
99
  std::vector < std::string >::const_iterator I;
100
- for (I = cmps.begin(); I != cmps.end(); I++) {
100
+ for (I = cmps.begin(); I != cmps.end(); ++I) {
101
101
  rb_ary_push(result, rb_str_new2((*I).c_str()));
102
102
  }
103
103
  return result;
@@ -33,6 +33,32 @@ gen_caches(VALUE self)
33
33
  return INT2BOOL(res);
34
34
  }
35
35
 
36
+ /*
37
+ * call-seq: update() -> bool
38
+ *
39
+ * Update the index files used by the cache.
40
+ * Return `nil` when config, system, cache is not configured.
41
+ *
42
+ * Debian::AptPkg::PkgCache.update # => false
43
+ *
44
+ **/
45
+ static VALUE
46
+ update(VALUE self)
47
+ {
48
+ if (!config_system_initialized()) {
49
+ return Qnil;
50
+ }
51
+ pkgCacheFile CacheFile;
52
+ // Get the source list
53
+ if (CacheFile.BuildSourceList() == false) {
54
+ return Qnil;
55
+ }
56
+ pkgAcquireStatus *Stat(NULL);
57
+ pkgSourceList *List = CacheFile.GetSourceList();
58
+ int res = ListUpdate(*Stat, *List);
59
+ return INT2BOOL(res);
60
+ }
61
+
36
62
  /*
37
63
  * call-seq: is_multi_arch() -> bool
38
64
  *
@@ -268,6 +294,8 @@ init_apt_pkg_pkgcache()
268
294
 
269
295
  rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "gen_caches",
270
296
  RUBY_METHOD_FUNC(gen_caches), 0);
297
+ rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "update",
298
+ RUBY_METHOD_FUNC(update), 0);
271
299
  rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "is_multi_arch",
272
300
  RUBY_METHOD_FUNC(is_multi_arch), 0);
273
301
  rb_define_singleton_method(rb_mDebianAptPkgConfiguration, "pkg_names",
@@ -3,5 +3,6 @@
3
3
  #include <apt-pkg/cacheiterators.h>
4
4
  #include <apt-pkg/depcache.h>
5
5
  #include <apt-pkg/pkgcache.h>
6
+ #include <apt-pkg/update.h>
6
7
 
7
8
  void init_apt_pkg_pkgcache();
@@ -3,6 +3,6 @@ module Debian
3
3
  # AptPkg base module
4
4
  module AptPkg
5
5
  # Gem version
6
- VERSION = '0.2.0'.freeze
6
+ VERSION = '0.3.0'.freeze
7
7
  end
8
8
  end
@@ -2,6 +2,12 @@ require_relative 'test_helper'
2
2
 
3
3
  describe Debian::AptPkg::PkgCache do
4
4
  describe 'not init' do
5
+ describe '.update' do
6
+ it 'can be called' do
7
+ Debian::AptPkg::PkgCache.update
8
+ end
9
+ end
10
+
5
11
  %i(package version depends package_file ver_file provides group).each do |m|
6
12
  describe ".#{m}_count" do
7
13
  it 'can be called' do
@@ -5,6 +5,12 @@ describe Debian::AptPkg::PkgCache do
5
5
  Debian::AptPkg.init
6
6
  end
7
7
 
8
+ describe '.update' do
9
+ it 'can be called' do
10
+ Debian::AptPkg::PkgCache.update
11
+ end
12
+ end
13
+
8
14
  describe '.gen_caches' do
9
15
  it 'return boolean' do
10
16
  if Process.uid == 0
@@ -55,13 +55,17 @@ describe Debian::AptPkg::Configuration do
55
55
  Debian::AptPkg::Configuration.config_find
56
56
  end.must_raise ArgumentError
57
57
 
58
- Debian::AptPkg::Configuration.config_find('Dir::Etc::main')
58
+ Debian::AptPkg::Configuration
59
+ .config_find('Dir::Etc::main')
59
60
  .must_equal 'apt.conf'
60
- Debian::AptPkg::Configuration.config_find('Dir::Etc::netrc')
61
+ Debian::AptPkg::Configuration
62
+ .config_find('Dir::Etc::netrc')
61
63
  .must_equal 'auth.conf'
62
- Debian::AptPkg::Configuration.config_find('Dir::Etc::parts')
64
+ Debian::AptPkg::Configuration
65
+ .config_find('Dir::Etc::parts')
63
66
  .must_equal 'apt.conf.d'
64
- Debian::AptPkg::Configuration.config_find('Spk', 'DebianUser')
67
+ Debian::AptPkg::Configuration
68
+ .config_find('Spk', 'DebianUser')
65
69
  .must_equal 'DebianUser'
66
70
  end
67
71
 
@@ -70,9 +74,11 @@ describe Debian::AptPkg::Configuration do
70
74
  Debian::AptPkg::Configuration.config_find_file
71
75
  end.must_raise ArgumentError
72
76
 
73
- Debian::AptPkg::Configuration.config_find_file('Dir::Etc::main')
77
+ Debian::AptPkg::Configuration
78
+ .config_find_file('Dir::Etc::main')
74
79
  .must_equal '/etc/apt/apt.conf'
75
- Debian::AptPkg::Configuration.config_find_file('Dir::Etc::netrc')
80
+ Debian::AptPkg::Configuration
81
+ .config_find_file('Dir::Etc::netrc')
76
82
  .must_equal '/etc/apt/auth.conf'
77
83
  end
78
84
  end
data/test/apt_pkg_test.rb CHANGED
@@ -64,11 +64,14 @@ describe Debian::AptPkg do
64
64
 
65
65
  describe 'NotEquals' do
66
66
  it 'should compare Debian version' do
67
- Debian::AptPkg.check_dep('1', Debian::AptPkg::NOT_EQUALS, '2')
67
+ Debian::AptPkg
68
+ .check_dep('1', Debian::AptPkg::NOT_EQUALS, '2')
68
69
  .must_equal true
69
- Debian::AptPkg.check_dep('2', Debian::AptPkg::NOT_EQUALS, '1')
70
+ Debian::AptPkg
71
+ .check_dep('2', Debian::AptPkg::NOT_EQUALS, '1')
70
72
  .must_equal true
71
- Debian::AptPkg.check_dep('1', Debian::AptPkg::NOT_EQUALS, '1')
73
+ Debian::AptPkg
74
+ .check_dep('1', Debian::AptPkg::NOT_EQUALS, '1')
72
75
  .must_equal false
73
76
  end
74
77
  end
@@ -84,7 +87,8 @@ describe Debian::AptPkg do
84
87
 
85
88
  describe '.uri_to_filename' do
86
89
  it 'should return a filename which can be used to store the file' do
87
- Debian::AptPkg.uri_to_filename('http://debian.org/index.html')
90
+ Debian::AptPkg
91
+ .uri_to_filename('http://debian.org/index.html')
88
92
  .must_equal 'debian.org_index.html'
89
93
  end
90
94
  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.2.0
4
+ version: 0.3.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-01-04 00:00:00.000000000 Z
11
+ date: 2016-01-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake