Sfoglia il codice sorgente

reactivex: implement get_latest_version

Jasper van Merle 6 anni fa
parent
commit
c88ae2c1e1

+ 6 - 0
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

+ 5 - 1
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
       &copy; ReactiveX contributors<br>
       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

+ 0 - 0
public/icons/docs/reactivex/logo.png → public/icons/docs/reactivex/16.png


+ 0 - 0
public/icons/docs/reactivex/logo@2x.png → public/icons/docs/reactivex/16@2x.png