pokeapi 0.1.0 → 0.1.1

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
  SHA1:
3
- metadata.gz: b997b1f4926f3bf6618b90479fccedc8c9f533b6
4
- data.tar.gz: 9b3a18ced58b02d04793842361d478d2c41c7ae5
3
+ metadata.gz: 1e2dbd18db0c4cd72a952802659ed6ec3f0f68fd
4
+ data.tar.gz: 33d2aac81d880c8d8dde2d5f89deb409e5a4f9c7
5
5
  SHA512:
6
- metadata.gz: 1459cb74617c6b135cc045c16a1072dab8b50c13cf84f0deebac3950ffe654c759173fd1e63c8488d6910662015a60e47a8ca93ee020843c2d36a12af5633e9c
7
- data.tar.gz: 2c753cf01e37f32e41168751ba91881d700adedad0f7c08e51702994b0445ca97b3dfa033cf9fc95fbd0e0aebe6f7d1fed015966538fe7ab02b1c036e08b9a4f
6
+ metadata.gz: 5385481672a79046f1d5909d1401b8fa40370ba0834a990b837ec09b981a12fe9c5555119fb514f1e6117b81a8020cc2417c9c025ab922491dafc8efa0873173
7
+ data.tar.gz: cee1a9870567e2f62a5cdf1a782232fc76bdc6eddd1618fa1b66a382b936bd32162e41c53363b48322abf936d06ebdca77158f17dd8a576fa7640b9af08b0917
@@ -2,19 +2,20 @@ require "http"
2
2
 
3
3
  module PokeAPI
4
4
  class Requester
5
+ NotFoundError = Class.new(StandardError)
6
+
5
7
  API_ENDPOINT = "https://pokeapi.co/api/v2/"
6
8
  POKEMON_ENDPOINT = "pokemon/"
7
9
 
8
10
  class << self
9
11
  def pokemon(id)
10
- url = POKEMON_ENDPOINT + id.to_s
11
- get(url)
12
+ get("#{POKEMON_ENDPOINT}#{id}")
12
13
  end
13
14
 
14
15
  def get(path)
15
- url = API_ENDPOINT + path + "/"
16
- response = HTTP.get(url).to_s
17
- JSON.parse(response, symbolize_names: true)
16
+ http = HTTP.get("#{API_ENDPOINT}#{path}/")
17
+ fail NotFoundError if http.code == 404
18
+ JSON.parse(http.to_s, symbolize_names: true)
18
19
  end
19
20
  end
20
21
  end
@@ -1,3 +1,3 @@
1
1
  module PokeAPI
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pokeapi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edgar Ortega