Class: Apipie::Extractor::ActionDescriptionUpdater
- Inherits:
-
Object
- Object
- Apipie::Extractor::ActionDescriptionUpdater
show all
- Defined in:
- lib/apipie/extractor/writer.rb
Defined Under Namespace
Classes: ActionNotFound, ControllerNotFound
Instance Method Summary
collapse
Constructor Details
Returns a new instance of ActionDescriptionUpdater.
235
236
237
238
|
# File 'lib/apipie/extractor/writer.rb', line 235
def initialize(controller, action)
@controller = controller
@action = action
end
|
Instance Method Details
#generated? ⇒ Boolean
240
241
242
|
# File 'lib/apipie/extractor/writer.rb', line 240
def generated?
.include?(Apipie.configuration.generated_doc_disclaimer)
end
|
266
267
268
269
270
271
272
273
|
# File 'lib/apipie/extractor/writer.rb', line 266
def
return @old_header if defined? @old_header
@old_header = lines_above_method[/^\s*?#{Regexp.escape(Apipie.configuration.generated_doc_disclaimer)}.*/m]
@old_header ||= lines_above_method[/^\s*?\b(api|params|error|example)\b.*/m]
@old_header ||= ""
@old_header.sub!(/\A\s*\n/,"")
@old_header = align_indented(@old_header)
end
|
#update(new_header) ⇒ Object
262
263
264
|
# File 'lib/apipie/extractor/writer.rb', line 262
def update()
()
end
|
#update_apis(apis) ⇒ Object
244
245
246
247
248
249
250
251
252
253
|
# File 'lib/apipie/extractor/writer.rb', line 244
def update_apis(apis)
= ""
<< Apipie.configuration.generated_doc_disclaimer << "\n" if generated?
<< generate_apis_code(apis)
<< ensure_line_breaks(.lines).reject do |line|
line.include?(Apipie.configuration.generated_doc_disclaimer) ||
line =~ /^api/
end.join
()
end
|
#update_generated_description(desc) ⇒ Object
255
256
257
258
259
260
|
# File 'lib/apipie/extractor/writer.rb', line 255
def update_generated_description(desc)
if generated? || .empty?
= generate_code(desc)
()
end
end
|
#write! ⇒ Object
275
276
277
278
|
# File 'lib/apipie/extractor/writer.rb', line 275
def write!
File.open(controller_path, "w") { |f| f << @controller_content }
@changed=false
end
|