phari_doc_gen 3.1.0 → 3.1.1
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/phari_doc_gen +0 -0
- data/lib/phari_doc_gen/fileHandler.rb +19 -11
- data/lib/phari_doc_gen/meta.rb +1 -1
- data/lib/phari_doc_gen/methodParam.rb +39 -27
- data/lib/phari_doc_gen/templates/model.html.erb +26 -18
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9cfc4375dfeebfedbc72b6c1d72606e1bd785956
|
4
|
+
data.tar.gz: 2af9ab2a967951d392116b56ff6bc994a00c09f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 227d7265a65225e844dc144faa4a43481c534aad13c8ad296a5f9980ecfc8a4b9b8ac1d8c0ffab85a52b93ba627ff14190211533f4dc0768c37947445f1cc527
|
7
|
+
data.tar.gz: 2b30ebe10d48fbfbad635019205c972235a0c3dcdb082b01dd570ebd237e16ac48dcf6c90970eb2a1e84be60f43efacb024ed069c32b4f1d5977884ef658804e
|
data/bin/phari_doc_gen
CHANGED
File without changes
|
@@ -5,19 +5,18 @@
|
|
5
5
|
# Luiz Philippe.
|
6
6
|
#--------------------------------------------------------------------------------------------
|
7
7
|
|
8
|
+
require 'erubis'
|
8
9
|
require_relative 'modelo.rb'
|
9
10
|
require_relative 'rota.rb'
|
10
11
|
require_relative 'metodo.rb'
|
11
12
|
require_relative 'methodParam.rb'
|
12
13
|
require_relative 'meta.rb'
|
13
|
-
require 'erubis'
|
14
14
|
|
15
15
|
class FileHandler
|
16
16
|
# Reading files
|
17
17
|
# Find a folder with the project name
|
18
18
|
def packageExistis?(packageName)
|
19
19
|
found = false
|
20
|
-
package = ''
|
21
20
|
puts'Finding project'
|
22
21
|
puts'It may take some time...'
|
23
22
|
packageName += '/' unless packageName.end_with?('/')
|
@@ -481,7 +480,9 @@ class FileHandler
|
|
481
480
|
type = type.slice(0, type.index("\s"))
|
482
481
|
end
|
483
482
|
type = type.slice(0, type.size-1) if type.end_with?("\s") || type.end_with?("\n")
|
484
|
-
isObject =
|
483
|
+
isObject = type.downcase == "object"
|
484
|
+
isCollection = type.downcase == "array"
|
485
|
+
# Inserting attributes inside objects
|
485
486
|
if name.include?(">")
|
486
487
|
isChild = true
|
487
488
|
path = []
|
@@ -492,17 +493,23 @@ class FileHandler
|
|
492
493
|
end
|
493
494
|
fatherObject = nil
|
494
495
|
path.each do |object|
|
495
|
-
|
496
|
-
|
496
|
+
if (fatherObject.nil? || fatherObject.isObject)
|
497
|
+
raise ArgumentError, "Object #{object} does not exists!" unless objects.has_key?(object) && (objects["#{object}"].isObject || objects["#{object}"].isCollection)
|
498
|
+
fatherObject = objects["#{object}"]
|
499
|
+
elsif (fatherObject.isCollection)
|
500
|
+
raise ArgumentError, "Object #{object} is not a position of #{fatherObject.name}!" unless (objects["content"].isObject || objects["content"].isCollection)
|
501
|
+
fatherObject = objects["content"]
|
502
|
+
end
|
497
503
|
objects = fatherObject.childAttributes
|
498
504
|
end
|
499
505
|
end
|
500
|
-
data = MethodParam.new(name, type, notNull, isObject, isChild, example)
|
501
|
-
fatherObject.addField data unless fatherObject.nil?
|
506
|
+
data = MethodParam.new(name, type, notNull, isObject, isCollection, isChild, example)
|
507
|
+
fatherObject.addField data unless (fatherObject.nil? || fatherObject.isCollection)
|
508
|
+
fatherObject.setContent data unless (fatherObject.nil? || fatherObject.isObject)
|
502
509
|
# Return the data
|
503
510
|
return data
|
504
511
|
elsif argument.include? "nil"
|
505
|
-
data = MethodParam.new('', 'nil',
|
512
|
+
data = MethodParam.new('', 'nil', false, false, false, false, nil)
|
506
513
|
return data
|
507
514
|
end
|
508
515
|
argumentText = argument.slice(0, argument.index("\n"))
|
@@ -545,8 +552,7 @@ class FileHandler
|
|
545
552
|
# Write the css content
|
546
553
|
def writeCSS(file)
|
547
554
|
css_file = gem_libdir+'/templates/style.css'
|
548
|
-
|
549
|
-
file.write(css)
|
555
|
+
file.write(File.read(css_file))
|
550
556
|
end
|
551
557
|
|
552
558
|
#Write the main project HTML content
|
@@ -588,7 +594,9 @@ class FileHandler
|
|
588
594
|
def gem_libdir
|
589
595
|
t = ["#{File.dirname(File.expand_path($0))}/../lib/#{Meta::NAME}",
|
590
596
|
"#{Gem.dir}/gems/#{Meta::NAME}-#{Meta::VERSION}/lib/#{Meta::NAME}"]
|
591
|
-
t.each
|
597
|
+
t.each do |i|
|
598
|
+
return i if File.readable?(i)
|
599
|
+
end
|
592
600
|
raise "both paths are invalid: #{t}"
|
593
601
|
end
|
594
602
|
end
|
data/lib/phari_doc_gen/meta.rb
CHANGED
@@ -6,44 +6,56 @@
|
|
6
6
|
#--------------------------------------------------------------------------------------------
|
7
7
|
|
8
8
|
class MethodParam
|
9
|
-
attr_accessor :name, :type, :notNull, :isObject, :isChild, :example, :childAttributes, :serial
|
9
|
+
attr_accessor :name, :type, :notNull, :isObject, :isCollection, :isChild, :example, :childAttributes, :serial
|
10
10
|
|
11
|
-
def initialize(name = "", type = "", notNull = true, isObject = false, isChild = false, example = nil)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
11
|
+
def initialize(name = "", type = "", notNull = true, isObject = false, isCollection = false, isChild = false, example = nil)
|
12
|
+
@name = name
|
13
|
+
@type = type
|
14
|
+
@notNull = notNull
|
15
|
+
@isObject = isObject
|
16
|
+
@isCollection = isCollection
|
17
|
+
@isChild = isChild
|
18
|
+
@example = example
|
19
|
+
@childAttributes = {} if (@isObject || @isCollection)
|
20
20
|
end
|
21
21
|
|
22
22
|
def addField attribute
|
23
|
-
|
24
|
-
|
23
|
+
raise ArgumentError, "Cannot add field to no object param" unless @isObject
|
24
|
+
@childAttributes["#{attribute.name}"] = attribute
|
25
|
+
end
|
26
|
+
|
27
|
+
def setContent attribute
|
28
|
+
raise ArgumentError, "Cannot set content of no array param" unless @isCollection
|
29
|
+
@childAttributes["content"] = attribute
|
25
30
|
end
|
26
31
|
|
27
32
|
def serialize
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
33
|
+
if @type == 'nil'
|
34
|
+
serialized = "Null"
|
35
|
+
elsif @isObject
|
36
|
+
serialized = "#{@name}: {<br><ul>"
|
37
|
+
@childAttributes.each do |attribute|
|
38
|
+
serialized = serialized + "<li>#{attribute[1].serialize}</li>"
|
39
|
+
end
|
40
|
+
serialized = serialized + "</ul>}"
|
41
|
+
elsif @isCollection
|
42
|
+
if @childAttributes['content'].nil?
|
43
|
+
serialized = "#{@name}: [<br><ul><li>Null</li><li>...</li></ul>"
|
44
|
+
else
|
45
|
+
# puts "child attributes: #{@childAttributes['content'].type}"
|
46
|
+
serialized = "#{@name}: [<br><ul><li>#{@childAttributes['content'].serialize},</li><li>...</li>]</ul>"
|
47
|
+
end
|
48
|
+
else
|
49
|
+
unless @example.nil?
|
50
|
+
serialized = "#{@name}: #{@example}"
|
36
51
|
else
|
37
|
-
|
38
|
-
serialized = "#{@name}: #{@example}"
|
39
|
-
else
|
40
|
-
serialized = "#{@name}: #{@type}"
|
41
|
-
end
|
52
|
+
serialized = "#{@name}: #{@type}"
|
42
53
|
end
|
43
|
-
|
54
|
+
end
|
55
|
+
serialized
|
44
56
|
end
|
45
57
|
|
46
|
-
def
|
58
|
+
def dump
|
47
59
|
puts self.serialize
|
48
60
|
end
|
49
61
|
end
|
@@ -54,25 +54,33 @@
|
|
54
54
|
<%description = method.description%>
|
55
55
|
<div class='list-group-item'>
|
56
56
|
<h4 class='list-group-item-heading'>CRUD: <%=type%><br>Name: <%name%></h4>
|
57
|
-
<p
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
<%unless outputs.nil?%>
|
66
|
-
<% for output in outputs%>
|
67
|
-
<%output = output[1]%>
|
68
|
-
<%if output != 'nil'%>
|
69
|
-
<li><%=output.serialize%></li>
|
70
|
-
<%else%>
|
71
|
-
<li>Null</li>
|
57
|
+
<p>
|
58
|
+
<br>Inputs:
|
59
|
+
<br>
|
60
|
+
<ul>
|
61
|
+
<%unless inputs.nil?%>
|
62
|
+
<%for input in inputs%>
|
63
|
+
<%input = input[1]%>
|
64
|
+
<li><%=input.serialize%></li>
|
72
65
|
<%end%>
|
73
|
-
|
74
|
-
|
75
|
-
|
66
|
+
<%end%>
|
67
|
+
</ul>
|
68
|
+
<br>Outputs:
|
69
|
+
<br>
|
70
|
+
<ul>
|
71
|
+
<%unless outputs.nil?%>
|
72
|
+
<% for output in outputs%>
|
73
|
+
<%output = output[1]%>
|
74
|
+
<%if output != 'nil'%>
|
75
|
+
<li><%=output.serialize%></li>
|
76
|
+
<%else%>
|
77
|
+
<li>Null</li>
|
78
|
+
<%end%>
|
79
|
+
<%end%>
|
80
|
+
<%end%>
|
81
|
+
</ul>
|
82
|
+
<br>Description: <%=description%>
|
83
|
+
</p>
|
76
84
|
</div>
|
77
85
|
<%end%>
|
78
86
|
<%end%>
|
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: 3.1.
|
4
|
+
version: 3.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Phari Solutions
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2018-02-
|
12
|
+
date: 2018-02-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|