grape-dsl 1.2.2 → 1.3.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 CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- YzRlNGVmZGMwODZlOTJhMTY5NjJkNjY4YjZiNDFhMTNmNDU4ZmJkZg==
5
- data.tar.gz: !binary |-
6
- NTZhN2Q0OWI0M2U1NDIzYjhlOTA2OWNjZWQ1NGFjY2I5ZTViMTBhNQ==
2
+ SHA1:
3
+ metadata.gz: 0d49f85e73510207801984abfad36a45999bf54c
4
+ data.tar.gz: e1aa53de44935e387db8121c2985aaf388d360e9
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- Zjc1NDFlMGU2YzNiODg1ZTc0MzIxNGJmMzZlZWVmNzNhMWFmMjBlZWEzYzMz
10
- Mjg4M2U5NGY3NzEyMzZkMWU5OGIwMzE3ZjlhNTM4ZGRkYjI2NDk4MGY2YmNl
11
- N2Y0Mjc1ZWYyMjdkNDk5MzBkYmVmNDU2ZjBiNTE1OGI0YzVjMTQ=
12
- data.tar.gz: !binary |-
13
- YzlhOGI2ZGI5NzIxZmJhMjcxNzAwNDdkMTg2Y2ViZWVlNTZkYTQzZWY0OGM5
14
- NWYyMGZhNDAyYTM2ZDgxOTM3OWQwZjI5MGRjYjE4YjRjYTVmY2M5ZDA5ZGVh
15
- N2VjYjY0YTYyZjJhNzY2NDM4NmE5NjcwNjBmNzAwNDFiNmRlMTk=
6
+ metadata.gz: a0cb2d97ce1259c36bbff809b037d91efd52076aa789af65bd095c16ab00221862887711fe0e85ada408c312845c7d86b3007681b9ad38f373de66077ab3e5ed
7
+ data.tar.gz: 62e02105d1be4a63d276077cc3dd8ef12a7eab75dea64db53dda3cb1c5fc728dea4e3eafad527d07232f0ae5074444e4013228411ba9b6b6826b9f598d8731ac
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.2
1
+ 1.3.0
data/files.rb CHANGED
@@ -1,9 +1,9 @@
1
1
  ### Get Files from dir
2
2
  begin
3
3
 
4
- files_to_be_loaded = %w[version.rb]
5
-
6
- SpecFiles= Array.new
4
+ module GrapeDSL
5
+ SpecFiles= Array.new
6
+ end
7
7
 
8
8
  Dir[File.expand_path(File.join(File.dirname(__FILE__),"**","*"))].sort.uniq.each do |one_file_name|
9
9
  one_file_name = File.expand_path one_file_name
@@ -11,11 +11,10 @@ begin
11
11
 
12
12
  if !one_file_name.include?("pkg")
13
13
  if !File.directory? file_name
14
- SpecFiles.push file_name
14
+
15
+ GrapeDSL::SpecFiles.push file_name
15
16
  STDOUT.puts file_name if $DEBUG
16
- if files_to_be_loaded.include? one_file_name.split(File::SEPARATOR).last
17
- load one_file_name
18
- end
17
+
19
18
  end
20
19
  end
21
20
 
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
14
14
  spec.homepage = "https://github.com/adamluzsi/grape-dsl"
15
15
  spec.license = "MIT"
16
16
 
17
- spec.files = SpecFiles
17
+ spec.files = GrapeDSL::SpecFiles
18
18
  spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
20
  spec.require_paths = ["lib"]
@@ -1,13 +1,11 @@
1
1
  #encoding: UTF-8
2
- module Grape
3
- module DSL
2
+ module GrapeDSL
4
3
 
5
- require 'procemon'
6
- require 'grape'
7
- require 'json'
8
- require 'yaml'
4
+ require 'procemon'
5
+ require 'grape'
6
+ require 'json'
7
+ require 'yaml'
9
8
 
10
- require_relative_directory 'grape-dsl'
9
+ require_relative_directory 'grape-dsl'
11
10
 
12
- end
13
- end
11
+ end
@@ -1,6 +1,5 @@
1
1
 
2
2
  class Array
3
-
4
3
  def convert_all_value_to_s
5
4
 
6
5
  self.count.times do |index|
@@ -23,12 +22,8 @@ class Array
23
22
 
24
23
  return self
25
24
  end
26
-
27
25
  end
28
-
29
-
30
26
  class Hash
31
-
32
27
  def convert_all_value_to_s
33
28
 
34
29
  self.each do |key,value|
@@ -50,479 +45,482 @@ class Hash
50
45
 
51
46
  return self
52
47
  end
53
-
54
48
  end
55
49
 
56
- module Grape
57
- class << self
50
+ module GrapeDSL
51
+ module Extend
52
+ module Doc
58
53
 
59
- def syntax_highlight target,wrapper_begin,wrapper_end
60
- return "#{wrapper_begin}#{target}#{wrapper_end}"
61
- end
54
+ def syntax_highlight target,wrapper_begin,wrapper_end
55
+ return "#{wrapper_begin}#{target}#{wrapper_end}"
56
+ end
62
57
 
63
- # helpers for doc generation
64
- def wiki_body(route,wrapper_begin,wrapper_end,wrapper_close)
58
+ # helpers for doc generation
59
+ def wiki_body(route,wrapper_begin,wrapper_end,wrapper_close)
65
60
 
66
- description_key= :body
67
- tmp_array= Array.new()
68
- params= nil
69
- evalue= nil
70
- content_type= nil
61
+ description_key= :body
62
+ tmp_array= Array.new()
63
+ params= nil
64
+ evalue= nil
65
+ content_type= nil
71
66
 
72
- #if route.route_path == "/booking/request(.:format)"
73
- # debugger
74
- #end
67
+ #if route.route_path == "/booking/request(.:format)"
68
+ # debugger
69
+ #end
75
70
 
76
- case route.route_description.class.to_s.downcase
71
+ case route.route_description.class.to_s.downcase
77
72
 
78
- when "string"
79
- params= route.route_params
73
+ when "string"
74
+ params= route.route_params
80
75
 
81
- when "hash"
76
+ when "hash"
82
77
 
83
- if !route.route_description[:content_type].nil?
84
- content_type= route.route_description[:content_type]
85
- end
78
+ if !route.route_description[:content_type].nil?
79
+ content_type= route.route_description[:content_type]
80
+ end
86
81
 
87
- if description_key.nil?
88
- params= route.route_params
89
- evalue= "value[:type]"
90
- else
91
- params= route.route_description[description_key]
92
- evalue= "value"
93
- end
82
+ if description_key.nil?
83
+ params= route.route_params
84
+ evalue= "value[:type]"
85
+ else
86
+ params= route.route_description[description_key]
87
+ evalue= "value"
88
+ end
94
89
 
95
- when "nilclass"
96
- params= route.route_params
97
- params ||= "no return"
98
- content_type= "TXT"
90
+ when "nilclass"
91
+ params= route.route_params
92
+ params ||= "no return"
93
+ content_type= "TXT"
99
94
 
100
- else
101
- params= route.route_params
102
- content_type= "TXT"
95
+ else
96
+ params= route.route_params
97
+ content_type= "TXT"
103
98
 
104
- end
99
+ end
105
100
 
106
- case params.class.to_s.downcase
101
+ case params.class.to_s.downcase
107
102
 
108
- when "hash"
103
+ when "hash"
109
104
 
110
- if params == route.route_params
111
- tmp_hash= Hash.new
112
- params.each do |key,value|
113
- tmp_hash[key]= value[:type].to_s
105
+ if params == route.route_params
106
+ tmp_hash= Hash.new
107
+ params.each do |key,value|
108
+ tmp_hash[key]= value[:type].to_s
109
+ end
110
+ params= tmp_hash
114
111
  end
115
- params= tmp_hash
116
- end
117
112
 
118
- params = params.convert_all_value_to_s
113
+ params = params.convert_all_value_to_s
119
114
 
120
- when "class"
121
- begin
122
- if params.to_s.include? '::'
123
- if params.to_s.downcase.include? 'boolean'
124
- params= params.to_s.split('::').last
115
+ when "class"
116
+ begin
117
+ if params.to_s.include? '::'
118
+ if params.to_s.downcase.include? 'boolean'
119
+ params= params.to_s.split('::').last
120
+ end
125
121
  end
122
+
123
+ content_type= "TXT"
126
124
  end
127
125
 
126
+ when "string"
128
127
  content_type= "TXT"
129
- end
130
128
 
131
- when "string"
132
- content_type= "TXT"
129
+ else
130
+ begin
131
+ params= "no params spec"
132
+ content_type= "TXT"
133
+ end
133
134
 
134
- else
135
- begin
136
- params= "no params spec"
137
- content_type= "TXT"
138
- end
135
+ end
139
136
 
140
- end
137
+ content_type ||= "TXT"
138
+ case content_type.to_s.downcase
141
139
 
142
- content_type ||= "TXT"
143
- case content_type.to_s.downcase
140
+ when "json"
141
+ begin
144
142
 
145
- when "json"
146
- begin
147
143
 
148
144
 
145
+ tmp_array.push syntax_highlight(content_type.to_s,wrapper_begin,wrapper_end)
149
146
 
150
- tmp_array.push syntax_highlight(content_type.to_s,wrapper_begin,wrapper_end)
147
+ require "json"
151
148
 
152
- require "json"
149
+ formatted_string= params.to_json
150
+
151
+ {
152
+ "{" => "{\n",
153
+ "}" => "\n}",
154
+ "," => ",\n"
155
+ }.each do |from,to|
156
+ formatted_string.gsub!(from,to)
157
+ end
153
158
 
154
- formatted_string= params.to_json
159
+ formatted_string.gsub!(/^"/," \"")
155
160
 
156
- {
157
- "{" => "{\n",
158
- "}" => "\n}",
159
- "," => ",\n"
160
- }.each do |from,to|
161
- formatted_string.gsub!(from,to)
161
+ tmp_array.push formatted_string
162
+ tmp_array.push wrapper_close
162
163
  end
163
164
 
164
- formatted_string.gsub!(/^"/," \"")
165
+ when "txt"
166
+ begin
167
+ tmp_array.push(params.inspect)
168
+ end
165
169
 
166
- tmp_array.push formatted_string
167
- tmp_array.push wrapper_close
168
- end
169
170
 
170
- when "txt"
171
- begin
172
- tmp_array.push(params.inspect)
173
- end
174
171
 
172
+ end
175
173
 
174
+ return tmp_array
176
175
 
177
176
  end
178
177
 
179
- return tmp_array
180
-
181
- end
178
+ # this method help create from grape params and description a ppt like redmine wiki doc
179
+ # Usage:
180
+ #
181
+ ##> example variable for description (hash obj)
182
+ #description= Hash.new
183
+ #
184
+ ##> optional -> :description
185
+ #description[:desc]= String.new
186
+ #
187
+ ##> response body like if JSON than a ruby Hash obj with the Structure and the values are the types
188
+ #description[:body]= Hash.new
189
+ #
190
+ ##> response body code type -> like json usually same as content_type (format :xy)
191
+ #description[:content_type]= String.new #> "JSON"
192
+ #
193
+ #desc description
194
+ #params do
195
+ # optional :blabla, :type => String, :desc => "bla bla desc"
196
+ # requires :xy, type: String, desc: "XY desc"
197
+ #end
198
+ #get "xy" do
199
+ #
200
+ #end
201
+ #
202
+ ##>---------------------------------------------------------------------------------------------------
203
+ #> OR the classic
204
+ #desc "My awsome String Description"
205
+ #params do
206
+ # optional :blabla, :type => String, :desc => "bla bla desc"
207
+ # requires :xy, type: String, desc: "XY desc"
208
+ #end
209
+ #delete "xy" do
210
+ #
211
+ #end
212
+ #
213
+ ##>---------------------------------------------------------------------
214
+ ## For the method use
215
+ #
216
+ ## for a targeted specified class
217
+ #Grape.create_redmine_wiki_doc target_class: REST::API,
218
+ # path: File.expand_path(File.join(File.dirname(__FILE__),"test_file.txt"))
219
+ #
220
+ ## for all grape subclass (directs and indirects)
221
+ #Grape.create_redmine_wiki_doc path: File.expand_path(File.join(File.dirname(__FILE__),"test_file.txt"))
222
+ #
223
+ def create_wiki_doc(*args)
224
+
225
+ # default set in args
226
+ begin
227
+
228
+ args= Hash[*args]
229
+ args.dup.each do |key,value|
230
+ if key.class != Symbol
231
+ args[key.to_s.to_sym]= value
232
+ args.delete key
233
+ end
234
+ end
182
235
 
183
- # this method help create from grape params and description a ppt like redmine wiki doc
184
- # Usage:
185
- #
186
- ##> example variable for description (hash obj)
187
- #description= Hash.new
188
- #
189
- ##> optional -> :description
190
- #description[:desc]= String.new
191
- #
192
- ##> response body like if JSON than a ruby Hash obj with the Structure and the values are the types
193
- #description[:body]= Hash.new
194
- #
195
- ##> response body code type -> like json usually same as content_type (format :xy)
196
- #description[:content_type]= String.new #> "JSON"
197
- #
198
- #desc description
199
- #params do
200
- # optional :blabla, :type => String, :desc => "bla bla desc"
201
- # requires :xy, type: String, desc: "XY desc"
202
- #end
203
- #get "xy" do
204
- #
205
- #end
206
- #
207
- ##>---------------------------------------------------------------------------------------------------
208
- #> OR the classic
209
- #desc "My awsome String Description"
210
- #params do
211
- # optional :blabla, :type => String, :desc => "bla bla desc"
212
- # requires :xy, type: String, desc: "XY desc"
213
- #end
214
- #delete "xy" do
215
- #
216
- #end
217
- #
218
- ##>---------------------------------------------------------------------
219
- ## For the method use
220
- #
221
- ## for a targeted specified class
222
- #Grape.create_redmine_wiki_doc target_class: REST::API,
223
- # path: File.expand_path(File.join(File.dirname(__FILE__),"test_file.txt"))
224
- #
225
- ## for all grape subclass (directs and indirects)
226
- #Grape.create_redmine_wiki_doc path: File.expand_path(File.join(File.dirname(__FILE__),"test_file.txt"))
227
- #
228
- def create_wiki_doc(*args)
229
-
230
- # default set in args
231
- begin
232
-
233
- args= Hash[*args]
234
- args.dup.each do |key,value|
235
- if key.class != Symbol
236
- args[key.to_s.to_sym]= value
237
- args.delete key
236
+ if args[:path].nil?
237
+ raise ArgumentError,"You must set a file path with a file name in order to create documentation for grape!"
238
238
  end
239
- end
240
239
 
241
- if args[:path].nil?
242
- raise ArgumentError,"You must set a file path with a file name in order to create documentation for grape!"
243
- end
240
+ args[:desc_files] ||= Array.new
244
241
 
245
- args[:desc_files] ||= Array.new
242
+ [:desc,:desc_file,:extra_desc_file].each do |one_key|
246
243
 
247
- [:desc,:desc_file,:extra_desc_file].each do |one_key|
244
+ args[:desc_files] += args[(one_key.to_s+"s").to_sym] if args[(one_key.to_s+"s").to_sym].class == Array
245
+ args[:desc_files].push(args[one_key]) if args[one_key].class == String
248
246
 
249
- args[:desc_files] += args[(one_key.to_s+"s").to_sym] if args[(one_key.to_s+"s").to_sym].class == Array
250
- args[:desc_files].push(args[one_key]) if args[one_key].class == String
247
+ end
251
248
 
252
- end
249
+ args[:type] ||= args[:doc_type]
250
+ args[:type] ||= 'wiki'
253
251
 
254
- args[:type] ||= args[:doc_type]
255
- args[:type] ||= 'wiki'
252
+ #args[:path],
253
+ #args[:extra_desc_file]
254
+ #args[:target_class]
255
+ #args[:type]
256
256
 
257
- #args[:path],
258
- #args[:extra_desc_file]
259
- #args[:target_class]
260
- #args[:type]
257
+ end
261
258
 
262
- end
263
259
 
260
+ # defaults
261
+ begin
264
262
 
265
- # defaults
266
- begin
263
+ uni_tab= ""
264
+ case args[:type].to_s.downcase
267
265
 
268
- uni_tab= ""
269
- case args[:type].to_s.downcase
266
+ when "redmine","redmine_wiki","redmine-wiki","redminewiki"
267
+ begin
270
268
 
271
- when "redmine","redmine_wiki","redmine-wiki","redminewiki"
272
- begin
269
+ mid_tab= " "*3
273
270
 
274
- mid_tab= " "*3
271
+ bsym= "*"
272
+ isym= "_"
275
273
 
276
- bsym= "*"
277
- isym= "_"
274
+ htsym= "* "
275
+ mtsym= htsym[0]*2 +" "
276
+ stsym= htsym[0]*3 +" "
278
277
 
279
- htsym= "* "
280
- mtsym= htsym[0]*2 +" "
281
- stsym= htsym[0]*3 +" "
278
+ hheader= "h3. "
279
+ mheader= "h4. "
280
+ sheader= "h5. "
282
281
 
283
- hheader= "h3. "
284
- mheader= "h4. "
285
- sheader= "h5. "
282
+ container_markup_begin= "<pre><code class=\""
283
+ container_markup_end= "\">"
284
+ container_markup_close= "</code></pre>"
286
285
 
287
- container_markup_begin= "<pre><code class=\""
288
- container_markup_end= "\">"
289
- container_markup_close= "</code></pre>"
286
+ toc_mark= "\n{{>toc}}\n"
290
287
 
291
- toc_mark= "\n{{>toc}}\n"
288
+ end
292
289
 
293
- end
290
+ when "github","wiki","md"
291
+ begin
294
292
 
295
- when "github","wiki","md"
296
- begin
293
+ mid_tab= " "*3
297
294
 
298
- mid_tab= " "*3
295
+ bsym= "*"
296
+ isym= "_"
299
297
 
300
- bsym= "*"
301
- isym= "_"
298
+ htsym= "* "
299
+ mtsym= htsym[0]*2 +" "
300
+ stsym= htsym[0]*3 +" "
302
301
 
303
- htsym= "* "
304
- mtsym= htsym[0]*2 +" "
305
- stsym= htsym[0]*3 +" "
302
+ hheader= "# "
303
+ mheader= hheader[0]*2 +" "
304
+ sheader= hheader[0]*3 +" "
306
305
 
307
- hheader= "# "
308
- mheader= hheader[0]*2 +" "
309
- sheader= hheader[0]*3 +" "
306
+ container_markup_begin= "```"
307
+ container_markup_end= ""
308
+ container_markup_close= "```"
309
+ toc_mark= ""
310
310
 
311
- container_markup_begin= "```"
312
- container_markup_end= ""
313
- container_markup_close= "```"
314
- toc_mark= ""
311
+ end
315
312
 
316
- end
313
+ else
314
+ raise ArgumentError, "invalid :type has been set, try github or redmine"
317
315
 
318
- else
319
- raise ArgumentError, "invalid :type has been set, try github or redmine"
316
+ end
320
317
 
321
318
  end
322
319
 
323
- end
324
-
325
- # site name
326
- begin
327
- write_out_array = Array.new
328
- write_out_array.push "#{hheader}#{$0} REST Interface Documentation\n\n"
329
- end
320
+ # site name
321
+ begin
322
+ write_out_array = Array.new
323
+ write_out_array.push "#{hheader}#{$0} REST Interface Documentation\n\n"
324
+ end
330
325
 
331
- # description
332
- begin
333
- args[:desc_files].each do |extra_desc_file_path|
326
+ # description
327
+ begin
328
+ args[:desc_files].each do |extra_desc_file_path|
334
329
 
335
- write_out_array.push "#{sheader}#{extra_desc_file_path.split(File::Separator).last.split('.')[0].camelcase}\n"
336
- write_out_array.push " "+File.open(extra_desc_file_path,"r").read+"\n"
330
+ write_out_array.push "#{sheader}#{extra_desc_file_path.split(File::Separator).last.split('.')[0].camelcase}\n"
331
+ write_out_array.push " "+File.open(extra_desc_file_path,"r").read+"\n"
337
332
 
333
+ end
338
334
  end
339
- end
340
335
 
341
- # table of contents
342
- begin
343
- write_out_array.push toc_mark
344
- end
336
+ # table of contents
337
+ begin
338
+ write_out_array.push toc_mark
339
+ end
345
340
 
346
- # classes array
347
- begin
348
- rest_models= Array.new
349
- end
350
- if args[:target_class].nil?
351
- Grape::API.each_subclass do |one_class|
352
- rest_models.push(one_class)
341
+ # classes array
342
+ begin
343
+ rest_models= Array.new
353
344
  end
354
- else
355
- if args[:target_class].class != Class && args[:target_class] != nil
356
- raise ArgumentError, "invalid input :target_class is not a Class obj"
345
+ if args[:target_class].nil?
346
+ Grape::API.each_subclass do |one_class|
347
+ rest_models.push(one_class)
348
+ end
349
+ else
350
+ if args[:target_class].class != Class && args[:target_class] != nil
351
+ raise ArgumentError, "invalid input :target_class is not a Class obj"
352
+ end
353
+ rest_models.push(args[:target_class])
357
354
  end
358
- rest_models.push(args[:target_class])
359
- end
360
355
 
361
- rest_models.each do |rest_api_model|
362
- next if Grape::API == rest_api_model
363
- rest_api_model.routes.map do |route|
356
+ rest_models.each do |rest_api_model|
357
+ next if Grape::API == rest_api_model
358
+ rest_api_model.routes.map do |route|
364
359
 
365
360
 
366
- method_name= "#{hheader}Request: #{route.route_path} call: #{route.route_method.to_s.downcase} part"
361
+ method_name= "#{hheader}Request: #{route.route_path} call: #{route.route_method.to_s.downcase} part"
367
362
 
368
- # check that does the method already in the documentation
369
- unless write_out_array.include?(method_name)
363
+ # check that does the method already in the documentation
364
+ unless write_out_array.include?(method_name)
370
365
 
371
- # create call name
372
- begin
373
- write_out_array.push method_name
374
- end
375
-
376
- # request
377
- begin
366
+ # create call name
367
+ begin
368
+ write_out_array.push method_name
369
+ end
378
370
 
379
- # create request description
371
+ # request
380
372
  begin
381
- write_out_array.push("\n"+(uni_tab*1)+"#{mheader}Request description")
382
- case route.route_description.class.to_s.downcase
383
373
 
384
- when "string"
385
- route.route_description.each_line do |one_line|
386
- write_out_array.push((uni_tab*2)+htsym+one_line.chomp)
387
- end
374
+ # create request description
375
+ begin
376
+ write_out_array.push("\n"+(uni_tab*1)+"#{mheader}Request description")
377
+ case route.route_description.class.to_s.downcase
388
378
 
389
- when "hash"
390
- begin
391
- sym_to_find= :desc
392
- if route.route_description[sym_to_find].nil?
393
- sym_to_find= :description
394
- end
395
- route.route_description[sym_to_find].each_line do |one_line|
379
+ when "string"
380
+ route.route_description.each_line do |one_line|
396
381
  write_out_array.push((uni_tab*2)+htsym+one_line.chomp)
397
382
  end
398
- end
399
383
 
384
+ when "hash"
385
+ begin
386
+ sym_to_find= :desc
387
+ if route.route_description[sym_to_find].nil?
388
+ sym_to_find= :description
389
+ end
390
+ route.route_description[sym_to_find].each_line do |one_line|
391
+ write_out_array.push((uni_tab*2)+htsym+one_line.chomp)
392
+ end
393
+ end
400
394
 
401
- end
402
- end
403
395
 
404
- # pre request
405
- begin
406
- write_out_array.push("\n#{mheader}request\n")
407
- end
396
+ end
397
+ end
408
398
 
409
- # create route method
410
- begin
411
- write_out_array.push((uni_tab*2)+"#{htsym}#{bsym}method:#{bsym}#{mid_tab} #{route.route_method}")
412
- end
399
+ # pre request
400
+ begin
401
+ write_out_array.push("\n#{mheader}request\n")
402
+ end
413
403
 
414
- # create route path
415
- begin
416
- write_out_array.push((uni_tab*2)+"#{htsym}#{bsym}path:#{bsym}#{mid_tab} #{route.route_path}")
417
- end
404
+ # create route method
405
+ begin
406
+ write_out_array.push((uni_tab*2)+"#{htsym}#{bsym}method:#{bsym}#{mid_tab} #{route.route_method}")
407
+ end
418
408
 
419
- # create route content_type
420
- begin
421
- write_out_array.push((uni_tab*2)+"#{htsym}#{bsym}headers:#{bsym}#{mid_tab}")
422
- rest_api_model.content_types.each do |one_format_type,one_format_header|
423
- write_out_array.push "#{mtsym}#{uni_tab*2}#{one_format_header}"
409
+ # create route path
410
+ begin
411
+ write_out_array.push((uni_tab*2)+"#{htsym}#{bsym}path:#{bsym}#{mid_tab} #{route.route_path}")
424
412
  end
425
413
 
426
- write_out_array.push ""
427
- end
414
+ # create route content_type
415
+ begin
416
+ write_out_array.push((uni_tab*2)+"#{htsym}#{bsym}headers:#{bsym}#{mid_tab}")
417
+ rest_api_model.content_types.each do |one_format_type,one_format_header|
418
+ write_out_array.push "#{mtsym}#{uni_tab*2}#{one_format_header}"
419
+ end
428
420
 
429
- # parameters
430
- begin
431
- new_docs_element= Array.new
432
- if route.route_params.count == 0
433
- new_docs_element.push " No specified or special params"
434
- else
435
- new_docs_element.push ""
436
- new_docs_element.push "#{htsym}#{isym}#{bsym}Parameters#{bsym}#{isym}"
437
- route.route_params.each do |key,value|
438
- new_docs_element.push "#{mtsym}#{isym}#{key}#{isym}"
439
- value.each do |value_key,value_value|
440
- new_docs_element.push "#{stsym}#{value_key}: #{value_value}"
421
+ write_out_array.push ""
422
+ end
423
+
424
+ # parameters
425
+ begin
426
+ new_docs_element= Array.new
427
+ if route.route_params.count == 0
428
+ new_docs_element.push " No specified or special params"
429
+ else
430
+ new_docs_element.push ""
431
+ new_docs_element.push "#{htsym}#{isym}#{bsym}Parameters#{bsym}#{isym}"
432
+ route.route_params.each do |key,value|
433
+ new_docs_element.push "#{mtsym}#{isym}#{key}#{isym}"
434
+ value.each do |value_key,value_value|
435
+ new_docs_element.push "#{stsym}#{value_key}: #{value_value}"
436
+ end
441
437
  end
438
+ new_docs_element.push "\n"
442
439
  end
443
- new_docs_element.push "\n"
444
- end
445
- refactored_element= Array.new
446
- new_docs_element.each do |one_element|
447
- refactored_element.push((uni_tab*2)+one_element)
440
+ refactored_element= Array.new
441
+ new_docs_element.each do |one_element|
442
+ refactored_element.push((uni_tab*2)+one_element)
443
+ end
444
+ write_out_array.push refactored_element.join("\n")
448
445
  end
449
- write_out_array.push refactored_element.join("\n")
446
+
450
447
  end
451
448
 
452
- end
449
+ # response
450
+ begin
453
451
 
454
- # response
455
- begin
452
+ # pre response
453
+ begin
454
+ write_out_array.push("\n#{mheader}response\n")
455
+ end
456
456
 
457
- # pre response
458
- begin
459
- write_out_array.push("\n#{mheader}response\n")
460
- end
457
+ #create route content_type
458
+ begin
459
+ if !Grape::Endpoint.config_obj.nil?
461
460
 
462
- #create route content_type
463
- begin
464
- if !Grape::Endpoint.config_obj.nil?
461
+ write_out_array.push((uni_tab*2)+"#{sheader}Extra headers:")
465
462
 
466
- write_out_array.push((uni_tab*2)+"#{sheader}Extra headers:")
463
+ Grape::Endpoint.header_config_obj.each do |header_key,header_value|
464
+ write_out_array.push "#{htsym}#{header_key}: #{header_value.join(', ')}"
465
+ end
466
+
467
+ write_out_array.push ""
467
468
 
468
- Grape::Endpoint.header_config_obj.each do |header_key,header_value|
469
- write_out_array.push "#{htsym}#{header_key}: #{header_value.join(', ')}"
470
469
  end
470
+ end
471
471
 
472
+ # create response bodies
473
+ begin
474
+ #TODO check out why not working normaly with evry path!
475
+ write_out_array.push((uni_tab*2)+"#{sheader}*body:*")
476
+ wiki_body(route,container_markup_begin,container_markup_end,container_markup_close ).each do |one_element|
477
+ write_out_array.push one_element
478
+ end
472
479
  write_out_array.push ""
473
-
474
480
  end
481
+
475
482
  end
476
483
 
477
- # create response bodies
484
+ # error resp
478
485
  begin
479
- #TODO check out why not working normaly with evry path!
480
- write_out_array.push((uni_tab*2)+"#{sheader}*body:*")
481
- wiki_body(route,container_markup_begin,container_markup_end,container_markup_close ).each do |one_element|
482
- write_out_array.push one_element
483
- end
484
- write_out_array.push ""
485
- end
486
486
 
487
- end
487
+ # pre error
488
+ begin
489
+ write_out_array.push("\n#{mheader}response in case of failure\n")
490
+ end
488
491
 
489
- # error resp
490
- begin
492
+ # create error response headers
493
+ begin
491
494
 
492
- # pre error
493
- begin
494
- write_out_array.push("\n#{mheader}response in case of failure\n")
495
- end
495
+ end
496
496
 
497
- # create error response headers
498
- begin
497
+ # create error response bodies
498
+ begin
499
+ #write_out_array.push((uni_tab*2)+"*body:*")
500
+ write_out_array.push((uni_tab*2)+"#{htsym}*Internal Server Error:500*")
501
+ end
499
502
 
500
503
  end
501
504
 
502
- # create error response bodies
505
+ # after space
503
506
  begin
504
- #write_out_array.push((uni_tab*2)+"*body:*")
505
- write_out_array.push((uni_tab*2)+"#{htsym}*Internal Server Error:500*")
507
+ write_out_array.push "\n----\n"
506
508
  end
507
509
 
508
510
  end
509
511
 
510
- # after space
511
- begin
512
- write_out_array.push "\n----\n"
513
- end
514
-
515
512
  end
516
-
517
513
  end
518
- end
519
514
 
520
- File.new(args[:path],"w").write write_out_array.join("\n")
515
+ File.new(args[:path],"w").write write_out_array.join("\n")
521
516
 
522
- return nil
523
- end
517
+ return nil
518
+ end
524
519
 
525
- alias :create_ppt_doc :create_wiki_doc
520
+ alias :create_ppt_doc :create_wiki_doc
526
521
 
522
+ end
527
523
  end
528
524
  end
525
+
526
+ Grape.__send__ :extend, ::GrapeDSL::Extend::Doc