Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Erlectricity::Decoder.read_any_from -> Erlectricity::Decoder.decode

  • Loading branch information...
commit d6afa69a30b3932fdb526ace15afec5273731f2f 1 parent ac81089
@mojombo authored
View
1  History.txt
@@ -8,6 +8,7 @@
instead of STDIN and STDOUT. This prevents inadvertent output
statements from silently corrupting the transfer protocol.
* Erlang atoms 'true' and 'false' are now converted into Ruby booleans
+ * Erlectricity::Decoder.read_any_from -> Erlectricity::Decoder.decode
* Major Enhancements
* Calling `rake` now runs tests (with and without compiled C extensions)
* Package management is now done by Jeweler
View
4 Rakefile
@@ -25,8 +25,8 @@ task :test do
require 'fileutils'
puts "\nCleaning extension build files and running all specs in native ruby mode..."
- FileUtils.rm_f("ext/*.bundle")
- FileUtils.rm_f("ext/*.o")
+ `rm -f ext/*.bundle` && puts("rm -f ext/*.bundle")
+ `rm -f ext/*.o` && puts("rm -f ext/*.o")
Open3.popen3("ruby test/spec_suite.rb") do |stdin, stdout, stderr|
while !stdout.eof?
print stdout.read(1)
View
2  benchmarks/bench.rb
@@ -10,7 +10,7 @@
Benchmark.bm do|b|
b.report("Decoder") do
- 100_000.times { Erl::Decoder.read_any_from(bert) }
+ 100_000.times { Erl::Decoder.decode(bert) }
end
end
View
6 ext/decoder.c
@@ -25,7 +25,7 @@ static VALUE mErlectricity;
static VALUE cDecoder;
void Init_decoder();
-VALUE method_read_any_from(VALUE klass, VALUE rString);
+VALUE method_decode(VALUE klass, VALUE rString);
VALUE read_any_raw(unsigned char **pData);
@@ -383,7 +383,7 @@ VALUE read_any_raw(unsigned char **pData) {
return Qnil;
}
-VALUE method_read_any_from(VALUE klass, VALUE rString) {
+VALUE method_decode(VALUE klass, VALUE rString) {
unsigned char *data = (unsigned char *) StringValuePtr(rString);
unsigned char **pData = &data;
@@ -399,5 +399,5 @@ VALUE method_read_any_from(VALUE klass, VALUE rString) {
void Init_decoder() {
mErlectricity = rb_const_get(rb_cObject, rb_intern("Erlectricity"));
cDecoder = rb_define_class_under(mErlectricity, "Decoder", rb_cObject);
- rb_define_singleton_method(cDecoder, "read_any_from", method_read_any_from, 1);
+ rb_define_singleton_method(cDecoder, "decode", method_decode, 1);
}
View
2  lib/erlectricity/decoder.rb
@@ -3,7 +3,7 @@ class Decoder
attr_accessor :in
include Erlectricity::External::Types
- def self.read_any_from(string)
+ def self.decode(string)
new(StringIO.new(string)).read_any
end
View
2  lib/erlectricity/port.rb
@@ -40,7 +40,7 @@ def read_from_input
packet_length = raw.unpack('N').first
data = input.read(packet_length)
- Erlectricity::Decoder.read_any_from(data)
+ Erlectricity::Decoder.decode(data)
end
end
end
View
2  test/decode_spec.rb
@@ -123,6 +123,6 @@
def get(str)
x = "term_to_binary(#{str.gsub(/"/, '\\\"')})"
bin = run_erl(x)
- Erlectricity::Decoder.read_any_from(bin)
+ Erlectricity::Decoder.decode(bin)
end
end
View
4 test/encode_spec.rb
@@ -67,7 +67,7 @@
specify "An Erlectiricity::NewReference should encode back to its original form" do
ref_bin = run_erl("term_to_binary(make_ref())")
- ruby_ref = Erlectricity::Decoder.read_any_from(ref_bin)
+ ruby_ref = Erlectricity::Decoder.decode(ref_bin)
get{@encoder.write_new_reference(ruby_ref)}.should == ref_bin[1..-1]
write_any(ruby_ref).should == ref_bin
@@ -75,7 +75,7 @@
specify "An Erlectiricity::Pid should encode back to its original form" do
pid_bin = run_erl("term_to_binary(spawn(fun() -> 3 end))")
- ruby_pid = Erlectricity::Decoder.read_any_from(pid_bin)
+ ruby_pid = Erlectricity::Decoder.decode(pid_bin)
get{@encoder.write_pid(ruby_pid)}.should == pid_bin[1..-1]
write_any(ruby_pid).should == pid_bin
Please sign in to comment.
Something went wrong with that request. Please try again.