apt-pkg 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +19 -2
- data/apt-pkg.gemspec +3 -5
- data/ext/apt_pkg/apt-pkg.cpp +23 -7
- data/test/apt_pkg_test.rb +20 -15
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 87712bb513a4494dcf32cccd94507c3f06384fd1
|
4
|
+
data.tar.gz: 1abb0ebc3f50bdac8f80a4857e8e59e9195a5fd4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 381f94c894465eb5cb7046095d9e652ae64b098920a7f7156f91c8463fe1a491ff794671e2cc7947e32d6d92945dcb9326edec4ce8d3b6826488e32bf3ae64d4
|
7
|
+
data.tar.gz: fc8c34e7891e54259fac2770ceb43a737ae3d24f7171807da8e10504b782f3a084b59f8bbfe85e3f97e08894ad76e26c79512cdeb6f9f3a36bc4d5245690887c
|
data/README.md
CHANGED
@@ -4,13 +4,30 @@
|
|
4
4
|
|
5
5
|
~~~ console
|
6
6
|
aptitude install libapt-pkg-dev ruby2.0-dev
|
7
|
-
gem install
|
8
|
-
|
7
|
+
gem install apt-pkg
|
8
|
+
~~~
|
9
|
+
|
10
|
+
## USING
|
11
|
+
|
12
|
+
~~~ ruby
|
13
|
+
require 'apt_pkg'
|
14
|
+
|
15
|
+
Debian::AptPkg.check_dep('1', '<', '2') # => true
|
16
|
+
Debian::AptPkg.check_dep('1', Debian::AptPkg::NOT_EQUALS, '2') # => true
|
17
|
+
Debian::AptPkg.check_domain_list("alioth.debian.org", "debian.net,debian.org") # => true
|
18
|
+
Debian::AptPkg.cmp_version('1.1', '1.0') # => 1
|
19
|
+
Debian::AptPkg.size_to_str(10000) # => '10.0 k'
|
20
|
+
Debian::AptPkg.string_to_bool('yes') # => 1
|
21
|
+
Debian::AptPkg.time_to_str(3601) # => '1h 0min 1s'
|
22
|
+
Debian::AptPkg.upstream_version('3.4.15-1+b1') # => '3.4.15'
|
23
|
+
Debian::AptPkg.uri_to_filename('http://debian.org/index.html') # => 'debian.org_index.html'
|
9
24
|
~~~
|
10
25
|
|
11
26
|
## BUILD
|
12
27
|
|
13
28
|
~~~ console
|
29
|
+
gem install bundler
|
30
|
+
bundle install
|
14
31
|
bundle exec rake compile
|
15
32
|
~~~
|
16
33
|
|
data/apt-pkg.gemspec
CHANGED
@@ -1,16 +1,14 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = "apt-pkg"
|
3
|
-
s.version = '0.0.
|
3
|
+
s.version = '0.0.2'
|
4
4
|
|
5
5
|
s.authors = ["Laurent Arnoud"]
|
6
6
|
s.description = %q{Ruby interface to apt-pkg}
|
7
|
-
s.summary =
|
7
|
+
s.summary = %q{Ruby interface to libapt-pkg}
|
8
8
|
s.email = %q{laurent@spkdev.net}
|
9
9
|
s.license = "MIT"
|
10
10
|
s.extensions = ["ext/apt_pkg/extconf.rb"]
|
11
|
-
s.extra_rdoc_files = [
|
12
|
-
"README.md"
|
13
|
-
]
|
11
|
+
s.extra_rdoc_files = Dir['*.md', 'ext/**/*.cpp']
|
14
12
|
s.files = `git ls-files`.split($\)
|
15
13
|
s.homepage = %q{http://github.com/spk/ruby-apt-pkg}
|
16
14
|
s.rdoc_options = ["--charset=UTF-8"]
|
data/ext/apt_pkg/apt-pkg.cpp
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#include <ruby.h>
|
2
|
+
#include <apt-pkg/deblistparser.h>
|
2
3
|
#include <apt-pkg/debversion.h>
|
3
4
|
#include <apt-pkg/pkgcache.h>
|
4
5
|
#include <apt-pkg/strutl.h>
|
@@ -12,14 +13,15 @@ using namespace std;
|
|
12
13
|
/* function prototypes */
|
13
14
|
extern "C" void Init_apt_pkg();
|
14
15
|
/* String functions */
|
15
|
-
static VALUE cmp_version(VALUE self, VALUE pkg_version_a, VALUE pkg_version_b);
|
16
|
-
static VALUE check_dep(VALUE self, VALUE pkg_version_a, VALUE op, VALUE pkg_version_b);
|
17
16
|
static VALUE uri_to_filename(VALUE self, VALUE uri);
|
18
|
-
static VALUE upstream_version(VALUE self, VALUE ver);
|
19
17
|
static VALUE time_to_str(VALUE self, VALUE secondes);
|
20
18
|
static VALUE size_to_str(VALUE self, VALUE size);
|
21
19
|
static VALUE string_to_bool(VALUE self, VALUE text);
|
22
20
|
static VALUE check_domain_list(VALUE self, VALUE host, VALUE list);
|
21
|
+
/* Versioning */
|
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);
|
24
|
+
static VALUE upstream_version(VALUE self, VALUE ver);
|
23
25
|
|
24
26
|
/*
|
25
27
|
* call-seq: cmp_version(pkg_version_a, pkg_version_b) -> int
|
@@ -48,15 +50,29 @@ VALUE cmp_version(VALUE self, VALUE pkg_version_a, VALUE pkg_version_b) {
|
|
48
50
|
* Params:
|
49
51
|
*
|
50
52
|
* +pkg_version_a+:: Version to compare from.
|
51
|
-
* +op+:: See operators const
|
53
|
+
* +op+:: See operators const or string (<, >, <=, >=, =)
|
52
54
|
* +pkg_version_b+:: Version to compare to.
|
53
55
|
*
|
54
|
-
* Debian::AptPkg.check_dep('1',
|
56
|
+
* Debian::AptPkg.check_dep('1', '<', '2') # => true
|
57
|
+
* Debian::AptPkg.check_dep('1', Debian::AptPkg::NOT_EQUALS, '2') # => true
|
55
58
|
*
|
56
59
|
**/
|
57
60
|
static
|
58
|
-
VALUE check_dep(VALUE self, VALUE pkg_version_a, VALUE
|
59
|
-
int
|
61
|
+
VALUE check_dep(VALUE self, VALUE pkg_version_a, VALUE cmp_type, VALUE pkg_version_b) {
|
62
|
+
unsigned int op = 0;
|
63
|
+
if (TYPE(cmp_type) == T_FIXNUM) {
|
64
|
+
op = NUM2INT(cmp_type);
|
65
|
+
} else {
|
66
|
+
const char *op_str = StringValuePtr(cmp_type);
|
67
|
+
if (strcmp(op_str, ">") == 0) op_str = ">>";
|
68
|
+
if (strcmp(op_str, "<") == 0) op_str = "<<";
|
69
|
+
if (*debListParser::ConvertRelation(op_str, op) != 0)
|
70
|
+
{
|
71
|
+
rb_raise(rb_eArgError, "Bad comparison operation");
|
72
|
+
return 0;
|
73
|
+
}
|
74
|
+
}
|
75
|
+
int res = debVS.CheckDep(StringValuePtr(pkg_version_a), op, StringValuePtr(pkg_version_b));
|
60
76
|
return INT2BOOL(res);
|
61
77
|
}
|
62
78
|
|
data/test/apt_pkg_test.rb
CHANGED
@@ -14,37 +14,37 @@ describe Debian::AptPkg do
|
|
14
14
|
describe 'Debian::AptPkg.check_dep' do
|
15
15
|
describe 'LessEq' do
|
16
16
|
it 'should compare Debian version' do
|
17
|
-
Debian::AptPkg.check_dep('1',
|
18
|
-
Debian::AptPkg.check_dep('2',
|
19
|
-
Debian::AptPkg.check_dep('1',
|
17
|
+
Debian::AptPkg.check_dep('1', '<=', '2').must_equal true
|
18
|
+
Debian::AptPkg.check_dep('2', '<=', '1').must_equal false
|
19
|
+
Debian::AptPkg.check_dep('1', '<=', '1').must_equal true
|
20
20
|
end
|
21
21
|
end
|
22
22
|
describe 'GreaterEq' do
|
23
23
|
it 'should compare Debian version' do
|
24
|
-
Debian::AptPkg.check_dep('1',
|
25
|
-
Debian::AptPkg.check_dep('2',
|
26
|
-
Debian::AptPkg.check_dep('1',
|
24
|
+
Debian::AptPkg.check_dep('1', '>=', '2').must_equal false
|
25
|
+
Debian::AptPkg.check_dep('2', '>=', '1').must_equal true
|
26
|
+
Debian::AptPkg.check_dep('1', '>=', '1').must_equal true
|
27
27
|
end
|
28
28
|
end
|
29
29
|
describe 'Less' do
|
30
30
|
it 'should compare Debian version' do
|
31
|
-
Debian::AptPkg.check_dep('1',
|
32
|
-
Debian::AptPkg.check_dep('2',
|
33
|
-
Debian::AptPkg.check_dep('1',
|
31
|
+
Debian::AptPkg.check_dep('1', '<', '2').must_equal true
|
32
|
+
Debian::AptPkg.check_dep('2', '<', '1').must_equal false
|
33
|
+
Debian::AptPkg.check_dep('1', '<', '1').must_equal false
|
34
34
|
end
|
35
35
|
end
|
36
36
|
describe 'Greater' do
|
37
37
|
it 'should compare Debian version' do
|
38
|
-
Debian::AptPkg.check_dep('1',
|
39
|
-
Debian::AptPkg.check_dep('2',
|
40
|
-
Debian::AptPkg.check_dep('1',
|
38
|
+
Debian::AptPkg.check_dep('1', '>', '2').must_equal false
|
39
|
+
Debian::AptPkg.check_dep('2', '>', '1').must_equal true
|
40
|
+
Debian::AptPkg.check_dep('1', '>', '1').must_equal false
|
41
41
|
end
|
42
42
|
end
|
43
43
|
describe 'Equals' do
|
44
44
|
it 'should compare Debian version' do
|
45
|
-
Debian::AptPkg.check_dep('1',
|
46
|
-
Debian::AptPkg.check_dep('2',
|
47
|
-
Debian::AptPkg.check_dep('1',
|
45
|
+
Debian::AptPkg.check_dep('1', '=', '2').must_equal false
|
46
|
+
Debian::AptPkg.check_dep('2', '=', '1').must_equal false
|
47
|
+
Debian::AptPkg.check_dep('1', '=', '1').must_equal true
|
48
48
|
end
|
49
49
|
end
|
50
50
|
describe 'NotEquals' do
|
@@ -54,6 +54,11 @@ describe Debian::AptPkg do
|
|
54
54
|
Debian::AptPkg.check_dep('1', Debian::AptPkg::NOT_EQUALS, '1').must_equal false
|
55
55
|
end
|
56
56
|
end
|
57
|
+
describe 'Errors' do
|
58
|
+
it 'should raise argument error with bad comparison' do
|
59
|
+
lambda { Debian::AptPkg.check_dep('1', 'bad', '2') }.must_raise ArgumentError
|
60
|
+
end
|
61
|
+
end
|
57
62
|
end
|
58
63
|
|
59
64
|
describe 'Debian::AptPkg.uri_to_filename' do
|
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.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Laurent Arnoud
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-01-
|
11
|
+
date: 2014-01-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -73,6 +73,7 @@ extensions:
|
|
73
73
|
- ext/apt_pkg/extconf.rb
|
74
74
|
extra_rdoc_files:
|
75
75
|
- README.md
|
76
|
+
- ext/apt_pkg/apt-pkg.cpp
|
76
77
|
files:
|
77
78
|
- .gitignore
|
78
79
|
- Gemfile
|
@@ -108,5 +109,5 @@ rubyforge_project:
|
|
108
109
|
rubygems_version: 2.0.14
|
109
110
|
signing_key:
|
110
111
|
specification_version: 4
|
111
|
-
summary: Ruby interface to
|
112
|
+
summary: Ruby interface to libapt-pkg
|
112
113
|
test_files: []
|