phari_doc_gen 1.2.1 → 1.2.2

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: 0c59179d663a41f7f6646966da28c019bded358d
4
- data.tar.gz: 978dd3f5616a8d6e497278472547c8c4cb70ef4c
3
+ metadata.gz: 3561436d19593047d435d3b001152c030855bfd9
4
+ data.tar.gz: b13faaedeb84caf6621e9463bb1765334a3b6a93
5
5
  SHA512:
6
- metadata.gz: bb6ee7e3b71a0f94983622b5844b7301d6a82bae32573a018ad3085d54ddb16e3f3322dbcae38bdee664083cc0500270192687487d5cac2e5c00f2e73654ea08
7
- data.tar.gz: 9f4fe4a27d14dec2dea0ff80093889412adc4531fe2f37fc7f8c111e60d54b48a4fe9734ce9e74f56938f116f61de1930713b372365066f3bb7d84bc2633514f
6
+ metadata.gz: 0bc457c7f8cfdf5b8aa7546c3855eb0dbc2a9da0a524d170b8919f85f3affebc780532f34ad05dab4877c70aab09e402b75ccad893cf49ec2b84f7164bb73b7d
7
+ data.tar.gz: 1073bee5b12b651b8800bb00c0aac2761f9e435308fb5c91e1d5defd0109f33ae0d1052ee6f621771b58a7c1af8de342227ce17de843917053e88660a3cb3c9e
data/bin/generate CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
- require 'phari_doc_gen'
3
+ require_relative 'phari_doc_gen'
4
4
  docGen = PhariDocGen.new()
5
5
  docGen.generate(ARGV[0], ARGV[1])
data/lib/phari_doc_gen.rb CHANGED
@@ -19,10 +19,11 @@ class PhariDocGen
19
19
  projectDescription = generate.readProject(project)
20
20
  models = generate.readFiles(project)
21
21
  if path == nil
22
- puts 'Insert path to output file'
22
+ puts 'Insert full path to output file'
23
23
  path = gets.chomp
24
24
  end
25
25
  path += '/' unless path.end_with?('/')
26
+ path = '/'+path unless path.start_with?('/')
26
27
  if path == ''
27
28
  puts 'Aborting generation due to empty path'
28
29
  exit
@@ -44,7 +44,7 @@ class FileHandler
44
44
  if File.exist?(helpername) && File.exist?(controllername)
45
45
  modelHelper = File.new(helpername, 'r')
46
46
  modelController = File.new(controllername, 'r')
47
- methods = readMethods(modelHelper)
47
+ methods = readMethods(modelHelper, helpername)
48
48
  routes = readRoutes(modelController)
49
49
  currentModel = Modelo.new(modelname, methods, routes)
50
50
  models << currentModel
@@ -146,7 +146,8 @@ class FileHandler
146
146
  line
147
147
  end
148
148
 
149
- def readMethods(helper)
149
+ def readMethods(helper, helpername)
150
+ linha = 0
150
151
  tipo = ''
151
152
  nome = ''
152
153
  descricao = ''
@@ -154,41 +155,47 @@ class FileHandler
154
155
  outputs = []
155
156
  methods = []
156
157
  toSent = true
157
- arr = IO.readlines(helper)
158
- arr.each do |line|
159
- if hasKeyword?(line)
160
- arg = decodeArgument(line)
161
- keyword = arg[0]
162
- argument = arg[1]
163
- case keyword
164
- when 'methods'
165
- if nome != ''
166
- methods << Metodo.new(nome, tipo, inputs, outputs, descricao)
167
- inputs = []
168
- outputs = []
169
- toSent = false
170
- end
171
- tipo = argument
172
- when 'name'
173
- if nome != '' && toSent
174
- methods << Metodo.new(nome, tipo, inputs, outputs, descricao)
175
- inputs = []
176
- outputs = []
177
- else
178
- toSent = true
158
+ begin
159
+ arr = IO.readlines(helper)
160
+ arr.each do |line|
161
+ linha += 1
162
+ if hasKeyword?(line)
163
+ arg = decodeArgument(line)
164
+ keyword = arg[0]
165
+ argument = arg[1]
166
+ case keyword
167
+ when 'methods'
168
+ if nome != ''
169
+ methods << Metodo.new(nome, tipo, inputs, outputs, descricao)
170
+ inputs = []
171
+ outputs = []
172
+ toSent = false
173
+ end
174
+ tipo = argument
175
+ when 'name'
176
+ if nome != '' && toSent
177
+ methods << Metodo.new(nome, tipo, inputs, outputs, descricao)
178
+ inputs = []
179
+ outputs = []
180
+ else
181
+ toSent = true
182
+ end
183
+ nome = argument
184
+ # methods.last.printName
185
+ # puts "#{methods.size}"
186
+ when 'param'
187
+ data = dataValue(argument)
188
+ inputs << data
189
+ when 'return'
190
+ data = dataValue(argument)
191
+ outputs << data
179
192
  end
180
- nome = argument
181
- # methods.last.printName
182
- # puts "#{methods.size}"
183
- when 'param'
184
- data = dataValue(argument)
185
- inputs << data
186
- when 'return'
187
- data = dataValue(argument)
188
- outputs << data
189
193
  end
194
+ descricao = decodeDescription(line) if hasDescription?(line)
190
195
  end
191
- descricao = decodeDescription(line) if hasDescription?(line)
196
+ rescue ArgumentError => e
197
+ puts "#{helpername}::#{linha} in #{nome}"
198
+ puts e.message
192
199
  end
193
200
  methods << Metodo.new(nome, tipo, inputs, outputs, descricao)
194
201
  methods
@@ -275,11 +282,12 @@ class FileHandler
275
282
  # Métodos de decodificação da leitura
276
283
  def hasKeyword?(line)
277
284
  if (line.include? '#') && (line.include? '@')
278
- if line.index('#') < line.index('@')
279
- true
280
- else
281
- false
285
+ for i in 0..line.index('#')-1
286
+ if line[i].match(/^[[:alpha:]]$/)
287
+ return false
288
+ end
282
289
  end
290
+ true
283
291
  else
284
292
  false
285
293
  end
@@ -301,6 +309,9 @@ class FileHandler
301
309
  args = []
302
310
  initialIndex = line.index('@') + 1
303
311
  finalIndex = line.index("\s", line.index('@'))
312
+ if finalIndex == nil || initialIndex == nil
313
+ raise ArgumentError.new("Sytanx error: expected 2 arguments (one given)")
314
+ end
304
315
  lenght = finalIndex - initialIndex
305
316
  keyword = line.slice(initialIndex, lenght)
306
317
  argument = line.slice(finalIndex + 1, line.size - finalIndex)
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.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Phari