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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bd479ee089887c3af964c5fc23c5ef4d1bec8072
4
- data.tar.gz: 05cea00a4d7663b1ab9e80114fa8404acd891471
3
+ metadata.gz: 3601d91c1507e3949f9c60b571091b9a959419d0
4
+ data.tar.gz: 39d79df7d50eb719fe6dabb77640a14041135811
5
5
  SHA512:
6
- metadata.gz: 5b2e3165e979b23f2fcf83e1018c3ddc306967a0f5634146a1476ee94e0ba2af9854b1c5778aa09dccd3c0ec369281dd0034374c48493dfe31d32adcfd92403e
7
- data.tar.gz: ca3941286ddadff6b183a027f81690cad2c041d07d4e760f08ffa1cc3eeb1b2b6e018a153c5ec439fca653f37ca2807ddc17aa0715a89842d4a74b96fea94934
6
+ metadata.gz: 3c3a3073708fc654cd4fe651e56baf379ff2a2f49726e5f648b891dfd16c8f18c0ae61500384212bcb8cd8a8ff76ad4c0fbf36eafc3753583340d0dedbe9254f
7
+ data.tar.gz: 4eaf82c1a4ec55cf0b73f37d2ac9dc15e2371235276630f41f1590bf3e2e7cf9bb31078180e84bb08e7efa617abddfbf29a07608a4c4206ebc7dcd046fd85579
data/README.md CHANGED
@@ -1,24 +1,119 @@
1
1
  # Erlang::Terms
2
2
 
3
- TODO: Write a gem description
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
- gem 'erlang-terms'
11
+ ```ruby
12
+ gem 'erlang-terms', require: 'erlang/terms'
13
+ ```
10
14
 
11
15
  And then execute:
12
16
 
13
- $ bundle
17
+ ```bash
18
+ $ bundle
19
+ ```
14
20
 
15
21
  Or install it yourself as:
16
22
 
17
- $ gem install erlang-terms
23
+ ```bash
24
+ $ gem install erlang-terms
25
+ ```
18
26
 
19
27
  ## Usage
20
28
 
21
- TODO: Write usage instructions here
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
@@ -6,8 +6,13 @@ module Erlang
6
6
  tail != []
7
7
  end
8
8
 
9
- def tail
10
- @tail ||= []
9
+ def tail(value = nil)
10
+ if value
11
+ self.tail = value
12
+ self
13
+ else
14
+ @tail ||= []
15
+ end
11
16
  end
12
17
 
13
18
  def inspect
@@ -1,5 +1,5 @@
1
1
  module Erlang
2
2
  module Terms
3
- VERSION = "0.0.1"
3
+ VERSION = "0.0.2"
4
4
  end
5
5
  end
@@ -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].tap { |list| list.tail = :b } }
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: erlang-terms
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Bennett