class TestsDoc::Index

Constants

PATH

Public Instance Methods

write() click to toggle source
# File lib/tests_doc/index.rb, line 9
def write
  ::File.write(::File.join(TestsDoc.configuration.root_folder, PATH), content)
end

Private Instance Methods

content() click to toggle source
# File lib/tests_doc/index.rb, line 15
def content
  [
    main,
    endpoints_output
  ].flatten.join("\n")
end
endpoint_file_text(endpoint) click to toggle source
# File lib/tests_doc/index.rb, line 53
def endpoint_file_text(endpoint)
  "[#{endpoint}](#{endpoint.gsub(/^\//, '')})\n"
end
endpoints_output() click to toggle source
# File lib/tests_doc/index.rb, line 34
def endpoints_output
  output = [
    "# Endpoints\n"
  ]

  endpoints.each do |endpoint, files|
    output << "##{endpoint}"
    output += files.map(&method(:endpoint_file_text))
  end

  output
end
main() click to toggle source
# File lib/tests_doc/index.rb, line 22
      def main
        strip_heredoc <<-EO
          # Api Interactions

          This document contains a list of api endpoints tested.
          If one of the api endpoint is modified during the test suite if its a deletion,
          make sure this wont affect any of code consuming the api endpoint.

          #{timestamps_content}
        EO
      end
strip_heredoc(string) click to toggle source

copied from activesupport/lib/active_support/core_ext/string/strip.rb, line 22

# File lib/tests_doc/index.rb, line 58
def strip_heredoc(string)
  indent = string.scan(/^[ \t]*(?=\S)/).min.try(:size) || 0
  string.gsub(/^[ \t]{#{indent}}/, '')
end
timestamps_content() click to toggle source
# File lib/tests_doc/index.rb, line 47
def timestamps_content
  return "" unless TestsDoc.configuration.add_index_timestamps

  "Last modified at: #{Time.now.strftime("%m/%d/%Y %I:%M%p")}\n"
end