eol_rb 0.1.0 → 0.2.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: f869412732c788fe696a4e02cc9a1027c095196017e5381a15c2abb8dfc5e8c3
4
+ data.tar.gz: 62f4d9767acfd5021c6d1362f8a29af4d712251e5989f9a8761093a99f0a4661
5
5
  SHA512:
6
- metadata.gz: 5336fb2ff4381e04be59332b7bd3bb8858b38eef543e2f333d7671b7ae70a77a4bfd88228516421353819738c1b8180ba0781c26f5b71e129f32a1079f83b579
7
- data.tar.gz: 01abf889f63ba25756b6fc219776f98f1f01db862fcb0dc1c72394f046cd2dfc89afad77f7b0cb66f48ead201a9eb95b843f085d9630db1fbb571aadce38af8b
6
+ metadata.gz: 8a24a8c5a7b99ef2a778f8b3977ed50c6d3539a490dafaedc9acc014d2dee509f28804c6e0f8b700e89e21dbc7a7efba05e44e716d5138ed82d98955bb42ecc1
7
+ data.tar.gz: 58caa00b251cfc6d423ce8f338e926a54144293f72bdaef246724e4436efaf4586dc73287fd978def8aa23e929954cff1dcded9a0b71448de93a94bc243bc84d
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  ## [Unreleased]
2
2
 
3
+ ## [0.2.0] - 2022-11-29
4
+
5
+ - Refactors resources usage
6
+
3
7
  ## [0.1.0] - 2022-11-23
4
8
 
5
9
  - Initial release
data/lib/eol_rb/cycle.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "json"
4
+
3
5
  module EOL
4
6
  class Client
5
7
  # Class for retrieving information about Cycles
@@ -9,9 +11,18 @@ module EOL
9
11
  class << self
10
12
  def get(client, product, cycle)
11
13
  res = client.get("/#{product}/#{cycle}.json")
12
- raise NotFoundError, "Cycle #{cycle} could not be found under product #{product}" if res.status == 404
13
14
 
14
- res
15
+ if res.status == 404
16
+ available_cycles = []
17
+ Product.get(client, product).each do |p|
18
+ available_cycles.push(p["cycle"])
19
+ end
20
+
21
+ raise NotFoundError,
22
+ "Cycle #{cycle} could not be found under product #{product}. Try any of #{available_cycles.inspect}"
23
+ end
24
+
25
+ JSON.parse(res.body)
15
26
  end
16
27
  end
17
28
  end
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "json"
4
+
3
5
  module EOL
4
6
  class Client
5
7
  # Class for retrieving information about Products
@@ -8,14 +10,14 @@ module EOL
8
10
 
9
11
  class << self
10
12
  def all(client)
11
- client.get("/all.json")
13
+ JSON.parse(client.get("/all.json").body)
12
14
  end
13
15
 
14
16
  def get(client, product)
15
17
  res = client.get("/#{product}.json")
16
18
  raise NotFoundError, "Product #{product} could not be found in the API" if res.status == 404
17
19
 
18
- res
20
+ JSON.parse(res.body)
19
21
  end
20
22
  end
21
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.2.0"
5
5
  end
data/lib/eol_rb.rb CHANGED
@@ -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
+ Client::Product.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
+ Client::Product.get(@client, product)
41
+ else
42
+ Client::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.2.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