latest_ruby_version_is 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/latest_ruby_version_is.rb +9 -5
  3. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d4f890d3591ffe6c43608735140d1793ebc6c3e0f7367fd77298cd704218591
4
- data.tar.gz: 0451feff3e47b37d597d1401103d22d2779cd92135ff35aa531a509c1d172f01
3
+ metadata.gz: b1c33ce5ed2d9ac17fdfa5e5280f6426d57fcd161dd6e5ea83dcfb460d208929
4
+ data.tar.gz: 2cbc1db84057200b7b2e483329ba7aa4f812ee9d8ade220b93aaee1b39681c86
5
5
  SHA512:
6
- metadata.gz: 8eb08b20c1e7d251972909c9b65a232d7531ff418743d9d7ae94c3e7a02b22f7e07a370f7fae0b71c523e135ec8b33c0064b6fc9b9805661c9bbb1633686ea00
7
- data.tar.gz: 513bcbd7c314dc6cc3b2e9ce48cb6da7869c335569fc3c5754246a21e5536ed243721b2ac823a9eb20becdea4a953784b201d448b2818c4e744a5f3477a3995b
6
+ metadata.gz: ecb798603e247ce231c75f009dfb31fe2cc5797a73e232f5bc8605286cc6548097739dc4df11ddffa01af856c0701ebe4d2bda9809f9b941ce06eb9b847866b4
7
+ data.tar.gz: 4f14fa7522f8efe32989550180c496d0bd1bb3ad288aad222df1ca805934db4aeb2e8e63cade690955f07f839c39b878e0fc62c6ea4ee96ae73a875a5c5c76e1
@@ -1,14 +1,18 @@
1
1
  require 'net/http'
2
+ require 'json'
2
3
 
3
- def latest_ruby_version_is( src, fallback: true )
4
- NOW_IS = '2.7.1'
4
+ LATEST_HARDCODED_RUBY_VERSION = '2.7.1'.freeze
5
+
6
+ def latest_ruby_version_is( src = :remote , fallback = true )
5
7
  case src
6
- when :local then NOW_IS
8
+ when :local then LATEST_HARDCODED_RUBY_VERSION
7
9
  when :remote
8
10
  begin
9
- Net::HTTP.get( URI 'https://www.ruby-lang.org/en/downloads/')[ /The current stable version is (\d+\.\d+\.\d+)/, 1 ]
11
+ JSON.parse(
12
+ Net::HTTP.get( URI 'https://api.github.com/repos/ruby/ruby/tags?per_page=1')
13
+ ).first['name'][1..-1].gsub('_','.')
10
14
  rescue
11
- fallback ? NOW_IS : raise
15
+ fallback ? LATEST_HARDCODED_RUBY_VERSION : raise
12
16
  end
13
17
  else
14
18
  raise ArgumentError.new( 'src must be :local or :remote.' )
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: latest_ruby_version_is
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - deemytch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-05-19 00:00:00.000000000 Z
11
+ date: 2020-05-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email: aspamkiller@yandex.ru
@@ -39,5 +39,5 @@ requirements: []
39
39
  rubygems_version: 3.1.2
40
40
  signing_key:
41
41
  specification_version: 4
42
- summary: Simple additions for standard classes.
42
+ summary: Determine which is the last ruby version.
43
43
  test_files: []