darksky_ruby_client 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -1
- data/README.md +12 -0
- data/darksky_ruby_client.gemspec +1 -0
- data/lib/darksky_ruby_client/client.rb +8 -5
- data/lib/darksky_ruby_client/version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01d5dd2dc927fee5d68600a9494a032737dcd55f
|
4
|
+
data.tar.gz: 86ca2ce2d194773ec09f7e7ab5a63b2cd950380b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 66c47760124957f164c301251435644e6f68a445fa3225bde8c5a363319319500ada9acb9ddb45bbec4a1823e04f281fb3b2abebaa61ee353494891cfea9d674
|
7
|
+
data.tar.gz: 2c31deb3251328201b8d69d8414cf165f0ffa6820096cb07acff2651a0b7b903899d4b995d0cc2992e2fc820c28e6da5ff764da81a69c3453dc4719ffdaf83d1
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# DarkskyRubyClient
|
2
2
|
[![Gem Version](https://badge.fury.io/rb/darksky_ruby_client.svg)](https://badge.fury.io/rb/darksky_ruby_client)
|
3
|
+
[![Build Status](https://travis-ci.org/appcot/darksky_ruby_client.svg?branch=master)](https://travis-ci.org/appcot/darksky_ruby_client)
|
4
|
+
[![Documentation](http://img.shields.io/badge/docs-rdoc.info-blue.svg)](http://www.rubydoc.info/github/appcot/darksky_ruby_client)
|
3
5
|
|
4
6
|
This Client for more convenient use of the DarkSky API.
|
5
7
|
|
@@ -31,6 +33,16 @@ client = DarkskyRubyClient::Client.new('your Dark Sky secret key')
|
|
31
33
|
client.weather_forecast('latitude', 'longitude')
|
32
34
|
```
|
33
35
|
|
36
|
+
Options example
|
37
|
+
```ruby
|
38
|
+
require 'darksky_ruby_client'
|
39
|
+
client = DarkskyRubyClient::Client.new('your Dark Sky secret key')
|
40
|
+
client.weather_forecast('latitude', 'longitude', lang: "en", exclude: "daily")
|
41
|
+
```
|
42
|
+
Sets options after the second argument.
|
43
|
+
Available options are exclude, extend, lang, units.
|
44
|
+
See https://darksky.net/dev/docs#forecast-request for more details.
|
45
|
+
|
34
46
|
Parallel requests.
|
35
47
|
```ruby
|
36
48
|
require 'darksky_ruby_client'
|
data/darksky_ruby_client.gemspec
CHANGED
@@ -9,7 +9,8 @@ module DarkskyRubyClient
|
|
9
9
|
@@base_url = 'https://api.darksky.net/forecast/'
|
10
10
|
|
11
11
|
#TODO logger
|
12
|
-
|
12
|
+
@@logger ||= Logger.new(STDOUT)
|
13
|
+
@@logger.level = Logger::ERROR
|
13
14
|
|
14
15
|
# Don't need this method to use until the base_url of darksky api has changed.
|
15
16
|
def base_url
|
@@ -67,17 +68,19 @@ module DarkskyRubyClient
|
|
67
68
|
# * si: SI units
|
68
69
|
# Please check with https://darksky.net/dev/docs#forecast-request for available SI units.
|
69
70
|
def weather_forecast(lat, long, **options)
|
70
|
-
@request_url = @@base_url
|
71
|
+
@request_url = "#{@@base_url}#{@secret_key}/#{lat},#{long}"
|
72
|
+
multiple_parameters = false
|
71
73
|
unless options.empty? then
|
72
74
|
options.each {|key, value|
|
73
75
|
if [:exclude, :extend, :lang, :units].include?(key)
|
74
|
-
|
76
|
+
unless multiple_parameters then
|
75
77
|
@request_url << '?' + key.to_s + '=' + value
|
78
|
+
multiple_parameters = true
|
76
79
|
else
|
77
80
|
@request_url << '&' + key.to_s + '=' + value
|
78
81
|
end
|
79
82
|
else
|
80
|
-
|
83
|
+
@@logger.warn("invalid options key \"#{key}\".")
|
81
84
|
end
|
82
85
|
}
|
83
86
|
end
|
@@ -147,7 +150,7 @@ module DarkskyRubyClient
|
|
147
150
|
if response.code == 200
|
148
151
|
@responses[place_name] = JSON.parse(response.body)
|
149
152
|
else
|
150
|
-
|
153
|
+
@@logger.error("HTTP request failed: " + response.code.to_s)
|
151
154
|
end
|
152
155
|
end
|
153
156
|
hydra.queue @client
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: darksky_ruby_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- appcot
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11-
|
11
|
+
date: 2017-11-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -80,6 +80,20 @@ dependencies:
|
|
80
80
|
- - "~>"
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '3.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: vcr
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
83
97
|
description: This Client for more convenient use of the DarkSky API.
|
84
98
|
email:
|
85
99
|
- appcot.2013@gmail.com
|