mojombo-erlectricity 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/History.txt +6 -0
- data/VERSION.yml +1 -1
- data/benchmarks/bench.rb +21 -0
- data/erlectricity.gemspec +103 -0
- data/ext/decoder.c +2 -2
- data/lib/erlectricity/decoder.rb +2 -0
- data/test/decode_spec.rb +8 -0
- metadata +5 -2
data/.gitignore
ADDED
data/History.txt
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
== 1.0.2 / 2009-06-03
|
2
|
+
* Bug Fixes
|
3
|
+
* Fix decoding of atoms [github.com/bwbuchanan]
|
4
|
+
* Work around Ruby's reluctance to convert the empty string to
|
5
|
+
a symbol [github.com/bwbuchanan]
|
6
|
+
|
1
7
|
== 1.0.1 / 2009-05-03
|
2
8
|
* Bug Fixes
|
3
9
|
* Fix premature null byte termination on binary decode
|
data/VERSION.yml
CHANGED
data/benchmarks/bench.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
$:.unshift(File.dirname(__FILE__) + '/../lib')
|
2
|
+
|
3
|
+
require 'erlectricity'
|
4
|
+
require 'benchmark'
|
5
|
+
|
6
|
+
data = [:ok, [:foo, :bar, [99, "bottles", "of", "beer", 3.14], [true, false]]]
|
7
|
+
bert = Erlectricity::Encoder.encode(data)
|
8
|
+
|
9
|
+
p bert
|
10
|
+
|
11
|
+
Benchmark.bm do|b|
|
12
|
+
b.report("Decoder") do
|
13
|
+
100_000.times { Erl::Decoder.decode(bert) }
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
# user system total real
|
18
|
+
# C Decoder 0.400000 0.000000 0.400000 ( 0.425373)
|
19
|
+
# Ruby Decoder 30.250000 0.220000 30.470000 ( 32.140890)
|
20
|
+
#
|
21
|
+
# C decoder is 75.56x faster than Ruby decoder on this data
|
@@ -0,0 +1,103 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
|
3
|
+
Gem::Specification.new do |s|
|
4
|
+
s.name = %q{erlectricity}
|
5
|
+
s.version = "1.0.2"
|
6
|
+
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
|
+
s.authors = ["Scott Fleckenstein", "Tom Preston-Werner"]
|
9
|
+
s.date = %q{2009-06-03}
|
10
|
+
s.email = %q{tom@mojombo.com}
|
11
|
+
s.extensions = ["ext/extconf.rb"]
|
12
|
+
s.extra_rdoc_files = [
|
13
|
+
"LICENSE",
|
14
|
+
"README.md"
|
15
|
+
]
|
16
|
+
s.files = [
|
17
|
+
".gitignore",
|
18
|
+
"History.txt",
|
19
|
+
"LICENSE",
|
20
|
+
"README.md",
|
21
|
+
"Rakefile",
|
22
|
+
"VERSION.yml",
|
23
|
+
"benchmarks/bench.rb",
|
24
|
+
"erlectricity.gemspec",
|
25
|
+
"examples/echo/README.md",
|
26
|
+
"examples/echo/echo.erl",
|
27
|
+
"examples/echo/echo.rb",
|
28
|
+
"examples/gruff/gruff.erl",
|
29
|
+
"examples/gruff/gruff_provider.rb",
|
30
|
+
"examples/gruff/gruff_run.sh",
|
31
|
+
"examples/gruff/stat_run.sh",
|
32
|
+
"examples/gruff/stat_writer.erl",
|
33
|
+
"examples/simple/README.md",
|
34
|
+
"examples/simple/rerl.rb",
|
35
|
+
"examples/simple/rerl.sh",
|
36
|
+
"examples/tinderl/README.md",
|
37
|
+
"examples/tinderl/tinderl.erl",
|
38
|
+
"examples/tinderl/tinderl.rb",
|
39
|
+
"ext/decoder.c",
|
40
|
+
"ext/extconf.rb",
|
41
|
+
"lib/erlectricity.rb",
|
42
|
+
"lib/erlectricity/condition.rb",
|
43
|
+
"lib/erlectricity/conditions/boolean.rb",
|
44
|
+
"lib/erlectricity/conditions/hash.rb",
|
45
|
+
"lib/erlectricity/conditions/static.rb",
|
46
|
+
"lib/erlectricity/conditions/type.rb",
|
47
|
+
"lib/erlectricity/constants.rb",
|
48
|
+
"lib/erlectricity/decoder.rb",
|
49
|
+
"lib/erlectricity/encoder.rb",
|
50
|
+
"lib/erlectricity/errors/decode_error.rb",
|
51
|
+
"lib/erlectricity/errors/encode_error.rb",
|
52
|
+
"lib/erlectricity/errors/erlectricity_error.rb",
|
53
|
+
"lib/erlectricity/matcher.rb",
|
54
|
+
"lib/erlectricity/port.rb",
|
55
|
+
"lib/erlectricity/receiver.rb",
|
56
|
+
"lib/erlectricity/types/function.rb",
|
57
|
+
"lib/erlectricity/types/list.rb",
|
58
|
+
"lib/erlectricity/types/new_function.rb",
|
59
|
+
"lib/erlectricity/types/new_reference.rb",
|
60
|
+
"lib/erlectricity/types/pid.rb",
|
61
|
+
"lib/erlectricity/types/reference.rb",
|
62
|
+
"lib/erlectricity/version.rb",
|
63
|
+
"test/condition_spec.rb",
|
64
|
+
"test/decode_spec.rb",
|
65
|
+
"test/encode_spec.rb",
|
66
|
+
"test/matcher_spec.rb",
|
67
|
+
"test/port_spec.rb",
|
68
|
+
"test/receiver_spec.rb",
|
69
|
+
"test/spec_suite.rb",
|
70
|
+
"test/test_helper.rb"
|
71
|
+
]
|
72
|
+
s.has_rdoc = true
|
73
|
+
s.homepage = %q{http://github.com/mojombo/erlectricity}
|
74
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
75
|
+
s.require_paths = ["lib", "ext"]
|
76
|
+
s.rubyforge_project = %q{erlectricity}
|
77
|
+
s.rubygems_version = %q{1.3.0}
|
78
|
+
s.summary = %q{A library to interface erlang and ruby through the erlang port system}
|
79
|
+
s.test_files = [
|
80
|
+
"test/condition_spec.rb",
|
81
|
+
"test/decode_spec.rb",
|
82
|
+
"test/encode_spec.rb",
|
83
|
+
"test/matcher_spec.rb",
|
84
|
+
"test/port_spec.rb",
|
85
|
+
"test/receiver_spec.rb",
|
86
|
+
"test/spec_suite.rb",
|
87
|
+
"test/test_helper.rb",
|
88
|
+
"examples/echo/echo.rb",
|
89
|
+
"examples/gruff/gruff_provider.rb",
|
90
|
+
"examples/simple/rerl.rb",
|
91
|
+
"examples/tinderl/tinderl.rb"
|
92
|
+
]
|
93
|
+
|
94
|
+
if s.respond_to? :specification_version then
|
95
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
96
|
+
s.specification_version = 2
|
97
|
+
|
98
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
99
|
+
else
|
100
|
+
end
|
101
|
+
else
|
102
|
+
end
|
103
|
+
end
|
data/ext/decoder.c
CHANGED
@@ -180,9 +180,9 @@ VALUE read_atom(unsigned char **pData) {
|
|
180
180
|
read_string_raw(buf, pData, length);
|
181
181
|
|
182
182
|
// Erlang true and false are actually atoms
|
183
|
-
if(strncmp((char *) buf, "true", length) == 0) {
|
183
|
+
if(length == 4 && strncmp((char *) buf, "true", length) == 0) {
|
184
184
|
return Qtrue;
|
185
|
-
} else if(strncmp((char *) buf, "false", length) == 0) {
|
185
|
+
} else if(length == 5 && strncmp((char *) buf, "false", length) == 0) {
|
186
186
|
return Qfalse;
|
187
187
|
} else {
|
188
188
|
return ID2SYM(rb_intern((char *) buf));
|
data/lib/erlectricity/decoder.rb
CHANGED
data/test/decode_spec.rb
CHANGED
@@ -110,10 +110,18 @@ context "When unpacking from a binary stream" do
|
|
110
110
|
get("<< 99,0,99 >>").should == "c\000c"
|
111
111
|
end
|
112
112
|
|
113
|
+
specify "the empty atom should decode to the empty symbol" do
|
114
|
+
empty_symbol = get("''")
|
115
|
+
empty_symbol.should.be.instance_of Symbol
|
116
|
+
empty_symbol.to_s.should == ""
|
117
|
+
end
|
118
|
+
|
113
119
|
specify "erlang atomic booleans should decode to ruby booleans" do
|
114
120
|
get("true").should == true
|
115
121
|
get("false").should == false
|
116
122
|
get("falsereio").should == :falsereio
|
123
|
+
get("t").should == :t
|
124
|
+
get("f").should == :f
|
117
125
|
end
|
118
126
|
|
119
127
|
specify "a good thing should be awesome" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mojombo-erlectricity
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Fleckenstein
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2009-
|
13
|
+
date: 2009-06-03 00:00:00 -07:00
|
14
14
|
default_executable:
|
15
15
|
dependencies: []
|
16
16
|
|
@@ -24,11 +24,14 @@ extra_rdoc_files:
|
|
24
24
|
- LICENSE
|
25
25
|
- README.md
|
26
26
|
files:
|
27
|
+
- .gitignore
|
27
28
|
- History.txt
|
28
29
|
- LICENSE
|
29
30
|
- README.md
|
30
31
|
- Rakefile
|
31
32
|
- VERSION.yml
|
33
|
+
- benchmarks/bench.rb
|
34
|
+
- erlectricity.gemspec
|
32
35
|
- examples/echo/README.md
|
33
36
|
- examples/echo/echo.erl
|
34
37
|
- examples/echo/echo.rb
|