bencode_ext 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +1 -0
- data/Rakefile +11 -20
- data/bencode_ext.gemspec +3 -14
- data/ext/bencode_ext/bencode.c +17 -8
- metadata +26 -73
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9f32eeeba8927735a02485ab9e5aa48c5e0a21bb
|
4
|
+
data.tar.gz: e0b222847806e5910fb5f2ddccab8e7a94b5bd3e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3fcc9d6aa80abaffd6faa25b2b6d1c933b003772356bb67c277ec2d81a2ce0b591268d232f1efa6674dd3f0b510b60a3bb9c65cb7bdb602947dc8df962a97df7
|
7
|
+
data.tar.gz: e937334c85dbf723d3f7feed8793d5469bb987b73a6795c0e22fd844aa2c0c020409e6e48bb296b80d9133966d0969e904865c5c49ff692c64e9414c3ec18a36
|
data/.document
CHANGED
data/Rakefile
CHANGED
@@ -1,22 +1,17 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rake'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
gem.required_ruby_version = '~>1.9.2'
|
15
|
-
gem.add_development_dependency 'rake-compiler', '~>0.7.5'
|
16
|
-
gem.add_development_dependency 'jeweler', '~> 1.5.2'
|
4
|
+
NAME = 'bencode_ext'
|
5
|
+
|
6
|
+
desc 'Build gem'
|
7
|
+
task :build do
|
8
|
+
Dir.chdir("ext/bencode_ext") do
|
9
|
+
ruby 'extconf.rb'
|
10
|
+
sh 'make'
|
11
|
+
end
|
12
|
+
|
13
|
+
cp 'ext/bencode_ext/bencode_ext.so', 'lib/bencode_ext.so'
|
17
14
|
end
|
18
|
-
Jeweler::RubygemsDotOrgTasks.new
|
19
|
-
Jeweler::GemcutterTasks.new
|
20
15
|
|
21
16
|
require 'rake/testtask'
|
22
17
|
Rake::TestTask.new(:test) do |test|
|
@@ -27,7 +22,7 @@ end
|
|
27
22
|
|
28
23
|
task :default => :test
|
29
24
|
|
30
|
-
require '
|
25
|
+
require 'rdoc/task'
|
31
26
|
Rake::RDocTask.new do |rdoc|
|
32
27
|
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
33
28
|
|
@@ -36,7 +31,3 @@ Rake::RDocTask.new do |rdoc|
|
|
36
31
|
rdoc.rdoc_files.include('README*')
|
37
32
|
rdoc.rdoc_files.include('ext/**/*.c')
|
38
33
|
end
|
39
|
-
|
40
|
-
|
41
|
-
require 'rake/extensiontask'
|
42
|
-
Rake::ExtensionTask.new('bencode_ext')
|
data/bencode_ext.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{bencode_ext}
|
8
|
-
s.version = "0.2.
|
8
|
+
s.version = "0.2.7"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["naquad"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2013-05-11}
|
13
13
|
s.description = %q{BEncodeExt is implementation of Bencode reader/writer (BitTorent encoding) in C.}
|
14
14
|
s.email = %q{naquad@gmail.com}
|
15
15
|
s.extensions = ["ext/bencode_ext/extconf.rb"]
|
@@ -33,7 +33,7 @@ Gem::Specification.new do |s|
|
|
33
33
|
s.homepage = %q{http://github.com/naquad/bencode_ext}
|
34
34
|
s.licenses = ["MIT"]
|
35
35
|
s.require_paths = ["lib"]
|
36
|
-
s.required_ruby_version = Gem::Requirement.new("
|
36
|
+
s.required_ruby_version = Gem::Requirement.new("> 1.9.1")
|
37
37
|
s.rubygems_version = %q{1.3.7}
|
38
38
|
s.summary = %q{BitTorrent encoding parser/writer}
|
39
39
|
s.test_files = [
|
@@ -44,17 +44,6 @@ Gem::Specification.new do |s|
|
|
44
44
|
if s.respond_to? :specification_version then
|
45
45
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
46
46
|
s.specification_version = 3
|
47
|
-
|
48
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
49
|
-
s.add_development_dependency(%q<rake-compiler>, ["~> 0.7.5"])
|
50
|
-
s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
|
51
|
-
else
|
52
|
-
s.add_dependency(%q<rake-compiler>, ["~> 0.7.5"])
|
53
|
-
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
54
|
-
end
|
55
|
-
else
|
56
|
-
s.add_dependency(%q<rake-compiler>, ["~> 0.7.5"])
|
57
|
-
s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
|
58
47
|
end
|
59
48
|
end
|
60
49
|
|
data/ext/bencode_ext/bencode.c
CHANGED
@@ -26,6 +26,9 @@
|
|
26
26
|
static long parse_num(char** str, long* len){
|
27
27
|
long t = 1, ret = 0;
|
28
28
|
|
29
|
+
if(!*len)
|
30
|
+
return 0;
|
31
|
+
|
29
32
|
if(**str == '-'){
|
30
33
|
t = -1;
|
31
34
|
++*str;
|
@@ -110,7 +113,6 @@ static VALUE decode(VALUE self, VALUE encoded){
|
|
110
113
|
|
111
114
|
if(len && *str != ':')
|
112
115
|
rb_raise(DecodeError, "Invalid string length specification at %d: %c", rlen - len, *str);
|
113
|
-
|
114
116
|
if(!len || len < slen + 1)
|
115
117
|
rb_raise(DecodeError, "Unexpected string end!");
|
116
118
|
|
@@ -221,19 +223,25 @@ static VALUE decode_file(VALUE self, VALUE path){
|
|
221
223
|
*/
|
222
224
|
|
223
225
|
static VALUE encode(VALUE self){
|
224
|
-
if(TYPE(self) == T_SYMBOL)
|
226
|
+
if(TYPE(self) == T_SYMBOL)
|
225
227
|
return encode(rb_id2str(SYM2ID(self)));
|
226
|
-
|
228
|
+
|
229
|
+
if(rb_obj_is_kind_of(self, rb_cString)){
|
227
230
|
long len = RSTRING_LEN(self);
|
228
231
|
return rb_sprintf("%ld:%.*s", len, len, RSTRING_PTR(self));
|
229
|
-
}
|
232
|
+
}
|
233
|
+
|
234
|
+
if(rb_obj_is_kind_of(self, rb_cInteger))
|
230
235
|
return rb_sprintf("i%lde", NUM2LONG(self));
|
231
|
-
|
236
|
+
|
237
|
+
if(rb_obj_is_kind_of(self, rb_cHash)){
|
232
238
|
VALUE ret = rb_str_new2("d");
|
233
239
|
rb_hash_foreach(self, hash_traverse, ret);
|
234
240
|
rb_str_cat2(ret, "e");
|
235
241
|
return ret;
|
236
|
-
}
|
242
|
+
}
|
243
|
+
|
244
|
+
if(rb_obj_is_kind_of(self, rb_cArray)){
|
237
245
|
long i, c;
|
238
246
|
VALUE *ptr, ret = rb_str_new2("l");
|
239
247
|
|
@@ -242,8 +250,9 @@ static VALUE encode(VALUE self){
|
|
242
250
|
|
243
251
|
rb_str_cat2(ret, "e");
|
244
252
|
return ret;
|
245
|
-
}
|
246
|
-
|
253
|
+
}
|
254
|
+
|
255
|
+
rb_raise(EncodeError, "Don't know how to encode %s!", rb_class2name(CLASS_OF(self)));
|
247
256
|
}
|
248
257
|
|
249
258
|
static int hash_traverse(VALUE key, VALUE val, VALUE str){
|
metadata
CHANGED
@@ -1,62 +1,25 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: bencode_ext
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
segments:
|
6
|
-
- 0
|
7
|
-
- 2
|
8
|
-
- 6
|
9
|
-
version: 0.2.6
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.7
|
10
5
|
platform: ruby
|
11
|
-
authors:
|
6
|
+
authors:
|
12
7
|
- naquad
|
13
8
|
autorequire:
|
14
9
|
bindir: bin
|
15
10
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
21
|
-
name: rake-compiler
|
22
|
-
prerelease: false
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
-
none: false
|
25
|
-
requirements:
|
26
|
-
- - ~>
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 0
|
30
|
-
- 7
|
31
|
-
- 5
|
32
|
-
version: 0.7.5
|
33
|
-
type: :development
|
34
|
-
version_requirements: *id001
|
35
|
-
- !ruby/object:Gem::Dependency
|
36
|
-
name: jeweler
|
37
|
-
prerelease: false
|
38
|
-
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
-
none: false
|
40
|
-
requirements:
|
41
|
-
- - ~>
|
42
|
-
- !ruby/object:Gem::Version
|
43
|
-
segments:
|
44
|
-
- 1
|
45
|
-
- 5
|
46
|
-
- 2
|
47
|
-
version: 1.5.2
|
48
|
-
type: :development
|
49
|
-
version_requirements: *id002
|
50
|
-
description: BEncodeExt is implementation of Bencode reader/writer (BitTorent encoding) in C.
|
11
|
+
date: 2013-05-11 00:00:00.000000000 Z
|
12
|
+
dependencies: []
|
13
|
+
description: BEncodeExt is implementation of Bencode reader/writer (BitTorent encoding)
|
14
|
+
in C.
|
51
15
|
email: naquad@gmail.com
|
52
16
|
executables: []
|
53
|
-
|
54
|
-
extensions:
|
17
|
+
extensions:
|
55
18
|
- ext/bencode_ext/extconf.rb
|
56
|
-
extra_rdoc_files:
|
19
|
+
extra_rdoc_files:
|
57
20
|
- LICENSE.txt
|
58
21
|
- README.rdoc
|
59
|
-
files:
|
22
|
+
files:
|
60
23
|
- .document
|
61
24
|
- LICENSE.txt
|
62
25
|
- README.rdoc
|
@@ -68,40 +31,30 @@ files:
|
|
68
31
|
- ext/bencode_ext/extconf.rb
|
69
32
|
- test/helper.rb
|
70
33
|
- test/test_bencode_ext.rb
|
71
|
-
has_rdoc: true
|
72
34
|
homepage: http://github.com/naquad/bencode_ext
|
73
|
-
licenses:
|
35
|
+
licenses:
|
74
36
|
- MIT
|
37
|
+
metadata: {}
|
75
38
|
post_install_message:
|
76
39
|
rdoc_options: []
|
77
|
-
|
78
|
-
require_paths:
|
40
|
+
require_paths:
|
79
41
|
- lib
|
80
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
version:
|
90
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
-
none: false
|
92
|
-
requirements:
|
93
|
-
- - ">="
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
segments:
|
96
|
-
- 0
|
97
|
-
version: "0"
|
42
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - '>'
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 1.9.1
|
47
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - '>='
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: '0'
|
98
52
|
requirements: []
|
99
|
-
|
100
53
|
rubyforge_project:
|
101
|
-
rubygems_version:
|
54
|
+
rubygems_version: 2.0.0
|
102
55
|
signing_key:
|
103
56
|
specification_version: 3
|
104
57
|
summary: BitTorrent encoding parser/writer
|
105
|
-
test_files:
|
58
|
+
test_files:
|
106
59
|
- test/helper.rb
|
107
60
|
- test/test_bencode_ext.rb
|