openweather2 0.1.6 → 0.1.7

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: 159c652dc6409423e69f8f03349370ba4c57f7ac
4
- data.tar.gz: e6ce5a96df0a6f8f90ceded6694b313eb41ae245
3
+ metadata.gz: c172988c1e35afbb0b9c3a5e9ab01715d7a608fb
4
+ data.tar.gz: 955de0972fa726dfa9e4b6114a7ee26909c5dadb
5
5
  SHA512:
6
- metadata.gz: 385f88c0ff9ad4f7481f15446e32aade179ebca69528f7132f6ec327aaa9735688743cce583d3dfebb1be916d8b2b33e0065e69c8c8f8f67f9425ec9d404a3ee
7
- data.tar.gz: 728e4f82522b0be04a013ee8cbd543b89666f17490d57b784c8296c24b2a6bd58f2e473df526c783b229ee761c5975e87c7c0f55393ed2c26f9d3f45d7526abc
6
+ metadata.gz: 2e88b7cc5a3df935288d8b88e663fecb34df9241dac2d016999a805d157ef5789c9fb7f6569cb5f15d4136fe7dc1c10a6689726fff82b56ff4b5466af048104e
7
+ data.tar.gz: 789ac67f13d85e979894cbb1e9489af65bfd62d031f3e5d23fc1a770ed5bbbe4a12c081e1e4ab3cd9eea3961c98172d761340c2d116ed95c12d71784daad5833
@@ -36,8 +36,7 @@ module Openweather2
36
36
  def parse_json(response)
37
37
  case response
38
38
  when Net::HTTPSuccess
39
- json = JSON.parse(response.body)
40
- Openweather2::Weather.new(json)
39
+ check_response(response)
41
40
  when Net::HTTPUnprocessableEntity
42
41
  raise UnprocessableError, 'Bad URI param!'
43
42
  else
@@ -62,6 +61,15 @@ module Openweather2
62
61
  raise ArgumentError, 'You must configure Openweather2'
63
62
  end
64
63
  end
64
+
65
+ def check_response(response)
66
+ json = JSON.parse(response.body)
67
+ if json['cod'] == 200
68
+ Openweather2::Weather.new(json)
69
+ else
70
+ nil
71
+ end
72
+ end
65
73
 
66
74
  def default_params
67
75
  {APPID: Openweather2.configuration.apikey}
@@ -1,3 +1,3 @@
1
1
  module Openweather2
2
- VERSION = "0.1.6"
2
+ VERSION = "0.1.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: openweather2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lucas Ocon
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-08-14 00:00:00.000000000 Z
11
+ date: 2015-08-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: minitest