From 84afa65bcb02171baa7b6935b1868aa05e9a9b84 Mon Sep 17 00:00:00 2001 From: Oleksii Filonenko Date: Tue, 24 Sep 2019 15:53:25 +0300 Subject: [PATCH 1/3] Update Crystal documentation (0.31.0) --- lib/docs/scrapers/crystal.rb | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/docs/scrapers/crystal.rb b/lib/docs/scrapers/crystal.rb index 92eb54e3..6c98dd4e 100644 --- a/lib/docs/scrapers/crystal.rb +++ b/lib/docs/scrapers/crystal.rb @@ -1,7 +1,6 @@ module Docs class Crystal < UrlScraper self.type = 'crystal' - self.release = '0.30.1' self.base_url = 'https://crystal-lang.org/' self.root_path = "api/#{release}/index.html" self.initial_paths = %w(docs/index.html) @@ -35,6 +34,14 @@ module Docs end } + version '0.31' do + self.release = '0.31.0' + end + + version '0.30' do + self.release = '0.30.1' + end + def get_latest_version(opts) body = fetch('https://crystal-lang.org/api', opts) body.scan(/Crystal Docs ([0-9.]+)/)[0][0] From f47326e787005097bade8098f0adfd87229c971e Mon Sep 17 00:00:00 2001 From: Jasper van Merle Date: Fri, 4 Oct 2019 18:44:44 +0200 Subject: [PATCH 2/3] Fix version blocks and update patch version --- lib/docs/scrapers/crystal.rb | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/lib/docs/scrapers/crystal.rb b/lib/docs/scrapers/crystal.rb index 6c98dd4e..166be2f9 100644 --- a/lib/docs/scrapers/crystal.rb +++ b/lib/docs/scrapers/crystal.rb @@ -2,7 +2,6 @@ module Docs class Crystal < UrlScraper self.type = 'crystal' self.base_url = 'https://crystal-lang.org/' - self.root_path = "api/#{release}/index.html" self.initial_paths = %w(docs/index.html) self.links = { home: 'https://crystal-lang.org/', @@ -11,14 +10,6 @@ module Docs html_filters.push 'crystal/entries', 'crystal/clean_html' - options[:only_patterns] = [/\Adocs\//, /\Aapi\/#{release}\//] - options[:skip_patterns] = [/debug/i] - - options[:replace_paths] = { - "api/#{release}/" => "api/#{release}/index.html", - 'docs/' => 'docs/index.html' - } - options[:attribution] = ->(filter) { if filter.slug.start_with?('docs') <<-HTML @@ -35,11 +26,29 @@ module Docs } version '0.31' do - self.release = '0.31.0' + self.release = '0.31.1' + self.root_path = "api/#{release}/index.html" + + options[:only_patterns] = [/\Adocs\//, /\Aapi\/#{release}\//] + options[:skip_patterns] = [/debug/i] + + options[:replace_paths] = { + "api/#{release}/" => "api/#{release}/index.html", + 'docs/' => 'docs/index.html' + } end version '0.30' do self.release = '0.30.1' + self.root_path = "api/#{release}/index.html" + + options[:only_patterns] = [/\Adocs\//, /\Aapi\/#{release}\//] + options[:skip_patterns] = [/debug/i] + + options[:replace_paths] = { + "api/#{release}/" => "api/#{release}/index.html", + 'docs/' => 'docs/index.html' + } end def get_latest_version(opts) From 946fcc28ac2c6de9aa5dc64ea3a82c7c87595a2c Mon Sep 17 00:00:00 2001 From: Jasper van Merle Date: Fri, 4 Oct 2019 18:46:29 +0200 Subject: [PATCH 3/3] crystal: update get_latest_version --- lib/docs/scrapers/crystal.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/docs/scrapers/crystal.rb b/lib/docs/scrapers/crystal.rb index 166be2f9..7813b848 100644 --- a/lib/docs/scrapers/crystal.rb +++ b/lib/docs/scrapers/crystal.rb @@ -52,8 +52,8 @@ module Docs end def get_latest_version(opts) - body = fetch('https://crystal-lang.org/api', opts) - body.scan(/Crystal Docs ([0-9.]+)/)[0][0] + doc = fetch_doc('https://crystal-lang.org/', opts) + doc.at_css('.latest-release').content.scan(/([0-9.]+)/)[0][0] end end end