From c88ae2c1e1cb4e4f4f2a487bb44734f7101d82b1 Mon Sep 17 00:00:00 2001 From: Jasper van Merle Date: Tue, 13 Aug 2019 23:28:08 +0200 Subject: [PATCH] reactivex: implement get_latest_version --- lib/docs/core/doc.rb | 6 ++++++ lib/docs/scrapers/reactivex.rb | 6 +++++- public/icons/docs/reactivex/{logo.png => 16.png} | Bin .../icons/docs/reactivex/{logo@2x.png => 16@2x.png} | Bin 4 files changed, 11 insertions(+), 1 deletion(-) rename public/icons/docs/reactivex/{logo.png => 16.png} (100%) rename public/icons/docs/reactivex/{logo@2x.png => 16@2x.png} (100%) diff --git a/lib/docs/core/doc.rb b/lib/docs/core/doc.rb index da21daf8..a5268300 100644 --- a/lib/docs/core/doc.rb +++ b/lib/docs/core/doc.rb @@ -262,5 +262,11 @@ module Docs json = fetch_json("https://api.github.com/repos/#{owner}/#{repo}/contents/#{path}", opts) Base64.decode64(json['content']) end + + def get_latest_github_commit_date(owner, repo, opts) + commits = fetch_json("https://api.github.com/repos/#{owner}/#{repo}/commits", opts) + timestamp = commits[0]['commit']['author']['date'] + Date.iso8601(timestamp).to_time.to_i + end end end diff --git a/lib/docs/scrapers/reactivex.rb b/lib/docs/scrapers/reactivex.rb index 1374468b..007ae00f 100644 --- a/lib/docs/scrapers/reactivex.rb +++ b/lib/docs/scrapers/reactivex.rb @@ -1,7 +1,7 @@ module Docs class Reactivex < UrlScraper - self.type = 'reactivex' self.name = 'ReactiveX' + self.type = 'reactivex' self.base_url = 'http://reactivex.io/' self.root_path = 'intro.html' self.links = { @@ -19,5 +19,9 @@ module Docs © ReactiveX contributors
Licensed under the Apache License 2.0. HTML + + def get_latest_version(opts) + get_latest_github_commit_date('ReactiveX', 'reactivex.github.io', opts) + end end end diff --git a/public/icons/docs/reactivex/logo.png b/public/icons/docs/reactivex/16.png similarity index 100% rename from public/icons/docs/reactivex/logo.png rename to public/icons/docs/reactivex/16.png diff --git a/public/icons/docs/reactivex/logo@2x.png b/public/icons/docs/reactivex/16@2x.png similarity index 100% rename from public/icons/docs/reactivex/logo@2x.png rename to public/icons/docs/reactivex/16@2x.png