erlang-terms 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +100 -5
- data/lib/erlang/list.rb +7 -2
- data/lib/erlang/terms/version.rb +1 -1
- data/spec/erlang/list_spec.rb +1 -1
- 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: 3601d91c1507e3949f9c60b571091b9a959419d0
|
4
|
+
data.tar.gz: 39d79df7d50eb719fe6dabb77640a14041135811
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c3a3073708fc654cd4fe651e56baf379ff2a2f49726e5f648b891dfd16c8f18c0ae61500384212bcb8cd8a8ff76ad4c0fbf36eafc3753583340d0dedbe9254f
|
7
|
+
data.tar.gz: 4eaf82c1a4ec55cf0b73f37d2ac9dc15e2371235276630f41f1590bf3e2e7cf9bb31078180e84bb08e7efa617abddfbf29a07608a4c4206ebc7dcd046fd85579
|
data/README.md
CHANGED
@@ -1,24 +1,119 @@
|
|
1
1
|
# Erlang::Terms
|
2
2
|
|
3
|
-
|
3
|
+
[![Build Status](https://travis-ci.org/potatosalad/erlang-terms.png)](https://travis-ci.org/potatosalad/erlang-terms)
|
4
|
+
|
5
|
+
Includes simple classes that represent Erlang's export, list, pid, string, and tuple.
|
4
6
|
|
5
7
|
## Installation
|
6
8
|
|
7
9
|
Add this line to your application's Gemfile:
|
8
10
|
|
9
|
-
|
11
|
+
```ruby
|
12
|
+
gem 'erlang-terms', require: 'erlang/terms'
|
13
|
+
```
|
10
14
|
|
11
15
|
And then execute:
|
12
16
|
|
13
|
-
|
17
|
+
```bash
|
18
|
+
$ bundle
|
19
|
+
```
|
14
20
|
|
15
21
|
Or install it yourself as:
|
16
22
|
|
17
|
-
|
23
|
+
```bash
|
24
|
+
$ gem install erlang-terms
|
25
|
+
```
|
18
26
|
|
19
27
|
## Usage
|
20
28
|
|
21
|
-
|
29
|
+
The following classes show the [Erlang](http://www.erlang.org/) representation followed by the corresponding [Ruby](http://www.ruby-lang.org/) representation.
|
30
|
+
|
31
|
+
See [erlang-etf](https://github.com/potatosalad/erlang-etf) for more information.
|
32
|
+
|
33
|
+
### Erlang::Export
|
34
|
+
|
35
|
+
```erlang
|
36
|
+
Module = erlang,
|
37
|
+
Function = now,
|
38
|
+
Arity = 0,
|
39
|
+
Export = fun Module:Function/Arity.
|
40
|
+
```
|
41
|
+
|
42
|
+
```ruby
|
43
|
+
export = Erlang::Export.new(:erlang, :now, 0)
|
44
|
+
# => #<Erlang::Export fun erlang:now/0>
|
45
|
+
```
|
46
|
+
|
47
|
+
### Erlang::List
|
48
|
+
|
49
|
+
##### Improper List
|
50
|
+
|
51
|
+
```erlang
|
52
|
+
List = [a | b].
|
53
|
+
```
|
54
|
+
|
55
|
+
```ruby
|
56
|
+
list = Erlang::List[:a].tail(:b)
|
57
|
+
# => #<Erlang::List [:a | :b]">
|
58
|
+
list.improper?
|
59
|
+
# => true
|
60
|
+
```
|
61
|
+
|
62
|
+
##### Proper List
|
63
|
+
|
64
|
+
```erlang
|
65
|
+
List = [a, b].
|
66
|
+
```
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
list = Erlang::List[:a, :b]
|
70
|
+
# => #<Erlang::List [:a, :b | []]">
|
71
|
+
list.improper?
|
72
|
+
# => false
|
73
|
+
```
|
74
|
+
|
75
|
+
### Erlang::Pid
|
76
|
+
|
77
|
+
```erlang
|
78
|
+
Pid = self().
|
79
|
+
|
80
|
+
%% or
|
81
|
+
|
82
|
+
Id = 100,
|
83
|
+
Serial = 5,
|
84
|
+
Pid = pid(0, Id, Serial).
|
85
|
+
|
86
|
+
%% or
|
87
|
+
|
88
|
+
Pid = list_to_pid("<0.100.5>").
|
89
|
+
```
|
90
|
+
|
91
|
+
```ruby
|
92
|
+
pid = Erlang::Pid.new('node@host', 100, 5, 0)
|
93
|
+
# => #<Erlang::Pid <0.100.5> @node="node@host" @creation=0>
|
94
|
+
```
|
95
|
+
|
96
|
+
### Erlang::String
|
97
|
+
|
98
|
+
```erlang
|
99
|
+
String = "test".
|
100
|
+
```
|
101
|
+
|
102
|
+
```ruby
|
103
|
+
string = Erlang::String.new("test")
|
104
|
+
# => #<Erlang::String "test">
|
105
|
+
```
|
106
|
+
|
107
|
+
### Erlang::Tuple
|
108
|
+
|
109
|
+
```erlang
|
110
|
+
Tuple = {atom, 1}.
|
111
|
+
```
|
112
|
+
|
113
|
+
```ruby
|
114
|
+
tuple = Erlang::Tuple[:atom, 1]
|
115
|
+
# => #<Erlang::Tuple {:atom, 1}>
|
116
|
+
```
|
22
117
|
|
23
118
|
## Contributing
|
24
119
|
|
data/lib/erlang/list.rb
CHANGED
data/lib/erlang/terms/version.rb
CHANGED
data/spec/erlang/list_spec.rb
CHANGED
@@ -3,7 +3,7 @@ require 'spec_helper'
|
|
3
3
|
describe Erlang::List do
|
4
4
|
describe '#inspect' do
|
5
5
|
context 'improper list' do
|
6
|
-
subject { Erlang::List[:a].
|
6
|
+
subject { Erlang::List[:a].tail(:b) }
|
7
7
|
|
8
8
|
it { should be_improper }
|
9
9
|
it 'formats as #<Erlang::List [:a | :b]>' do
|