immutable.rb 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. module Docs
  2. class Immutable < UrlScraper
  3. self.name = 'Immutable.js'
  4. self.slug = 'immutable'
  5. self.type = 'simple'
  6. self.release = '3.8.1'
  7. self.base_url = 'https://facebook.github.io/immutable-js/docs/'
  8. self.links = {
  9. home: 'https://facebook.github.io/immutable-js/',
  10. code: 'https://github.com/facebook/immutable-js'
  11. }
  12. html_filters.push 'immutable/clean_html', 'immutable/entries', 'title'
  13. options[:skip_links] = true
  14. options[:container] = '.docContents'
  15. options[:root_title] = 'Immutable.js'
  16. options[:attribution] = <<-HTML
  17. &copy; 2014&ndash;2015 Facebook, Inc.<br>
  18. Licensed under the 3-clause BSD License.
  19. HTML
  20. stub '' do
  21. capybara = load_capybara_selenium
  22. capybara.app_host = 'https://facebook.github.io'
  23. capybara.visit(URL.parse(self.base_url).path)
  24. capybara.execute_script <<-JS
  25. var content, event, links, link;
  26. event = document.createEvent('Event');
  27. event.initEvent('hashchange', false, false);
  28. content = document.querySelector('.docContents section').cloneNode(true);
  29. links = Array.prototype.slice.call(document.querySelectorAll('.sideBar .scrollContent a'));
  30. while (link = links.shift()) {
  31. if (!document.body.contains(link)) {
  32. document.body.appendChild(link);
  33. }
  34. link.click();
  35. dispatchEvent(event);
  36. content.innerHTML += document.querySelector('.docContents').innerHTML;
  37. document.querySelectorAll('.sideBar .scrollContent .groupTitle').forEach(function(el) {
  38. if (el.textContent == 'Types') {
  39. Array.prototype.unshift.apply(links, Array.prototype.slice.call(el.parentNode.querySelectorAll('a')));
  40. }
  41. });
  42. }
  43. document.querySelector('.docContents').innerHTML = content.innerHTML;
  44. JS
  45. capybara.html
  46. end
  47. def get_latest_version(opts)
  48. get_npm_version('immutable', opts)
  49. end
  50. end
  51. end