eol_rb 0.2.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +20 -7
- data/lib/eol_rb/client.rb +4 -2
- data/lib/eol_rb/cycle.rb +16 -16
- data/lib/eol_rb/models/cycle.rb +23 -0
- data/lib/eol_rb/products.rb +23 -0
- data/lib/eol_rb/version.rb +1 -1
- data/lib/eol_rb.rb +7 -6
- metadata +4 -3
- data/lib/eol_rb/product.rb +0 -25
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: deb5ee5f5e55c55d103549f179b6078084153e50e5587321da7bb5dfbf83f4de
|
4
|
+
data.tar.gz: 0ab6131015550d5dda5e89b2f47daa01ccf65936f23515e6615eb01448024037
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fd25b0ea142602354fedc7a3cb39b389757870cdee1ad1c5e6996afb29f49b5344722fad7620592f11d352036488b083c7498ae0c739a8d82374ec68bb1b8cce
|
7
|
+
data.tar.gz: 7b70b8189c4b66ead731fba5f815844cc79d37d3ac5993f81f314e0eea7ba4ca5ca884a489932abc2a05d5bb6c550a365b3b82ade92f982fd504f4453aa20925
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -26,14 +26,27 @@ end
|
|
26
26
|
EOL.products
|
27
27
|
# => ["almalinux", "alpine", "amazon-eks", ...
|
28
28
|
|
29
|
-
EOL.
|
29
|
+
EOL.info('ruby')
|
30
30
|
# =>
|
31
|
-
# [
|
32
|
-
#
|
33
|
-
#
|
34
|
-
|
35
|
-
|
36
|
-
#
|
31
|
+
# [#<EOL::Models::Cycle:0x000000010403dd60
|
32
|
+
# @eol=#<Date: 2026-03-31 ((2461131j,0s,0n),+0s,2299161j)>,
|
33
|
+
# @is_supported=true,
|
34
|
+
# @latest=Gem::Version.new("3.2.1"),
|
35
|
+
# @latest_release_date=#<Date: 2023-02-08 ((2459984j,0s,0n),+0s,2299161j)>,
|
36
|
+
# @lts=false,
|
37
|
+
# @release_date=#<Date: 2022-12-25 ((2459939j,0s,0n),+0s,2299161j)>,
|
38
|
+
# @version=Gem::Version.new("3.2")>,
|
39
|
+
|
40
|
+
EOL.info('ruby', cycle: '3.1')
|
41
|
+
# =>
|
42
|
+
# #<EOL::Models::Cycle:0x0000000104044890
|
43
|
+
# @eol=#<Date: 2025-03-31 ((2460766j,0s,0n),+0s,2299161j)>,
|
44
|
+
# @is_supported=true,
|
45
|
+
# @latest=Gem::Version.new("3.1.3"),
|
46
|
+
# @latest_release_date=#<Date: 2022-11-24 ((2459908j,0s,0n),+0s,2299161j)>,
|
47
|
+
# @lts=false,
|
48
|
+
# @release_date=#<Date: 2021-12-25 ((2459574j,0s,0n),+0s,2299161j)>,
|
49
|
+
# @version=Gem::Version.new("3.1")>
|
37
50
|
```
|
38
51
|
|
39
52
|
## Development
|
data/lib/eol_rb/client.rb
CHANGED
@@ -7,8 +7,10 @@ require "json"
|
|
7
7
|
module EOL
|
8
8
|
# HTTP client for endoflife.date API
|
9
9
|
class Client
|
10
|
-
|
11
|
-
|
10
|
+
attr_reader :http
|
11
|
+
|
12
|
+
def initialize(http = nil)
|
13
|
+
@http = http || Faraday.new(
|
12
14
|
url: "#{api.scheme}://#{api.host}",
|
13
15
|
headers: {
|
14
16
|
"Content-Type" => "application/json",
|
data/lib/eol_rb/cycle.rb
CHANGED
@@ -3,27 +3,27 @@
|
|
3
3
|
require "json"
|
4
4
|
|
5
5
|
module EOL
|
6
|
-
|
7
|
-
|
8
|
-
class
|
9
|
-
class NotFoundError < StandardError; end
|
6
|
+
# Class for retrieving information about Cycles
|
7
|
+
class Cycle
|
8
|
+
class NotFoundError < StandardError; end
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
class << self
|
11
|
+
def get(client, product, cycle)
|
12
|
+
res = client.get("/#{product}/#{cycle}.json")
|
14
13
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end
|
20
|
-
|
21
|
-
raise NotFoundError,
|
22
|
-
"Cycle #{cycle} could not be found under product #{product}. Try any of #{available_cycles.inspect}"
|
14
|
+
if res.status == 404
|
15
|
+
available_cycles = []
|
16
|
+
Products.get(client, product).each do |p|
|
17
|
+
available_cycles.push(p["cycle"])
|
23
18
|
end
|
24
19
|
|
25
|
-
|
20
|
+
raise NotFoundError,
|
21
|
+
"Cycle #{cycle} could not be found under product #{product}. Try any of #{available_cycles.inspect}"
|
26
22
|
end
|
23
|
+
|
24
|
+
specs = JSON.parse(res.body).merge({ "cycle" => cycle })
|
25
|
+
|
26
|
+
Models::Cycle.new(specs)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EOL
|
4
|
+
module Models
|
5
|
+
# EOL Cycle model https://endoflife.date/docs/api
|
6
|
+
class Cycle
|
7
|
+
attr_reader :version, :eol, :latest, :latest_release_date, :release_date, :lts
|
8
|
+
|
9
|
+
def initialize(specs)
|
10
|
+
@version = Gem::Version.new(specs.fetch("cycle"))
|
11
|
+
@eol = Date.parse(specs.fetch("eol"))
|
12
|
+
@latest = Gem::Version.new(specs.fetch("latest"))
|
13
|
+
@latest_release_date = Date.parse(specs.fetch("latestReleaseDate"))
|
14
|
+
@release_date = Date.parse(specs.fetch("releaseDate"))
|
15
|
+
@lts = specs.fetch("lts")
|
16
|
+
end
|
17
|
+
|
18
|
+
def supported?
|
19
|
+
@eol > Time.now.to_date
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module EOL
|
6
|
+
# Class for retrieving information about Products
|
7
|
+
class Products
|
8
|
+
class NotFoundError < StandardError; end
|
9
|
+
|
10
|
+
class << self
|
11
|
+
def all(client)
|
12
|
+
JSON.parse(client.get("/all.json").body)
|
13
|
+
end
|
14
|
+
|
15
|
+
def get(client, product)
|
16
|
+
res = client.get("/#{product}.json")
|
17
|
+
raise NotFoundError, "Product #{product} could not be found in the API" if res.status == 404
|
18
|
+
|
19
|
+
JSON.parse(res.body).map { |p| Models::Cycle.new(p) }
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/eol_rb/version.rb
CHANGED
data/lib/eol_rb.rb
CHANGED
@@ -2,15 +2,16 @@
|
|
2
2
|
|
3
3
|
require_relative "eol_rb/client"
|
4
4
|
require_relative "eol_rb/configuration"
|
5
|
-
require_relative "eol_rb/
|
5
|
+
require_relative "eol_rb/products"
|
6
6
|
require_relative "eol_rb/cycle"
|
7
|
+
require_relative "eol_rb/models/cycle"
|
7
8
|
|
8
9
|
# Root module for EndOfLife
|
9
10
|
module EOL
|
10
11
|
class << self
|
11
12
|
extend Forwardable
|
12
13
|
|
13
|
-
def_delegators :new, :
|
14
|
+
def_delegators :new, :info, :products
|
14
15
|
|
15
16
|
def new
|
16
17
|
Instance.new
|
@@ -32,14 +33,14 @@ module EOL
|
|
32
33
|
end
|
33
34
|
|
34
35
|
def products
|
35
|
-
|
36
|
+
Products.all(@client)
|
36
37
|
end
|
37
38
|
|
38
|
-
def
|
39
|
+
def info(product, cycle: "")
|
39
40
|
if cycle.empty?
|
40
|
-
|
41
|
+
Products.get(@client, product)
|
41
42
|
else
|
42
|
-
|
43
|
+
Cycle.get(@client, product, cycle)
|
43
44
|
end
|
44
45
|
end
|
45
46
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eol_rb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alejandro Colomina
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|
@@ -80,7 +80,8 @@ files:
|
|
80
80
|
- lib/eol_rb/client.rb
|
81
81
|
- lib/eol_rb/configuration.rb
|
82
82
|
- lib/eol_rb/cycle.rb
|
83
|
-
- lib/eol_rb/
|
83
|
+
- lib/eol_rb/models/cycle.rb
|
84
|
+
- lib/eol_rb/products.rb
|
84
85
|
- lib/eol_rb/version.rb
|
85
86
|
homepage: https://github.com/Coolomina/eol-rb
|
86
87
|
licenses:
|
data/lib/eol_rb/product.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require "json"
|
4
|
-
|
5
|
-
module EOL
|
6
|
-
class Client
|
7
|
-
# Class for retrieving information about Products
|
8
|
-
class Product
|
9
|
-
class NotFoundError < StandardError; end
|
10
|
-
|
11
|
-
class << self
|
12
|
-
def all(client)
|
13
|
-
JSON.parse(client.get("/all.json").body)
|
14
|
-
end
|
15
|
-
|
16
|
-
def get(client, product)
|
17
|
-
res = client.get("/#{product}.json")
|
18
|
-
raise NotFoundError, "Product #{product} could not be found in the API" if res.status == 404
|
19
|
-
|
20
|
-
JSON.parse(res.body)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|