phari_doc_gen 1.2.3 → 1.2.4

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
  SHA1:
3
- metadata.gz: 9fbb3185d3c51d9df091cece9d9dfebc79ece933
4
- data.tar.gz: df53a5f7e5e5a9f4b244e379131bc2c22056a732
3
+ metadata.gz: aed71e1fbe5849d84078cb876c4f5d68aa5635a7
4
+ data.tar.gz: b7d38db5e2f66a51bdea1eb825f100115c0a0b18
5
5
  SHA512:
6
- metadata.gz: 49311c2e74bd690489b826e1969ad1cdf6d119ac1e20c189fb4f48fe3901718d190eba1f366795940f1b7d7ea254314911a88298ac5ce5b1f978bd132d6d203d
7
- data.tar.gz: 0a15ff03c292842962e109cc9357fbd49e0427adcb6d047bd3d2872a894a40003d109dbce6d2e2e2b60bdc5169dc40c274643d1b1ed0ef3f6949af30e5a1c872
6
+ metadata.gz: 41a1f5d33ebb0d1691948025a9b5d4fcb441d40208cd5a657c05e8c41f3d0df2e3f654efd5fbc53a7fb9a396b55c8aa41935f71f1bf42ded2dd42e8b1b4ca5aa
7
+ data.tar.gz: 32fe9025e35439cf9cec31e6cc6e47218680a40b8775b95bfc95599a105cc885a087cbebcb2eae586447257fb46c63cc7909081d996cecfcbc6e5cddeaabe3ea
data/bin/generate CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'phari_doc_gen'
3
+ require_relative '../lib/phari_doc_gen.rb'
4
4
  docGen = PhariDocGen.new()
5
5
  docGen.generate(ARGV[0], ARGV[1])
@@ -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
- linha = 0
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
- linha += 1
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}::#{linha} in #{nome}"
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
- arr = IO.readlines(controller)
214
- arr.each do |line|
215
- next unless hasKeyword?(line)
216
- arg = decodeArgument(line)
217
- keyword = arg[0]
218
- argument = arg[1]
219
- case keyword
220
- when 'route'
221
- if nome != ''
222
- routes << Rota.new(nome, tipo, requisicao, dataInput, inputs, outputs)
223
- inputs = []
224
- outputs = []
225
- toSent = false
226
- end
227
- tipo = argument
228
- when 'POST'
229
- if nome != '' && toSent
230
- routes << Rota.new(nome, tipo, requisicao, dataInput, inputs, outputs)
231
- inputs = []
232
- outputs = []
233
- else
234
- toSent = true
235
- end
236
- requisicao = keyword
237
- dataInput = argument
238
- when 'GET'
239
- if nome != '' && toSent
240
- routes << Rota.new(nome, tipo, requisicao, dataInput, inputs, outputs)
241
- inputs = []
242
- outputs = []
243
- else
244
- toSent = true
245
- end
246
- requisicao = keyword
247
- dataInput = argument
248
- when 'PUT'
249
- if nome != '' && toSent
250
- routes << Rota.new(nome, tipo, requisicao, dataInput, inputs, outputs)
251
- inputs = []
252
- outputs = []
253
- else
254
- toSent = true
255
- end
256
- requisicao = keyword
257
- dataInput = argument
258
- when 'DELETE'
259
- if nome != '' && toSent
260
- routes << Rota.new(nome, tipo, requisicao, dataInput, inputs, outputs)
261
- inputs = []
262
- outputs = []
263
- else
264
- toSent = true
265
- end
266
- requisicao = keyword
267
- dataInput = argument
268
- when 'name'
269
- nome = argument
270
- when 'param'
271
- data = dataValue(argument)
272
- inputs << data
273
- when 'return'
274
- data = dataValue(argument)
275
- outputs << data
276
- end
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
- if line.index('#') < line.index('**')
299
- true
300
- else
301
- false
302
- end
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
- 'nil'
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)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: phari_doc_gen
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.3
4
+ version: 1.2.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Phari