csdl 0.2.0 → 0.2.1

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: a90262fd16ee8936dd0fe2de172ca90a443603f6
4
- data.tar.gz: 89cb93fa4bdcb617dbd066edc004bde34f33c1af
3
+ metadata.gz: 135ecbcd588b93734289488616a6da8e47933dc3
4
+ data.tar.gz: 21e8f7d9fa247a9aecaae66c710cc0a85c07608f
5
5
  SHA512:
6
- metadata.gz: 485e7164255da714fb1d5bc59e4a9d01b7568e6a58acb5c6b865d85bcef56063cc4c904482482e45c9bdbcb82fab90f097a99fbc2778f2b2b8b46c49c041f494
7
- data.tar.gz: 55d987844a46743cc6013402225279458aa33419ea38b38e5226ea1ea665debff6124f8671030d76df24236f4d506e8f16fef13129c63ecc5470159a48b7530b
6
+ metadata.gz: 7d8499b0904fa8ce5da292cb8f9704407235549e4fd8052105883dce5a59bd3fcf067a82cbc77ca286b6fd25751139b6f610fc0ade7b0725c234601a52f363c8
7
+ data.tar.gz: 7977cd29e77bc3e548a7019df211b063e218cf345d7ed4f3ce1dcde20f31be29b74422d851ae811156a808f144f4279d459e89f0533328f842601b76ccbe794f
data/lib/csdl/builder.rb CHANGED
@@ -39,7 +39,14 @@ module CSDL
39
39
  # @see #logical_group
40
40
  #
41
41
  def _and(&block)
42
- s(:and, *__one_or_more_child_nodes(&block))
42
+ children = __one_or_more_child_nodes(&block)
43
+ if children.empty?
44
+ nil
45
+ elsif children.size == 1
46
+ children.first
47
+ else
48
+ s(:and, *children)
49
+ end
43
50
  end
44
51
 
45
52
  # Negate a condition. Analogous to {#condition} with NOT prepended to the condition.
@@ -89,7 +96,14 @@ module CSDL
89
96
  # @see #logical_group
90
97
  #
91
98
  def _or(&block)
92
- s(:or, *__one_or_more_child_nodes(&block))
99
+ children = __one_or_more_child_nodes(&block)
100
+ if children.empty?
101
+ nil
102
+ elsif children.size == 1
103
+ children.first
104
+ else
105
+ s(:or, *children)
106
+ end
93
107
  end
94
108
 
95
109
  # Wrap child nodes in a return statement scope.
@@ -215,10 +229,13 @@ module CSDL
215
229
  # @see #_or
216
230
  #
217
231
  def logical_group(logical_operator = nil, &block)
232
+ children = __one_or_more_child_nodes(&block)
233
+ return nil if children.empty?
234
+
218
235
  if logical_operator.nil?
219
- s(:logical_group, *__one_or_more_child_nodes(&block))
236
+ s(:logical_group, *children)
220
237
  else
221
- s(:logical_group, s(logical_operator, *__one_or_more_child_nodes(&block)))
238
+ s(:logical_group, s(logical_operator, *children))
222
239
  end
223
240
  end
224
241
 
@@ -251,7 +268,12 @@ module CSDL
251
268
  # @see #tag_tree
252
269
  #
253
270
  def root(&block)
254
- s(:root, *__one_or_more_child_nodes(&block))
271
+ children = __one_or_more_child_nodes(&block)
272
+ if children.empty?
273
+ nil
274
+ else
275
+ s(:root, *children)
276
+ end
255
277
  end
256
278
 
257
279
  # Wrap child nodes in braces. @note Generally not useful on its own, see {#_return}, {#tag}, or {#tag_tree} usage.
@@ -274,7 +296,12 @@ module CSDL
274
296
  # @see #tag_tree
275
297
  #
276
298
  def statement_scope(&block)
277
- s(:statement_scope, *__one_or_more_child_nodes(&block))
299
+ children = __one_or_more_child_nodes(&block)
300
+ if children.empty?
301
+ nil
302
+ else
303
+ s(:statement_scope, *children)
304
+ end
278
305
  end
279
306
 
280
307
  # Wrap child nodes in a VEDO tag classification.
@@ -340,7 +367,7 @@ module CSDL
340
367
 
341
368
  def __one_or_more_child_nodes(&block)
342
369
  children = instance_eval(&block)
343
- [ children ].flatten
370
+ [ children ].flatten.compact
344
371
  end
345
372
 
346
373
  end
data/lib/csdl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module CSDL
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: csdl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - BJ Neilsen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-17 00:00:00.000000000 Z
11
+ date: 2015-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ast