erle 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,3 @@
1
+ module ERLE
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,33 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe ERLE::Atom do
4
+
5
+ it 'enclosed' do
6
+ input = "'foo'"
7
+ output = "foo"
8
+
9
+ obj = ERLE.parse(input)
10
+ expect(obj.to_ruby).to eq(output)
11
+ end
12
+
13
+ it 'outclosed' do
14
+ input = "foo"
15
+ output = :foo
16
+
17
+ obj = ERLE.parse(input)
18
+ expect(obj.to_ruby).to eq(output)
19
+ end
20
+
21
+ it 'close syntax error' do
22
+ input = "'foo"
23
+
24
+ expect{ERLE.parse(input)}.to raise_error(ERLE::ParserError)
25
+ end
26
+
27
+ it 'content syntax error' do
28
+ input = "{@}"
29
+
30
+ expect{ERLE.parse(input)}.to raise_error(ERLE::ParserError)
31
+ end
32
+
33
+ end
@@ -0,0 +1,19 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe ERLE::Binary do
4
+
5
+ it 'enclosed' do
6
+ input = "<<a,b>>"
7
+ output = [:a, :b]
8
+
9
+ obj = ERLE.parse(input)
10
+ expect(obj.to_ruby).to eq(output)
11
+ end
12
+
13
+ it 'syntax error' do
14
+ input = "<<A,B"
15
+
16
+ expect{ERLE.parse(input)}.to raise_error(ERLE::ParserError)
17
+ end
18
+
19
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe ERLE::Enum do
4
+
5
+
6
+ it 'ends with atom' do
7
+ input = "{'bar', a, 'fiz',foop}"
8
+ output = {"bar"=>[:a, "fiz", :foop]}
9
+
10
+ obj = ERLE.parse(input)
11
+ expect(obj.to_ruby).to eq(output)
12
+ end
13
+
14
+ it 'syntax error' do
15
+ input = "[1,2,3"
16
+
17
+ expect{ERLE.parse(input)}.to raise_error(ERLE::ParserError)
18
+ end
19
+
20
+ end
@@ -0,0 +1,21 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe ERLE::Number do
4
+
5
+ it 'floats' do
6
+ input = "1.232"
7
+ output = 1.232
8
+
9
+ obj = ERLE.parse(input)
10
+ expect(obj.to_ruby).to eq(output)
11
+ end
12
+
13
+ it 'sinks lol kidding, integers' do
14
+ input = "10"
15
+ output = 10
16
+
17
+ obj = ERLE.parse(input)
18
+ expect(obj.to_ruby).to eq(output)
19
+ end
20
+
21
+ end
@@ -0,0 +1,135 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe ERLE::Term do
4
+
5
+ it 'outer node is array' do
6
+ input = "[{a,[{a_foo,'ABCDE',\"ABCDE\",<<\"ABCDE\">>},{a_bar,1,2,3}]},{b,[{b_foo,1,2,3},{b_bar,1,2,3}]}]"
7
+ output = [{:a=>[{:a_foo=>["ABCDE", "ABCDE", "ABCDE"]}, {:a_bar=>[1, 2, 3]}]}, {:b=>[{:b_foo=>[1, 2, 3]}, {:b_bar=>[1, 2, 3]}]}]
8
+ obj = ERLE.parse(input)
9
+ expect(obj.to_ruby).to eq(output)
10
+ end
11
+
12
+ it 'outer node is object' do
13
+ input = " {a,[{a_foo,'ABCDE',\"ABCDE\",<<\"ABCDE\">>}]} "
14
+ output = {:a=>[{:a_foo=>["ABCDE", "ABCDE", "ABCDE"]}]}
15
+ expect(ERLE.to_ruby(input)).to eq(output)
16
+ end
17
+
18
+ it 'outer node is rep' do
19
+ input = "<<12,13,14,15,16,17,18,\"abcdefg\">>"
20
+ output = [12, 13, 14, 15, 16, 17, 18, "abcdefg"]
21
+ expect(ERLE.to_ruby(input)).to eq(output)
22
+ end
23
+
24
+
25
+ it 'contains wtf' do
26
+ input = "{true,<<\"o_e-13885-2\">>,expiry, {63487411200,63519123599,[{offer,9434},{offer_url,none}]}}"
27
+ output = { true =>["o_e-13885-2", :expiry, {63487411200=>[63519123599, [{:offer=>9434}, {:offer_url=>:none}]]}]}
28
+ expect(ERLE.to_ruby(input)).to eq(output)
29
+ end
30
+
31
+ it 'contains wtf' do
32
+ input = "[{sub,<<\"JCT\">>}, {sub2,none}]"
33
+ output = [{:sub=>"JCT"}, {:sub2=>:none}]
34
+ expect(ERLE.to_ruby(input)).to eq(output)
35
+ end
36
+
37
+ it 'contains wtf' do
38
+ input = <<-RBT
39
+ [{nodes,[{disc,['rabbit@ip-10-1-2-220.us-west-2.compute.internal',
40
+ 'rabbit@ip-10-1-3-250.us-west-2.compute.internal']}]},
41
+ {running_nodes,['rabbit@ip-10-1-2-220.us-west-2.compute.internal',
42
+ 'rabbit@ip-10-1-3-250.us-west-2.compute.internal']},
43
+ {cluster_name,<<"rabbit@ip-10-1-2-220.us-west-2.compute.internal">>},
44
+ {partitions,[]},
45
+ {alarms,[{'rabbit@ip-10-1-2-220.us-west-2.compute.internal',[]},
46
+ {'rabbit@ip-10-1-3-250.us-west-2.compute.internal',[]}]}]
47
+ RBT
48
+ output = [
49
+ {
50
+ nodes: [
51
+ {
52
+ disc: [
53
+ "rabbit@ip-10-1-2-220.us-west-2.compute.internal",
54
+ "rabbit@ip-10-1-3-250.us-west-2.compute.internal"
55
+ ]
56
+ }
57
+ ]
58
+ },
59
+ {
60
+ running_nodes: [
61
+ "rabbit@ip-10-1-2-220.us-west-2.compute.internal",
62
+ "rabbit@ip-10-1-3-250.us-west-2.compute.internal"
63
+ ]
64
+ },
65
+ {
66
+ cluster_name: "rabbit@ip-10-1-2-220.us-west-2.compute.internal"
67
+ },
68
+ {
69
+ partitions: []
70
+ },
71
+ {
72
+ alarms: [
73
+ {
74
+ "rabbit@ip-10-1-2-220.us-west-2.compute.internal" => []
75
+ },
76
+ {
77
+ "rabbit@ip-10-1-3-250.us-west-2.compute.internal" => []
78
+ }
79
+ ]
80
+ }
81
+ ]
82
+
83
+ expect(ERLE.to_ruby(input)).to eq(output)
84
+ end
85
+
86
+ it 'contains wtf' do
87
+ input = <<-RBT
88
+ [{nodes,[{disc,['rabbit@ip-10-1-2-220.us-west-2.compute.internal',
89
+ 'rabbit@ip-10-1-3-250.us-west-2.compute.internal']}]},
90
+ {running_nodes,['rabbit@ip-10-1-2-220.us-west-2.compute.internal',
91
+ 'rabbit@ip-10-1-3-250.us-west-2.compute.internal']},
92
+ {cluster_name,<<"rabbit@ip-10-1-2-220.us-west-2.compute.internal">>},
93
+ {partitions,[]},
94
+ {alarms,[{'rabbit@ip-10-1-2-220.us-west-2.compute.internal',[]},
95
+ {'rabbit@ip-10-1-3-250.us-west-2.compute.internal',[]}]}]
96
+ RBT
97
+ output = [
98
+ {
99
+ nodes: [
100
+ {
101
+ disc: [
102
+ "rabbit@ip-10-1-2-220.us-west-2.compute.internal",
103
+ "rabbit@ip-10-1-3-250.us-west-2.compute.internal"
104
+ ]
105
+ }
106
+ ]
107
+ },
108
+ {
109
+ running_nodes: [
110
+ "rabbit@ip-10-1-2-220.us-west-2.compute.internal",
111
+ "rabbit@ip-10-1-3-250.us-west-2.compute.internal"
112
+ ]
113
+ },
114
+ {
115
+ cluster_name: "rabbit@ip-10-1-2-220.us-west-2.compute.internal"
116
+ },
117
+ {
118
+ partitions: []
119
+ },
120
+ {
121
+ alarms: [
122
+ {
123
+ "rabbit@ip-10-1-2-220.us-west-2.compute.internal" => []
124
+ },
125
+ {
126
+ "rabbit@ip-10-1-3-250.us-west-2.compute.internal" => []
127
+ }
128
+ ]
129
+ }
130
+ ]
131
+
132
+ expect(ERLE.to_ruby(input)).to eq(output)
133
+ end
134
+
135
+ end
@@ -0,0 +1,18 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe ERLE::Pid do
4
+
5
+ it 'parses' do
6
+ input = "<1.2.3>"
7
+ output = "1.2.3"
8
+ obj = ERLE.to_ruby(input)
9
+ expect(obj).to eq(output)
10
+ end
11
+
12
+ it 'renders' do
13
+ input = "<1.2.3>"
14
+ obj = ERLE.to_ruby(input)
15
+ expect(obj.to_erl).to eq(input)
16
+ end
17
+
18
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe ERLE::Ref do
4
+
5
+ it 'returns Ref' do
6
+ input = "#Ref<1.2.3>"
7
+
8
+ output = ["1", "2", "3"]
9
+
10
+ obj = ERLE.parse(input)
11
+ expect(obj.to_ruby).to eq(output)
12
+ end
13
+
14
+ it 'raises if no close' do
15
+ input = "#Ref<1.2.3"
16
+
17
+ expect{ERLE.parse(input)}.to raise_error(ERLE::ParserError)
18
+ end
19
+
20
+ end
@@ -0,0 +1,20 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe ERLE::Term do
4
+
5
+ it 'outputs input' do
6
+ input = "foo"
7
+ output = "foo"
8
+
9
+ obj = ERLE::Term.new(input)
10
+ expect(obj.to_ruby).to eq(output)
11
+ end
12
+
13
+ it 'syntax error' do
14
+ # pid
15
+ input = "<1.2"
16
+
17
+ expect{ERLE.parse(input)}.to raise_error(ERLE::ParserError)
18
+ end
19
+
20
+ end
@@ -0,0 +1,27 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe ERLE::Tuple do
4
+
5
+ it 'parses' do
6
+ input = "{a,[{a_foo,'ABCDE',\"ABCDE\",<<\"ABCDE\">>}]}"
7
+ # output = {:a=>[{:a_foo=>["ABCDE", "ABCDE", "ABCDE"]}]}
8
+ # expect(ERLE::Tuple.new(input).to_ruby).to eq(output)
9
+
10
+ output = {:a=>[{:a_foo=>["ABCDE", "ABCDE", "ABCDE"]}]}
11
+
12
+ obj = ERLE.parse(input)
13
+ expect(obj.to_ruby).to eq(output)
14
+ end
15
+
16
+ it 'simple' do
17
+ input = "{a,123}"
18
+ # output = {:a=>[{:a_foo=>["ABCDE", "ABCDE", "ABCDE"]}]}
19
+ # expect(ERLE::Tuple.new(input).to_ruby).to eq(output)
20
+
21
+ output = {a: 123}
22
+
23
+ obj = ERLE.parse(input)
24
+ expect(obj.to_ruby).to eq(output)
25
+ end
26
+
27
+ end
@@ -0,0 +1,7 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe ERLE do
4
+ it "has a version number" do
5
+ expect(ERLE::VERSION).not_to be nil
6
+ end
7
+ end
@@ -0,0 +1,22 @@
1
+ require "bundler/setup"
2
+ require 'pry'
3
+
4
+ require 'simplecov'
5
+ SimpleCov.start do
6
+ add_filter 'spec'
7
+ end
8
+
9
+ require 'erle'
10
+
11
+
12
+ RSpec.configure do |config|
13
+ # Enable flags like --only-failures and --next-failure
14
+ config.example_status_persistence_file_path = ".rspec_status"
15
+
16
+ # Disable RSpec exposing methods globally on `Module` and `main`
17
+ config.disable_monkey_patching!
18
+
19
+ config.expect_with :rspec do |c|
20
+ c.syntax = :expect
21
+ end
22
+ end
metadata ADDED
@@ -0,0 +1,153 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: erle
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Dale Stevens
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-01-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: pry-byebug
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '1.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '1.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '12.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '12.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '3.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '3.0'
69
+ description:
70
+ email:
71
+ - dale@twilightcoders.net
72
+ executables:
73
+ - console
74
+ - setup
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".gitignore"
79
+ - ".rspec"
80
+ - ".travis.yml"
81
+ - CODE_OF_CONDUCT.md
82
+ - Gemfile
83
+ - LICENSE.txt
84
+ - README.md
85
+ - Rakefile
86
+ - bin/console
87
+ - bin/setup
88
+ - erle.gemspec
89
+ - lib/erle.rb
90
+ - lib/erle/elements/atom.rb
91
+ - lib/erle/elements/binary.rb
92
+ - lib/erle/elements/enum.rb
93
+ - lib/erle/elements/list.rb
94
+ - lib/erle/elements/map.rb
95
+ - lib/erle/elements/numbers.rb
96
+ - lib/erle/elements/pid.rb
97
+ - lib/erle/elements/ref.rb
98
+ - lib/erle/elements/string.rb
99
+ - lib/erle/elements/term.rb
100
+ - lib/erle/elements/tuple.rb
101
+ - lib/erle/errors.rb
102
+ - lib/erle/parser.rb
103
+ - lib/erle/registry.rb
104
+ - lib/erle/version.rb
105
+ - spec/erle/parser/atom_spec.rb
106
+ - spec/erle/parser/binary_spec.rb
107
+ - spec/erle/parser/enum_spec.rb
108
+ - spec/erle/parser/numbers_spec.rb
109
+ - spec/erle/parser/parser_spec.rb
110
+ - spec/erle/parser/pid_spec.rb
111
+ - spec/erle/parser/ref_spec.rb
112
+ - spec/erle/parser/term_spec.rb
113
+ - spec/erle/parser/tuple_spec.rb
114
+ - spec/erle/parser_spec.rb
115
+ - spec/spec_helper.rb
116
+ homepage: https://github.com/TwilightCoders/erlang-parser.
117
+ licenses:
118
+ - MIT
119
+ metadata:
120
+ allowed_push_host: https://rubygems.org
121
+ post_install_message:
122
+ rdoc_options: []
123
+ require_paths:
124
+ - lib
125
+ - spec
126
+ required_ruby_version: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '2.1'
131
+ required_rubygems_version: !ruby/object:Gem::Requirement
132
+ requirements:
133
+ - - ">="
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ requirements: []
137
+ rubyforge_project:
138
+ rubygems_version: 2.6.14
139
+ signing_key:
140
+ specification_version: 4
141
+ summary: Parses Erlang terms into Ruby objects
142
+ test_files:
143
+ - spec/erle/parser/atom_spec.rb
144
+ - spec/erle/parser/binary_spec.rb
145
+ - spec/erle/parser/enum_spec.rb
146
+ - spec/erle/parser/numbers_spec.rb
147
+ - spec/erle/parser/parser_spec.rb
148
+ - spec/erle/parser/pid_spec.rb
149
+ - spec/erle/parser/ref_spec.rb
150
+ - spec/erle/parser/term_spec.rb
151
+ - spec/erle/parser/tuple_spec.rb
152
+ - spec/erle/parser_spec.rb
153
+ - spec/spec_helper.rb