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 +4 -4
- data/lib/opulent/parser/define.rb +7 -1
- data/lib/opulent/parser/node.rb +19 -18
- data/lib/opulent/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 00de440bb2707f1677577c3166c6afc30dd12d0e
|
4
|
+
data.tar.gz: 451a6be59313e43cd42dc4cb2eff4ea57891e2d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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 = [
|
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
|
data/lib/opulent/parser/node.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
213
|
-
|
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
|
-
#
|
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
|
-
|
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
|
data/lib/opulent/version.rb
CHANGED