Class: RspecApiDocumentation::Views::MarkupExample
- Inherits:
-
Mustache
- Object
- Mustache
- RspecApiDocumentation::Views::MarkupExample
show all
- Defined in:
- lib/rspec_api_documentation/views/markup_example.rb
Instance Method Summary
collapse
Constructor Details
#initialize(example, configuration) ⇒ MarkupExample
Returns a new instance of MarkupExample.
6
7
8
9
10
11
|
# File 'lib/rspec_api_documentation/views/markup_example.rb', line 6
def initialize(example, configuration)
@example = example
@host = configuration.curl_host
@filter_headers = configuration.
self.template_path = configuration.template_path
end
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
13
14
15
|
# File 'lib/rspec_api_documentation/views/markup_example.rb', line 13
def method_missing(method, *args, &block)
@example.send(method, *args, &block)
end
|
Instance Method Details
#dirname ⇒ Object
21
22
23
|
# File 'lib/rspec_api_documentation/views/markup_example.rb', line 21
def dirname
resource_name.to_s.downcase.gsub(/\s+/, '_').gsub(":", "_")
end
|
#extension ⇒ Object
62
63
64
|
# File 'lib/rspec_api_documentation/views/markup_example.rb', line 62
def extension
raise 'Parent class. This method should not be called.'
end
|
#filename ⇒ Object
25
26
27
28
29
|
# File 'lib/rspec_api_documentation/views/markup_example.rb', line 25
def filename
basename = description.downcase.gsub(/\s+/, '_').gsub(Pathname::SEPARATOR_PAT, '')
basename = Digest::MD5.new.update(description).to_s if basename.blank?
"#{basename}.#{extension}"
end
|
#parameters ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
# File 'lib/rspec_api_documentation/views/markup_example.rb', line 31
def parameters
super.each do |parameter|
if parameter.has_key?(:scope)
scope = Array(parameter[:scope]).each_with_index.map do |scope, index|
if index == 0
scope
else
"[#{scope}]"
end
end.join
parameter[:scope] = scope
end
end
end
|
#requests ⇒ Object
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/rspec_api_documentation/views/markup_example.rb', line 46
def requests
super.map do |hash|
hash[:request_headers_text] = format_hash(hash[:request_headers])
hash[:request_query_parameters_text] = format_hash(hash[:request_query_parameters])
hash[:response_headers_text] = format_hash(hash[:response_headers])
if @host
if hash[:curl].is_a? RspecApiDocumentation::Curl
hash[:curl] = hash[:curl].output(@host, @filter_headers)
end
else
hash[:curl] = nil
end
hash
end
end
|
#respond_to?(method, include_private = false) ⇒ Boolean
17
18
19
|
# File 'lib/rspec_api_documentation/views/markup_example.rb', line 17
def respond_to?(method, include_private = false)
super || @example.respond_to?(method, include_private)
end
|