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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a2f391feb742261cf7205700f71a6455c3994b88ff33e07ec3acc8b5bba322e7
4
- data.tar.gz: af2616d688fc0b18844737aaa26dd37a597ed92a8ef338a46fc27c252beab739
3
+ metadata.gz: b6cc25679183ee119b6f32c93032dcaf62ec212ccadf9d603db3208343ed6e9f
4
+ data.tar.gz: dda2d1e9b7cea95d61686b22a96ed453fe694e3179047a13b9fbaae60c719c7a
5
5
  SHA512:
6
- metadata.gz: 202515ed652a577f8eb270116397254c0d46e601e4062db196f8c4dd07abd13914e74dce21ee4a086d9e7e404b823f56671573bbafc382f950b32fec9fdfdab8
7
- data.tar.gz: 2fca9df1461cc20b7e5a4c0e6aa60c9c54d35ec2bbe3b954b539b5b757818cfab5d315bc8bbd48d53aa35a2beb3a8fdb3f914dfced09068299cc104da0088578
6
+ metadata.gz: 17a9b6906e1f95883084f08236604edbd6197121a175b707a1e91c5f9e0778c224fd526dbb66819f1a6fe8477f8ca88b6ac5e436ec6b63b73aaa7ca717d04b1d
7
+ data.tar.gz: 72da6952e2c7cbf92b95b36e1893f2dbbcb4b8c8715e306496e400fc48c7ecd89808fda38711e665c12a9e5fb1ce38fd7082a7c7b185f3edf78939d4651ad599
@@ -42,11 +42,11 @@ Metrics/AbcSize:
42
42
  # Offense count: 2
43
43
  # Configuration parameters: CountComments.
44
44
  Metrics/ClassLength:
45
- Max: 300
45
+ Max: 350
46
46
 
47
47
  # Offense count: 8
48
48
  Metrics/CyclomaticComplexity:
49
- Max: 13
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: 15
58
+ Max: 20
59
59
 
60
60
  # Offense count: 1
61
61
  Naming/AccessorMethodName:
@@ -76,7 +76,7 @@ module Delorean
76
76
 
77
77
  # add new arguments, results in a new NodeCall
78
78
  def +(args)
79
- raise 'bad arg to %' unless args.is_a?(Hash)
79
+ raise 'bad arg to +' unless args.is_a?(Hash)
80
80
 
81
81
  NodeCall.new(_e, engine, node, params.merge(args))
82
82
  end
@@ -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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Delorean
4
- VERSION = '2.4.2'
4
+ VERSION = '2.5.0'
5
5
  end
@@ -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.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-03 00:00:00.000000000 Z
11
+ date: 2020-03-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord