eol_rb 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +21 -0
- data/README.md +55 -0
- data/lib/eol_rb/client.rb +40 -0
- data/lib/eol_rb/configuration.rb +13 -0
- data/lib/eol_rb/cycle.rb +19 -0
- data/lib/eol_rb/product.rb +23 -0
- data/lib/eol_rb/version.rb +5 -0
- data/lib/eol_rb.rb +50 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 491894da6db5634007466ed6a22c12157eec58696fe5c2dac6504b76ed29908b
|
4
|
+
data.tar.gz: a305819c3871d10e5cdbd8acf629579e617f802bf08dd6d0c03b56d2575ddc9f
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 5336fb2ff4381e04be59332b7bd3bb8858b38eef543e2f333d7671b7ae70a77a4bfd88228516421353819738c1b8180ba0781c26f5b71e129f32a1079f83b579
|
7
|
+
data.tar.gz: 01abf889f63ba25756b6fc219776f98f1f01db862fcb0dc1c72394f046cd2dfc89afad77f7b0cb66f48ead201a9eb95b843f085d9630db1fbb571aadce38af8b
|
data/CHANGELOG.md
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2022 Coolomina
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,55 @@
|
|
1
|
+
# endoflife.date ruby gem
|
2
|
+
|
3
|
+
`eol_rb` is an endoflife.date Ruby wrapper built on top of Faraday.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Install the gem and add to the application's Gemfile by executing:
|
8
|
+
|
9
|
+
$ bundle add eol_rb
|
10
|
+
|
11
|
+
If bundler is not being used to manage dependencies, install the gem by executing:
|
12
|
+
|
13
|
+
$ gem install eol_rb
|
14
|
+
|
15
|
+
## Usage
|
16
|
+
|
17
|
+
```ruby
|
18
|
+
require 'eol_rb'
|
19
|
+
|
20
|
+
# Optional configuration
|
21
|
+
EOL.configure do |config|
|
22
|
+
config.timeout = 1
|
23
|
+
config.open_timeout = 1
|
24
|
+
end
|
25
|
+
|
26
|
+
EOL.products
|
27
|
+
# => ["almalinux", "alpine", "amazon-eks", ...
|
28
|
+
|
29
|
+
EOL.of('ruby')
|
30
|
+
# =>
|
31
|
+
# [{"cycle"=>"3.1", "eol"=>"2025-12-25", "latest"=>"3.1.2", "latestReleaseDate"=>"2022-04-12", "releaseDate"=>"2021-12-25"},
|
32
|
+
# {"cycle"=>"3.0", "eol"=>"2024-03-31", "latest"=>"3.0.4", "latestReleaseDate"=>"2022-04-12", "releaseDate"=>"2020-12-25"},
|
33
|
+
# ...
|
34
|
+
|
35
|
+
EOL.of('ruby', cycle: '3.1')
|
36
|
+
# => {"eol"=>"2025-12-25", "latest"=>"3.1.2", "latestReleaseDate"=>"2022-04-12", "releaseDate"=>"2021-12-25"}
|
37
|
+
```
|
38
|
+
|
39
|
+
## Development
|
40
|
+
|
41
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
42
|
+
|
43
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
44
|
+
|
45
|
+
## Contributing
|
46
|
+
|
47
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/eol_rb. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/eol_rb/blob/master/CODE_OF_CONDUCT.md).
|
48
|
+
|
49
|
+
## License
|
50
|
+
|
51
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
52
|
+
|
53
|
+
## Code of Conduct
|
54
|
+
|
55
|
+
Everyone interacting in the EolRb project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/eol_rb/blob/master/CODE_OF_CONDUCT.md).
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "faraday"
|
4
|
+
require "uri"
|
5
|
+
require "json"
|
6
|
+
|
7
|
+
module EOL
|
8
|
+
# HTTP client for endoflife.date API
|
9
|
+
class Client
|
10
|
+
def initialize
|
11
|
+
@http = Faraday.new(
|
12
|
+
url: "#{api.scheme}://#{api.host}",
|
13
|
+
headers: {
|
14
|
+
"Content-Type" => "application/json",
|
15
|
+
"User-Agent" => "endoflife.date Ruby Gem v#{EOL::VERSION}"
|
16
|
+
}
|
17
|
+
)
|
18
|
+
end
|
19
|
+
|
20
|
+
def get(endpoint)
|
21
|
+
@http.get("#{api.path}/#{endpoint}")
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
EOL_DATE_API_BASE_URL = "https://endoflife.date/api"
|
27
|
+
|
28
|
+
def api
|
29
|
+
URI(EOL_DATE_API_BASE_URL)
|
30
|
+
end
|
31
|
+
|
32
|
+
def open_timeout
|
33
|
+
EOL.configuration.open_timeout || 10
|
34
|
+
end
|
35
|
+
|
36
|
+
def timeout
|
37
|
+
EOL.configuration.timeout || 10
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EOL
|
4
|
+
# Configuration class for EndOfLife HTTP client
|
5
|
+
class Configuration
|
6
|
+
SETTINGS = %i[timeout open_timeout].freeze
|
7
|
+
attr_accessor(*SETTINGS)
|
8
|
+
|
9
|
+
def reset!
|
10
|
+
SETTINGS.each { |s| instance_variable_set(:"@#{s}", nil) }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/lib/eol_rb/cycle.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EOL
|
4
|
+
class Client
|
5
|
+
# Class for retrieving information about Cycles
|
6
|
+
class Cycle
|
7
|
+
class NotFoundError < StandardError; end
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def get(client, product, cycle)
|
11
|
+
res = client.get("/#{product}/#{cycle}.json")
|
12
|
+
raise NotFoundError, "Cycle #{cycle} could not be found under product #{product}" if res.status == 404
|
13
|
+
|
14
|
+
res
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EOL
|
4
|
+
class Client
|
5
|
+
# Class for retrieving information about Products
|
6
|
+
class Product
|
7
|
+
class NotFoundError < StandardError; end
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def all(client)
|
11
|
+
client.get("/all.json")
|
12
|
+
end
|
13
|
+
|
14
|
+
def get(client, product)
|
15
|
+
res = client.get("/#{product}.json")
|
16
|
+
raise NotFoundError, "Product #{product} could not be found in the API" if res.status == 404
|
17
|
+
|
18
|
+
res
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/eol_rb.rb
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "eol_rb/client"
|
4
|
+
require_relative "eol_rb/configuration"
|
5
|
+
require_relative "eol_rb/product"
|
6
|
+
require_relative "eol_rb/cycle"
|
7
|
+
|
8
|
+
# Root module for EndOfLife
|
9
|
+
module EOL
|
10
|
+
class << self
|
11
|
+
extend Forwardable
|
12
|
+
|
13
|
+
def_delegators :new, :of, :products
|
14
|
+
|
15
|
+
def new
|
16
|
+
Instance.new
|
17
|
+
end
|
18
|
+
|
19
|
+
def configure
|
20
|
+
yield(configuration)
|
21
|
+
end
|
22
|
+
|
23
|
+
def configuration
|
24
|
+
@configuration ||= Configuration.new
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
# Instance of EOL HTTP client
|
29
|
+
class Instance
|
30
|
+
def initialize
|
31
|
+
@client = Client.new
|
32
|
+
end
|
33
|
+
|
34
|
+
def products
|
35
|
+
res = Client::Product.all(@client)
|
36
|
+
|
37
|
+
JSON.parse(res.body)
|
38
|
+
end
|
39
|
+
|
40
|
+
def of(product, cycle: "")
|
41
|
+
res = if cycle.empty?
|
42
|
+
Client::Product.get(@client, product)
|
43
|
+
else
|
44
|
+
Client::Cycle.get(@client, product, cycle)
|
45
|
+
end
|
46
|
+
|
47
|
+
JSON.parse(res.body)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: eol_rb
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alejandro Colomina
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2022-11-28 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: faraday
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '2.7'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '13.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '13.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.12'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.12'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rubocop
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '1.39'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1.39'
|
69
|
+
description: Ruby client for endoflife.date API
|
70
|
+
email:
|
71
|
+
- ale@coolomina.dev
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- CHANGELOG.md
|
77
|
+
- LICENSE.txt
|
78
|
+
- README.md
|
79
|
+
- lib/eol_rb.rb
|
80
|
+
- lib/eol_rb/client.rb
|
81
|
+
- lib/eol_rb/configuration.rb
|
82
|
+
- lib/eol_rb/cycle.rb
|
83
|
+
- lib/eol_rb/product.rb
|
84
|
+
- lib/eol_rb/version.rb
|
85
|
+
homepage: https://github.com/Coolomina/eol-rb
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
metadata:
|
89
|
+
homepage_uri: https://github.com/Coolomina/eol-rb
|
90
|
+
source_code_uri: https://github.com/Coolomina/eol-rb
|
91
|
+
bug_tracker_uri: https://github.com/Coolomina/eol-rb/issues
|
92
|
+
changelog_uri: https://github.com/Coolomina/eol-rb/releases
|
93
|
+
post_install_message:
|
94
|
+
rdoc_options: []
|
95
|
+
require_paths:
|
96
|
+
- lib
|
97
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: 2.6.0
|
102
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
|
+
requirements:
|
104
|
+
- - ">="
|
105
|
+
- !ruby/object:Gem::Version
|
106
|
+
version: '0'
|
107
|
+
requirements: []
|
108
|
+
rubygems_version: 3.1.6
|
109
|
+
signing_key:
|
110
|
+
specification_version: 4
|
111
|
+
summary: A Ruby wrapper for the endoflife.date API
|
112
|
+
test_files: []
|