asker-tool 2.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/LICENSE +674 -0
- data/README.md +53 -0
- data/bin/asker +4 -0
- data/docs/changelog/v2.1.md +99 -0
- data/docs/commands.md +15 -0
- data/docs/contributions.md +18 -0
- data/docs/history.md +40 -0
- data/docs/idea.md +44 -0
- data/docs/inputs/README.md +39 -0
- data/docs/inputs/code.md +69 -0
- data/docs/inputs/concepts.md +142 -0
- data/docs/inputs/jedi.md +68 -0
- data/docs/inputs/tables.md +112 -0
- data/docs/inputs/templates.md +87 -0
- data/docs/install/README.md +38 -0
- data/docs/install/manual.md +26 -0
- data/docs/install/scripts.md +26 -0
- data/docs/revise/asker-file.md +41 -0
- data/docs/revise/buenas-practicas/01-convocatoria.md +30 -0
- data/docs/revise/buenas-practicas/02-formulario.md +35 -0
- data/docs/revise/buenas-practicas/03-descripcion.md +63 -0
- data/docs/revise/buenas-practicas/04-resultados.md +17 -0
- data/docs/revise/buenas-practicas/05-reproducir.md +10 -0
- data/docs/revise/ejemplos/01/README.md +27 -0
- data/docs/revise/ejemplos/02/README.md +31 -0
- data/docs/revise/ejemplos/03/README.md +31 -0
- data/docs/revise/ejemplos/04/README.md +37 -0
- data/docs/revise/ejemplos/05/README.md +25 -0
- data/docs/revise/ejemplos/06/README.md +43 -0
- data/docs/revise/ejemplos/README.md +11 -0
- data/docs/revise/projects.md +74 -0
- data/lib/asker.rb +103 -0
- data/lib/asker/ai/ai.rb +70 -0
- data/lib/asker/ai/ai_calculate.rb +55 -0
- data/lib/asker/ai/concept_ai.rb +49 -0
- data/lib/asker/ai/question.rb +58 -0
- data/lib/asker/ai/stages/base_stage.rb +16 -0
- data/lib/asker/ai/stages/main.rb +8 -0
- data/lib/asker/ai/stages/stage_b.rb +87 -0
- data/lib/asker/ai/stages/stage_d.rb +160 -0
- data/lib/asker/ai/stages/stage_f.rb +156 -0
- data/lib/asker/ai/stages/stage_i.rb +140 -0
- data/lib/asker/ai/stages/stage_s.rb +52 -0
- data/lib/asker/ai/stages/stage_t.rb +170 -0
- data/lib/asker/application.rb +30 -0
- data/lib/asker/checker.rb +356 -0
- data/lib/asker/cli.rb +85 -0
- data/lib/asker/code/ai/base_code_ai.rb +48 -0
- data/lib/asker/code/ai/code_ai_factory.rb +26 -0
- data/lib/asker/code/ai/javascript_code_ai.rb +167 -0
- data/lib/asker/code/ai/python_code_ai.rb +167 -0
- data/lib/asker/code/ai/ruby_code_ai.rb +169 -0
- data/lib/asker/code/ai/sql_code_ai.rb +69 -0
- data/lib/asker/code/code.rb +53 -0
- data/lib/asker/data/column.rb +62 -0
- data/lib/asker/data/concept.rb +183 -0
- data/lib/asker/data/data_field.rb +87 -0
- data/lib/asker/data/row.rb +93 -0
- data/lib/asker/data/table.rb +96 -0
- data/lib/asker/data/template.rb +65 -0
- data/lib/asker/data/world.rb +53 -0
- data/lib/asker/exporter/code_gift_exporter.rb +35 -0
- data/lib/asker/exporter/code_screen_exporter.rb +45 -0
- data/lib/asker/exporter/concept_ai_gift_exporter.rb +33 -0
- data/lib/asker/exporter/concept_ai_screen_exporter.rb +115 -0
- data/lib/asker/exporter/concept_ai_yaml_exporter.rb +33 -0
- data/lib/asker/exporter/concept_doc_exporter.rb +21 -0
- data/lib/asker/exporter/concept_screen_exporter.rb +25 -0
- data/lib/asker/exporter/main.rb +9 -0
- data/lib/asker/files/config.ini +40 -0
- data/lib/asker/formatter/code_string_formatter.rb +16 -0
- data/lib/asker/formatter/concept_doc_formatter.rb +37 -0
- data/lib/asker/formatter/concept_string_formatter.rb +66 -0
- data/lib/asker/formatter/question_gift_formatter.rb +65 -0
- data/lib/asker/formatter/question_hash_formatter.rb +40 -0
- data/lib/asker/formatter/question_moodlexml_formatter.rb +71 -0
- data/lib/asker/formatter/rb2haml_formatter.rb +26 -0
- data/lib/asker/lang/lang.rb +42 -0
- data/lib/asker/lang/lang_factory.rb +19 -0
- data/lib/asker/lang/text_actions.rb +150 -0
- data/lib/asker/loader/code_loader.rb +53 -0
- data/lib/asker/loader/content_loader.rb +101 -0
- data/lib/asker/loader/directory_loader.rb +58 -0
- data/lib/asker/loader/file_loader.rb +33 -0
- data/lib/asker/loader/image_url_loader.rb +61 -0
- data/lib/asker/loader/input_loader.rb +24 -0
- data/lib/asker/loader/project_loader.rb +71 -0
- data/lib/asker/logger.rb +21 -0
- data/lib/asker/project.rb +170 -0
- metadata +261 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'singleton'
|
4
|
+
require 'inifile'
|
5
|
+
|
6
|
+
# Global parameters
|
7
|
+
class Application
|
8
|
+
include Singleton
|
9
|
+
|
10
|
+
VERSION = '2.1.2' # Application version
|
11
|
+
NAME = 'asker' # Application name
|
12
|
+
GEM = 'asker-tool' # Gem name
|
13
|
+
attr_reader :config
|
14
|
+
|
15
|
+
##
|
16
|
+
# Initialize Application singleton
|
17
|
+
def initialize
|
18
|
+
reset
|
19
|
+
end
|
20
|
+
|
21
|
+
##
|
22
|
+
# Initialize config values from external "config.ini" file.
|
23
|
+
def reset
|
24
|
+
filename = File.join(Dir.pwd, 'config.ini')
|
25
|
+
unless File.exist? filename
|
26
|
+
filename = File.join(File.dirname(__FILE__), 'files', 'config.ini')
|
27
|
+
end
|
28
|
+
@config = IniFile.load(filename)
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,356 @@
|
|
1
|
+
|
2
|
+
require 'rainbow'
|
3
|
+
|
4
|
+
module Checker
|
5
|
+
def self.check(filepath)
|
6
|
+
unless File.exist? filepath
|
7
|
+
puts Rainbow("File not found!").red.bright
|
8
|
+
return false
|
9
|
+
end
|
10
|
+
unless File.extname(filepath) == '.haml'
|
11
|
+
puts Rainbow("Only check HAML files!").yellow.bright
|
12
|
+
return false
|
13
|
+
end
|
14
|
+
check_filepath(filepath)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.check_filepath(filepath)
|
18
|
+
data = Data.new(filepath)
|
19
|
+
data.check
|
20
|
+
data.show_errors
|
21
|
+
data.is_ok?
|
22
|
+
end
|
23
|
+
|
24
|
+
class Data
|
25
|
+
attr_reader :inputs
|
26
|
+
attr_reader :outputs
|
27
|
+
def initialize(filepath)
|
28
|
+
@inputs = File.read(filepath).split("\n")
|
29
|
+
@outputs = []
|
30
|
+
@inputs.each_with_index do |line, index|
|
31
|
+
output = { id: index,
|
32
|
+
level: 0,
|
33
|
+
state: :none,
|
34
|
+
type: :none,
|
35
|
+
source: line,
|
36
|
+
msg: '' }
|
37
|
+
@outputs << output
|
38
|
+
end
|
39
|
+
@ok = false
|
40
|
+
end
|
41
|
+
|
42
|
+
def is_ok?
|
43
|
+
@ok
|
44
|
+
end
|
45
|
+
|
46
|
+
def show
|
47
|
+
@outputs.each do |i|
|
48
|
+
puts "#{i[:id]}: #{i[:state]} [#{i[:type]}] #{i[:msg]}"
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
def show_errors
|
53
|
+
errors = 0
|
54
|
+
@outputs.each do |i|
|
55
|
+
next if i[:state] == :ok
|
56
|
+
errors += 1
|
57
|
+
puts "%02d" % i[:id] + ": %s." % i[:msg] + " => #{i[:source][0,40]}" if errors < 11
|
58
|
+
puts "..." if errors == 11
|
59
|
+
end
|
60
|
+
puts Rainbow("[ERROR] #{errors} errors from #{@inputs.size} lines!").red.bright if errors > 0
|
61
|
+
puts Rainbow("Syntax OK!").green if errors == 0
|
62
|
+
end
|
63
|
+
|
64
|
+
def check
|
65
|
+
@ok = true
|
66
|
+
@inputs.each_with_index do |line, index|
|
67
|
+
check_empty_lines(line, index)
|
68
|
+
check_map(line, index)
|
69
|
+
check_concept(line, index)
|
70
|
+
check_names(line, index)
|
71
|
+
check_tags(line, index)
|
72
|
+
check_def(line, index)
|
73
|
+
check_table(line, index)
|
74
|
+
check_row(line, index)
|
75
|
+
check_col(line, index)
|
76
|
+
check_template(line, index)
|
77
|
+
check_code(line, index)
|
78
|
+
check_type(line, index)
|
79
|
+
check_path(line, index)
|
80
|
+
check_features(line, index)
|
81
|
+
check_unknown(line, index)
|
82
|
+
@ok = false unless @outputs[index][:state] == :ok
|
83
|
+
@ok = false if @outputs[index][:type] == :unkown
|
84
|
+
end
|
85
|
+
@ok
|
86
|
+
end
|
87
|
+
|
88
|
+
def check_empty_lines(line, index)
|
89
|
+
if line.strip.size.zero? or line.start_with? '#'
|
90
|
+
@outputs[index][:type] = :empty
|
91
|
+
@outputs[index][:level] = -1
|
92
|
+
@outputs[index][:state] = :ok
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def check_map(line, index)
|
97
|
+
if index == 0
|
98
|
+
@outputs[index][:type] = :map
|
99
|
+
if line.start_with?('%map{')
|
100
|
+
@outputs[index][:state] = :ok
|
101
|
+
else
|
102
|
+
@outputs[index][:state] = :err
|
103
|
+
@outputs[index][:msg] = "Start with '%map{'"
|
104
|
+
end
|
105
|
+
elsif index > 0 and line.include?('%map{')
|
106
|
+
@outputs[index][:state] = :err
|
107
|
+
@outputs[index][:type] = :map
|
108
|
+
@outputs[index][:msg] = "Write '%map' on line 0"
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def check_concept(line, index)
|
113
|
+
return unless @outputs[index][:state] == :none
|
114
|
+
return unless line.include? '%concept'
|
115
|
+
|
116
|
+
@outputs[index][:type] = :concept
|
117
|
+
@outputs[index][:level] = 1
|
118
|
+
@outputs[index][:state] = :ok
|
119
|
+
if find_parent(index) != :map
|
120
|
+
@outputs[index][:state] = :err
|
121
|
+
@outputs[index][:msg] = 'Parent(map) not found!'
|
122
|
+
elsif line != ' %concept'
|
123
|
+
@outputs[index][:state] = :err
|
124
|
+
@outputs[index][:msg] = 'Write 2 spaces before %concept'
|
125
|
+
end
|
126
|
+
end
|
127
|
+
|
128
|
+
def check_names(line, index)
|
129
|
+
return unless @outputs[index][:state] == :none
|
130
|
+
return unless line.include? '%names'
|
131
|
+
|
132
|
+
@outputs[index][:type] = :names
|
133
|
+
@outputs[index][:level] = 2
|
134
|
+
@outputs[index][:state] = :ok
|
135
|
+
if find_parent(index) != :concept
|
136
|
+
@outputs[index][:state] = :err
|
137
|
+
@outputs[index][:msg] = 'Parent(concept) not found!'
|
138
|
+
elsif not line.start_with? ' %names'
|
139
|
+
@outputs[index][:state] = :err
|
140
|
+
@outputs[index][:msg] = "Write 4 spaces before %names"
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
def check_tags(line, index)
|
145
|
+
return unless @outputs[index][:state] == :none
|
146
|
+
return unless line.include? '%tags'
|
147
|
+
|
148
|
+
@outputs[index][:type] = :tags
|
149
|
+
@outputs[index][:level] = 2
|
150
|
+
@outputs[index][:state] = :ok
|
151
|
+
if find_parent(index) != :concept
|
152
|
+
@outputs[index][:state] = :err
|
153
|
+
@outputs[index][:msg] = 'Parent(concept) not found!'
|
154
|
+
elsif not line.start_with? ' %tags'
|
155
|
+
@outputs[index][:state] = :err
|
156
|
+
@outputs[index][:msg] = "Write 4 spaces before %tags"
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
def check_def(line, index)
|
161
|
+
return unless @outputs[index][:state] == :none
|
162
|
+
return unless line.include? '%def'
|
163
|
+
|
164
|
+
@outputs[index][:type] = :def
|
165
|
+
@outputs[index][:level] = 2
|
166
|
+
@outputs[index][:state] = :ok
|
167
|
+
if find_parent(index) != :concept
|
168
|
+
@outputs[index][:state] = :err
|
169
|
+
@outputs[index][:msg] = 'Parent(concept) not found!'
|
170
|
+
elsif not line.start_with? ' %def'
|
171
|
+
@outputs[index][:state] = :err
|
172
|
+
@outputs[index][:msg] = "Write 4 spaces before %def"
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
def check_table(line, index)
|
177
|
+
return unless @outputs[index][:state] == :none
|
178
|
+
return unless line.include? '%table'
|
179
|
+
|
180
|
+
@outputs[index][:type] = :table
|
181
|
+
@outputs[index][:level] = 2
|
182
|
+
@outputs[index][:state] = :ok
|
183
|
+
if find_parent(index) != :concept
|
184
|
+
@outputs[index][:state] = :err
|
185
|
+
@outputs[index][:msg] = 'Parent(concept) not found!'
|
186
|
+
elsif not line.start_with? ' %table'
|
187
|
+
@outputs[index][:state] = :err
|
188
|
+
@outputs[index][:msg] = "Write 4 spaces before %table"
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
def check_row(line, index)
|
193
|
+
return unless @outputs[index][:state] == :none
|
194
|
+
return unless line.include? '%row'
|
195
|
+
|
196
|
+
@outputs[index][:type] = :row
|
197
|
+
@outputs[index][:state] = :ok
|
198
|
+
|
199
|
+
if count_spaces(line) == 6
|
200
|
+
@outputs[index][:level] = 3
|
201
|
+
parent = find_parent(index)
|
202
|
+
unless [:table, :features].include? parent
|
203
|
+
@outputs[index][:state] = :err
|
204
|
+
@outputs[index][:msg] = 'Parent(table/features) not found!'
|
205
|
+
end
|
206
|
+
elsif count_spaces(line) == 8
|
207
|
+
@outputs[index][:level] = 4
|
208
|
+
if find_parent(index) != :template
|
209
|
+
@outputs[index][:state] = :err
|
210
|
+
@outputs[index][:msg] = 'Parent(template) not found!'
|
211
|
+
end
|
212
|
+
else
|
213
|
+
@outputs[index][:state] = :err
|
214
|
+
@outputs[index][:msg] = "Write 6 or 8 spaces before %row"
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
def check_col(line, index)
|
219
|
+
return unless @outputs[index][:state] == :none
|
220
|
+
return unless line.include? '%col'
|
221
|
+
|
222
|
+
@outputs[index][:type] = :col
|
223
|
+
@outputs[index][:state] = :ok
|
224
|
+
if count_spaces(line) == 8
|
225
|
+
@outputs[index][:level] = 4
|
226
|
+
if find_parent(index) != :row
|
227
|
+
@outputs[index][:state] = :err
|
228
|
+
@outputs[index][:msg] = 'Parent(row) not found!'
|
229
|
+
end
|
230
|
+
elsif count_spaces(line) == 10
|
231
|
+
@outputs[index][:level] = 5
|
232
|
+
if find_parent(index) != :row
|
233
|
+
@outputs[index][:state] = :err
|
234
|
+
@outputs[index][:msg] = 'Parent(row) not found!'
|
235
|
+
end
|
236
|
+
else
|
237
|
+
@outputs[index][:state] = :err
|
238
|
+
@outputs[index][:msg] = "Write 8 or 10 spaces before %col"
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
def check_template(line, index)
|
243
|
+
return unless @outputs[index][:state] == :none
|
244
|
+
return unless line.include? '%template'
|
245
|
+
|
246
|
+
@outputs[index][:type] = :template
|
247
|
+
@outputs[index][:level] = 3
|
248
|
+
@outputs[index][:state] = :ok
|
249
|
+
if find_parent(index) != :table
|
250
|
+
@outputs[index][:state] = :err
|
251
|
+
@outputs[index][:msg] = 'Parent(concept) not found!'
|
252
|
+
elsif not line.start_with? ' %template'
|
253
|
+
@outputs[index][:state] = :err
|
254
|
+
@outputs[index][:msg] = "Write 6 spaces before %template"
|
255
|
+
end
|
256
|
+
end
|
257
|
+
|
258
|
+
def check_code(line, index)
|
259
|
+
return unless @outputs[index][:state] == :none
|
260
|
+
return unless line.include? '%code'
|
261
|
+
|
262
|
+
@outputs[index][:type] = :code
|
263
|
+
@outputs[index][:level] = 1
|
264
|
+
@outputs[index][:state] = :ok
|
265
|
+
if find_parent(index) != :map
|
266
|
+
@outputs[index][:state] = :err
|
267
|
+
@outputs[index][:msg] = 'Parent(map) not found!'
|
268
|
+
elsif line != ' %code'
|
269
|
+
@outputs[index][:state] = :err
|
270
|
+
@outputs[index][:msg] = 'Write 2 spaces before %code'
|
271
|
+
end
|
272
|
+
end
|
273
|
+
|
274
|
+
def check_type(line, index)
|
275
|
+
return unless @outputs[index][:state] == :none
|
276
|
+
return unless line.include? '%type'
|
277
|
+
|
278
|
+
@outputs[index][:type] = :type
|
279
|
+
@outputs[index][:level] = 2
|
280
|
+
@outputs[index][:state] = :ok
|
281
|
+
if find_parent(index) != :code
|
282
|
+
@outputs[index][:state] = :err
|
283
|
+
@outputs[index][:msg] = 'Parent(code) not found!'
|
284
|
+
elsif not line.start_with? ' %type'
|
285
|
+
@outputs[index][:state] = :err
|
286
|
+
@outputs[index][:msg] = "Write 4 spaces before %type"
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
def check_path(line, index)
|
291
|
+
return unless @outputs[index][:state] == :none
|
292
|
+
return unless line.include? '%path'
|
293
|
+
|
294
|
+
@outputs[index][:type] = :path
|
295
|
+
@outputs[index][:level] = 2
|
296
|
+
@outputs[index][:state] = :ok
|
297
|
+
if find_parent(index) != :code
|
298
|
+
@outputs[index][:state] = :err
|
299
|
+
@outputs[index][:msg] = 'Parent(code) not found!'
|
300
|
+
elsif not line.start_with? ' %path'
|
301
|
+
@outputs[index][:state] = :err
|
302
|
+
@outputs[index][:msg] = "Write 4 spaces before %type"
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
def check_features(line, index)
|
307
|
+
return unless @outputs[index][:state] == :none
|
308
|
+
return unless line.include? '%features'
|
309
|
+
|
310
|
+
@outputs[index][:type] = :features
|
311
|
+
@outputs[index][:level] = 2
|
312
|
+
@outputs[index][:state] = :ok
|
313
|
+
if find_parent(index) != :code
|
314
|
+
@outputs[index][:state] = :err
|
315
|
+
@outputs[index][:msg] = 'Parent(code) not found!'
|
316
|
+
elsif not line.start_with? ' %features'
|
317
|
+
@outputs[index][:state] = :err
|
318
|
+
@outputs[index][:msg] = "Write 4 spaces before %features"
|
319
|
+
end
|
320
|
+
end
|
321
|
+
|
322
|
+
def check_unknown(line, index)
|
323
|
+
return unless @outputs[index][:state] == :none
|
324
|
+
@outputs[index][:type] = :unknown
|
325
|
+
@outputs[index][:level] = count_spaces(line)/2
|
326
|
+
@outputs[index][:state] = :err
|
327
|
+
@outputs[index][:msg] = "Unknown tag with parent(#{find_parent(index)})!"
|
328
|
+
end
|
329
|
+
|
330
|
+
def find_parent(index)
|
331
|
+
current_level = @outputs[index][:level]
|
332
|
+
return :noparent if current_level.zero?
|
333
|
+
i = index - 1
|
334
|
+
while(i >= 0)
|
335
|
+
return @outputs[i][:type] if @outputs[i][:level] == current_level - 1
|
336
|
+
i = i - 1
|
337
|
+
end
|
338
|
+
return :noparent
|
339
|
+
end
|
340
|
+
|
341
|
+
def count_spaces(line)
|
342
|
+
return 0 if line.start_with? '%'
|
343
|
+
return 1 if line.start_with? ' %'
|
344
|
+
return 2 if line.start_with? ' %'
|
345
|
+
return 3 if line.start_with? ' %'
|
346
|
+
return 4 if line.start_with? ' %'
|
347
|
+
return 5 if line.start_with? ' %'
|
348
|
+
return 6 if line.start_with? ' %'
|
349
|
+
return 7 if line.start_with? ' %'
|
350
|
+
return 8 if line.start_with? ' %'
|
351
|
+
return 9 if line.start_with? ' %'
|
352
|
+
return 10 if line.start_with? ' %'
|
353
|
+
return -1
|
354
|
+
end
|
355
|
+
end
|
356
|
+
end
|
data/lib/asker/cli.rb
ADDED
@@ -0,0 +1,85 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rainbow'
|
4
|
+
require 'thor'
|
5
|
+
require_relative 'application'
|
6
|
+
require_relative '../asker'
|
7
|
+
|
8
|
+
##
|
9
|
+
# Command Line User Interface
|
10
|
+
class CLI < Thor
|
11
|
+
map ['h', '-h', '--help'] => 'help'
|
12
|
+
|
13
|
+
map ['v', '-v', '--version'] => 'version'
|
14
|
+
desc 'version', 'Show the program version'
|
15
|
+
##
|
16
|
+
# Show current version
|
17
|
+
def version
|
18
|
+
print Rainbow(Application::NAME).bright.blue
|
19
|
+
puts " (version #{Rainbow(Application::VERSION).green})"
|
20
|
+
end
|
21
|
+
|
22
|
+
map ['f', '-f', '--file'] => 'file'
|
23
|
+
desc 'file NAME', 'Build output files, from HAML/XML input file.'
|
24
|
+
option :color, type: :boolean
|
25
|
+
long_desc <<-LONGDESC
|
26
|
+
Create output files, from input file (HAML/XML format).
|
27
|
+
|
28
|
+
Build questions about contents defined into input file specified.
|
29
|
+
|
30
|
+
Examples:
|
31
|
+
|
32
|
+
(1) #{Rainbow('asker input/foo/foo.haml').yellow}, Build questions from HAML file.
|
33
|
+
|
34
|
+
(2) #{Rainbow('asker input/foo/foo.xml').yellow}, Build questions from XML file.
|
35
|
+
|
36
|
+
(3) #{Rainbow('asker file --no-color input/foo/foo.haml').yellow}, Same as (1) but without colors.
|
37
|
+
|
38
|
+
(4) #{Rainbow('asker projects/foo/foo.yaml').yellow}, Build questions from YAML project file.
|
39
|
+
|
40
|
+
LONGDESC
|
41
|
+
##
|
42
|
+
# Create questions from input file
|
43
|
+
# @param filename (String) Path to input file
|
44
|
+
def file(filename)
|
45
|
+
# Enable/disable color output
|
46
|
+
Rainbow.enabled = false if options['color'] == false
|
47
|
+
# Asker start processing input file
|
48
|
+
Asker.new.start(filename)
|
49
|
+
end
|
50
|
+
|
51
|
+
map ['i', '-i', '--init'] => 'init'
|
52
|
+
desc 'init', 'Create default INI config fie'
|
53
|
+
##
|
54
|
+
# Create default INI config file
|
55
|
+
def init
|
56
|
+
src = File.join(File.dirname(__FILE__), 'files', 'config.ini')
|
57
|
+
dst = File.join(Dir.pwd, 'config.ini')
|
58
|
+
if File.exist? dst
|
59
|
+
puts "[WARN] Exists file! => #{Rainbow(File.basename(dst)).yellow.bright}"
|
60
|
+
else
|
61
|
+
FileUtils.cp(src, dst)
|
62
|
+
puts "[ OK ] Create file => #{Rainbow(File.basename(dst)).green}"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
map ['c', '-c', '--check'] => 'check'
|
67
|
+
desc 'check', 'Check input HAML file syntax'
|
68
|
+
##
|
69
|
+
# Check input file syntax
|
70
|
+
# @param filename (String) Path to input file
|
71
|
+
def check(filename)
|
72
|
+
# Enable/disable color output
|
73
|
+
Rainbow.enabled = false if options['color'] == false
|
74
|
+
# Asker start processing input file
|
75
|
+
Asker.check(filename)
|
76
|
+
end
|
77
|
+
|
78
|
+
##
|
79
|
+
# This actions are equals:
|
80
|
+
# * asker demo/foo.haml
|
81
|
+
# * asker file demo/fool.haml
|
82
|
+
def method_missing(method, *_args, &_block)
|
83
|
+
file(method.to_s)
|
84
|
+
end
|
85
|
+
end
|