phpunit.rb 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. module Docs
  2. class Phpunit < UrlScraper
  3. self.name = 'PHPUnit'
  4. self.type = 'phpunit'
  5. self.root_path = 'index.html'
  6. self.links = {
  7. home: 'https://phpunit.de/',
  8. code: 'https://github.com/sebastianbergmann/phpunit'
  9. }
  10. options[:skip] = [
  11. 'bibliography.html',
  12. 'copyright.html'
  13. ]
  14. options[:root_title] = 'PHPUnit'
  15. options[:title] = false
  16. options[:attribution] = <<-HTML
  17. &copy; 2005&ndash;2020 Sebastian Bergmann<br>
  18. Licensed under the Creative Commons Attribution 3.0 Unported License.
  19. HTML
  20. FILTERS = %w(phpunit/clean_html phpunit/entries title)
  21. version '9' do
  22. self.release = '9.5'
  23. self.base_url = "https://phpunit.readthedocs.io/en/#{release}/"
  24. html_filters.push FILTERS
  25. options[:container] = '.document'
  26. end
  27. version '8' do
  28. self.release = '8.5'
  29. self.base_url = "https://phpunit.readthedocs.io/en/#{release}/"
  30. html_filters.push FILTERS
  31. options[:container] = '.document'
  32. end
  33. OLDFILTERS = %w(phpunit/clean_html_old phpunit/entries_old title)
  34. OLDSKIP = %w(
  35. appendixes.index.html
  36. appendixes.bibliography.html
  37. appendixes.copyright.html)
  38. version '6' do
  39. self.release = '6.5'
  40. self.base_url = "https://phpunit.de/manual/#{release}/en/"
  41. html_filters.push OLDFILTERS
  42. options[:skip] = OLDSKIP
  43. end
  44. version '5' do
  45. self.release = '5.7'
  46. self.base_url = "https://phpunit.de/manual/#{release}/en/"
  47. html_filters.push OLDFILTERS
  48. options[:skip] = OLDSKIP
  49. end
  50. version '4' do
  51. self.release = '4.8'
  52. self.base_url = "https://phpunit.de/manual/#{release}/en/"
  53. options[:skip] = OLDSKIP
  54. html_filters.push OLDFILTERS
  55. end
  56. def get_latest_version(opts)
  57. doc = fetch_doc('https://phpunit.readthedocs.io/', opts)
  58. label = doc.at_css('.rst-current-version').content.strip
  59. label.scan(/v: ([0-9.]+)/)[0][0]
  60. end
  61. end
  62. end