wdt-skywise-forecast 0.1.1 → 0.1.2

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: d1788ddc4a5f7b13fcb77ad0994694ce2d452940
4
- data.tar.gz: 9f5b3cf55858bc73c6c618f00f5e8fb7515fabda
3
+ metadata.gz: 0a5630468679794086ef17b9c19252bcf321b122
4
+ data.tar.gz: c96acdb2e1883790bbffe222e4a0cd2658dc9113
5
5
  SHA512:
6
- metadata.gz: 59a58adfc51eb17bc5c5f20b0861a74121b45c7c7666d29fab097d6c2ec6dc548d01e5e4975c59a68def7d20c48de2b6ca61afb83edaa17b6abd930129700d90
7
- data.tar.gz: 9588eb1dfb575af3ff88ae8dc4ba3b5ef6834c4bc1cceb64ce3cfecb14a636f6b202cfbbfd323f9d9b2eef21914e5be1ff086b62255480f28161d1a76ad65b64
6
+ metadata.gz: ddb2dd44d62069150bf7fc467b2481154e035706c45a6eb0c88bbe22424d6417cb9f65205547d8bf003420ca7e7b3558f9f1905b5fa0e680ef5879ccbc789f0a
7
+ data.tar.gz: 9af18a4685da809250cd7431fe123df8e795f69218dc651b05c2e42af4d4775998a4c87b0ce145f7eb1d8ffff52cc86ab17444f5889a557cec11164aa9f81f00
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
1
  # WDT Skywise API
2
+ [![Code Climate](https://codeclimate.com/github/coryp/wdt-skywise-forecast/badges/gpa.svg)](https://codeclimate.com/github/coryp/wdt-skywise-forecast)
3
+ [![Gem Version](https://badge.fury.io/rb/wdt-skywise-forecast.svg)](https://badge.fury.io/rb/wdt-skywise-forecast)
2
4
  [![Build Status](https://travis-ci.org/coryp/wdt-skywise-forecast.svg?branch=master)](https://travis-ci.org/coryp/wdt-skywise-forecast)
3
5
  [![Coverage Status](https://coveralls.io/repos/github/coryp/wdt-skywise-forecast/badge.svg?branch=master)](https://coveralls.io/github/coryp/wdt-skywise-forecast?branch=master)
4
6
 
@@ -38,8 +40,8 @@ Get weather data:
38
40
 
39
41
  weather_data = wdt_client.weather_for(ZIP: '32128')
40
42
 
41
- weather_data.success # returns true
42
- weather_data.error # returns nil
43
+ weather_data.success # => true
44
+ weather_data.error # => nil
43
45
 
44
46
  weather_data.response.present? # => true
45
47
 
@@ -1,7 +1,7 @@
1
1
  module Wdt
2
2
  module Skywise
3
3
  module Forecast
4
- VERSION = "0.1.1"
4
+ VERSION = "0.1.2"
5
5
  end
6
6
  end
7
7
  end
@@ -30,20 +30,9 @@ module Wdt
30
30
 
31
31
  def weather_for(options)
32
32
  # validate parameter combinations
33
- if options.empty?
34
- return Wdt::Skywise::Forecast::Response.new({error: "No parameters specified", success: false} )
35
- end
36
-
37
- if options.has_key?(:CITY) && ( !options.has_key?(:STATE) && !options.has_key?(:COUNTRY))
38
- return Wdt::Skywise::Forecast::Response.new({error: "STATE or COUNTRY must be provided with CITY", success: false} )
39
- end
40
-
41
- if options.has_key?(:LAT) && !options.has_key?(:LONG)
42
- return Wdt::Skywise::Forecast::Response.new({error: "LONG must be provided with LAT", success: false} )
43
- end
44
-
45
- if options.has_key?(:LONG) && !options.has_key?(:LAT)
46
- return Wdt::Skywise::Forecast::Response.new({error: "LAT must be provided with LONG", success: false} )
33
+ valid = validate_options(options)
34
+ if !valid[:success]
35
+ return Wdt::Skywise::Forecast::Response.new({error: valid[:error], success: valid[:success]} )
47
36
  end
48
37
 
49
38
  # set format and units defaults
@@ -62,6 +51,24 @@ module Wdt
62
51
  end
63
52
 
64
53
  private
54
+ def validate_options(options)
55
+ success = true
56
+ if options.empty?
57
+ error = "No parameters specified"
58
+ success = false
59
+ elsif options.has_key?(:CITY) && ( !options.has_key?(:STATE) && !options.has_key?(:COUNTRY))
60
+ error = "STATE or COUNTRY must be provided with CITY"
61
+ success = false
62
+ elsif options.has_key?(:LAT) && !options.has_key?(:LONG)
63
+ error = "LONG must be provided with LAT"
64
+ success = false
65
+ elsif options.has_key?(:LONG) && !options.has_key?(:LAT)
66
+ error = "LAT must be provided with LONG"
67
+ success = false
68
+ end
69
+ {error: error, success: success}
70
+ end
71
+
65
72
  def auth
66
73
  {app_id: Wdt::Skywise::Forecast::Client.app_id, app_key: Wdt::Skywise::Forecast::Client.app_key}
67
74
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wdt-skywise-forecast
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cory Patterson