1
0

nix.rb 887 B

12345678910111213141516171819202122232425262728293031
  1. module Docs
  2. class Nix < UrlScraper
  3. self.type = 'simple'
  4. self.release = '2.8.0'
  5. self.base_url = 'https://nixos.org/manual/'
  6. self.root_path = 'nix/stable/expressions/builtins.html'
  7. self.initial_paths = %w(
  8. nix/stable/expressions/builtins.html
  9. nixpkgs/stable/index.html)
  10. self.links = {
  11. home: 'https://nixos.org/',
  12. code: 'https://github.com/NixOS/nix'
  13. }
  14. html_filters.push 'nix/clean_html', 'nix/entries'
  15. options[:skip_links] = true
  16. options[:attribution] = <<-HTML
  17. &copy; 2022 NixOS Contributors<br>
  18. Licensed under the LGPL License.
  19. HTML
  20. def get_latest_version(opts)
  21. doc = fetch_doc('https://nixos.org/manual/nix/stable/', opts)
  22. json = JSON.parse(doc.at_css('body')['data-nix-channels'])
  23. channel = json.find { |c| c['channel'] == 'stable' }
  24. channel['version']
  25. end
  26. end
  27. end