simonmenke-bencoding 0.0.3 → 0.0.4

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/History.txt CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.0.4 3008-09-14
2
+
3
+ * 1 minor enhancement:
4
+ * Don't dump empty dictionaries or lists
5
+
1
6
  == 0.0.3 3008-09-13
2
7
 
3
8
  * 5 major enhancement:
@@ -3,6 +3,7 @@ module Bencoding
3
3
  module Array
4
4
 
5
5
  def to_bencoding
6
+ return '' if empty?
6
7
  "l"+collect{|item|item.to_bencoding}.join+"e"
7
8
  end
8
9
 
@@ -3,7 +3,15 @@ module Bencoding
3
3
  module Hash
4
4
 
5
5
  def to_bencoding
6
- "d"+sort{|a,b|a[0].to_s<=>b[0].to_s}.collect{|key, item|key.to_bencoding+item.to_bencoding}.join+"e"
6
+ return '' if empty?
7
+ data = sort{|a,b|a[0].to_s<=>b[0].to_s}.collect do|key, item|
8
+ unless (item_data = item.to_bencoding).nil?
9
+ key.to_bencoding+item.to_bencoding
10
+ else
11
+ ''
12
+ end
13
+ end.join
14
+ "d"+data+"e"
7
15
  end
8
16
 
9
17
  end
@@ -2,7 +2,7 @@ module Bencoding
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- TINY = 3
5
+ TINY = 4
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simonmenke-bencoding
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Menke