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