asker-tool 2.1.7 → 2.2.3
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/{LICENSE.txt → LICENSE} +0 -0
- data/README.md +14 -15
- data/bin/asker +1 -1
- data/lib/asker/ai/ai.rb +6 -3
- data/lib/asker/ai/ai_calculate.rb +20 -6
- data/lib/asker/ai/concept_ai.rb +12 -3
- data/lib/asker/ai/question.rb +28 -6
- data/lib/asker/ai/stages/base_stage.rb +45 -6
- data/lib/asker/ai/stages/stage_b.rb +90 -49
- data/lib/asker/ai/stages/stage_d.rb +69 -90
- data/lib/asker/ai/stages/stage_f.rb +47 -38
- data/lib/asker/ai/stages/stage_i.rb +79 -92
- data/lib/asker/ai/stages/stage_s.rb +41 -36
- data/lib/asker/ai/stages/stage_t.rb +114 -73
- data/lib/asker/application.rb +7 -16
- data/lib/asker/check_input/check_haml_data.rb +264 -0
- data/lib/asker/check_input/check_table.rb +104 -0
- data/lib/asker/check_input.rb +51 -0
- data/lib/asker/cli.rb +47 -44
- data/lib/asker/data/code.rb +5 -16
- data/lib/asker/data/concept.rb +71 -24
- data/lib/asker/data/project_data.rb +63 -0
- data/lib/asker/data/table.rb +2 -0
- data/lib/asker/data/template.rb +3 -1
- data/lib/asker/data/world.rb +8 -16
- data/lib/asker/displayer/code_displayer.rb +7 -0
- data/lib/asker/displayer/concept_ai_displayer.erb +10 -0
- data/lib/asker/displayer/concept_ai_displayer.rb +24 -22
- data/lib/asker/displayer/concept_displayer.rb +9 -4
- data/lib/asker/displayer/stats_displayer.rb +8 -0
- data/lib/asker/exporter/concept_ai_gift_exporter.rb +7 -11
- data/lib/asker/exporter/concept_ai_moodle_exporter.rb +45 -0
- data/lib/asker/exporter/concept_ai_yaml_exporter.rb +6 -3
- data/lib/asker/exporter/concept_doc_exporter.rb +12 -2
- data/lib/asker/exporter/data_gift_exporter.rb +31 -0
- data/lib/asker/exporter/output_file_exporter.rb +9 -6
- data/lib/asker/files/{config.ini → asker.ini} +14 -4
- data/lib/asker/files/language/du/connectors.yaml +81 -0
- data/lib/asker/files/language/du/mistakes.yaml +82 -0
- data/lib/asker/files/language/du/templates.yaml +28 -49
- data/lib/asker/files/language/en/templates.yaml +19 -19
- data/lib/asker/files/language/es/mistakes.yaml +9 -7
- data/lib/asker/files/language/es/templates.yaml +19 -19
- data/lib/asker/files/language/fr/connectors.yaml +68 -84
- data/lib/asker/files/language/fr/templates.yaml +22 -22
- data/lib/asker/formatter/concept_doc_formatter.rb +0 -4
- data/lib/asker/formatter/concept_string_formatter.rb +7 -4
- data/lib/asker/formatter/moodle/matching.erb +38 -0
- data/lib/asker/formatter/moodle/multichoice.erb +49 -0
- data/lib/asker/formatter/moodle/shortanswer.erb +30 -0
- data/lib/asker/formatter/moodle/truefalse.erb +47 -0
- data/lib/asker/formatter/question_gift_formatter.rb +21 -19
- data/lib/asker/formatter/question_moodle_formatter.rb +27 -0
- data/lib/asker/lang/lang_factory.rb +7 -1
- data/lib/asker/loader/code_loader.rb +1 -1
- data/lib/asker/loader/content_loader.rb +12 -14
- data/lib/asker/loader/directory_loader.rb +1 -8
- data/lib/asker/loader/embedded_file.rb +42 -0
- data/lib/asker/loader/file_loader.rb +1 -6
- data/lib/asker/loader/haml_loader.rb +9 -5
- data/lib/asker/loader/image_url_loader.rb +8 -9
- data/lib/asker/loader/input_loader.rb +5 -6
- data/lib/asker/loader/project_loader.rb +18 -10
- data/lib/asker/logger.rb +36 -9
- data/lib/asker/skeleton.rb +3 -2
- data/lib/asker/version.rb +9 -0
- data/lib/asker.rb +72 -43
- metadata +60 -18
- data/lib/asker/checker.rb +0 -455
- data/lib/asker/project.rb +0 -146
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: asker-tool
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Vargas Ruiz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2022-02-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: haml
|
@@ -52,6 +52,34 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: colorize
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.8'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.8'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rexml
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '3.2'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '3.2'
|
55
83
|
- !ruby/object:Gem::Dependency
|
56
84
|
name: terminal-table
|
57
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,33 +109,33 @@ dependencies:
|
|
81
109
|
- !ruby/object:Gem::Version
|
82
110
|
version: '0.20'
|
83
111
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
112
|
+
name: minitest
|
85
113
|
requirement: !ruby/object:Gem::Requirement
|
86
114
|
requirements:
|
87
115
|
- - "~>"
|
88
116
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
90
|
-
type: :
|
117
|
+
version: '5.11'
|
118
|
+
type: :development
|
91
119
|
prerelease: false
|
92
120
|
version_requirements: !ruby/object:Gem::Requirement
|
93
121
|
requirements:
|
94
122
|
- - "~>"
|
95
123
|
- !ruby/object:Gem::Version
|
96
|
-
version: '
|
124
|
+
version: '5.11'
|
97
125
|
- !ruby/object:Gem::Dependency
|
98
|
-
name:
|
126
|
+
name: pry-byebug
|
99
127
|
requirement: !ruby/object:Gem::Requirement
|
100
128
|
requirements:
|
101
129
|
- - "~>"
|
102
130
|
- !ruby/object:Gem::Version
|
103
|
-
version: '
|
131
|
+
version: '3.9'
|
104
132
|
type: :development
|
105
133
|
prerelease: false
|
106
134
|
version_requirements: !ruby/object:Gem::Requirement
|
107
135
|
requirements:
|
108
136
|
- - "~>"
|
109
137
|
- !ruby/object:Gem::Version
|
110
|
-
version: '
|
138
|
+
version: '3.9'
|
111
139
|
- !ruby/object:Gem::Dependency
|
112
140
|
name: rubocop
|
113
141
|
requirement: !ruby/object:Gem::Requirement
|
@@ -130,9 +158,9 @@ executables:
|
|
130
158
|
extensions: []
|
131
159
|
extra_rdoc_files:
|
132
160
|
- README.md
|
133
|
-
- LICENSE
|
161
|
+
- LICENSE
|
134
162
|
files:
|
135
|
-
- LICENSE
|
163
|
+
- LICENSE
|
136
164
|
- README.md
|
137
165
|
- bin/asker
|
138
166
|
- lib/asker.rb
|
@@ -156,28 +184,36 @@ files:
|
|
156
184
|
- lib/asker/ai/stages/stage_s.rb
|
157
185
|
- lib/asker/ai/stages/stage_t.rb
|
158
186
|
- lib/asker/application.rb
|
159
|
-
- lib/asker/
|
187
|
+
- lib/asker/check_input.rb
|
188
|
+
- lib/asker/check_input/check_haml_data.rb
|
189
|
+
- lib/asker/check_input/check_table.rb
|
160
190
|
- lib/asker/cli.rb
|
161
191
|
- lib/asker/data/code.rb
|
162
192
|
- lib/asker/data/column.rb
|
163
193
|
- lib/asker/data/concept.rb
|
164
194
|
- lib/asker/data/data_field.rb
|
195
|
+
- lib/asker/data/project_data.rb
|
165
196
|
- lib/asker/data/row.rb
|
166
197
|
- lib/asker/data/table.rb
|
167
198
|
- lib/asker/data/template.rb
|
168
199
|
- lib/asker/data/world.rb
|
169
200
|
- lib/asker/displayer/code_displayer.rb
|
201
|
+
- lib/asker/displayer/concept_ai_displayer.erb
|
170
202
|
- lib/asker/displayer/concept_ai_displayer.rb
|
171
203
|
- lib/asker/displayer/concept_displayer.rb
|
172
204
|
- lib/asker/displayer/stats_displayer.rb
|
173
205
|
- lib/asker/exporter/code_gift_exporter.rb
|
174
206
|
- lib/asker/exporter/concept_ai_gift_exporter.rb
|
207
|
+
- lib/asker/exporter/concept_ai_moodle_exporter.rb
|
175
208
|
- lib/asker/exporter/concept_ai_yaml_exporter.rb
|
176
209
|
- lib/asker/exporter/concept_doc_exporter.rb
|
210
|
+
- lib/asker/exporter/data_gift_exporter.rb
|
177
211
|
- lib/asker/exporter/output_file_exporter.rb
|
178
|
-
- lib/asker/files/
|
212
|
+
- lib/asker/files/asker.ini
|
179
213
|
- lib/asker/files/example-code.haml
|
180
214
|
- lib/asker/files/example-concept.haml
|
215
|
+
- lib/asker/files/language/du/connectors.yaml
|
216
|
+
- lib/asker/files/language/du/mistakes.yaml
|
181
217
|
- lib/asker/files/language/du/templates.yaml
|
182
218
|
- lib/asker/files/language/en/connectors.yaml
|
183
219
|
- lib/asker/files/language/en/mistakes.yaml
|
@@ -206,8 +242,13 @@ files:
|
|
206
242
|
- lib/asker/formatter/code_string_formatter.rb
|
207
243
|
- lib/asker/formatter/concept_doc_formatter.rb
|
208
244
|
- lib/asker/formatter/concept_string_formatter.rb
|
245
|
+
- lib/asker/formatter/moodle/matching.erb
|
246
|
+
- lib/asker/formatter/moodle/multichoice.erb
|
247
|
+
- lib/asker/formatter/moodle/shortanswer.erb
|
248
|
+
- lib/asker/formatter/moodle/truefalse.erb
|
209
249
|
- lib/asker/formatter/question_gift_formatter.rb
|
210
250
|
- lib/asker/formatter/question_hash_formatter.rb
|
251
|
+
- lib/asker/formatter/question_moodle_formatter.rb
|
211
252
|
- lib/asker/formatter/question_moodlexml_formatter.rb
|
212
253
|
- lib/asker/formatter/rb2haml_formatter.rb
|
213
254
|
- lib/asker/lang/lang.rb
|
@@ -216,19 +257,20 @@ files:
|
|
216
257
|
- lib/asker/loader/code_loader.rb
|
217
258
|
- lib/asker/loader/content_loader.rb
|
218
259
|
- lib/asker/loader/directory_loader.rb
|
260
|
+
- lib/asker/loader/embedded_file.rb
|
219
261
|
- lib/asker/loader/file_loader.rb
|
220
262
|
- lib/asker/loader/haml_loader.rb
|
221
263
|
- lib/asker/loader/image_url_loader.rb
|
222
264
|
- lib/asker/loader/input_loader.rb
|
223
265
|
- lib/asker/loader/project_loader.rb
|
224
266
|
- lib/asker/logger.rb
|
225
|
-
- lib/asker/project.rb
|
226
267
|
- lib/asker/skeleton.rb
|
227
|
-
|
268
|
+
- lib/asker/version.rb
|
269
|
+
homepage: https://github.com/teuton-software/asker/tree/v2.2
|
228
270
|
licenses:
|
229
271
|
- GPL-3.0
|
230
272
|
metadata: {}
|
231
|
-
post_install_message:
|
273
|
+
post_install_message:
|
232
274
|
rdoc_options: []
|
233
275
|
require_paths:
|
234
276
|
- lib
|
@@ -236,14 +278,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
236
278
|
requirements:
|
237
279
|
- - ">="
|
238
280
|
- !ruby/object:Gem::Version
|
239
|
-
version: 2.
|
281
|
+
version: 2.6.9
|
240
282
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
241
283
|
requirements:
|
242
284
|
- - ">="
|
243
285
|
- !ruby/object:Gem::Version
|
244
286
|
version: '0'
|
245
287
|
requirements: []
|
246
|
-
rubygems_version: 3.1.
|
288
|
+
rubygems_version: 3.1.6
|
247
289
|
signing_key:
|
248
290
|
specification_version: 4
|
249
291
|
summary: Asker generates questions from input definitions file.
|
data/lib/asker/checker.rb
DELETED
@@ -1,455 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'rainbow'
|
4
|
-
|
5
|
-
##
|
6
|
-
# Check HAML file syntax
|
7
|
-
module Checker
|
8
|
-
##
|
9
|
-
# Check:
|
10
|
-
# * file exist
|
11
|
-
# * filename extension
|
12
|
-
# * and HAML syntax
|
13
|
-
# @param filepath (String)
|
14
|
-
def self.check(filepath)
|
15
|
-
unless File.exist? filepath
|
16
|
-
puts Rainbow('File not found!').red.bright
|
17
|
-
return false
|
18
|
-
end
|
19
|
-
unless File.extname(filepath) == '.haml'
|
20
|
-
puts Rainbow('Only check HAML files!').yellow.bright
|
21
|
-
return false
|
22
|
-
end
|
23
|
-
check_filepath(filepath)
|
24
|
-
end
|
25
|
-
|
26
|
-
##
|
27
|
-
# Check HAML syntax
|
28
|
-
# @param filepath (String)
|
29
|
-
def self.check_filepath(filepath)
|
30
|
-
data = Data.new(filepath)
|
31
|
-
data.check
|
32
|
-
data.show_errors
|
33
|
-
data.ok?
|
34
|
-
end
|
35
|
-
|
36
|
-
##
|
37
|
-
# Internal class that revise syntax
|
38
|
-
# rubocop:disable Metrics/ClassLength
|
39
|
-
class Data
|
40
|
-
attr_reader :inputs
|
41
|
-
attr_reader :outputs
|
42
|
-
|
43
|
-
# rubocop:disable Metrics/MethodLength
|
44
|
-
def initialize(filepath)
|
45
|
-
@inputs = File.read(filepath).split("\n")
|
46
|
-
@outputs = []
|
47
|
-
@inputs.each_with_index do |line, index|
|
48
|
-
output = { id: index,
|
49
|
-
level: 0,
|
50
|
-
state: :none,
|
51
|
-
type: :none,
|
52
|
-
source: line,
|
53
|
-
msg: '' }
|
54
|
-
@outputs << output
|
55
|
-
end
|
56
|
-
@ok = false
|
57
|
-
end
|
58
|
-
# rubocop:enable Metrics/MethodLength
|
59
|
-
|
60
|
-
def ok?
|
61
|
-
@ok
|
62
|
-
end
|
63
|
-
|
64
|
-
def show
|
65
|
-
@outputs.each do |i|
|
66
|
-
puts "#{i[:id]}: #{i[:state]} [#{i[:type]}] #{i[:msg]}"
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
# rubocop:disable Metrics/AbcSize
|
71
|
-
# rubocop:disable Metrics/MethodLength
|
72
|
-
def show_errors
|
73
|
-
errors = 0
|
74
|
-
# puts "Line : Error description"
|
75
|
-
@outputs.each do |i|
|
76
|
-
next if i[:state] == :ok
|
77
|
-
|
78
|
-
errors += 1
|
79
|
-
if errors < 11
|
80
|
-
data = { id: i[:id], msg: i[:msg], source: i[:source][0, 40] }
|
81
|
-
puts format(' %<id>03d : %<msg>s. => %<source>s', data)
|
82
|
-
end
|
83
|
-
puts '...' if errors == 11
|
84
|
-
end
|
85
|
-
|
86
|
-
if errors.positive?
|
87
|
-
puts Rainbow("[ERROR] #{errors} errors " \
|
88
|
-
"from #{@inputs.size} lines!").red.bright
|
89
|
-
end
|
90
|
-
puts Rainbow('Syntax OK!').green if errors.zero?
|
91
|
-
end
|
92
|
-
# rubocop:enable Metrics/AbcSize
|
93
|
-
# rubocop:enable Metrics/MethodLength
|
94
|
-
|
95
|
-
# rubocop:disable Metrics/MethodLength
|
96
|
-
# rubocop:disable Metrics/AbcSize
|
97
|
-
def check
|
98
|
-
@ok = true
|
99
|
-
@inputs.each_with_index do |line, index|
|
100
|
-
check_empty_lines(line, index)
|
101
|
-
check_map(line, index)
|
102
|
-
check_concept(line, index)
|
103
|
-
check_names(line, index)
|
104
|
-
check_tags(line, index)
|
105
|
-
check_def(line, index)
|
106
|
-
check_table(line, index)
|
107
|
-
check_row(line, index)
|
108
|
-
check_col(line, index)
|
109
|
-
check_template(line, index)
|
110
|
-
check_code(line, index)
|
111
|
-
check_type(line, index)
|
112
|
-
check_path(line, index)
|
113
|
-
check_features(line, index)
|
114
|
-
check_unknown(line, index)
|
115
|
-
@ok = false unless @outputs[index][:state] == :ok
|
116
|
-
@ok = false if @outputs[index][:type] == :unkown
|
117
|
-
end
|
118
|
-
@ok
|
119
|
-
end
|
120
|
-
# rubocop:enable Metrics/MethodLength
|
121
|
-
# rubocop:enable Metrics/AbcSize
|
122
|
-
|
123
|
-
private
|
124
|
-
|
125
|
-
def check_empty_lines(line, index)
|
126
|
-
return unless line.strip.size.zero? || line.start_with?('#')
|
127
|
-
|
128
|
-
@outputs[index][:type] = :empty
|
129
|
-
@outputs[index][:level] = -1
|
130
|
-
@outputs[index][:state] = :ok
|
131
|
-
end
|
132
|
-
|
133
|
-
# rubocop:disable Metrics/MethodLength
|
134
|
-
def check_map(line, index)
|
135
|
-
if index.zero?
|
136
|
-
@outputs[index][:type] = :map
|
137
|
-
if line.start_with?('%map{')
|
138
|
-
@outputs[index][:state] = :ok
|
139
|
-
else
|
140
|
-
@outputs[index][:state] = :err
|
141
|
-
@outputs[index][:msg] = 'Start with %map{'
|
142
|
-
end
|
143
|
-
elsif index.positive? && line.include?('%map{')
|
144
|
-
@outputs[index][:state] = :err
|
145
|
-
@outputs[index][:type] = :map
|
146
|
-
@outputs[index][:msg] = 'Write %map on line 0'
|
147
|
-
end
|
148
|
-
end
|
149
|
-
# rubocop:enable Metrics/MethodLength
|
150
|
-
|
151
|
-
# rubocop:disable Metrics/MethodLength
|
152
|
-
def check_concept(line, index)
|
153
|
-
return unless @outputs[index][:state] == :none
|
154
|
-
return unless line.include? '%concept'
|
155
|
-
|
156
|
-
@outputs[index][:type] = :concept
|
157
|
-
@outputs[index][:level] = 1
|
158
|
-
@outputs[index][:state] = :ok
|
159
|
-
if find_parent(index) != :map
|
160
|
-
@outputs[index][:state] = :err
|
161
|
-
@outputs[index][:msg] = 'Parent(map) not found!'
|
162
|
-
elsif line != ' %concept'
|
163
|
-
@outputs[index][:state] = :err
|
164
|
-
@outputs[index][:msg] = 'Write 2 spaces before %concept'
|
165
|
-
end
|
166
|
-
end
|
167
|
-
# rubocop:enable Metrics/MethodLength
|
168
|
-
|
169
|
-
# rubocop:disable Metrics/AbcSize
|
170
|
-
# rubocop:disable Metrics/MethodLength
|
171
|
-
def check_names(line, index)
|
172
|
-
return unless @outputs[index][:state] == :none
|
173
|
-
return unless line.include? '%names'
|
174
|
-
|
175
|
-
@outputs[index][:type] = :names
|
176
|
-
@outputs[index][:level] = 2
|
177
|
-
@outputs[index][:state] = :ok
|
178
|
-
if find_parent(index) != :concept
|
179
|
-
@outputs[index][:state] = :err
|
180
|
-
@outputs[index][:msg] = 'Parent(concept) not found!'
|
181
|
-
elsif !line.start_with? ' %names'
|
182
|
-
@outputs[index][:state] = :err
|
183
|
-
@outputs[index][:msg] = 'Write 4 spaces before %names'
|
184
|
-
end
|
185
|
-
end
|
186
|
-
# rubocop:enable Metrics/AbcSize
|
187
|
-
# rubocop:enable Metrics/MethodLength
|
188
|
-
|
189
|
-
# rubocop:disable Metrics/AbcSize
|
190
|
-
# rubocop:disable Metrics/MethodLength
|
191
|
-
def check_tags(line, index)
|
192
|
-
return unless @outputs[index][:state] == :none
|
193
|
-
return unless line.include? '%tags'
|
194
|
-
|
195
|
-
@outputs[index][:type] = :tags
|
196
|
-
@outputs[index][:level] = 2
|
197
|
-
@outputs[index][:state] = :ok
|
198
|
-
if find_parent(index) != :concept
|
199
|
-
@outputs[index][:state] = :err
|
200
|
-
@outputs[index][:msg] = 'Parent(concept) not found!'
|
201
|
-
elsif !line.start_with? ' %tags'
|
202
|
-
@outputs[index][:state] = :err
|
203
|
-
@outputs[index][:msg] = 'Write 4 spaces before %tags'
|
204
|
-
end
|
205
|
-
end
|
206
|
-
# rubocop:enable Metrics/AbcSize
|
207
|
-
# rubocop:enable Metrics/MethodLength
|
208
|
-
|
209
|
-
# rubocop:disable Metrics/AbcSize
|
210
|
-
# rubocop:disable Metrics/MethodLength
|
211
|
-
def check_def(line, index)
|
212
|
-
return unless @outputs[index][:state] == :none
|
213
|
-
return unless line.include? '%def'
|
214
|
-
|
215
|
-
@outputs[index][:type] = :def
|
216
|
-
@outputs[index][:level] = 2
|
217
|
-
@outputs[index][:state] = :ok
|
218
|
-
if find_parent(index) != :concept
|
219
|
-
@outputs[index][:state] = :err
|
220
|
-
@outputs[index][:msg] = 'Parent(concept) not found!'
|
221
|
-
elsif !line.start_with? ' %def'
|
222
|
-
@outputs[index][:state] = :err
|
223
|
-
@outputs[index][:msg] = 'Write 4 spaces before %def'
|
224
|
-
end
|
225
|
-
end
|
226
|
-
# rubocop:enable Metrics/AbcSize
|
227
|
-
# rubocop:enable Metrics/MethodLength
|
228
|
-
|
229
|
-
# rubocop:disable Metrics/AbcSize
|
230
|
-
# rubocop:disable Metrics/MethodLength
|
231
|
-
def check_table(line, index)
|
232
|
-
return unless @outputs[index][:state] == :none
|
233
|
-
return unless line.include? '%table'
|
234
|
-
|
235
|
-
@outputs[index][:type] = :table
|
236
|
-
@outputs[index][:level] = 2
|
237
|
-
@outputs[index][:state] = :ok
|
238
|
-
if find_parent(index) != :concept
|
239
|
-
@outputs[index][:state] = :err
|
240
|
-
@outputs[index][:msg] = 'Parent(concept) not found!'
|
241
|
-
elsif !line.start_with? ' %table'
|
242
|
-
@outputs[index][:state] = :err
|
243
|
-
@outputs[index][:msg] = 'Write 4 spaces before %table'
|
244
|
-
end
|
245
|
-
end
|
246
|
-
# rubocop:enable Metrics/AbcSize
|
247
|
-
# rubocop:enable Metrics/MethodLength
|
248
|
-
|
249
|
-
# rubocop:disable Metrics/AbcSize
|
250
|
-
# rubocop:disable Metrics/CyclomaticComplexity
|
251
|
-
# rubocop:disable Metrics/MethodLength
|
252
|
-
# rubocop:disable Metrics/PerceivedComplexity
|
253
|
-
def check_row(line, index)
|
254
|
-
return unless @outputs[index][:state] == :none
|
255
|
-
return unless line.include? '%row'
|
256
|
-
|
257
|
-
@outputs[index][:type] = :row
|
258
|
-
@outputs[index][:state] = :ok
|
259
|
-
|
260
|
-
if count_spaces(line) == 6
|
261
|
-
@outputs[index][:level] = 3
|
262
|
-
parent = find_parent(index)
|
263
|
-
unless %i[table features].include? parent
|
264
|
-
@outputs[index][:state] = :err
|
265
|
-
@outputs[index][:msg] = 'Parent(table/features) not found!'
|
266
|
-
end
|
267
|
-
elsif count_spaces(line) == 8
|
268
|
-
@outputs[index][:level] = 4
|
269
|
-
if find_parent(index) != :template
|
270
|
-
@outputs[index][:state] = :err
|
271
|
-
@outputs[index][:msg] = 'Parent(template) not found!'
|
272
|
-
end
|
273
|
-
else
|
274
|
-
@outputs[index][:state] = :err
|
275
|
-
@outputs[index][:msg] = 'Write 6 or 8 spaces before %row'
|
276
|
-
end
|
277
|
-
end
|
278
|
-
# rubocop:enable Metrics/AbcSize
|
279
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
280
|
-
# rubocop:enable Metrics/MethodLength
|
281
|
-
# rubocop:enable Metrics/PerceivedComplexity
|
282
|
-
|
283
|
-
# rubocop:disable Metrics/AbcSize
|
284
|
-
# rubocop:disable Metrics/CyclomaticComplexity
|
285
|
-
# rubocop:disable Metrics/MethodLength
|
286
|
-
# rubocop:disable Metrics/PerceivedComplexity
|
287
|
-
def check_col(line, index)
|
288
|
-
return unless @outputs[index][:state] == :none
|
289
|
-
return unless line.include? '%col'
|
290
|
-
|
291
|
-
@outputs[index][:type] = :col
|
292
|
-
@outputs[index][:state] = :ok
|
293
|
-
if count_spaces(line) == 8
|
294
|
-
@outputs[index][:level] = 4
|
295
|
-
if find_parent(index) != :row
|
296
|
-
@outputs[index][:state] = :err
|
297
|
-
@outputs[index][:msg] = 'Parent(row) not found!'
|
298
|
-
end
|
299
|
-
elsif count_spaces(line) == 10
|
300
|
-
@outputs[index][:level] = 5
|
301
|
-
if find_parent(index) != :row
|
302
|
-
@outputs[index][:state] = :err
|
303
|
-
@outputs[index][:msg] = 'Parent(row) not found!'
|
304
|
-
end
|
305
|
-
else
|
306
|
-
@outputs[index][:state] = :err
|
307
|
-
@outputs[index][:msg] = 'Write 8 or 10 spaces before %col'
|
308
|
-
end
|
309
|
-
check_text(line, index)
|
310
|
-
end
|
311
|
-
# rubocop:enable Metrics/AbcSize
|
312
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
313
|
-
# rubocop:enable Metrics/MethodLength
|
314
|
-
# rubocop:enable Metrics/PerceivedComplexity
|
315
|
-
|
316
|
-
def check_text(line, index)
|
317
|
-
return unless @outputs[index][:state] == :ok
|
318
|
-
|
319
|
-
ok = ''
|
320
|
-
%w[< >].each do |char|
|
321
|
-
ok = char if line.include? char
|
322
|
-
end
|
323
|
-
return if ok == ''
|
324
|
-
|
325
|
-
@outputs[index][:state] = :err
|
326
|
-
@outputs[index][:msg] = "Char #{ok} not allow!"
|
327
|
-
end
|
328
|
-
|
329
|
-
# rubocop:disable Metrics/MethodLength
|
330
|
-
# rubocop:disable Metrics/AbcSize
|
331
|
-
def check_template(line, index)
|
332
|
-
return unless @outputs[index][:state] == :none
|
333
|
-
return unless line.include? '%template'
|
334
|
-
|
335
|
-
@outputs[index][:type] = :template
|
336
|
-
@outputs[index][:level] = 3
|
337
|
-
@outputs[index][:state] = :ok
|
338
|
-
if find_parent(index) != :table
|
339
|
-
@outputs[index][:state] = :err
|
340
|
-
@outputs[index][:msg] = 'Parent(concept) not found!'
|
341
|
-
elsif !line.start_with? ' %template'
|
342
|
-
@outputs[index][:state] = :err
|
343
|
-
@outputs[index][:msg] = 'Write 6 spaces before %template'
|
344
|
-
end
|
345
|
-
end
|
346
|
-
# rubocop:enable Metrics/AbcSize
|
347
|
-
# rubocop:enable Metrics/MethodLength
|
348
|
-
|
349
|
-
# rubocop:disable Metrics/MethodLength
|
350
|
-
def check_code(line, index)
|
351
|
-
return unless @outputs[index][:state] == :none
|
352
|
-
return unless line.include? '%code'
|
353
|
-
|
354
|
-
@outputs[index][:type] = :code
|
355
|
-
@outputs[index][:level] = 1
|
356
|
-
@outputs[index][:state] = :ok
|
357
|
-
if find_parent(index) != :map
|
358
|
-
@outputs[index][:state] = :err
|
359
|
-
@outputs[index][:msg] = 'Parent(map) not found!'
|
360
|
-
elsif line != ' %code'
|
361
|
-
@outputs[index][:state] = :err
|
362
|
-
@outputs[index][:msg] = 'Write 2 spaces before %code'
|
363
|
-
end
|
364
|
-
end
|
365
|
-
# rubocop:enable Metrics/MethodLength
|
366
|
-
|
367
|
-
# rubocop:disable Metrics/MethodLength
|
368
|
-
# rubocop:disable Metrics/AbcSize
|
369
|
-
def check_type(line, index)
|
370
|
-
return unless @outputs[index][:state] == :none
|
371
|
-
return unless line.include? '%type'
|
372
|
-
|
373
|
-
@outputs[index][:type] = :type
|
374
|
-
@outputs[index][:level] = 2
|
375
|
-
@outputs[index][:state] = :ok
|
376
|
-
if find_parent(index) != :code
|
377
|
-
@outputs[index][:state] = :err
|
378
|
-
@outputs[index][:msg] = 'Parent(code) not found!'
|
379
|
-
elsif !line.start_with? ' %type'
|
380
|
-
@outputs[index][:state] = :err
|
381
|
-
@outputs[index][:msg] = 'Write 4 spaces before %type'
|
382
|
-
end
|
383
|
-
end
|
384
|
-
# rubocop:enable Metrics/AbcSize
|
385
|
-
# rubocop:enable Metrics/MethodLength
|
386
|
-
|
387
|
-
# rubocop:disable Metrics/MethodLength
|
388
|
-
# rubocop:disable Metrics/AbcSize
|
389
|
-
def check_path(line, index)
|
390
|
-
return unless @outputs[index][:state] == :none
|
391
|
-
return unless line.include? '%path'
|
392
|
-
|
393
|
-
@outputs[index][:type] = :path
|
394
|
-
@outputs[index][:level] = 2
|
395
|
-
@outputs[index][:state] = :ok
|
396
|
-
if find_parent(index) != :code
|
397
|
-
@outputs[index][:state] = :err
|
398
|
-
@outputs[index][:msg] = 'Parent(code) not found!'
|
399
|
-
elsif !line.start_with? ' %path'
|
400
|
-
@outputs[index][:state] = :err
|
401
|
-
@outputs[index][:msg] = 'Write 4 spaces before %type'
|
402
|
-
end
|
403
|
-
end
|
404
|
-
# rubocop:enable Metrics/AbcSize
|
405
|
-
# rubocop:enable Metrics/MethodLength
|
406
|
-
|
407
|
-
# rubocop:disable Metrics/MethodLength
|
408
|
-
# rubocop:disable Metrics/AbcSize
|
409
|
-
def check_features(line, index)
|
410
|
-
return unless @outputs[index][:state] == :none
|
411
|
-
return unless line.include? '%features'
|
412
|
-
|
413
|
-
@outputs[index][:type] = :features
|
414
|
-
@outputs[index][:level] = 2
|
415
|
-
@outputs[index][:state] = :ok
|
416
|
-
if find_parent(index) != :code
|
417
|
-
@outputs[index][:state] = :err
|
418
|
-
@outputs[index][:msg] = 'Parent(code) not found!'
|
419
|
-
elsif !line.start_with? ' %features'
|
420
|
-
@outputs[index][:state] = :err
|
421
|
-
@outputs[index][:msg] = 'Write 4 spaces before %features'
|
422
|
-
end
|
423
|
-
end
|
424
|
-
# rubocop:enable Metrics/AbcSize
|
425
|
-
# rubocop:enable Metrics/MethodLength
|
426
|
-
|
427
|
-
def check_unknown(line, index)
|
428
|
-
return unless @outputs[index][:state] == :none
|
429
|
-
|
430
|
-
@outputs[index][:type] = :unknown
|
431
|
-
@outputs[index][:level] = count_spaces(line) / 2
|
432
|
-
@outputs[index][:state] = :err
|
433
|
-
@outputs[index][:msg] = "Unknown tag with parent(#{find_parent(index)})!"
|
434
|
-
end
|
435
|
-
|
436
|
-
def find_parent(index)
|
437
|
-
current_level = @outputs[index][:level]
|
438
|
-
return :noparent if current_level.zero?
|
439
|
-
|
440
|
-
i = index - 1
|
441
|
-
while i >= 0
|
442
|
-
return @outputs[i][:type] if @outputs[i][:level] == current_level - 1
|
443
|
-
|
444
|
-
i -= 1
|
445
|
-
end
|
446
|
-
:noparent
|
447
|
-
end
|
448
|
-
|
449
|
-
def count_spaces(line)
|
450
|
-
a = line.split('%')
|
451
|
-
a[0].count(' ')
|
452
|
-
end
|
453
|
-
end
|
454
|
-
# rubocop:enable Metrics/ClassLength
|
455
|
-
end
|