erlang-terms 1.0.0 → 1.1.0

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: 5eac7619f9acc493a2e29c2034bfbca752e3e3a2
4
- data.tar.gz: d0453d251e15a1c97e0fbedd3430c83611ffdc31
3
+ metadata.gz: 8ad4212bcd8edbea5fe3b917196d48759c4ad6bc
4
+ data.tar.gz: be6f85104ebcbce57e7cfb20434ab1290ae77ce2
5
5
  SHA512:
6
- metadata.gz: 9df6cd4f3ff07549e79ed11840ad7707486bcfc5bd925bbf73fa1dce4b1c70495f64d0a6cfbeaa0735b1f1326c927a329e206785fd3c0c0d918e31692c8d9dd1
7
- data.tar.gz: f1f1540c3bc703057833fecbedf0915c8991d674239438b20e35a20b7327a86d6d8e275d5d3ec58a8bd984fe22782a486c5079dd2be02f98eb893437d1717af4
6
+ metadata.gz: 1367b7b5d0bd9d47b65540248f7189ba292d234dc1e6844729f7194e171e97589f45522444c0812e44033c1502b2a4aa3288ab97370e86cf31bb1b6a8c9b429d
7
+ data.tar.gz: 0e7cf956bd8531328fed8ce033fe4bb688700b17eb520d44f326b0659e80b58fb5ac62204dff8445595097d0aea26c66c4d2b7eea9de12dbbbf3c2414b30fcbc
@@ -2,3 +2,4 @@ language: ruby
2
2
  rvm:
3
3
  - 1.9.3
4
4
  - 2.0.0
5
+ - 2.1.1
data/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![Build Status](https://travis-ci.org/potatosalad/erlang-terms.png)](https://travis-ci.org/potatosalad/erlang-terms)
4
4
 
5
- Includes simple classes that represent Erlang's export, list, pid, string, and tuple.
5
+ Includes simple classes that represent Erlang's export, list, pid, string, tuple, and map.
6
6
 
7
7
  ## Installation
8
8
 
@@ -72,6 +72,17 @@ list.improper?
72
72
  # => false
73
73
  ```
74
74
 
75
+ ### Erlang::Map
76
+
77
+ ```erlang
78
+ Map = #{atom => 1}.
79
+ ```
80
+
81
+ ```ruby
82
+ map = Erlang::Map[:atom, 1]
83
+ # => #<Erlang::Map #{:atom => 1}>
84
+ ```
85
+
75
86
  ### Erlang::Nil
76
87
 
77
88
  ```erlang
@@ -0,0 +1,31 @@
1
+ module Erlang
2
+ class Map < ::Hash
3
+ def inspect
4
+ "#<#{self.class.name} \##{super}>"
5
+ end
6
+
7
+ def pretty_inspect
8
+ "#<#{self.class.name} #{super[0..-2]}>\n"
9
+ end
10
+
11
+ def pretty_print(q)
12
+ q.group(1, '#{', '}') {
13
+ q.seplist(self, nil, :each_pair) { |k, v|
14
+ q.group {
15
+ q.pp k
16
+ q.text ' => '
17
+ q.group(1) {
18
+ q.breakable ''
19
+ q.pp v
20
+ }
21
+ }
22
+ }
23
+ }
24
+ end
25
+
26
+ alias_method :original_to_s, :to_s
27
+ def to_s
28
+ "\##{original_to_s}"
29
+ end
30
+ end
31
+ end
@@ -7,6 +7,7 @@ end
7
7
 
8
8
  require "erlang/export"
9
9
  require "erlang/list"
10
+ require "erlang/map"
10
11
  require "erlang/nil"
11
12
  require "erlang/pid"
12
13
  require "erlang/string"
@@ -1,5 +1,5 @@
1
1
  module Erlang
2
2
  module Terms
3
- VERSION = "1.0.0"
3
+ VERSION = "1.1.0"
4
4
  end
5
5
  end
@@ -0,0 +1,24 @@
1
+ require 'spec_helper'
2
+
3
+ describe Erlang::Map do
4
+ describe '#inspect' do
5
+ subject { Erlang::Map[:a, 1, "one", 1.0] }
6
+
7
+ it 'formats as #<Erlang::Map #{:a=>1, "one"=>1.0}>' do
8
+ expect(subject.inspect).to eq('#<Erlang::Map #{:a=>1, "one"=>1.0}>')
9
+ end
10
+
11
+ it 'has #{} in pretty_inspect' do
12
+ expect(Erlang::Map[].pretty_inspect).to include('#{}')
13
+ expect(Erlang::Map[Erlang::Map[], 1].pretty_inspect).to include('#{#{} => 1}')
14
+ end
15
+ end
16
+
17
+ describe '#to_s' do
18
+ subject { Erlang::Map[:a, 1, "one", 1.0] }
19
+
20
+ it 'formats as #{:a=>1, "one"=>1.0}' do
21
+ expect(subject.to_s).to eq('#{:a=>1, "one"=>1.0}')
22
+ end
23
+ end
24
+ 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: 1.0.0
4
+ version: 1.1.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-19 00:00:00.000000000 Z
11
+ date: 2014-03-06 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/map.rb
101
102
  - lib/erlang/nil.rb
102
103
  - lib/erlang/pid.rb
103
104
  - lib/erlang/string.rb
@@ -106,6 +107,7 @@ files:
106
107
  - lib/erlang/tuple.rb
107
108
  - spec/erlang/export_spec.rb
108
109
  - spec/erlang/list_spec.rb
110
+ - spec/erlang/map_spec.rb
109
111
  - spec/erlang/nil_spec.rb
110
112
  - spec/erlang/pid_spec.rb
111
113
  - spec/erlang/string_spec.rb
@@ -132,13 +134,14 @@ required_rubygems_version: !ruby/object:Gem::Requirement
132
134
  version: '0'
133
135
  requirements: []
134
136
  rubyforge_project:
135
- rubygems_version: 2.0.2
137
+ rubygems_version: 2.2.1
136
138
  signing_key:
137
139
  specification_version: 4
138
140
  summary: Erlang terms represented in Ruby
139
141
  test_files:
140
142
  - spec/erlang/export_spec.rb
141
143
  - spec/erlang/list_spec.rb
144
+ - spec/erlang/map_spec.rb
142
145
  - spec/erlang/nil_spec.rb
143
146
  - spec/erlang/pid_spec.rb
144
147
  - spec/erlang/string_spec.rb