bcodec 0.1.1 → 0.1.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.
- data/lib/bcodec.rb +2 -2
- data/lib/bcodec/decode.rb +13 -13
- data/lib/bcodec/encode.rb +13 -13
- metadata +4 -3
data/lib/bcodec.rb
CHANGED
@@ -25,7 +25,7 @@
|
|
25
25
|
#==Encoding example:
|
26
26
|
#
|
27
27
|
# require 'rubygems'
|
28
|
-
#
|
28
|
+
# require_gem 'bcodec'
|
29
29
|
#
|
30
30
|
# BCodec.encode("abcd") # returns "4:abcd"
|
31
31
|
# BCodec.encode(1000) # returns "i1000e"
|
@@ -36,7 +36,7 @@
|
|
36
36
|
#==Decoding example:
|
37
37
|
#
|
38
38
|
# require 'rubygems'
|
39
|
-
#
|
39
|
+
# require_gem 'bcodec'
|
40
40
|
#
|
41
41
|
# BCodec.decode(StringIO.new("4:abcd")) # returns "abcd"
|
42
42
|
# BCodec.decode(StringIO.new("i666e")) # returns 666
|
data/lib/bcodec/decode.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
#
|
2
|
-
#
|
1
|
+
# bcodec - Ruby library to decode/encode bencoded data
|
2
|
+
# Copyright (C) 2006 Thomas <[email protected]>
|
3
3
|
#
|
4
|
-
#
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
4
|
+
# This program is free software; you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation; either version 2 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
8
|
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
13
|
#
|
14
|
-
#
|
15
|
-
#
|
16
|
-
#
|
14
|
+
# You should have received a copy of the GNU General Public License along
|
15
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
16
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
17
17
|
|
18
18
|
module BCodec
|
19
19
|
|
data/lib/bcodec/encode.rb
CHANGED
@@ -1,19 +1,19 @@
|
|
1
|
-
#
|
2
|
-
# Copyright (C) 2006 Thomas <
|
1
|
+
# bcodec - Ruby library to decode/encode bencoded data
|
2
|
+
# Copyright (C) 2006 Thomas <tochiroNO@SPAMrubyforge.org>
|
3
3
|
#
|
4
|
-
# This
|
5
|
-
#
|
6
|
-
#
|
7
|
-
#
|
4
|
+
# This program is free software; you can redistribute it and/or modify
|
5
|
+
# it under the terms of the GNU General Public License as published by
|
6
|
+
# the Free Software Foundation; either version 2 of the License, or
|
7
|
+
# (at your option) any later version.
|
8
8
|
#
|
9
|
-
# This
|
9
|
+
# This program is distributed in the hope that it will be useful,
|
10
10
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
11
|
-
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
-
#
|
11
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
12
|
+
# GNU General Public License for more details.
|
13
13
|
#
|
14
|
-
# You should have received a copy of the GNU
|
15
|
-
#
|
16
|
-
#
|
14
|
+
# You should have received a copy of the GNU General Public License along
|
15
|
+
# with this program; if not, write to the Free Software Foundation, Inc.,
|
16
|
+
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
17
17
|
|
18
18
|
module BCodec
|
19
19
|
|
@@ -32,7 +32,7 @@ module BCodec
|
|
32
32
|
str = ""
|
33
33
|
if obj.class == String
|
34
34
|
str << "%d:%s" % [ obj.length, obj ]
|
35
|
-
elsif obj.class == Fixnum or obj.class ==
|
35
|
+
elsif obj.class == Fixnum or obj.class == Bignum
|
36
36
|
str << "i" << obj.to_s << "e"
|
37
37
|
elsif obj.class == Array
|
38
38
|
str << "l"
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.
|
2
|
+
rubygems_version: 0.9.0
|
3
3
|
specification_version: 1
|
4
4
|
name: bcodec
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.1.
|
7
|
-
date: 2006-
|
6
|
+
version: 0.1.2
|
7
|
+
date: 2006-12-15 00:00:00 +01:00
|
8
8
|
summary: Ruby library for encoding and decoding bencoded data used in the BitTorrent protocol
|
9
9
|
require_paths:
|
10
10
|
- lib
|
@@ -25,6 +25,7 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
|
|
25
25
|
platform: ruby
|
26
26
|
signing_key:
|
27
27
|
cert_chain:
|
28
|
+
post_install_message:
|
28
29
|
authors:
|
29
30
|
- thomas
|
30
31
|
files:
|