phari_doc_gen 1.2.3 → 1.2.4
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/bin/generate +1 -1
- data/lib/phari_doc_gen/FileHandler.rb +115 -79
- 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: aed71e1fbe5849d84078cb876c4f5d68aa5635a7
|
4
|
+
data.tar.gz: b7d38db5e2f66a51bdea1eb825f100115c0a0b18
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41a1f5d33ebb0d1691948025a9b5d4fcb441d40208cd5a657c05e8c41f3d0df2e3f654efd5fbc53a7fb9a396b55c8aa41935f71f1bf42ded2dd42e8b1b4ca5aa
|
7
|
+
data.tar.gz: 32fe9025e35439cf9cec31e6cc6e47218680a40b8775b95bfc95599a105cc885a087cbebcb2eae586447257fb46c63cc7909081d996cecfcbc6e5cddeaabe3ea
|
data/bin/generate
CHANGED
@@ -45,7 +45,7 @@ class FileHandler
|
|
45
45
|
modelHelper = File.new(helpername, 'r')
|
46
46
|
modelController = File.new(controllername, 'r')
|
47
47
|
methods = readMethods(modelHelper, helpername)
|
48
|
-
routes = readRoutes(modelController)
|
48
|
+
routes = readRoutes(modelController, controllername)
|
49
49
|
currentModel = Modelo.new(modelname, methods, routes)
|
50
50
|
models << currentModel
|
51
51
|
end
|
@@ -147,7 +147,7 @@ class FileHandler
|
|
147
147
|
end
|
148
148
|
|
149
149
|
def readMethods(helper, helpername)
|
150
|
-
|
150
|
+
lineIndex = 0
|
151
151
|
tipo = ''
|
152
152
|
nome = ''
|
153
153
|
descricao = ''
|
@@ -158,8 +158,8 @@ class FileHandler
|
|
158
158
|
begin
|
159
159
|
arr = IO.readlines(helper)
|
160
160
|
arr.each do |line|
|
161
|
-
|
162
|
-
if hasKeyword?(line)
|
161
|
+
lineIndex += 1
|
162
|
+
if hasKeyword?(line, lineIndex, helpername)
|
163
163
|
arg = decodeArgument(line)
|
164
164
|
keyword = arg[0]
|
165
165
|
argument = arg[1]
|
@@ -189,19 +189,22 @@ class FileHandler
|
|
189
189
|
when 'return'
|
190
190
|
data = dataValue(argument)
|
191
191
|
outputs << data
|
192
|
+
else
|
193
|
+
puts "Warning: in #{helpername}:#{lineIndex}: #{keyword} is not a keyword" if keyword != 'namespace'
|
192
194
|
end
|
193
195
|
end
|
194
|
-
descricao = decodeDescription(line) if hasDescription?(line)
|
196
|
+
descricao = decodeDescription(line) if hasDescription?(line, lineIndex, helpername)
|
195
197
|
end
|
196
198
|
rescue ArgumentError => e
|
197
|
-
puts "#{helpername}
|
199
|
+
puts "ERROR: #{helpername}:#{lineIndex}: in #{nome}"
|
198
200
|
puts e.message
|
199
201
|
end
|
200
202
|
methods << Metodo.new(nome, tipo, inputs, outputs, descricao)
|
201
203
|
methods
|
202
204
|
end
|
203
205
|
|
204
|
-
def readRoutes(controller)
|
206
|
+
def readRoutes(controller, controllername)
|
207
|
+
lineIndex = 0
|
205
208
|
tipo = ''
|
206
209
|
requisicao = ''
|
207
210
|
dataInput = ''
|
@@ -210,96 +213,119 @@ class FileHandler
|
|
210
213
|
outputs = []
|
211
214
|
routes = []
|
212
215
|
toSent = true
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
250
|
-
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
216
|
+
begin
|
217
|
+
arr = IO.readlines(controller)
|
218
|
+
arr.each do |line|
|
219
|
+
lineIndex += 1
|
220
|
+
next unless hasKeyword?(line, lineIndex, controllername)
|
221
|
+
arg = decodeArgument(line)
|
222
|
+
keyword = arg[0]
|
223
|
+
argument = arg[1]
|
224
|
+
case keyword
|
225
|
+
when 'route'
|
226
|
+
if nome != ''
|
227
|
+
routes << Rota.new(nome, tipo, requisicao, dataInput, inputs, outputs)
|
228
|
+
inputs = []
|
229
|
+
outputs = []
|
230
|
+
toSent = false
|
231
|
+
end
|
232
|
+
tipo = argument
|
233
|
+
when 'POST'
|
234
|
+
if nome != '' && toSent
|
235
|
+
routes << Rota.new(nome, tipo, requisicao, dataInput, inputs, outputs)
|
236
|
+
inputs = []
|
237
|
+
outputs = []
|
238
|
+
else
|
239
|
+
toSent = true
|
240
|
+
end
|
241
|
+
requisicao = keyword
|
242
|
+
dataInput = argument
|
243
|
+
when 'GET'
|
244
|
+
if nome != '' && toSent
|
245
|
+
routes << Rota.new(nome, tipo, requisicao, dataInput, inputs, outputs)
|
246
|
+
inputs = []
|
247
|
+
outputs = []
|
248
|
+
else
|
249
|
+
toSent = true
|
250
|
+
end
|
251
|
+
requisicao = keyword
|
252
|
+
dataInput = argument
|
253
|
+
when 'PUT'
|
254
|
+
if nome != '' && toSent
|
255
|
+
routes << Rota.new(nome, tipo, requisicao, dataInput, inputs, outputs)
|
256
|
+
inputs = []
|
257
|
+
outputs = []
|
258
|
+
else
|
259
|
+
toSent = true
|
260
|
+
end
|
261
|
+
requisicao = keyword
|
262
|
+
dataInput = argument
|
263
|
+
when 'DELETE'
|
264
|
+
if nome != '' && toSent
|
265
|
+
routes << Rota.new(nome, tipo, requisicao, dataInput, inputs, outputs)
|
266
|
+
inputs = []
|
267
|
+
outputs = []
|
268
|
+
else
|
269
|
+
toSent = true
|
270
|
+
end
|
271
|
+
requisicao = keyword
|
272
|
+
dataInput = argument
|
273
|
+
when 'name'
|
274
|
+
nome = argument
|
275
|
+
when 'param'
|
276
|
+
data = dataValue(argument)
|
277
|
+
inputs << data
|
278
|
+
when 'return'
|
279
|
+
data = dataValue(argument)
|
280
|
+
outputs << data
|
281
|
+
else
|
282
|
+
puts "Warning: in #{controllername}:#{lineIndex}: #{keyword} is not a keyword" if keyword != 'namespace'
|
283
|
+
end
|
284
|
+
end
|
285
|
+
rescue ArgumentError => e
|
286
|
+
puts "ERROR: #{controllername}:#{lineIndex}: in #{nome}"
|
287
|
+
puts e.message
|
277
288
|
end
|
278
289
|
routes << Rota.new(nome, tipo, requisicao, dataInput, inputs, outputs)
|
279
290
|
routes
|
280
291
|
end
|
281
292
|
|
282
293
|
# Métodos de decodificação da leitura
|
283
|
-
def hasKeyword?(line)
|
294
|
+
def hasKeyword?(line, lineIndex, fileName)
|
284
295
|
if (line.include? '#') && (line.include? '@')
|
285
296
|
for i in 0..line.index('#')-1
|
286
297
|
if line[i].match(/^[[:alpha:]]$/)
|
287
298
|
return false
|
288
299
|
end
|
289
300
|
end
|
301
|
+
for i in line.index('#')+1..line.index('@')-1
|
302
|
+
if line[i].match(/^[[:alpha:]]$/)
|
303
|
+
lineText = line.slice(line.index('#'), line.index("\n") - line.index('#'))
|
304
|
+
puts "Warning: in #{fileName}:#{lineIndex}: #{lineText} is not a keyword"
|
305
|
+
return false
|
306
|
+
end
|
307
|
+
end
|
290
308
|
true
|
291
309
|
else
|
292
310
|
false
|
293
311
|
end
|
294
312
|
end
|
295
313
|
|
296
|
-
def hasDescription?(line)
|
314
|
+
def hasDescription?(line, lineIndex, fileName)
|
297
315
|
if (line.include? '#') && (line.include? '**')
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
316
|
+
for i in 0..line.index('#')-1
|
317
|
+
if line[i].match(/^[[:alpha:]]$/)
|
318
|
+
return false
|
319
|
+
end
|
320
|
+
end
|
321
|
+
for i in line.index('#')+1..line.index('**')-1
|
322
|
+
if line[i].match(/^[[:alpha:]]$/)
|
323
|
+
lineText = line.slice(line.index('#'), line.index("\n") - line.index('#'))
|
324
|
+
puts "Warning: in #{fileName}:#{lineIndex}: #{lineText} is not a description"
|
325
|
+
return false
|
326
|
+
end
|
327
|
+
end
|
328
|
+
true
|
303
329
|
else
|
304
330
|
false
|
305
331
|
end
|
@@ -310,7 +336,10 @@ class FileHandler
|
|
310
336
|
initialIndex = line.index('@') + 1
|
311
337
|
finalIndex = line.index("\s", line.index('@'))
|
312
338
|
if finalIndex == nil || initialIndex == nil
|
339
|
+
if line.index('@')+1 == /^[[:alpha:]]$/
|
313
340
|
raise ArgumentError.new("Sytanx error: expected 2 arguments (one given)")
|
341
|
+
else raise ArgumentError.new("Sytanx error: expected 2 arguments (none given)")
|
342
|
+
end
|
314
343
|
end
|
315
344
|
lenght = finalIndex - initialIndex
|
316
345
|
keyword = line.slice(initialIndex, lenght)
|
@@ -327,8 +356,15 @@ class FileHandler
|
|
327
356
|
data = MethodParam.new(name, type)
|
328
357
|
# data.printSelf
|
329
358
|
return data
|
359
|
+
elsif argument.include? "nil"
|
360
|
+
data = MethodParam.new('', 'nil')
|
361
|
+
return data
|
362
|
+
elsif argument.include? "boolean"
|
363
|
+
data = MethodParam.new('', 'boolen')
|
364
|
+
return data
|
330
365
|
end
|
331
|
-
|
366
|
+
argumentText = argument.slice(0, argument.index("\n"))
|
367
|
+
raise ArgumentError.new("Sytanx error: #{argumentText} is no data")
|
332
368
|
end
|
333
369
|
|
334
370
|
def decodeDescription(line)
|