Module: Apipie::Extractor
- Defined in:
- lib/apipie/extractor.rb,
lib/apipie/extractor/writer.rb,
lib/apipie/extractor/recorder.rb,
lib/apipie/extractor/collector.rb
Defined Under Namespace
Classes: ActionDescriptionUpdater, Collector, OrderedHash, Recorder, Writer
Class Method Summary
collapse
Class Method Details
.apis_from_routes ⇒ Object
86
87
88
89
90
91
92
93
94
|
# File 'lib/apipie/extractor.rb', line 86
def apis_from_routes
return @apis_from_routes if @apis_from_routes
@api_prefix = Apipie.api_base_url.sub(/\/$/,"")
populate_api_routes
update_api_descriptions
@apis_from_routes
end
|
.call_finished ⇒ Object
67
68
69
70
71
72
|
# File 'lib/apipie/extractor.rb', line 67
def call_finished
@collector ||= Collector.new
if record = call_recorder.record
@collector.handle_record(record)
end
end
|
.call_recorder ⇒ Object
63
64
65
|
# File 'lib/apipie/extractor.rb', line 63
def call_recorder
Thread.current[:apipie_call_recorder] ||= Recorder.new
end
|
.clean_call_recorder ⇒ Object
74
75
76
|
# File 'lib/apipie/extractor.rb', line 74
def clean_call_recorder
Thread.current[:apipie_call_recorder] = nil
end
|
.controller_path(name) ⇒ Object
96
97
98
|
# File 'lib/apipie/extractor.rb', line 96
def controller_path(name)
Apipie.api_controllers_paths.detect { |p| p.include?("#{name}_controller.rb") }
end
|
.finish ⇒ Object
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/apipie/extractor.rb', line 41
def finish
record_params, record_examples = false, false
case Apipie.configuration.record
when "params" then record_params = true
when "examples" then record_examples = true
when "all" then record_params = true, record_examples = true
end
if record_examples
puts "Writing examples to a file"
write_examples
end
if record_params
puts "Updating auto-generated documentation"
write_docs
end
end
|
.logger ⇒ Object
59
60
61
|
# File 'lib/apipie/extractor.rb', line 59
def logger
Rails.logger
end
|
.write_docs ⇒ Object
78
79
80
|
# File 'lib/apipie/extractor.rb', line 78
def write_docs
Writer.new(@collector).write_docs if @collector
end
|
.write_examples ⇒ Object
82
83
84
|
# File 'lib/apipie/extractor.rb', line 82
def write_examples
Writer.new(@collector).write_examples if @collector
end
|