bencode 0.8.2 → 1.0.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: f269f41c659cd6d66f99d1419d2cace7c3f94240
4
- data.tar.gz: a98fbc376d916ea080721402f259e1b29c0694d6
2
+ SHA256:
3
+ metadata.gz: 3df918cce71dce118a46f227cc80ba6b72e99b37b6ac3765786a2ce3946320d5
4
+ data.tar.gz: ec14358f50516721c80a71ea31d28a66c1fa576eb683b09e79239d60fa4d9c00
5
5
  SHA512:
6
- metadata.gz: 1925b1abf12e284554b698dcf3985c9c56f22f42342ae8f7e6252edb71d8b8cdbd40fb1ee77891fea00a91e9a29a36e515264a9c1e4025b0640db1bf618bc65f
7
- data.tar.gz: 315c23efa0a7d0dd63995327277250f6e0d8f1371538b1fd80e8398727a49d7509a3b167a093f4b6255972be2b29220236caf15535335dfa5ccceb5dd757b609
6
+ metadata.gz: 90e126ffca4d28f53c874260c596c91c13fd6d51195e6d1fc9027dbdcdb49e9917899152307a78aff72d45caf611551d77ba2c7fe505878e5e49f7ffaf475e28
7
+ data.tar.gz: b975f17c141d32da9eedce9788badd6b5155ccfc875e2ddc7a541fb22a77ded9df59906684a38d2cea76aac4fd1ecd53ff84e3392d569b80cfaf90bc78ed292f
data/README.md CHANGED
@@ -59,3 +59,4 @@ Contributors
59
59
  - Allen Madsen ([blatyo](https://github.com/blatyo))
60
60
  - Ian Levesque ([ianlevesque](https://github.com/ianlevesque))
61
61
  - Dirk Geurs ([Dirklectisch](https://github.com/Dirklectisch))
62
+ - Xinyue Lu ([msg7086](https://github.com/msg7086))
data/bencode.gemspec CHANGED
@@ -7,8 +7,8 @@ Gem::Specification.new do |s|
7
7
  ## If your rubyforge_project name is different, then edit it and comment out
8
8
  ## the sub! line in the Rakefile
9
9
  s.name = 'bencode'
10
- s.version = '0.8.2'
11
- s.date = '2014-09-04'
10
+ s.version = '1.0.0'
11
+ s.date = '2024-08-12'
12
12
 
13
13
  s.summary = "Encode and decode bencoded data"
14
14
  s.description = "A simple encoder and decoder for the BitTorrent serialization format."
@@ -2,7 +2,7 @@ require 'stringio'
2
2
 
3
3
  module BEncode
4
4
  class Parser
5
- attr_reader :stream
5
+ attr_reader :stream, :encoding
6
6
 
7
7
  def initialize(stream)
8
8
  @stream =
@@ -13,6 +13,7 @@ module BEncode
13
13
  elsif stream.respond_to? :to_s
14
14
  StringIO.new stream.to_s
15
15
  end
16
+ @encoding = @stream.external_encoding || Encoding::default_external
16
17
  end
17
18
 
18
19
  def parse!
@@ -50,7 +51,7 @@ module BEncode
50
51
  until peek == ?e
51
52
  key = parse!
52
53
 
53
- unless key.is_a? String or key.is_a? Fixnum
54
+ unless key.is_a? String or key.is_a? Integer
54
55
  raise BEncode::DecodeError, "key must be a string or number"
55
56
  end
56
57
 
@@ -69,7 +70,7 @@ module BEncode
69
70
  begin
70
71
  length = num.chop.to_i
71
72
  return "" if length == 0 # Workaround for Rubinius bug
72
- str = stream.read(length)
73
+ str = stream.read(length).force_encoding(encoding)
73
74
  rescue
74
75
  raise BEncode::DecodeError, "invalid string length"
75
76
  end
data/lib/bencode.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  #
4
4
  # See {BEncode.load} and {BEncode.dump}.
5
5
  module BEncode
6
- VERSION = "0.8.2"
6
+ VERSION = "1.0.0"
7
7
 
8
8
  class DecodeError < StandardError
9
9
  end
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  require 'environment'
2
3
 
3
4
  describe "decoding" do
@@ -14,4 +15,7 @@ describe "decoding" do
14
15
  it_should_decode hsh, "d3:foo3:bar3:baz3:quxe"
15
16
 
16
17
  it_should_decode 42, "i42eBOGUS", :ignore_trailing_junk => true
18
+
19
+ it_should_decode "café", "5:café"
20
+ it_should_decode ["你好", "中文"], "l6:你好6:中文e"
17
21
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bencode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Schierbeck
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-09-04 00:00:00.000000000 Z
11
+ date: 2024-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rdoc
@@ -103,7 +103,7 @@ homepage: http://github.com/dasch/ruby-bencode
103
103
  licenses:
104
104
  - MIT
105
105
  metadata: {}
106
- post_install_message:
106
+ post_install_message:
107
107
  rdoc_options:
108
108
  - "--charset=UTF-8"
109
109
  require_paths:
@@ -119,10 +119,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
119
119
  - !ruby/object:Gem::Version
120
120
  version: '0'
121
121
  requirements: []
122
- rubyforge_project:
123
- rubygems_version: 2.2.2
124
- signing_key:
122
+ rubygems_version: 3.4.10
123
+ signing_key:
125
124
  specification_version: 2
126
125
  summary: Encode and decode bencoded data
127
126
  test_files: []
128
- has_rdoc: