Skip to content

Commit c88ae2c

Browse files
committed
reactivex: implement get_latest_version
1 parent 3e1e65e commit c88ae2c

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

lib/docs/core/doc.rb

+6
Original file line numberDiff line numberDiff line change
@@ -262,5 +262,11 @@ def get_github_file_contents(owner, repo, path, opts)
262262
json = fetch_json("https://api.github.com/repos/#{owner}/#{repo}/contents/#{path}", opts)
263263
Base64.decode64(json['content'])
264264
end
265+
266+
def get_latest_github_commit_date(owner, repo, opts)
267+
commits = fetch_json("https://api.github.com/repos/#{owner}/#{repo}/commits", opts)
268+
timestamp = commits[0]['commit']['author']['date']
269+
Date.iso8601(timestamp).to_time.to_i
270+
end
265271
end
266272
end

lib/docs/scrapers/reactivex.rb

+5-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
module Docs
22
class Reactivex < UrlScraper
3-
self.type = 'reactivex'
43
self.name = 'ReactiveX'
4+
self.type = 'reactivex'
55
self.base_url = 'http://reactivex.io/'
66
self.root_path = 'intro.html'
77
self.links = {
@@ -19,5 +19,9 @@ class Reactivex < UrlScraper
1919
&copy; ReactiveX contributors<br>
2020
Licensed under the Apache License 2.0.
2121
HTML
22+
23+
def get_latest_version(opts)
24+
get_latest_github_commit_date('ReactiveX', 'reactivex.github.io', opts)
25+
end
2226
end
2327
end

0 commit comments

Comments
 (0)