phari_doc_gen 1.2.1 → 1.2.2
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.rb +2 -1
- data/lib/phari_doc_gen/FileHandler.rb +49 -38
- 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: 3561436d19593047d435d3b001152c030855bfd9
|
4
|
+
data.tar.gz: b13faaedeb84caf6621e9463bb1765334a3b6a93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0bc457c7f8cfdf5b8aa7546c3855eb0dbc2a9da0a524d170b8919f85f3affebc780532f34ad05dab4877c70aab09e402b75ccad893cf49ec2b84f7164bb73b7d
|
7
|
+
data.tar.gz: 1073bee5b12b651b8800bb00c0aac2761f9e435308fb5c91e1d5defd0109f33ae0d1052ee6f621771b58a7c1af8de342227ce17de843917053e88660a3cb3c9e
|
data/bin/generate
CHANGED
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
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
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
|
-
|
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
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
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)
|