module ApiSim::ViewHelpers
Public Instance Methods
config()
click to toggle source
# File lib/api_sim/view_helpers.rb, line 15 def config @config end
custom_matcher?(endpoint)
click to toggle source
# File lib/api_sim/view_helpers.rb, line 7 def custom_matcher?(endpoint) endpoint.custom_matcher? ? '(Custom matcher)' : '' end
endpoint_match(endpoint)
click to toggle source
# File lib/api_sim/view_helpers.rb, line 41 def endpoint_match (endpoint) if endpoint.match_on_body? then "/#{endpoint.matcher.source}/" else '' end end
endpoint_query_string(endpoint)
click to toggle source
# File lib/api_sim/view_helpers.rb, line 11 def endpoint_query_string(endpoint) "?#{endpoint.query}" if endpoint.query != '' end
endpoints()
click to toggle source
# File lib/api_sim/view_helpers.rb, line 3 def endpoints self.class.endpoints.reject(&:overridden?).sort_by { |endpoint| [endpoint.http_method, endpoint.route].join(' ') } end
h(text)
click to toggle source
# File lib/api_sim/view_helpers.rb, line 28 def h(text) Rack::Utils.escape_html(text) end
link_to_read_requests(endpoint)
click to toggle source
# File lib/api_sim/view_helpers.rb, line 32 def link_to_read_requests(endpoint) match = endpoint.match_on_body? ? endpoint.matcher.source : '' <<-HTML <a href="#{ui_root}/requests/#{endpoint.http_method}#{endpoint.route}?match=#{match}"> #{endpoint.requests.count} </a> HTML end
link_to_response_edit(endpoint)
click to toggle source
# File lib/api_sim/view_helpers.rb, line 19 def link_to_response_edit(endpoint) match = endpoint.match_on_body? ? endpoint.matcher.source : '' <<-HTML <a href="#{ui_root}/response/#{endpoint.http_method}#{endpoint.route}?match=#{match}"> #{endpoint.route} </a> HTML end
ui_root()
click to toggle source
# File lib/api_sim/view_helpers.rb, line 49 def ui_root self.class.ui_root end