eol_rb 0.1.0 → 0.4.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 491894da6db5634007466ed6a22c12157eec58696fe5c2dac6504b76ed29908b
4
- data.tar.gz: a305819c3871d10e5cdbd8acf629579e617f802bf08dd6d0c03b56d2575ddc9f
3
+ metadata.gz: b81066b3f5b19119e404b9696bfa58ba315b028020802569189e1588f488d50e
4
+ data.tar.gz: 8ed604feb067e3970deb930109af1091537ea27b8d5f73cd89731ea82bc30112
5
5
  SHA512:
6
- metadata.gz: 5336fb2ff4381e04be59332b7bd3bb8858b38eef543e2f333d7671b7ae70a77a4bfd88228516421353819738c1b8180ba0781c26f5b71e129f32a1079f83b579
7
- data.tar.gz: 01abf889f63ba25756b6fc219776f98f1f01db862fcb0dc1c72394f046cd2dfc89afad77f7b0cb66f48ead201a9eb95b843f085d9630db1fbb571aadce38af8b
6
+ metadata.gz: 63c085ab185049d6cfd8e4e154975f58fded3b9846ee46d902f2c932a8cffe47d372299818c58ae8235794df7ed6e84c4ca46bb3c2de7582c75a1a0a3a412009
7
+ data.tar.gz: fcdf9914a43e42fd46624986f02ad2d58899dc0788db49a4aa4bd29f24ba1bc7e913efd30ac6cef97649f59dad4ab24347d8f9538968b840302bc1a12ad9c384
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.4.0] - 2022-11-29
4
+
5
+ - Adds release mechanism
6
+
7
+ ## [0.3.0] - 2022-11-29
8
+
9
+ - Refactors classes names and namespaces
10
+
11
+ ## [0.2.0] - 2022-11-29
12
+
13
+ - Refactors resources usage
14
+
3
15
  ## [0.1.0] - 2022-11-23
4
16
 
5
17
  - Initial release
data/lib/eol_rb/cycle.rb CHANGED
@@ -1,18 +1,27 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "json"
4
+
3
5
  module EOL
4
- class Client
5
- # Class for retrieving information about Cycles
6
- class Cycle
7
- class NotFoundError < StandardError; end
6
+ # Class for retrieving information about Cycles
7
+ class Cycle
8
+ class NotFoundError < StandardError; end
9
+
10
+ class << self
11
+ def get(client, product, cycle)
12
+ res = client.get("/#{product}/#{cycle}.json")
8
13
 
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
14
+ if res.status == 404
15
+ available_cycles = []
16
+ Products.get(client, product).each do |p|
17
+ available_cycles.push(p["cycle"])
18
+ end
13
19
 
14
- res
20
+ raise NotFoundError,
21
+ "Cycle #{cycle} could not be found under product #{product}. Try any of #{available_cycles.inspect}"
15
22
  end
23
+
24
+ JSON.parse(res.body)
16
25
  end
17
26
  end
18
27
  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)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EOL
4
- VERSION = "0.1.0"
4
+ VERSION = "0.4.0"
5
5
  end
data/lib/eol_rb.rb CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  require_relative "eol_rb/client"
4
4
  require_relative "eol_rb/configuration"
5
- require_relative "eol_rb/product"
5
+ require_relative "eol_rb/products"
6
6
  require_relative "eol_rb/cycle"
7
7
 
8
8
  # Root module for EndOfLife
@@ -32,19 +32,15 @@ module EOL
32
32
  end
33
33
 
34
34
  def products
35
- res = Client::Product.all(@client)
36
-
37
- JSON.parse(res.body)
35
+ Products.all(@client)
38
36
  end
39
37
 
40
38
  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)
39
+ if cycle.empty?
40
+ Products.get(@client, product)
41
+ else
42
+ Cycle.get(@client, product, cycle)
43
+ end
48
44
  end
49
45
  end
50
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.1.0
4
+ version: 0.4.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: 2022-11-28 00:00:00.000000000 Z
11
+ date: 2022-11-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday
@@ -80,7 +80,7 @@ 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/product.rb
83
+ - lib/eol_rb/products.rb
84
84
  - lib/eol_rb/version.rb
85
85
  homepage: https://github.com/Coolomina/eol-rb
86
86
  licenses:
@@ -1,23 +0,0 @@
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