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
81
82
83
84
85
86
87
88
89
|
# File 'lib/apipie/extractor.rb', line 81
def apis_from_routes
return @apis_from_routes if @apis_from_routes
@api_prefix = Apipie.api_base_url.sub(%r{/$},"")
populate_api_routes
update_api_descriptions
@apis_from_routes
end
|
.call_finished ⇒ Object
62
63
64
65
66
67
|
# File 'lib/apipie/extractor.rb', line 62
def call_finished
@collector ||= Collector.new
if record = call_recorder.record
@collector.handle_record(record)
end
end
|
.call_recorder ⇒ Object
58
59
60
|
# File 'lib/apipie/extractor.rb', line 58
def call_recorder
Thread.current[:apipie_call_recorder] ||= Recorder.new
end
|
.clean_call_recorder ⇒ Object
69
70
71
|
# File 'lib/apipie/extractor.rb', line 69
def clean_call_recorder
Thread.current[:apipie_call_recorder] = nil
end
|
.controller_path(name) ⇒ Object
91
92
93
|
# File 'lib/apipie/extractor.rb', line 91
def controller_path(name)
Apipie.api_controllers_paths.detect { |p| p.include?("#{name}_controller.rb") }
end
|
.finish ⇒ Object
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/apipie/extractor.rb', line 36
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
54
55
56
|
# File 'lib/apipie/extractor.rb', line 54
def logger
Rails.logger
end
|
.write_docs ⇒ Object
73
74
75
|
# File 'lib/apipie/extractor.rb', line 73
def write_docs
Writer.new(@collector).write_docs if @collector
end
|
.write_examples ⇒ Object
77
78
79
|
# File 'lib/apipie/extractor.rb', line 77
def write_examples
Writer.new(@collector).write_examples if @collector
end
|