fossyl 0.5.1 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -3
- data/README.md +3 -5
- data/fossyl.gemspec +3 -3
- data/lib/fossyl/parser.rb +4 -4
- data/lib/fossyl.rb +1 -1
- data/spec/fossyl_spec.rb +4 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c9848e6cce91e36c09ea8d32a5a353001c37da61
|
4
|
+
data.tar.gz: 401e7936d48e3846c2ef89e5e08e1e955a094fc4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5ccd47a82e527d62aefa34a45301a1b8fdab06476a3775c7324f45cb0e60b7a8d9d852d215466d4cc3426ffafa85797b82512fd2177012fac82898291522beec
|
7
|
+
data.tar.gz: f7af4d4a373716c0ee5fef8554cbc6405792c63281351db24781bc9f9be4742f28f6421d59f6e1ed832b0d61e492ddd36267b7d85d517a8102572368b08c1255
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -22,13 +22,13 @@ Or install it yourself as:
|
|
22
22
|
require "fossyl"
|
23
23
|
|
24
24
|
# Encoding
|
25
|
-
Fossyl.dump("
|
25
|
+
Fossyl.dump("bytes") # => "5:bytes"
|
26
26
|
Fossyl.dump(12) # => "i12e"
|
27
27
|
Fossyl.dump([1, "two", 3]) # => "li1e3:twoi3ee"
|
28
28
|
Fossyl.dump(a: 1, b: "two", c: [1]) # => "d1:ai1e1:b3:two1:cli1eee"
|
29
29
|
|
30
30
|
# Decoding
|
31
|
-
Fossyl.load("
|
31
|
+
Fossyl.load("5:bytes") # => "bytes"
|
32
32
|
Fossyl.load("i12e") # => 12
|
33
33
|
Fossyl.load("li1e3:twoi3ee") # => [1, "two", 3]
|
34
34
|
Fossyl.load("d1:ai1e1:b3:two1:cli1eee") # => { "a" => 1, "b" => "two", "c" => [1] }
|
@@ -36,9 +36,7 @@ Fossyl.load("d1:ai1e1:b3:two1:cli1eee") # => { "a" => 1, "b" => "two", "c" => [1
|
|
36
36
|
|
37
37
|
## Supported Platforms
|
38
38
|
|
39
|
-
* Ruby
|
40
|
-
* JRuby _(1.9 mode)_
|
41
|
-
* Rubinius _(1.9 mode)_
|
39
|
+
* Ruby 2.0.x
|
42
40
|
|
43
41
|
## Contributing
|
44
42
|
|
data/fossyl.gemspec
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
lib = File.expand_path(
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
4
|
|
5
5
|
Gem::Specification.new do |gem|
|
6
6
|
gem.name = "fossyl"
|
7
|
-
gem.version = "0.
|
7
|
+
gem.version = "0.6.0"
|
8
8
|
gem.authors = ["Adam Tanner"]
|
9
9
|
gem.email = ["adam@adamtanner.org"]
|
10
10
|
gem.description = %q{Pre-historic Bencoding}
|
@@ -13,7 +13,7 @@ Gem::Specification.new do |gem|
|
|
13
13
|
|
14
14
|
gem.files = `git ls-files`.split($/)
|
15
15
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
16
|
-
gem.test_files = gem.files.grep(%r{^
|
16
|
+
gem.test_files = gem.files.grep(%r{^spec/})
|
17
17
|
gem.require_paths = ["lib"]
|
18
18
|
|
19
19
|
gem.add_development_dependency "rake"
|
data/lib/fossyl/parser.rb
CHANGED
@@ -8,7 +8,7 @@ class Fossyl::Parser
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def parse
|
11
|
-
return
|
11
|
+
return parse_bytes if scanner.scan(/\d+/)
|
12
12
|
return parse_integer if scanner.scan(/i/)
|
13
13
|
return parse_list if scanner.scan(/l/)
|
14
14
|
return parse_dictionary if scanner.scan(/d/)
|
@@ -17,10 +17,10 @@ class Fossyl::Parser
|
|
17
17
|
end
|
18
18
|
|
19
19
|
private
|
20
|
-
def
|
20
|
+
def parse_bytes
|
21
21
|
length = scanner.matched.to_i
|
22
|
-
scanner.
|
23
|
-
length.times.map { scanner.
|
22
|
+
scanner.get_byte # Skip the ':'
|
23
|
+
length.times.map { scanner.get_byte }.join
|
24
24
|
end
|
25
25
|
|
26
26
|
def parse_integer
|
data/lib/fossyl.rb
CHANGED
data/spec/fossyl_spec.rb
CHANGED
@@ -3,8 +3,8 @@ require "minitest/autorun"
|
|
3
3
|
require "fossyl"
|
4
4
|
|
5
5
|
describe Fossyl do
|
6
|
-
it "encodes
|
7
|
-
Fossyl.dump("Fossyl").must_equal("
|
6
|
+
it "encodes bytes" do
|
7
|
+
Fossyl.dump("Fossyl\x9B").must_equal("7:Fossyl\x9B")
|
8
8
|
end
|
9
9
|
|
10
10
|
it "encodes integers" do
|
@@ -22,8 +22,8 @@ describe Fossyl do
|
|
22
22
|
Fossyl.dump(string: "Fossyl", integer: -12, list: [0, 12]).must_equal("d7:integeri-12e4:listli0ei12ee6:string6:Fossyle")
|
23
23
|
end
|
24
24
|
|
25
|
-
it "decodes
|
26
|
-
Fossyl.load("
|
25
|
+
it "decodes bytes" do
|
26
|
+
Fossyl.load("7:Fossyl\x9B").must_equal("Fossyl\x9B".b)
|
27
27
|
end
|
28
28
|
|
29
29
|
it "decodes integers" do
|