Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 

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