dart.rb 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. module Docs
  2. class Dart < FileScraper
  3. self.type = 'dart'
  4. self.root_path = 'index.html'
  5. self.links = {
  6. home: 'https://dart.dev/',
  7. code: 'https://github.com/dart-lang/sdk'
  8. }
  9. html_filters.push 'dart/entries', 'dart/clean_html'
  10. options[:fix_urls] = ->(url) do
  11. # localhost/dart-web_audio/..dart-io/dart-io-library.html > localhost/dart-io/dart-io-library.html
  12. url.remove!(/[^\/]+\/\.\./)
  13. url
  14. end
  15. options[:attribution] = <<-HTML
  16. &copy; 2012 the Dart project authors<br>
  17. Licensed under the Creative Commons Attribution-ShareAlike License v4.0.
  18. HTML
  19. version '2' do
  20. self.release = '2.5.0'
  21. self.base_url = "https://api.dart.dev/stable/#{release}/"
  22. end
  23. version '1' do
  24. self.release = '1.24.3'
  25. self.base_url = "https://api.dart.dev/stable/#{release}/"
  26. end
  27. def get_latest_version(opts)
  28. doc = fetch_doc('https://api.dartlang.org/', opts)
  29. label = doc.at_css('footer > span').content.strip
  30. label.sub(/Dart /, '')
  31. end
  32. end
  33. end