opulent 1.6.7 → 1.6.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f7a13ab0ad288c702f2f5a1c24f686c0bcea8ce6
4
- data.tar.gz: cc8762cd9d9701340ae1c1f59e2d7250464d162f
3
+ metadata.gz: 00de440bb2707f1677577c3166c6afc30dd12d0e
4
+ data.tar.gz: 451a6be59313e43cd42dc4cb2eff4ea57891e2d2
5
5
  SHA512:
6
- metadata.gz: 746952640cfc38ffa597c75227f9233d36cce8782a41ecf8f82d726896fe6e95c18692d2ef5091f246d6a5294eea65e2a047b633cb3feb128bf2f32c37a1c15a
7
- data.tar.gz: 673e591e2cf98021ff8eae91e9675a20a200d0845e6c2589b904e9d4278fc309c4c8e92220d11591026e6354ba0e774c27b0183fe658846865e2f8b034069346
6
+ metadata.gz: b612ad8fc5aba54968c011607fb277bcee38360e874339ff2cd3decc0ddaab3e04a2fc5f34472e9c1a07b7b7b7e0ca4ced47b7b7106ac5b0a3d8b04fa439fbcd
7
+ data.tar.gz: 8367054aebf9153a816f76aa51a9b72f66fc7885ea7ecbef9804eadb8ccfc08edb832980b22a8a1ef8075b865036ae4bb1238fc81fff76513e964a43c7389a83
@@ -23,7 +23,13 @@ module Opulent
23
23
  name = accept(:node, :*).to_sym
24
24
 
25
25
  # Create node
26
- definition = [:def, name, { parameters: attributes }, [], indent]
26
+ definition = [
27
+ :def,
28
+ name,
29
+ { parameters: attributes({}, true) },
30
+ [],
31
+ indent
32
+ ]
27
33
 
28
34
  # Set definition as root node and let the parser know that we're inside
29
35
  # a definition. This is used because inside definitions we do not
@@ -189,11 +189,12 @@ module Opulent
189
189
 
190
190
  # Get element attributes
191
191
  #
192
- # @atts [Hash] Accumulator for node attributes
192
+ # @param atts [Hash] Accumulator for node attributes
193
+ # @param for_definition [Boolean] Set default value in wrapped to nil
193
194
  #
194
- def attributes(atts = {})
195
- wrapped_attributes atts
196
- attributes_assignments atts, false
195
+ def attributes(atts = {}, for_definition = false)
196
+ wrapped_attributes atts, for_definition
197
+ attributes_assignments atts, false, for_definition
197
198
  atts
198
199
  end
199
200
 
@@ -203,27 +204,26 @@ module Opulent
203
204
  #
204
205
  # @param as_parameters [Boolean] Accept or reject identifier nodes
205
206
  #
206
- def wrapped_attributes(list)
207
- if (bracket = accept :brackets)
208
- accept_newline
209
- attributes_assignments list, true
210
- accept_newline
207
+ def wrapped_attributes(list = {}, for_definition = false)
208
+ return unless (bracket = accept :brackets)
211
209
 
212
- accept_stripped bracket.to_sym, :*
213
- end
210
+ accept_newline
211
+ attributes_assignments list, true, for_definition
212
+ accept_newline
213
+
214
+ accept_stripped bracket.to_sym, :*
214
215
 
215
216
  list
216
217
  end
217
218
 
218
- # Check if we match an expression node or
219
- # a node node
219
+ # Get all attribute assignments as key=value pairs or standalone keys
220
220
  #
221
221
  # [ assignments ]
222
222
  #
223
223
  # @param list [Hash] Parent to which we append nodes
224
224
  # @param as_parameters [Boolean] Accept or reject identifier nodes
225
225
  #
226
- def attributes_assignments(list, wrapped = true)
226
+ def attributes_assignments(list, wrapped = true, for_definition = false)
227
227
  if wrapped && lookahead(:exp_identifier_stripped_lookahead).nil? ||
228
228
  !wrapped && lookahead(:assignment_lookahead).nil?
229
229
  return list
@@ -253,7 +253,8 @@ module Opulent
253
253
  end
254
254
  else
255
255
  unless list[argument]
256
- list[argument] = [:expression, 'true', { escaped: false }]
256
+ default_value = for_definition ? 'nil' : 'true'
257
+ list[argument] = [:expression, default_value, { escaped: false }]
257
258
  end
258
259
  end
259
260
 
@@ -267,13 +268,13 @@ module Opulent
267
268
 
268
269
  # Lookahead for attributes on the current line and the next one
269
270
  if lookahead(:exp_identifier_stripped_lookahead)
270
- attributes_assignments list, wrapped
271
+ attributes_assignments list, wrapped, for_definition
271
272
  elsif lookahead_next_line(:exp_identifier_stripped_lookahead)
272
273
  accept_newline
273
- attributes_assignments list, wrapped
274
+ attributes_assignments list, wrapped, for_definition
274
275
  end
275
276
  elsif !wrapped && lookahead(:assignment_lookahead)
276
- attributes_assignments list, wrapped
277
+ attributes_assignments list, wrapped, for_definition
277
278
  end
278
279
 
279
280
  list
@@ -1,4 +1,4 @@
1
1
  # @Opulent
2
2
  module Opulent
3
- VERSION = '1.6.7'
3
+ VERSION = '1.6.8'
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: opulent
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.7
4
+ version: 1.6.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Alex Grozav