sinon.rb 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. module Docs
  2. class Sinon < UrlScraper
  3. self.name = 'Sinon.JS'
  4. self.slug = 'sinon'
  5. self.type = 'sinon'
  6. self.links = {
  7. home: 'https://sinonjs.org/',
  8. code: 'https://github.com/sinonjs/sinon'
  9. }
  10. html_filters.push 'sinon/clean_html', 'sinon/entries'
  11. options[:title] = 'Sinon.JS'
  12. options[:container] = '.content .container'
  13. options[:attribution] = <<-HTML
  14. &copy; 2010&ndash;2022 Christian Johansen<br>
  15. Licensed under the BSD License.
  16. HTML
  17. # Links in page point to '../page' what makes devdocs points to non-existent links
  18. options[:fix_urls] = -> (url) do
  19. if !(url =~ /releases\/v\d*/)
  20. url.gsub!(/.*releases\//, "")
  21. end
  22. url
  23. end
  24. RELEASE_MAPPINGS = {
  25. '15' => '15.0.1',
  26. '14' => '14.0.2',
  27. '13' => '13.0.1',
  28. '12' => '12.0.1',
  29. '11' => '11.1.2',
  30. '10' => '10.0.1',
  31. '9' => '9.2.2.',
  32. '8' => '8.1.1',
  33. '7' => '7.5.0',
  34. '6' => '6.3.5',
  35. '5' => '5.1.0',
  36. '4' => '4.5.0',
  37. '3' => '3.3.0',
  38. '2' => '2.4.1',
  39. '1' => '1.17.7'
  40. }
  41. RELEASE_MAPPINGS.each do |ver, release|
  42. version ver do
  43. self.release = release
  44. self.base_url = "https://sinonjs.org/releases/v#{ver}/"
  45. end
  46. end
  47. def get_latest_version(opts)
  48. tags = get_github_tags('sinonjs', 'sinon', opts)
  49. tags[0]['name'][1..-1]
  50. end
  51. end
  52. end