enolib 0.7.2 → 0.8.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: 88751440ddeb55fc6358a9ad2cafa998f3395787b475f3c42e1701c0ef17293c
4
- data.tar.gz: e61d935cf566395b4787f424930fb84fcfdd5b879254c35c6dc452f15963c187
3
+ metadata.gz: 49f109d1e380fde591e9fd8356d83a1024f5bcfb617d4408cbd803b8723379a0
4
+ data.tar.gz: 8015043eb20b92a86b6afd8a7ae510eb47f24b5fd10226bcadd0b8fe5021c76c
5
5
  SHA512:
6
- metadata.gz: a23ff5f077a95e19a302c24658f9f0324a4f7a335fffb53018a4f1a1f9f4fa849ce0ae046c279e49445d85175f7ea82b7d118380a0b1ff98d9aaa646510785b1
7
- data.tar.gz: 228ff010c1724b9db258c8989fa47678b78ad34af528d0ee42c788a3d302e0f6e390abc6723c0bf2cc890775114df0d04a4530cddd6c81521f83208a6f10dbfc
6
+ metadata.gz: 7525f016c0835c764b5b5888c98bf57214a8e1918458bd8253ac44cc424e9563713376fc369ee6198d389c63a52db79e6476c7ab476708780c4884883ba52693
7
+ data.tar.gz: 3667c043b3089e5ef598567adc6f5fe57e0246f98f82ff3f6052050945adbcb1af03a7f16aac343acb26c710229d7548deedd7108ddb310bdf2da66821a4e83f
@@ -4,10 +4,11 @@ module Enolib
4
4
  HUMAN_INDEXING = 1
5
5
  PRETTY_TYPES = {
6
6
  document: 'document',
7
- empty_element: 'empty_element',
7
+ empty: 'empty',
8
8
  field: 'field',
9
9
  fieldset: 'fieldset',
10
10
  fieldset_entry: 'fieldset_entry',
11
+ field_or_fieldset_or_list: 'field_or_fieldset_or_list',
11
12
  list: 'list',
12
13
  list_item: 'list_item',
13
14
  multiline_field_begin: 'field',
@@ -150,7 +150,7 @@ module Enolib
150
150
  result[:comment] = comment(element) if element.has_key?(:comments)
151
151
 
152
152
  case element[:type]
153
- when :empty_element
153
+ when :field_or_fieldset_or_list, :empty
154
154
  result[:key] = element[:key]
155
155
  when :field
156
156
  result[:key] = element[:key]
@@ -348,6 +348,9 @@ module Enolib
348
348
 
349
349
  element = elements[0]
350
350
 
351
+ # TODO: Other implementations use a direct check here (['type'] == :foo)
352
+ # Should this be unified across implementations? Follow up.
353
+ # (guess is that the main reason is stricter visibility in ruby currently)
351
354
  unless element.yields_empty?
352
355
  raise Errors::Validation.unexpected_element_type(
353
356
  @context,
@@ -5,7 +5,9 @@ module Enolib
5
5
  attr_reader :instruction # TODO: Revisit this hacky exposition
6
6
 
7
7
  def _untouched
8
- return @instruction unless instance_variable_defined?(:@yielded)
8
+ unless instance_variable_defined?(:@yielded)
9
+ return instance_variable_defined?(:@touched) ? false : @instruction
10
+ end
9
11
 
10
12
  return @instruction if instance_variable_defined?(:@empty) && !@empty.instance_variable_defined?(:@touched)
11
13
  return @instruction if instance_variable_defined?(:@field) && !@field.instance_variable_defined?(:@touched)
@@ -16,17 +18,13 @@ module Enolib
16
18
 
17
19
  def to_empty
18
20
  unless instance_variable_defined?(:@empty)
19
- if instance_variable_defined?(:@yielded)
20
- raise TypeError, "This element was already yielded as #{PRETTY_TYPES[@yielded]} and can't be yielded again as an empty."
21
- end
22
-
23
- unless @instruction[:type] == :empty_element
21
+ unless @instruction[:type] == :empty
24
22
  # TODO: Below and in all implementations - why nil for key as second parameter?
25
23
  raise Errors::Validation.unexpected_element_type(@context, nil, @instruction, 'expected_empty')
26
24
  end
27
25
 
28
26
  @empty = Empty.new(@context, @instruction, @parent)
29
- @yielded = :empty_element
27
+ @yielded = :empty
30
28
  end
31
29
 
32
30
  @empty
@@ -40,7 +38,7 @@ module Enolib
40
38
 
41
39
  unless @instruction[:type] == :field ||
42
40
  @instruction[:type] == :multiline_field_begin ||
43
- @instruction[:type] == :empty_element
41
+ @instruction[:type] == :field_or_fieldset_or_list
44
42
  raise Errors::Validation.unexpected_element_type(@context, nil, @instruction, 'expected_field')
45
43
  end
46
44
 
@@ -57,7 +55,7 @@ module Enolib
57
55
  raise TypeError, "This element was already yielded as #{PRETTY_TYPES[@yielded]} and can't be yielded again as a fieldset."
58
56
  end
59
57
 
60
- unless @instruction[:type] == :fieldset || @instruction[:type] == :empty_element
58
+ unless @instruction[:type] == :fieldset || @instruction[:type] == :field_or_fieldset_or_list
61
59
  raise Errors::Validation.unexpected_element_type(@context, nil, @instruction, 'expected_fieldset')
62
60
  end
63
61
 
@@ -74,7 +72,7 @@ module Enolib
74
72
  raise TypeError, "This element was already yielded as #{PRETTY_TYPES[@yielded]} and can't be yielded again as a list."
75
73
  end
76
74
 
77
- unless @instruction[:type] == :list || @instruction[:type] == :empty_element
75
+ unless @instruction[:type] == :list || @instruction[:type] == :field_or_fieldset_or_list
78
76
  raise Errors::Validation.unexpected_element_type(@context, nil, @instruction, 'expected_list')
79
77
  end
80
78
 
@@ -103,35 +101,40 @@ module Enolib
103
101
  end
104
102
 
105
103
  def touch
106
- # TODO: Here and other implementations: This needs to touch anyway; possibly not so small implications
107
- return unless instance_variable_defined?(:@yielded)
108
-
109
104
  # TODO: Revisit setting touched on foreign instances
110
- @empty.touched = true if instance_variable_defined?(:@empty)
111
- @field.touched = true if instance_variable_defined?(:@field)
112
- @fieldset.touch if instance_variable_defined?(:@fieldset)
113
- @list.touch if instance_variable_defined?(:@list)
114
- @section.touch if instance_variable_defined?(:@section)
105
+ if !instance_variable_defined?(:@yielded)
106
+ @touched = true
107
+ elsif instance_variable_defined?(:@empty)
108
+ @empty.touched = true
109
+ elsif instance_variable_defined?(:@field)
110
+ @field.touched = true
111
+ elsif instance_variable_defined?(:@fieldset)
112
+ @fieldset.touch
113
+ elsif instance_variable_defined?(:@list)
114
+ @list.touch
115
+ elsif instance_variable_defined?(:@section)
116
+ @section.touch
117
+ end
115
118
  end
116
119
 
117
120
  def yields_empty?
118
- @instruction[:type] == :empty_element
121
+ @instruction[:type] == :empty
119
122
  end
120
123
 
121
124
  def yields_field?
122
125
  @instruction[:type] == :field ||
123
126
  @instruction[:type] == :multiline_field_begin ||
124
- @instruction[:type] == :empty_element
127
+ @instruction[:type] == :field_or_fieldset_or_list
125
128
  end
126
129
 
127
130
  def yields_fieldset?
128
131
  @instruction[:type] == :fieldset ||
129
- @instruction[:type] == :empty_element
132
+ @instruction[:type] == :field_or_fieldset_or_list
130
133
  end
131
134
 
132
135
  def yields_list?
133
136
  @instruction[:type] == :list ||
134
- @instruction[:type] == :empty_element
137
+ @instruction[:type] == :field_or_fieldset_or_list
135
138
  end
136
139
 
137
140
  def yields_section?
@@ -141,8 +144,8 @@ module Enolib
141
144
  private
142
145
 
143
146
  def _yields
144
- if @instruction[:type] == :empty_element
145
- return "#{PRETTY_TYPES[:empty_element]},#{PRETTY_TYPES[:field]},#{PRETTY_TYPES[:fieldset]},#{PRETTY_TYPES[:list]}"
147
+ if @instruction[:type] == :field_or_fieldset_or_list
148
+ return "#{PRETTY_TYPES[:field]},#{PRETTY_TYPES[:fieldset]},#{PRETTY_TYPES[:list]}"
146
149
  end
147
150
 
148
151
  PRETTY_TYPES[@instruction[:type]]
@@ -47,7 +47,7 @@ module Enolib
47
47
  selection = {}
48
48
 
49
49
  if element[:type] == :field ||
50
- element[:type] == :empty_element ||
50
+ element[:type] == :field_or_fieldset_or_list ||
51
51
  element[:type] == :multiline_field_begin
52
52
  message = context.messages.missing_field_value(element[:key])
53
53
 
@@ -10,7 +10,7 @@ module Enolib
10
10
  REQUIRED = /(\S[^\n]*?)/.source
11
11
 
12
12
  #
13
- EMPTY = /()/.source
13
+ EMPTY_LINE = /()/.source
14
14
  EMPTY_LINE_INDEX = 1
15
15
 
16
16
  # | value
@@ -78,7 +78,7 @@ module Enolib
78
78
 
79
79
  # :
80
80
  # : value
81
- ELEMENT_OR_FIELD = /(:)[^\S\n]*#{OPTIONAL}/.source
81
+ FIELD_OR_FIELDSET_OR_LIST = /(:)[^\S\n]*#{OPTIONAL}/.source
82
82
  ELEMENT_OPERATOR_INDEX = 23
83
83
  FIELD_VALUE_INDEX = 24
84
84
 
@@ -94,10 +94,10 @@ module Enolib
94
94
  COPY_OPERATOR_INDEX = 27
95
95
  TEMPLATE_INDEX = 28
96
96
 
97
- LATE_DETERMINED = /#{KEY}\s*(?:#{ELEMENT_OR_FIELD}|#{FIELDSET_ENTRY}|#{COPY})/.source
97
+ LATE_DETERMINED = /#{KEY}\s*(?:#{FIELD_OR_FIELDSET_OR_LIST}|#{FIELDSET_ENTRY}|#{COPY})?/.source
98
98
 
99
- NOT_EMPTY = /(?:#{EARLY_DETERMINED}|#{LATE_DETERMINED})/.source
99
+ NON_EMPTY_LINE = /(?:#{EARLY_DETERMINED}|#{LATE_DETERMINED})/.source
100
100
 
101
- REGEX = /[^\S\n]*(?:#{EMPTY}|#{NOT_EMPTY})[^\S\n]*(?=\n|$)/.freeze
101
+ REGEX = /[^\S\n]*(?:#{EMPTY_LINE}|#{NON_EMPTY_LINE})[^\S\n]*(?=\n|$)/.freeze
102
102
  end
103
103
  end
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # GENERATED ON 2019-05-30T07:54:15 - DO NOT EDIT MANUALLY
3
+ # GENERATED ON 2019-06-18T08:50:41 - DO NOT EDIT MANUALLY
4
4
 
5
5
  module Enolib
6
6
  module Locales
7
7
  module De
8
8
  CONTENT_HEADER = 'Inhalt'
9
9
  EXPECTED_DOCUMENT = 'Das Dokument wurde erwartet.'
10
- EXPECTED_EMPTY = 'Ein leeres Element wurde erwartet.'
10
+ EXPECTED_EMPTY = 'Ein Leerfeld wurde erwartet.'
11
11
  EXPECTED_FIELD = 'Ein Feld wurde erwartet.'
12
12
  EXPECTED_FIELDS = 'Nur Felder wurden erwartet.'
13
13
  EXPECTED_FIELDSET = 'Ein Fieldset wurde erwartet.'
@@ -19,7 +19,7 @@ module Enolib
19
19
  EXPECTED_SECTION = 'Eine Sektion wurde erwartet.'
20
20
  EXPECTED_SECTIONS = 'Nur Sektionen wurden erwartet.'
21
21
  EXPECTED_SINGLE_ELEMENT = 'Nur ein einzelnes Element wurde erwartet.'
22
- EXPECTED_SINGLE_EMPTY = 'Nur ein einzelnes leeres Element wurde erwartet.'
22
+ EXPECTED_SINGLE_EMPTY = 'Nur ein einzelnes Leerfeld wurde erwartet.'
23
23
  EXPECTED_SINGLE_FIELD = 'Nur ein einzelnes Feld wurde erwartet.'
24
24
  EXPECTED_SINGLE_FIELDSET = 'Nur ein einzelnes Fieldset wurde erwartet.'
25
25
  EXPECTED_SINGLE_FIELDSET_ENTRY = 'Nur ein einzelner Fieldset Eintrag wurde erwartet.'
@@ -28,7 +28,7 @@ module Enolib
28
28
  GUTTER_HEADER = 'Zeile'
29
29
  MISSING_COMMENT = 'Ein erforderlicher Kommentar zu diesem Feld fehlt.'
30
30
  MISSING_ELEMENT = 'Ein einzelnes Element ist erforderlich - es kann einen beliebigen Schlüssel haben.'
31
- MISSING_EMPTY = 'Ein einzelnes leeres Element ist erforderlich - es kann einen beliebigen Schlüssel haben.'
31
+ MISSING_EMPTY = 'Ein einzelnes Leerfeld ist erforderlich - es kann einen beliebigen Schlüssel haben.'
32
32
  MISSING_FIELD = 'Ein einzelnes Feld ist erforderlich - es kann einen beliebigen Schlüssel haben.'
33
33
  MISSING_FIELDSET = 'Ein einzelnes Fieldset ist erforderlich - es kann einen beliebigen Schlüssel haben.'
34
34
  MISSING_FIELDSET_ENTRY = 'Ein einzelner Fieldset Eintrag ist erforderlich - er kann einen beliebigen Schlüssel haben.'
@@ -37,7 +37,7 @@ module Enolib
37
37
  UNEXPECTED_ELEMENT = 'Dieses Element wurde nicht erwartet, prüfe ob es am richtigen Platz ist und dass der Schlüssel keine Tippfehler enthält.'
38
38
  def self.comment_error(message) "Es gibt ein Problem mit dem Kommentar dieses Elements: #{message}" end
39
39
  def self.cyclic_dependency(line, key) "In Zeile #{line} wird '#{key}' in sich selbst kopiert." end
40
- def self.expected_empty_with_key(key) "Ein leeres Element mit dem Schlüssel '#{key}' wurde erwartet." end
40
+ def self.expected_empty_with_key(key) "Ein Leerfeld mit dem Schlüssel '#{key}' wurde erwartet." end
41
41
  def self.expected_field_with_key(key) "Ein Feld mit dem Schlüssel '#{key}' wurde erwartet." end
42
42
  def self.expected_fields_with_key(key) "Nur Felder mit dem Schlüssel '#{key}' wurden erwartet." end
43
43
  def self.expected_fieldset_with_key(key) "Ein Fieldset mit dem Schlüssel '#{key}' wurde erwartet." end
@@ -47,7 +47,7 @@ module Enolib
47
47
  def self.expected_section_with_key(key) "Eine Sektion mit dem Schlüssel '#{key}' wurde erwartet." end
48
48
  def self.expected_sections_with_key(key) "Nur Sektionen mit dem Schlüssel '#{key}' wurden erwartet." end
49
49
  def self.expected_single_element_with_key(key) "Nur ein einzelnes Element mit dem Schlüssel '#{key}' wurde erwartet." end
50
- def self.expected_single_empty_with_key(key) "Nur ein einzelnes leeres Element mit dem Schlüssel '#{key}' wurde erwartet." end
50
+ def self.expected_single_empty_with_key(key) "Nur ein einzelnes Leerfeld mit dem Schlüssel '#{key}' wurde erwartet." end
51
51
  def self.expected_single_field_with_key(key) "Nur ein einzelnes Feld mit dem Schlüssel '#{key}' wurde erwartet." end
52
52
  def self.expected_single_fieldset_entry_with_key(key) "Nur ein einzelner Fieldset Eintrag mit dem Schlüssel '#{key}' wurde erwartet." end
53
53
  def self.expected_single_fieldset_with_key(key) "Nur ein einzelnes Fieldset mit dem Schlüssel '#{key}' wurde erwartet." end
@@ -57,7 +57,7 @@ module Enolib
57
57
  def self.key_error(message) "Es gibt ein Problem mit dem Schlüssel dieses Elements: #{message}" end
58
58
  def self.missing_element_for_continuation(line) "Zeile #{line} enthält eine Zeilenfortsetzung ohne dass davor ein fortsetzbares Element begonnen wurde." end
59
59
  def self.missing_element_with_key(key) "Das Element '#{key}' fehlt - falls es angegeben wurde eventuell nach Tippfehlern Ausschau halten und auch die Gross/Kleinschreibung beachten." end
60
- def self.missing_empty_with_key(key) "Das leere Element '#{key}' fehlt - falls es angegeben wurde eventuell nach Tippfehlern Ausschau halten und auch die Gross/Kleinschreibung beachten." end
60
+ def self.missing_empty_with_key(key) "Das Leerfeld '#{key}' fehlt - falls es angegeben wurde eventuell nach Tippfehlern Ausschau halten und auch die Gross/Kleinschreibung beachten." end
61
61
  def self.missing_field_value(key) "Das Feld '#{key}' muss einen Wert enthalten." end
62
62
  def self.missing_field_with_key(key) "Das Feld '#{key}' fehlt - falls es angegeben wurde eventuell nach Tippfehlern Ausschau halten und auch die Gross/Kleinschreibung beachten." end
63
63
  def self.missing_fieldset_entry_value(key) "Der Fieldset Eintrag '#{key}' muss einen Wert enthalten." end
@@ -1,13 +1,13 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # GENERATED ON 2019-05-30T07:54:15 - DO NOT EDIT MANUALLY
3
+ # GENERATED ON 2019-06-18T08:50:41 - DO NOT EDIT MANUALLY
4
4
 
5
5
  module Enolib
6
6
  module Locales
7
7
  module En
8
8
  CONTENT_HEADER = 'Content'
9
9
  EXPECTED_DOCUMENT = 'The document was expected.'
10
- EXPECTED_EMPTY = 'An empty element was expected.'
10
+ EXPECTED_EMPTY = 'An empty was expected.'
11
11
  EXPECTED_FIELD = 'A field was expected.'
12
12
  EXPECTED_FIELDS = 'Only fields were expected.'
13
13
  EXPECTED_FIELDSET = 'A fieldset was expected.'
@@ -19,7 +19,7 @@ module Enolib
19
19
  EXPECTED_SECTION = 'A section was expected.'
20
20
  EXPECTED_SECTIONS = 'Only sections were expected.'
21
21
  EXPECTED_SINGLE_ELEMENT = 'Only a single element was expected.'
22
- EXPECTED_SINGLE_EMPTY = 'Only a single empty element was expected.'
22
+ EXPECTED_SINGLE_EMPTY = 'Only a single empty was expected.'
23
23
  EXPECTED_SINGLE_FIELD = 'Only a single field was expected.'
24
24
  EXPECTED_SINGLE_FIELDSET = 'Only a single fieldset was expected.'
25
25
  EXPECTED_SINGLE_FIELDSET_ENTRY = 'Only a single fieldset entry was expected.'
@@ -28,7 +28,7 @@ module Enolib
28
28
  GUTTER_HEADER = 'Line'
29
29
  MISSING_COMMENT = 'A required comment for this element is missing.'
30
30
  MISSING_ELEMENT = 'A single element is required - it can have any key.'
31
- MISSING_EMPTY = 'A single empty element is required - it can have any key.'
31
+ MISSING_EMPTY = 'A single empty is required - it can have any key.'
32
32
  MISSING_FIELD = 'A single field is required - it can have any key.'
33
33
  MISSING_FIELDSET = 'A single fieldset is required - it can have any key.'
34
34
  MISSING_FIELDSET_ENTRY = 'A single fieldset entry is required - it can have any key.'
@@ -37,7 +37,7 @@ module Enolib
37
37
  UNEXPECTED_ELEMENT = 'This element was not expected, make sure it is at the right place in the document and that its key is not mis-typed.'
38
38
  def self.comment_error(message) "There is a problem with the comment of this element: #{message}" end
39
39
  def self.cyclic_dependency(line, key) "In line #{line} '#{key}' is copied into itself." end
40
- def self.expected_empty_with_key(key) "An empty element with the key '#{key}' was expected." end
40
+ def self.expected_empty_with_key(key) "An empty with the key '#{key}' was expected." end
41
41
  def self.expected_field_with_key(key) "A field with the key '#{key}' was expected." end
42
42
  def self.expected_fields_with_key(key) "Only fields with the key '#{key}' were expected." end
43
43
  def self.expected_fieldset_with_key(key) "A fieldset with the key '#{key}' was expected." end
@@ -47,7 +47,7 @@ module Enolib
47
47
  def self.expected_section_with_key(key) "A section with the key '#{key}' was expected." end
48
48
  def self.expected_sections_with_key(key) "Only sections with the key '#{key}' were expected." end
49
49
  def self.expected_single_element_with_key(key) "Only a single element with the key '#{key}' was expected." end
50
- def self.expected_single_empty_with_key(key) "Only a single empty element with the key '#{key}' was expected." end
50
+ def self.expected_single_empty_with_key(key) "Only a single empty with the key '#{key}' was expected." end
51
51
  def self.expected_single_field_with_key(key) "Only a single field with the key '#{key}' was expected." end
52
52
  def self.expected_single_fieldset_entry_with_key(key) "Only a single fieldset entry with the key '#{key}' was expected." end
53
53
  def self.expected_single_fieldset_with_key(key) "Only a single fieldset with the key '#{key}' was expected." end
@@ -57,7 +57,7 @@ module Enolib
57
57
  def self.key_error(message) "There is a problem with the key of this element: #{message}" end
58
58
  def self.missing_element_for_continuation(line) "Line #{line} contains a line continuation without a continuable element being specified before." end
59
59
  def self.missing_element_with_key(key) "The element '#{key}' is missing - in case it has been specified look for typos and also check for correct capitalization." end
60
- def self.missing_empty_with_key(key) "The empty element '#{key}' is missing - in case it has been specified look for typos and also check for correct capitalization." end
60
+ def self.missing_empty_with_key(key) "The empty '#{key}' is missing - in case it has been specified look for typos and also check for correct capitalization." end
61
61
  def self.missing_field_value(key) "The field '#{key}' must contain a value." end
62
62
  def self.missing_field_with_key(key) "The field '#{key}' is missing - in case it has been specified look for typos and also check for correct capitalization." end
63
63
  def self.missing_fieldset_entry_value(key) "The fieldset entry '#{key}' must contain a value." end
@@ -1,6 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # GENERATED ON 2019-05-30T07:54:15 - DO NOT EDIT MANUALLY
3
+ # GENERATED ON 2019-06-18T08:50:41 - DO NOT EDIT MANUALLY
4
4
 
5
5
  module Enolib
6
6
  module Locales
@@ -77,7 +77,7 @@ module Enolib
77
77
  instruction[:type] = :field
78
78
  instruction[:value] = value
79
79
  else
80
- instruction[:type] = :empty_element
80
+ instruction[:type] = :field_or_fieldset_or_list
81
81
  end
82
82
 
83
83
  instruction[:parent] = last_section
@@ -107,7 +107,7 @@ module Enolib
107
107
  raise Errors::Parsing.missing_list_for_list_item(@context, instruction)
108
108
  elsif last_non_section_element[:type] == :list
109
109
  last_non_section_element[:items].push(instruction)
110
- elsif last_non_section_element[:type] == :empty_element
110
+ elsif last_non_section_element[:type] == :field_or_fieldset_or_list
111
111
  last_non_section_element[:items] = [instruction]
112
112
  last_non_section_element[:type] = :list
113
113
  else
@@ -152,7 +152,7 @@ module Enolib
152
152
  raise Errors::Parsing.missing_fieldset_for_fieldset_entry(@context, instruction)
153
153
  elsif last_non_section_element[:type] == :fieldset
154
154
  last_non_section_element[:entries].push(instruction)
155
- elsif last_non_section_element[:type] == :empty_element
155
+ elsif last_non_section_element[:type] == :field_or_fieldset_or_list
156
156
  last_non_section_element[:entries] = [instruction]
157
157
  last_non_section_element[:type] = :fieldset
158
158
  else
@@ -184,7 +184,7 @@ module Enolib
184
184
  if last_continuable_element.has_key?(:continuations)
185
185
  last_continuable_element[:continuations].push(instruction)
186
186
  else
187
- if last_continuable_element[:type] == :empty_element
187
+ if last_continuable_element[:type] == :field_or_fieldset_or_list
188
188
  last_continuable_element[:type] = :field
189
189
  end
190
190
 
@@ -216,7 +216,7 @@ module Enolib
216
216
  if last_continuable_element.has_key?(:continuations)
217
217
  last_continuable_element[:continuations].push(instruction)
218
218
  else
219
- if last_continuable_element[:type] == :empty_element
219
+ if last_continuable_element[:type] == :field_or_fieldset_or_list
220
220
  last_continuable_element[:type] = :field
221
221
  end
222
222
 
@@ -427,7 +427,7 @@ module Enolib
427
427
  instruction[:ranges][:copy_operator] = match.offset(Grammar::COPY_OPERATOR_INDEX)
428
428
  instruction[:ranges][:template] = match.offset(Grammar::TEMPLATE_INDEX)
429
429
  instruction[:template] = template
430
- instruction[:type] = :empty_element
430
+ instruction[:type] = :field_or_fieldset_or_list
431
431
 
432
432
  instruction[:key] = match[Grammar::KEY_UNESCAPED_INDEX]
433
433
 
@@ -452,6 +452,40 @@ module Enolib
452
452
  end
453
453
 
454
454
  instruction[:copy] = @unresolved_non_section_elements[template]
455
+ elsif match[Grammar::KEY_UNESCAPED_INDEX]
456
+
457
+ if comments
458
+ instruction[:comments] = comments
459
+ comments = nil
460
+ end
461
+
462
+ instruction[:key] = match[Grammar::KEY_UNESCAPED_INDEX]
463
+ instruction[:ranges][:key] = match.offset(Grammar::KEY_UNESCAPED_INDEX)
464
+ instruction[:type] = :empty
465
+
466
+ instruction[:parent] = last_section
467
+ last_section[:elements].push(instruction)
468
+ last_continuable_element = nil
469
+ last_non_section_element = instruction
470
+
471
+ elsif match[Grammar::KEY_ESCAPED_INDEX]
472
+
473
+ if comments
474
+ instruction[:comments] = comments
475
+ comments = nil
476
+ end
477
+
478
+ instruction[:key] = match[Grammar::KEY_ESCAPED_INDEX]
479
+ instruction[:ranges][:escape_begin_operator] = match.offset(Grammar::KEY_ESCAPE_BEGIN_OPERATOR_INDEX)
480
+ instruction[:ranges][:escape_end_operator] = match.offset(Grammar::KEY_ESCAPE_END_OPERATOR_INDEX)
481
+ instruction[:ranges][:key] = match.offset(Grammar::KEY_ESCAPED_INDEX)
482
+ instruction[:type] = :empty
483
+
484
+ instruction[:parent] = last_section
485
+ last_section[:elements].push(instruction)
486
+ last_continuable_element = nil
487
+ last_non_section_element = instruction
488
+
455
489
  end
456
490
 
457
491
  unless multiline_field
@@ -474,7 +508,7 @@ module Enolib
474
508
  end
475
509
 
476
510
  case element[:type]
477
- when :empty_element
511
+ when :field_or_fieldset_or_list
478
512
  case template[:type]
479
513
  when :multiline_field_begin
480
514
  element[:type] = :field
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: enolib
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simon Repp
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-06-12 00:00:00.000000000 Z
11
+ date: 2019-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: deep-cover