delorean_lang 2.4.2 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop_todo.yml +3 -3
- data/lib/delorean/base.rb +1 -1
- data/lib/delorean/engine.rb +11 -1
- data/lib/delorean/version.rb +1 -1
- data/spec/eval_spec.rb +78 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b6cc25679183ee119b6f32c93032dcaf62ec212ccadf9d603db3208343ed6e9f
|
4
|
+
data.tar.gz: dda2d1e9b7cea95d61686b22a96ed453fe694e3179047a13b9fbaae60c719c7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 17a9b6906e1f95883084f08236604edbd6197121a175b707a1e91c5f9e0778c224fd526dbb66819f1a6fe8477f8ca88b6ac5e436ec6b63b73aaa7ca717d04b1d
|
7
|
+
data.tar.gz: 72da6952e2c7cbf92b95b36e1893f2dbbcb4b8c8715e306496e400fc48c7ecd89808fda38711e665c12a9e5fb1ce38fd7082a7c7b185f3edf78939d4651ad599
|
data/.rubocop_todo.yml
CHANGED
@@ -42,11 +42,11 @@ Metrics/AbcSize:
|
|
42
42
|
# Offense count: 2
|
43
43
|
# Configuration parameters: CountComments.
|
44
44
|
Metrics/ClassLength:
|
45
|
-
Max:
|
45
|
+
Max: 350
|
46
46
|
|
47
47
|
# Offense count: 8
|
48
48
|
Metrics/CyclomaticComplexity:
|
49
|
-
Max:
|
49
|
+
Max: 20
|
50
50
|
|
51
51
|
# Offense count: 22
|
52
52
|
# Configuration parameters: CountComments, ExcludedMethods.
|
@@ -55,7 +55,7 @@ Metrics/MethodLength:
|
|
55
55
|
|
56
56
|
# Offense count: 6
|
57
57
|
Metrics/PerceivedComplexity:
|
58
|
-
Max:
|
58
|
+
Max: 20
|
59
59
|
|
60
60
|
# Offense count: 1
|
61
61
|
Naming/AccessorMethodName:
|
data/lib/delorean/base.rb
CHANGED
data/lib/delorean/engine.rb
CHANGED
@@ -220,6 +220,16 @@ module Delorean
|
|
220
220
|
@@parser ||= DeloreanParser.new
|
221
221
|
end
|
222
222
|
|
223
|
+
def closing_bracket?(line)
|
224
|
+
stripped = line.strip
|
225
|
+
|
226
|
+
return true if stripped == ']'
|
227
|
+
return true if stripped == ')'
|
228
|
+
return true if stripped == '}'
|
229
|
+
|
230
|
+
false
|
231
|
+
end
|
232
|
+
|
223
233
|
def generate(t)
|
224
234
|
t.check(self)
|
225
235
|
|
@@ -268,7 +278,7 @@ module Delorean
|
|
268
278
|
if multi_line
|
269
279
|
# if line starts with >4 spaces, assume it's a multline
|
270
280
|
# continuation.
|
271
|
-
if /\A {5}/.match?(line)
|
281
|
+
if /\A {5}/.match?(line) || closing_bracket?(line)
|
272
282
|
multi_line += line
|
273
283
|
next
|
274
284
|
else
|
data/lib/delorean/version.rb
CHANGED
data/spec/eval_spec.rb
CHANGED
@@ -1397,6 +1397,84 @@ eof
|
|
1397
1397
|
expect(r).to eq 1
|
1398
1398
|
end
|
1399
1399
|
|
1400
|
+
it 'allows to close the bracket with the same spacing as variable' do
|
1401
|
+
engine.parse defn('A:',
|
1402
|
+
' a = [',
|
1403
|
+
' 1,',
|
1404
|
+
' 2,',
|
1405
|
+
' ]',
|
1406
|
+
' b = 2',
|
1407
|
+
)
|
1408
|
+
r = engine.evaluate('A', 'a')
|
1409
|
+
expect(r).to eq [1, 2]
|
1410
|
+
|
1411
|
+
r = engine.evaluate('A', 'b')
|
1412
|
+
expect(r).to eq 2
|
1413
|
+
end
|
1414
|
+
|
1415
|
+
it 'allows to close the bracket with the same spacing as variable 2' do
|
1416
|
+
engine.parse defn('A:',
|
1417
|
+
' a = [',
|
1418
|
+
' {',
|
1419
|
+
' "a": 1,',
|
1420
|
+
' "b": 2,',
|
1421
|
+
' },',
|
1422
|
+
' 2,',
|
1423
|
+
' ]',
|
1424
|
+
)
|
1425
|
+
r = engine.evaluate('A', 'a')
|
1426
|
+
expect(r).to eq [{ 'a' => 1, 'b' => 2 }, 2]
|
1427
|
+
end
|
1428
|
+
|
1429
|
+
it 'allows to close the bracket with the same spacing as variable 3' do
|
1430
|
+
engine.parse defn('A:',
|
1431
|
+
' a = {',
|
1432
|
+
' "a": 1,',
|
1433
|
+
' "b": 2,',
|
1434
|
+
' }',
|
1435
|
+
' b = 2',
|
1436
|
+
)
|
1437
|
+
r = engine.evaluate('A', 'a')
|
1438
|
+
expect(r).to eq('a' => 1, 'b' => 2)
|
1439
|
+
|
1440
|
+
r = engine.evaluate('A', 'b')
|
1441
|
+
expect(r).to eq 2
|
1442
|
+
end
|
1443
|
+
|
1444
|
+
it 'allows to close the bracket with the same spacing as variable 4' do
|
1445
|
+
engine.parse defn('A:',
|
1446
|
+
' a = {',
|
1447
|
+
' "a": 1,',
|
1448
|
+
' "b": 2,',
|
1449
|
+
' }',
|
1450
|
+
' b = [1, 2]',
|
1451
|
+
' c = [',
|
1452
|
+
' {',
|
1453
|
+
' key : value + num',
|
1454
|
+
' for key, value in a',
|
1455
|
+
' }',
|
1456
|
+
' for num in b',
|
1457
|
+
' ]',
|
1458
|
+
)
|
1459
|
+
r = engine.evaluate('A', 'c')
|
1460
|
+
expect(r).to eq([{ 'a' => 2, 'b' => 3 }, { 'a' => 3, 'b' => 4 }])
|
1461
|
+
end
|
1462
|
+
|
1463
|
+
it 'allows to close the bracket with the same spacing as variable 5' do
|
1464
|
+
engine.parse defn('A:',
|
1465
|
+
' a = (',
|
1466
|
+
' 1 +',
|
1467
|
+
' 2',
|
1468
|
+
' )',
|
1469
|
+
' b = 2',
|
1470
|
+
)
|
1471
|
+
r = engine.evaluate('A', 'a')
|
1472
|
+
expect(r).to eq(3)
|
1473
|
+
|
1474
|
+
r = engine.evaluate('A', 'b')
|
1475
|
+
expect(r).to eq 2
|
1476
|
+
end
|
1477
|
+
|
1400
1478
|
describe 'blocks' do
|
1401
1479
|
let(:default_node) do
|
1402
1480
|
['A:',
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: delorean_lang
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arman Bostani
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|