Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

47 linhas
1.3 KiB

  1. #!/usr/bin/env ruby
  2. auth_keys = ['apiKey', 'OAuth', 'X-Mashape-Key', 'No']
  3. https_keys = ['Yes', 'No']
  4. args = ARGV
  5. filename = args[0]
  6. fail_flag = false
  7. File.foreach(filename).with_index do |line, line_num|
  8. line_num += 1
  9. # puts "#{line_num}: #{line}"
  10. if line.start_with?('|')
  11. # Skip table schema lines
  12. if line.eql? "|---|---|---|---|---|\n"
  13. next
  14. end
  15. values = line.split("|")
  16. # Check Auth values to conform to valid options only
  17. auth_val = values[3].lstrip.chop.tr('``', '')
  18. if !auth_keys.include?(auth_val)
  19. puts "(#{line_num}) Invalid Auth (not a valid option): #{auth_val}"
  20. fail_flag = true
  21. end
  22. # Check HTTPS Support values to be either "Yes" or "No"
  23. https_val = values[4].lstrip.chop
  24. if !https_keys.include?(https_val)
  25. puts "(#{line_num}) Invalid HTTPS: (must use \"Yes\" or \"No\"): #{https_val}"
  26. fail_flag = true
  27. end
  28. # Check Link to ensure url is wrapped in "[Go!]" view
  29. link_val = values[5].lstrip.chop
  30. if !link_val.start_with?("[Go!](") || !link_val.end_with?(')')
  31. puts "(#{line_num}) Invalid Link: (format should be \"[Go!](<LINK>)\"): #{link_val}"
  32. fail_flag = true
  33. end
  34. end
  35. end
  36. if fail_flag
  37. exit(1)
  38. else
  39. exit(0)
  40. end