erlang-terms 0.0.2 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +11 -0
- data/lib/erlang/export.rb +7 -0
- data/lib/erlang/list.rb +19 -1
- data/lib/erlang/nil.rb +15 -0
- data/lib/erlang/pid.rb +8 -0
- data/lib/erlang/terms.rb +1 -0
- data/lib/erlang/terms/version.rb +1 -1
- data/lib/erlang/tuple.rb +13 -1
- data/spec/erlang/export_spec.rb +6 -0
- data/spec/erlang/list_spec.rb +16 -0
- data/spec/erlang/nil_spec.rb +18 -0
- data/spec/erlang/pid_spec.rb +10 -0
- data/spec/erlang/tuple_spec.rb +9 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5eac7619f9acc493a2e29c2034bfbca752e3e3a2
|
4
|
+
data.tar.gz: d0453d251e15a1c97e0fbedd3430c83611ffdc31
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9df6cd4f3ff07549e79ed11840ad7707486bcfc5bd925bbf73fa1dce4b1c70495f64d0a6cfbeaa0735b1f1326c927a329e206785fd3c0c0d918e31692c8d9dd1
|
7
|
+
data.tar.gz: f1f1540c3bc703057833fecbedf0915c8991d674239438b20e35a20b7327a86d6d8e275d5d3ec58a8bd984fe22782a486c5079dd2be02f98eb893437d1717af4
|
data/README.md
CHANGED
data/lib/erlang/export.rb
CHANGED
@@ -12,5 +12,12 @@ module Erlang
|
|
12
12
|
def inspect
|
13
13
|
"#<#{self.class.name} fun #{mod}:#{function}/#{arity}>"
|
14
14
|
end
|
15
|
+
|
16
|
+
def ==(other)
|
17
|
+
self.class === other &&
|
18
|
+
mod.to_s == other.mod.to_s &&
|
19
|
+
function.to_s == other.function.to_s &&
|
20
|
+
arity == other.arity
|
21
|
+
end
|
15
22
|
end
|
16
23
|
end
|
data/lib/erlang/list.rb
CHANGED
@@ -20,7 +20,25 @@ module Erlang
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def pretty_inspect
|
23
|
-
"#<#{self.class.name} #{super[0..-
|
23
|
+
"#<#{self.class.name} #{super[0..-2]}>\n"
|
24
|
+
end
|
25
|
+
|
26
|
+
def pretty_print(q)
|
27
|
+
q.group(1, '[', " | #{tail.inspect}]") {
|
28
|
+
q.seplist(self) { |v|
|
29
|
+
q.pp v
|
30
|
+
}
|
31
|
+
}
|
32
|
+
end
|
33
|
+
|
34
|
+
def ==(other)
|
35
|
+
if improper? and not other.respond_to?(:tail)
|
36
|
+
false
|
37
|
+
elsif other.respond_to?(:tail)
|
38
|
+
super && tail == other.tail
|
39
|
+
else
|
40
|
+
super
|
41
|
+
end
|
24
42
|
end
|
25
43
|
end
|
26
44
|
end
|
data/lib/erlang/nil.rb
ADDED
data/lib/erlang/pid.rb
CHANGED
@@ -19,5 +19,13 @@ module Erlang
|
|
19
19
|
" @node=#{node.inspect}\n" <<
|
20
20
|
" @creation=#{creation.inspect}>"
|
21
21
|
end
|
22
|
+
|
23
|
+
def ==(other)
|
24
|
+
self.class === other &&
|
25
|
+
node.to_s == other.node.to_s &&
|
26
|
+
id.to_s == other.id.to_s &&
|
27
|
+
serial == other.serial &&
|
28
|
+
creation == other.creation
|
29
|
+
end
|
22
30
|
end
|
23
31
|
end
|
data/lib/erlang/terms.rb
CHANGED
data/lib/erlang/terms/version.rb
CHANGED
data/lib/erlang/tuple.rb
CHANGED
@@ -1,11 +1,23 @@
|
|
1
1
|
module Erlang
|
2
2
|
class Tuple < ::Array
|
3
|
+
def arity
|
4
|
+
length
|
5
|
+
end
|
6
|
+
|
3
7
|
def inspect
|
4
8
|
"#<#{self.class.name} {#{super[1..-2]}}>"
|
5
9
|
end
|
6
10
|
|
7
11
|
def pretty_inspect
|
8
|
-
"#<#{self.class.name}
|
12
|
+
"#<#{self.class.name} #{super[0..-2]}>\n"
|
13
|
+
end
|
14
|
+
|
15
|
+
def pretty_print(q)
|
16
|
+
q.group(1, '{', '}') {
|
17
|
+
q.seplist(self) { |v|
|
18
|
+
q.pp v
|
19
|
+
}
|
20
|
+
}
|
9
21
|
end
|
10
22
|
end
|
11
23
|
end
|
data/spec/erlang/export_spec.rb
CHANGED
@@ -7,5 +7,11 @@ describe Erlang::Export do
|
|
7
7
|
it 'formats as #<Erlang::Export fun module:function/arity>' do
|
8
8
|
expect(subject.inspect).to eq("#<Erlang::Export fun module:function/1>")
|
9
9
|
end
|
10
|
+
|
11
|
+
it 'compares with other exports' do
|
12
|
+
expect(subject).to eq(subject)
|
13
|
+
expect(subject).to eq(Erlang::Export.new('module', 'function', 1))
|
14
|
+
expect(subject).to_not eq(Erlang::Export.new('module', 'function', 0))
|
15
|
+
end
|
10
16
|
end
|
11
17
|
end
|
data/spec/erlang/list_spec.rb
CHANGED
@@ -20,4 +20,20 @@ describe Erlang::List do
|
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
23
|
+
|
24
|
+
it 'has | [] in pretty_inspect' do
|
25
|
+
expect(Erlang::List[:a].pretty_inspect).to include("| []")
|
26
|
+
end
|
27
|
+
|
28
|
+
context '#==' do
|
29
|
+
subject { Erlang::List[:a, :b] }
|
30
|
+
|
31
|
+
it 'compares with other lists' do
|
32
|
+
expect(subject).to eq(subject)
|
33
|
+
expect(subject).to eq(Erlang::List[:a, :b])
|
34
|
+
expect(subject).to_not eq(Erlang::List[:a, :b].tail(:c))
|
35
|
+
expect(subject).to eq([:a, :b])
|
36
|
+
expect(Erlang::List[:a].tail(:c)).to_not eq([:a])
|
37
|
+
end
|
38
|
+
end
|
23
39
|
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Erlang::Nil do
|
4
|
+
describe '#inspect' do
|
5
|
+
subject { Erlang::Nil.new }
|
6
|
+
|
7
|
+
it 'formats as #<Erlang::Nil []>' do
|
8
|
+
expect(subject.inspect).to eq("#<Erlang::Nil []>")
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'compares with other nil (and [])' do
|
12
|
+
expect(subject).to eq(subject)
|
13
|
+
expect(subject).to eq(Erlang::Nil.new)
|
14
|
+
expect(subject).to eq([])
|
15
|
+
expect(subject).to_not eq([:a])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/spec/erlang/pid_spec.rb
CHANGED
@@ -7,5 +7,15 @@ describe Erlang::Pid do
|
|
7
7
|
it 'formats as #<Erlang::Pid <0.100.5> @node="nonode@nohost" @creation=1>' do
|
8
8
|
expect(subject.inspect).to eq('#<Erlang::Pid <0.100.5> @node="nonode@nohost" @creation=1>')
|
9
9
|
end
|
10
|
+
|
11
|
+
it 'has <0.100.5> in the pretty_inspect' do
|
12
|
+
expect(subject.pretty_inspect).to include("<0.100.5>")
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'compares with other pids' do
|
16
|
+
expect(subject).to eq(subject)
|
17
|
+
expect(subject).to eq(Erlang::Pid.new(:'nonode@nohost', 100, 5, 1))
|
18
|
+
expect(subject).to_not eq(Erlang::Pid.new('nonode@nohost', 100, 5, 0))
|
19
|
+
end
|
10
20
|
end
|
11
21
|
end
|
data/spec/erlang/tuple_spec.rb
CHANGED
@@ -7,5 +7,14 @@ describe Erlang::Tuple do
|
|
7
7
|
it 'formats as #<Erlang::Tuple {:a, 1, "one"}>' do
|
8
8
|
expect(subject.inspect).to eq('#<Erlang::Tuple {:a, 1, "one"}>')
|
9
9
|
end
|
10
|
+
|
11
|
+
it 'has {} in pretty_inspect' do
|
12
|
+
expect(Erlang::Tuple[].pretty_inspect).to include("{}")
|
13
|
+
expect(Erlang::Tuple[Erlang::Tuple[]].pretty_inspect).to include("{{}}")
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'arity equals length' do
|
17
|
+
expect(subject.arity).to eq(subject.length)
|
18
|
+
end
|
10
19
|
end
|
11
20
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: erlang-terms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Bennett
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-03-
|
11
|
+
date: 2013-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -98,6 +98,7 @@ files:
|
|
98
98
|
- erlang-terms.gemspec
|
99
99
|
- lib/erlang/export.rb
|
100
100
|
- lib/erlang/list.rb
|
101
|
+
- lib/erlang/nil.rb
|
101
102
|
- lib/erlang/pid.rb
|
102
103
|
- lib/erlang/string.rb
|
103
104
|
- lib/erlang/terms.rb
|
@@ -105,6 +106,7 @@ files:
|
|
105
106
|
- lib/erlang/tuple.rb
|
106
107
|
- spec/erlang/export_spec.rb
|
107
108
|
- spec/erlang/list_spec.rb
|
109
|
+
- spec/erlang/nil_spec.rb
|
108
110
|
- spec/erlang/pid_spec.rb
|
109
111
|
- spec/erlang/string_spec.rb
|
110
112
|
- spec/erlang/terms_spec.rb
|
@@ -137,6 +139,7 @@ summary: Erlang terms represented in Ruby
|
|
137
139
|
test_files:
|
138
140
|
- spec/erlang/export_spec.rb
|
139
141
|
- spec/erlang/list_spec.rb
|
142
|
+
- spec/erlang/nil_spec.rb
|
140
143
|
- spec/erlang/pid_spec.rb
|
141
144
|
- spec/erlang/string_spec.rb
|
142
145
|
- spec/erlang/terms_spec.rb
|