Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

54 рядки
1.6 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 Description to make sure first character is capitalized
  17. desc_val = values[2].lstrip.chop
  18. if !/[[:upper:]]/.match(desc_val[0])
  19. puts "(#{line_num}) Invalid Description (first char not uppercase): #{desc_val}"
  20. fail_flag = true
  21. end
  22. # Check Auth values to conform to valid options only
  23. auth_val = values[3].lstrip.chop.tr('``', '')
  24. if !auth_keys.include?(auth_val)
  25. puts "(#{line_num}) Invalid Auth (not a valid option): #{auth_val}"
  26. fail_flag = true
  27. end
  28. # Check HTTPS Support values to be either "Yes" or "No"
  29. https_val = values[4].lstrip.chop
  30. if !https_keys.include?(https_val)
  31. puts "(#{line_num}) Invalid HTTPS: (must use \"Yes\" or \"No\"): #{https_val}"
  32. fail_flag = true
  33. end
  34. # Check Link to ensure url is wrapped in "[Go!]" view
  35. link_val = values[5].lstrip.chop
  36. if !link_val.start_with?("[Go!](") || !link_val.end_with?(')')
  37. puts "(#{line_num}) Invalid Link: (format should be \"[Go!](<LINK>)\"): #{link_val}"
  38. fail_flag = true
  39. end
  40. end
  41. end
  42. if fail_flag
  43. exit(1)
  44. else
  45. exit(0)
  46. end