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
84
85
86
87
88
89
90
91
92
|
# File 'lib/apipie/extractor.rb', line 84
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
65
66
67
68
69
70
|
# File 'lib/apipie/extractor.rb', line 65
def call_finished
@collector ||= Collector.new
if record = call_recorder.record
@collector.handle_record(record)
end
end
|
.call_recorder ⇒ Object
61
62
63
|
# File 'lib/apipie/extractor.rb', line 61
def call_recorder
Thread.current[:apipie_call_recorder] ||= Recorder.new
end
|
.clean_call_recorder ⇒ Object
72
73
74
|
# File 'lib/apipie/extractor.rb', line 72
def clean_call_recorder
Thread.current[:apipie_call_recorder] = nil
end
|
.controller_path(name) ⇒ Object
94
95
96
|
# File 'lib/apipie/extractor.rb', line 94
def controller_path(name)
Apipie.api_controllers_paths.detect { |p| p.include?("#{name}_controller.rb") }
end
|
.finish ⇒ Object
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
# File 'lib/apipie/extractor.rb', line 39
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
57
58
59
|
# File 'lib/apipie/extractor.rb', line 57
def logger
Rails.logger
end
|
.write_docs ⇒ Object
76
77
78
|
# File 'lib/apipie/extractor.rb', line 76
def write_docs
Writer.new(@collector).write_docs if @collector
end
|
.write_examples ⇒ Object
80
81
82
|
# File 'lib/apipie/extractor.rb', line 80
def write_examples
Writer.new(@collector).write_examples if @collector
end
|