swag 0.1.5 → 0.2.0
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/lib/global_vars.rb +1 -1
- data/lib/swag.rb +5 -3
- data/lib/swag_helper.rb +70 -12
- 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: 32bc8a758f8ddbfc48c7d10b11fc39f760744b8b
|
|
4
|
+
data.tar.gz: e177da8c57c5c06157a6a353ae2f64ec7c29cc3b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e5cbc5a2d8993061faf7364d6170a1e7806669ab67f88e9f119a5ca2d74e61d60b0d3237b059c2cd18419ba212b23a7fd01ec91e7f4e8efdb638888eb7502043
|
|
7
|
+
data.tar.gz: ac552d828e53d02f1d923f2483ab4ae9feecfc01ba72d7714411bc342f09ed371eb6b8462ef14208efcc4293bed3998995e7ce27c3fa40710a21bd5b1dd35700
|
data/lib/global_vars.rb
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
SWAG_VERSION = '0.2.0'
|
data/lib/swag.rb
CHANGED
|
@@ -48,6 +48,7 @@ class Swag
|
|
|
48
48
|
|
|
49
49
|
File.open("app/controllers/#{controllerName}", 'r') do |c|
|
|
50
50
|
@show = false
|
|
51
|
+
@delete = false
|
|
51
52
|
c.each_line do |line|
|
|
52
53
|
if line.include? "def index"
|
|
53
54
|
@helper.doIndex(nameSliced, controllerName, doc)
|
|
@@ -55,11 +56,12 @@ class Swag
|
|
|
55
56
|
@helper.doCreate(nameSliced, controllerName, doc)
|
|
56
57
|
elsif line.include? "def show"
|
|
57
58
|
@show = true
|
|
59
|
+
elsif line.include? "def delete"
|
|
60
|
+
@delete = true
|
|
58
61
|
end
|
|
59
62
|
end # end each_line do block
|
|
60
|
-
if @show
|
|
61
|
-
|
|
62
|
-
end
|
|
63
|
+
@helper.doShow(nameSliced, controllerName, doc) if @show
|
|
64
|
+
@helper.doDelete(nameSliced, controllerName, doc) if @delete
|
|
63
65
|
end # end File.open do block (File is closed automatically)
|
|
64
66
|
end # end analyzeController
|
|
65
67
|
|
data/lib/swag_helper.rb
CHANGED
|
@@ -15,15 +15,19 @@ class SwagHelper
|
|
|
15
15
|
|
|
16
16
|
def writeConfig
|
|
17
17
|
config = File.open("swagGem/config.yml", 'w')
|
|
18
|
-
config << "swag: #{
|
|
18
|
+
config << "swag: #{SWAG_VERSION}\n"
|
|
19
19
|
config << "info:\n"
|
|
20
|
-
config << "
|
|
21
|
-
config << "
|
|
22
|
-
config << "
|
|
23
|
-
config << "
|
|
24
|
-
config << "
|
|
25
|
-
config << "
|
|
26
|
-
config << "
|
|
20
|
+
config << " version:\n"
|
|
21
|
+
config << " title: #{File.basename(Dir.getwd)}\n"
|
|
22
|
+
config << " description: a Rails app.\n"
|
|
23
|
+
config << " author:\n"
|
|
24
|
+
config << " name:\n"
|
|
25
|
+
config << " contact:\n"
|
|
26
|
+
config << " license:\n"
|
|
27
|
+
config << "schemes:\n"
|
|
28
|
+
config << " - http\n"
|
|
29
|
+
config << "consumes:\n"
|
|
30
|
+
config << "produces:\n"
|
|
27
31
|
config << "paths:\n"
|
|
28
32
|
config.close
|
|
29
33
|
end
|
|
@@ -43,20 +47,74 @@ class SwagHelper
|
|
|
43
47
|
|
|
44
48
|
# prints index info to open YAML File 'doc'
|
|
45
49
|
def doIndex(nameSliced, controllerName, doc)
|
|
46
|
-
puts "#{controllerName} contains index"
|
|
50
|
+
# puts "#{controllerName} contains index"
|
|
47
51
|
doc << " get:\n"
|
|
48
52
|
doc << " description: returns an index for this resource.\n"
|
|
53
|
+
doc << " produces:\n"
|
|
54
|
+
doc << " parameters:\n"
|
|
55
|
+
doc << " responses:\n"
|
|
56
|
+
doc << " 200:\n"
|
|
57
|
+
doc << " description: #{nameSliced} response\n"
|
|
58
|
+
doc << " schema:\n"
|
|
59
|
+
doc << " default:\n"
|
|
60
|
+
doc << " description: unexpected error\n"
|
|
61
|
+
doc << " schema:\n"
|
|
49
62
|
end
|
|
50
63
|
|
|
51
64
|
def doCreate(nameSliced, controllerName, doc)
|
|
52
|
-
puts "#{controllerName} contains new"
|
|
65
|
+
# puts "#{controllerName} contains new"
|
|
53
66
|
doc << " post:\n"
|
|
54
|
-
singular = controllerName.slice(0..(nameSliced.index('s') -1))
|
|
55
67
|
doc << " description: creates a new instance of this resource.\n"
|
|
68
|
+
doc << " produces:\n"
|
|
69
|
+
doc << " parameters:\n"
|
|
70
|
+
doc << " responses:\n"
|
|
71
|
+
doc << " 200:\n"
|
|
72
|
+
doc << " description: #{nameSliced} response\n"
|
|
73
|
+
doc << " schema:\n"
|
|
74
|
+
doc << " default:\n"
|
|
75
|
+
doc << " description: unexpected error\n"
|
|
76
|
+
doc << " schema:\n"
|
|
56
77
|
end
|
|
57
78
|
|
|
58
79
|
def doShow(nameSliced, controllerName, doc)
|
|
59
|
-
puts "#{controllerName} contains show"
|
|
80
|
+
# puts "#{controllerName} contains show"
|
|
60
81
|
doc << " /#{nameSliced}/:id\n"
|
|
82
|
+
doc << " get:\n"
|
|
83
|
+
doc << " description: returns a specific #{nameSliced} item by id.\n"
|
|
84
|
+
doc << " produces:\n"
|
|
85
|
+
doc << " parameters:\n"
|
|
86
|
+
doc << " - name: id\n"
|
|
87
|
+
doc << " in: path\n"
|
|
88
|
+
doc << " description: id of specific #{nameSliced} object\n"
|
|
89
|
+
doc << " required: true\n"
|
|
90
|
+
doc << " type: integer\n"
|
|
91
|
+
doc << " format:\n"
|
|
92
|
+
doc << " responses:\n"
|
|
93
|
+
doc << " 200:\n"
|
|
94
|
+
doc << " description: #{nameSliced} response\n"
|
|
95
|
+
doc << " schema:\n"
|
|
96
|
+
doc << " default:\n"
|
|
97
|
+
doc << " description: unexpected error\n"
|
|
98
|
+
doc << " schema:\n"
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
def doDelete(nameSliced, controllerName, doc)
|
|
102
|
+
doc << " delete:\n"
|
|
103
|
+
doc << " description: deletes a specific #{nameSliced} item by id.\n"
|
|
104
|
+
doc << " produces:\n"
|
|
105
|
+
doc << " parameters:\n"
|
|
106
|
+
doc << " - name: id\n"
|
|
107
|
+
doc << " in: path\n"
|
|
108
|
+
doc << " description: id of specific #{nameSliced} object\n"
|
|
109
|
+
doc << " required: true\n"
|
|
110
|
+
doc << " type: integer\n"
|
|
111
|
+
doc << " format:\n"
|
|
112
|
+
doc << " responses:\n"
|
|
113
|
+
doc << " 204:\n"
|
|
114
|
+
doc << " description: #{nameSliced} object deleted\n"
|
|
115
|
+
doc << " schema:\n"
|
|
116
|
+
doc << " default:\n"
|
|
117
|
+
doc << " description: unexpected error\n"
|
|
118
|
+
doc << " schema:\n"
|
|
61
119
|
end
|
|
62
120
|
end # end class
|