| CARVIEW |
Select Language
HTTP/2 302
server: nginx
date: Mon, 22 Dec 2025 18:19:59 GMT
content-type: text/plain; charset=utf-8
content-length: 0
x-archive-redirect-reason: found capture at 20100603124105
location: https://web.archive.org/web/20100603124105/https://github.com/mojombo/erlectricity/tree/v1.0.0
server-timing: captures_list;dur=0.628894, exclusion.robots;dur=0.059597, exclusion.robots.policy;dur=0.049493, esindex;dur=0.011978, cdx.remote;dur=13.373453, LoadShardBlock;dur=327.514182, PetaboxLoader3.resolve;dur=91.403433, PetaboxLoader3.datanode;dur=85.224255
x-app-server: wwwb-app241-dc8
x-ts: 302
x-tr: 365
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=0
set-cookie: wb-p-SERVER=wwwb-app241; path=/
x-location: All
x-as: 14061
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
HTTP/2 200
server: nginx
date: Mon, 22 Dec 2025 18:19:59 GMT
content-type: text/html; charset=utf-8
x-archive-orig-server: nginx/0.7.61
x-archive-orig-date: Thu, 03 Jun 2010 12:41:05 GMT
x-archive-orig-connection: close
x-archive-orig-status: 200 OK
x-archive-orig-etag: "1b1468f4e331fabf6feada754484352f"
x-archive-orig-x-runtime: 92ms
x-archive-orig-content-length: 29332
x-archive-orig-cache-control: private, max-age=0, must-revalidate
x-archive-guessed-content-type: text/html
x-archive-guessed-charset: utf-8
memento-datetime: Thu, 03 Jun 2010 12:41:05 GMT
link: ; rel="original", ; rel="timemap"; type="application/link-format", ; rel="timegate"
content-security-policy: default-src 'self' 'unsafe-eval' 'unsafe-inline' data: blob: archive.org web.archive.org web-static.archive.org wayback-api.archive.org athena.archive.org analytics.archive.org pragma.archivelab.org wwwb-events.archive.org
x-archive-src: 52_16_20100603082528_crawl102-c/52_16_20100603124049_crawl101.arc.gz
server-timing: captures_list;dur=0.620733, exclusion.robots;dur=0.028602, exclusion.robots.policy;dur=0.016127, esindex;dur=0.014547, cdx.remote;dur=23.435226, LoadShardBlock;dur=302.386211, PetaboxLoader3.datanode;dur=264.404360, PetaboxLoader3.resolve;dur=180.226099, load_resource;dur=154.412953
x-app-server: wwwb-app241-dc8
x-ts: 200
x-tr: 573
server-timing: TR;dur=0,Tw;dur=0,Tc;dur=1
x-location: All
x-as: 14061
x-rl: 0
x-na: 0
x-page-cache: MISS
server-timing: MISS
x-nid: DigitalOcean
referrer-policy: no-referrer-when-downgrade
permissions-policy: interest-cohort=()
content-encoding: gzip
mojombo's erlectricity at v1.0.0 - GitHub
mojombo / erlectricity
- Source
- Commits
- Network (12)
- Issues (0)
- Downloads (6)
- Wiki (1)
- Graphs
-
Tag:
v1.0.0
click here to add a description
click here to add a homepage
| name | age | message | |
|---|---|---|---|
| |
.gitignore | Sun Apr 26 10:55:51 -0700 2009 | ensure that echo example works and add readme [mojombo] |
| |
History.txt | Mon Apr 27 23:18:34 -0700 2009 | Erlectricity::Decoder.read_any_from -> Erlectri... [mojombo] |
| |
LICENSE | Sun Apr 26 10:49:12 -0700 2009 | add license [mojombo] |
| |
README.md | Wed Apr 29 15:12:00 -0700 2009 | better production/steady terminology [mojombo] |
| |
Rakefile | Mon Apr 27 23:18:34 -0700 2009 | Erlectricity::Decoder.read_any_from -> Erlectri... [mojombo] |
| |
VERSION.yml | Loading commit data... |
|
| |
benchmarks/ | Mon Apr 27 23:18:34 -0700 2009 | Erlectricity::Decoder.read_any_from -> Erlectri... [mojombo] |
| |
erlectricity.gemspec | ||
| |
examples/ | Mon Apr 27 22:41:33 -0700 2009 | support boolean encoding and matching [mojombo] |
| |
ext/ | Mon Apr 27 23:26:09 -0700 2009 | fix whitespace in decoder.c [mojombo] |
| |
lib/ | Mon Apr 27 23:18:34 -0700 2009 | Erlectricity::Decoder.read_any_from -> Erlectri... [mojombo] |
| |
test/ | Mon Apr 27 23:18:34 -0700 2009 | Erlectricity::Decoder.read_any_from -> Erlectri... [mojombo] |
README.md
Erlectricity
https://github.com/mojombo/erlectricity
By Scott Fleckenstein, Tom Preston-Werner
Development Status: Production/Stable
Description
Erlectricity allows a Ruby program to receive and respond to Erlang messages sent over the Erlang binary protocol.
Install
$ gem install erlectricity
-or-
$ gem install mojombo-erlectricity -s https://gems.github.com
The Simplest Example
Ruby side (echo.rb)
require 'rubygems'
require 'erlectricity'
receive do |f|
f.when([:echo, String]) do |text|
f.send!([:result, "You said: #{text}"])
f.receive_loop
end
end
Erlang side (echo.erl)
-module(echo).
-export([test/0]).
test() ->
Cmd = "ruby echo.rb",
Port = open_port({spawn, Cmd}, [{packet, 4}, nouse_stdio, exit_status, binary]),
Payload = term_to_binary({echo, <<"hello world!">>}),
port_command(Port, Payload),
receive
{Port, {data, Data}} ->
{result, Text} = binary_to_term(Data),
io:format("~p~n", [Text])
end.
Data Type Conversions and Matching
% Port is the port opened via open_port({spawn, Cmd}, [{packet, 4}, ...])
% Message is the Erlang term to encode and send to the port
send(Port, Message) ->
port_command(Port, term_to_binary(Message)).
# Each triplet below represents:
# (line 1) the Erlang call
# (line 2) the Ruby matcher
# (line 3) the Ruby output
send(Port, test).
f.when(:test) { p :ok }
# :ok
send(Port, {atom, symbol}).
f.when([:atom, Symbol]) { |sym| p sym }
# :symbol
send(Port, {number, 1}).
f.when([:number, Fixnum]) { |num| p num }
# 1
send(Port, {string, <<"foo">>}).
f.when([:string, String]) { |str| p str }
# "foo"
send(Port, {array, [1,2,3]}).
f.when([:array, Array]) { |arr| p arr }
# [1, 2, 3]
send(Port, {array, [<<"abc">>, <<"def">>]}).
f.when([:array, Array]) { |arr| p arr }
# ["abc", "def"]
send(Port, {hash, [{key,val}]}).
f.when([:hash, Erl.hash]) { |hash| p hash }
# {:key=>:val}
send(Port, {object, {1,{2},3,<<"four">>}}).
f.when([:object, Any]) { |any| p any }
# [1, [2], 3, "four"]
Contribute
If you'd like to hack on Erlectricity, start by forking my repo on GitHub:
https://github.com/mojombo/erlectricity
To get all of the dependencies, install the gem first. The best way to get your changes merged back into core is as follows:
- Clone down your fork
- Create a topic branch to contain your change
- Hack away
- Add tests and make sure everything still passes by running
rake - If you are adding new functionality, document it in the README.md
- Do not change the version number, I will do that on my end
- If necessary, rebase your commits into logical chunks, without errors
- Push the branch up to GitHub
- Send me (mojombo) a pull request for your branch
Copyright
Copyright (c) 2009 Scott Fleckenstein and Tom Preston-Werner. See LICENSE for details.

