From 7084d9f082e589e651f5296896c5d76c55ad0c75 Mon Sep 17 00:00:00 2001 From: Jasper van Merle Date: Thu, 20 Jun 2019 21:40:15 +0200 Subject: [PATCH] Improve get_latest_github_release --- docs/scraper-reference.md | 2 +- lib/docs/core/doc.rb | 4 +++- lib/docs/scrapers/homebrew.rb | 2 +- lib/docs/scrapers/jasmine.rb | 2 +- lib/docs/scrapers/jsdoc.rb | 2 +- lib/docs/scrapers/julia.rb | 2 +- lib/docs/scrapers/knockout.rb | 2 +- lib/docs/scrapers/kotlin.rb | 2 +- lib/docs/scrapers/laravel.rb | 2 +- lib/docs/scrapers/matplotlib.rb | 2 +- lib/docs/scrapers/nokogiri2.rb | 2 +- lib/docs/scrapers/npm.rb | 2 +- lib/docs/scrapers/numpy.rb | 2 +- lib/docs/scrapers/opentsdb.rb | 2 +- lib/docs/scrapers/phaser.rb | 2 +- lib/docs/scrapers/pygame.rb | 2 +- lib/docs/scrapers/rdoc/rails.rb | 2 +- lib/docs/scrapers/rethinkdb.rb | 2 +- lib/docs/scrapers/sass.rb | 2 +- lib/docs/scrapers/symfony.rb | 2 +- lib/docs/scrapers/tensorflow.rb | 2 +- lib/docs/scrapers/typescript.rb | 2 +- lib/docs/scrapers/vue.rb | 2 +- lib/docs/scrapers/yarn.rb | 2 +- lib/docs/scrapers/yii.rb | 2 +- 25 files changed, 27 insertions(+), 25 deletions(-) diff --git a/docs/scraper-reference.md b/docs/scraper-reference.md index de7d3f15..4da0d2e5 100644 --- a/docs/scraper-reference.md +++ b/docs/scraper-reference.md @@ -212,7 +212,7 @@ To make life easier, there are a few utility methods that you can use in `get_la Example: [lib/docs/scrapers/bower.rb](../lib/docs/scrapers/bower.rb) * `get_latest_github_release(owner, repo, opts)` - Returns the latest GitHub release of the given repository ([format](https://developer.github.com/v3/repos/releases/#get-the-latest-release)). + Returns the tag name of the latest GitHub release of the given repository. If the tag name is preceeded by a "v", the "v" will be removed. Example: [lib/docs/scrapers/jsdoc.rb](../lib/docs/scrapers/jsdoc.rb) * `get_github_tags(owner, repo, opts)` diff --git a/lib/docs/core/doc.rb b/lib/docs/core/doc.rb index b50957c5..da21daf8 100644 --- a/lib/docs/core/doc.rb +++ b/lib/docs/core/doc.rb @@ -249,7 +249,9 @@ module Docs end def get_latest_github_release(owner, repo, opts) - fetch_json("https://api.github.com/repos/#{owner}/#{repo}/releases/latest", opts) + release = fetch_json("https://api.github.com/repos/#{owner}/#{repo}/releases/latest", opts) + tag_name = release['tag_name'] + tag_name.start_with?('v') ? tag_name[1..-1] : tag_name end def get_github_tags(owner, repo, opts) diff --git a/lib/docs/scrapers/homebrew.rb b/lib/docs/scrapers/homebrew.rb index c5647709..9dd1581a 100644 --- a/lib/docs/scrapers/homebrew.rb +++ b/lib/docs/scrapers/homebrew.rb @@ -21,7 +21,7 @@ module Docs HTML def get_latest_version(opts) - get_latest_github_release('Homebrew', 'brew', opts)['name'] + get_latest_github_release('Homebrew', 'brew', opts) end end end diff --git a/lib/docs/scrapers/jasmine.rb b/lib/docs/scrapers/jasmine.rb index 14c51869..b1971ecd 100644 --- a/lib/docs/scrapers/jasmine.rb +++ b/lib/docs/scrapers/jasmine.rb @@ -19,7 +19,7 @@ module Docs HTML def get_latest_version(opts) - get_latest_github_release('jasmine', 'jasmine', opts)['name'] + get_latest_github_release('jasmine', 'jasmine', opts) end end end diff --git a/lib/docs/scrapers/jsdoc.rb b/lib/docs/scrapers/jsdoc.rb index d88d46b6..df27e578 100644 --- a/lib/docs/scrapers/jsdoc.rb +++ b/lib/docs/scrapers/jsdoc.rb @@ -23,7 +23,7 @@ module Docs HTML def get_latest_version(opts) - get_latest_github_release('jsdoc3', 'jsdoc', opts)['tag_name'] + get_latest_github_release('jsdoc3', 'jsdoc', opts) end end end diff --git a/lib/docs/scrapers/julia.rb b/lib/docs/scrapers/julia.rb index d152f05d..c9c96da6 100644 --- a/lib/docs/scrapers/julia.rb +++ b/lib/docs/scrapers/julia.rb @@ -51,7 +51,7 @@ module Docs end def get_latest_version(opts) - get_latest_github_release('JuliaLang', 'julia', opts)['tag_name'][1..-1] + get_latest_github_release('JuliaLang', 'julia', opts) end end end diff --git a/lib/docs/scrapers/knockout.rb b/lib/docs/scrapers/knockout.rb index 6556bca8..efad86f0 100644 --- a/lib/docs/scrapers/knockout.rb +++ b/lib/docs/scrapers/knockout.rb @@ -35,7 +35,7 @@ module Docs HTML def get_latest_version(opts) - get_latest_github_release('knockout', 'knockout', opts)['tag_name'][1..-1] + get_latest_github_release('knockout', 'knockout', opts) end end end diff --git a/lib/docs/scrapers/kotlin.rb b/lib/docs/scrapers/kotlin.rb index 5f508ae7..5055b65e 100644 --- a/lib/docs/scrapers/kotlin.rb +++ b/lib/docs/scrapers/kotlin.rb @@ -30,7 +30,7 @@ module Docs HTML def get_latest_version(opts) - get_latest_github_release('JetBrains', 'kotlin', opts)['tag_name'][1..-1] + get_latest_github_release('JetBrains', 'kotlin', opts) end end end diff --git a/lib/docs/scrapers/laravel.rb b/lib/docs/scrapers/laravel.rb index 4fc17368..e45b0bed 100644 --- a/lib/docs/scrapers/laravel.rb +++ b/lib/docs/scrapers/laravel.rb @@ -135,7 +135,7 @@ module Docs end def get_latest_version(opts) - get_latest_github_release('laravel', 'laravel', opts)['tag_name'][1..-1] + get_latest_github_release('laravel', 'laravel', opts) end end end diff --git a/lib/docs/scrapers/matplotlib.rb b/lib/docs/scrapers/matplotlib.rb index 4a882270..eeecea71 100644 --- a/lib/docs/scrapers/matplotlib.rb +++ b/lib/docs/scrapers/matplotlib.rb @@ -66,7 +66,7 @@ module Docs end def get_latest_version(opts) - get_latest_github_release('matplotlib', 'matplotlib', opts)['tag_name'][1..-1] + get_latest_github_release('matplotlib', 'matplotlib', opts) end end end diff --git a/lib/docs/scrapers/nokogiri2.rb b/lib/docs/scrapers/nokogiri2.rb index 9da5daf4..7c28ca92 100644 --- a/lib/docs/scrapers/nokogiri2.rb +++ b/lib/docs/scrapers/nokogiri2.rb @@ -21,7 +21,7 @@ module Docs HTML def get_latest_version(opts) - get_latest_github_release('sparklemotion', 'nokogiri', opts)['tag_name'][1..-1] + get_latest_github_release('sparklemotion', 'nokogiri', opts) end end end diff --git a/lib/docs/scrapers/npm.rb b/lib/docs/scrapers/npm.rb index e18531ab..3f868a3c 100644 --- a/lib/docs/scrapers/npm.rb +++ b/lib/docs/scrapers/npm.rb @@ -31,7 +31,7 @@ module Docs HTML def get_latest_version(opts) - get_latest_github_release('npm', 'cli', opts)['tag_name'][1..-1] + get_latest_github_release('npm', 'cli', opts) end end end diff --git a/lib/docs/scrapers/numpy.rb b/lib/docs/scrapers/numpy.rb index 636fcf4a..84de6cab 100644 --- a/lib/docs/scrapers/numpy.rb +++ b/lib/docs/scrapers/numpy.rb @@ -51,7 +51,7 @@ module Docs end def get_latest_version(opts) - get_latest_github_release('numpy', 'numpy', opts)['tag_name'][1..-1] + get_latest_github_release('numpy', 'numpy', opts) end end end diff --git a/lib/docs/scrapers/opentsdb.rb b/lib/docs/scrapers/opentsdb.rb index 1de40478..6eec407c 100644 --- a/lib/docs/scrapers/opentsdb.rb +++ b/lib/docs/scrapers/opentsdb.rb @@ -20,7 +20,7 @@ module Docs HTML def get_latest_version(opts) - get_latest_github_release('OpenTSDB', 'opentsdb', opts)['tag_name'][1..-1] + get_latest_github_release('OpenTSDB', 'opentsdb', opts) end end end diff --git a/lib/docs/scrapers/phaser.rb b/lib/docs/scrapers/phaser.rb index 1939b1d0..bd5f411c 100644 --- a/lib/docs/scrapers/phaser.rb +++ b/lib/docs/scrapers/phaser.rb @@ -27,7 +27,7 @@ module Docs HTML def get_latest_version(opts) - get_latest_github_release('photonstorm', 'phaser', opts)['tag_name'][1..-1] + get_latest_github_release('photonstorm', 'phaser', opts) end end end diff --git a/lib/docs/scrapers/pygame.rb b/lib/docs/scrapers/pygame.rb index d5a5581d..94c3d508 100644 --- a/lib/docs/scrapers/pygame.rb +++ b/lib/docs/scrapers/pygame.rb @@ -19,7 +19,7 @@ module Docs HTML def get_latest_version(opts) - get_latest_github_release('pygame', 'pygame', opts)['tag_name'] + get_latest_github_release('pygame', 'pygame', opts) end end end diff --git a/lib/docs/scrapers/rdoc/rails.rb b/lib/docs/scrapers/rdoc/rails.rb index 771c2f64..0dec42a9 100644 --- a/lib/docs/scrapers/rdoc/rails.rb +++ b/lib/docs/scrapers/rdoc/rails.rb @@ -95,7 +95,7 @@ module Docs end def get_latest_version(opts) - get_latest_github_release('rails', 'rails', opts)['name'] + get_latest_github_release('rails', 'rails', opts) end end end diff --git a/lib/docs/scrapers/rethinkdb.rb b/lib/docs/scrapers/rethinkdb.rb index 3a6b87cf..35d8d334 100644 --- a/lib/docs/scrapers/rethinkdb.rb +++ b/lib/docs/scrapers/rethinkdb.rb @@ -59,7 +59,7 @@ module Docs end def get_latest_version(opts) - get_latest_github_release('rethinkdb', 'rethinkdb', opts)['tag_name'][1..-1] + get_latest_github_release('rethinkdb', 'rethinkdb', opts) end private diff --git a/lib/docs/scrapers/sass.rb b/lib/docs/scrapers/sass.rb index c81753d2..c9774cdf 100644 --- a/lib/docs/scrapers/sass.rb +++ b/lib/docs/scrapers/sass.rb @@ -25,7 +25,7 @@ module Docs HTML def get_latest_version(opts) - get_latest_github_release('sass', 'libsass', opts)['tag_name'] + get_latest_github_release('sass', 'libsass', opts) end end end diff --git a/lib/docs/scrapers/symfony.rb b/lib/docs/scrapers/symfony.rb index 439456f0..4bdde054 100644 --- a/lib/docs/scrapers/symfony.rb +++ b/lib/docs/scrapers/symfony.rb @@ -72,7 +72,7 @@ module Docs end def get_latest_version(opts) - get_latest_github_release('symfony', 'symfony', opts)['tag_name'][1..-1] + get_latest_github_release('symfony', 'symfony', opts) end end end diff --git a/lib/docs/scrapers/tensorflow.rb b/lib/docs/scrapers/tensorflow.rb index 8ac1ca65..9638b516 100644 --- a/lib/docs/scrapers/tensorflow.rb +++ b/lib/docs/scrapers/tensorflow.rb @@ -57,7 +57,7 @@ module Docs end def get_latest_version(opts) - get_latest_github_release('tensorflow', 'tensorflow', opts)['tag_name'][1..-1] + get_latest_github_release('tensorflow', 'tensorflow', opts) end private diff --git a/lib/docs/scrapers/typescript.rb b/lib/docs/scrapers/typescript.rb index 63d1c9af..777f5dd6 100644 --- a/lib/docs/scrapers/typescript.rb +++ b/lib/docs/scrapers/typescript.rb @@ -26,7 +26,7 @@ module Docs HTML def get_latest_version(opts) - get_latest_github_release('Microsoft', 'TypeScript', opts)['tag_name'][1..-1] + get_latest_github_release('Microsoft', 'TypeScript', opts) end end end diff --git a/lib/docs/scrapers/vue.rb b/lib/docs/scrapers/vue.rb index db48b898..333ade1d 100644 --- a/lib/docs/scrapers/vue.rb +++ b/lib/docs/scrapers/vue.rb @@ -34,7 +34,7 @@ module Docs end def get_latest_version(opts) - get_latest_github_release('vuejs', 'vue', opts)['tag_name'][1..-1] + get_latest_github_release('vuejs', 'vue', opts) end end end diff --git a/lib/docs/scrapers/yarn.rb b/lib/docs/scrapers/yarn.rb index d63e7121..c45695af 100644 --- a/lib/docs/scrapers/yarn.rb +++ b/lib/docs/scrapers/yarn.rb @@ -22,7 +22,7 @@ module Docs HTML def get_latest_version(opts) - get_latest_github_release('yarnpkg', 'yarn', opts)['tag_name'][1..-1] + get_latest_github_release('yarnpkg', 'yarn', opts) end end end diff --git a/lib/docs/scrapers/yii.rb b/lib/docs/scrapers/yii.rb index b05c5bf7..eaabdbf0 100755 --- a/lib/docs/scrapers/yii.rb +++ b/lib/docs/scrapers/yii.rb @@ -36,7 +36,7 @@ module Docs end def get_latest_version(opts) - get_latest_github_release('yiisoft', 'yii2', opts)['tag_name'] + get_latest_github_release('yiisoft', 'yii2', opts) end end end