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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d5de6788b9b993237d23881ecffdf89613b0ed16
4
- data.tar.gz: f1434deabeaf47eb81a65bd916d55cbe21266fe4
3
+ metadata.gz: 01d5dd2dc927fee5d68600a9494a032737dcd55f
4
+ data.tar.gz: 86ca2ce2d194773ec09f7e7ab5a63b2cd950380b
5
5
  SHA512:
6
- metadata.gz: d73402afe16116467f0aa979de67257d92a74b6879e762216d477f0fbb3ec33a147116dd00b07eb036def9c6d25af07bd02cfc4a1578009f4b9edebb18f0f9fa
7
- data.tar.gz: acc5b8fb1c4f01f980d18d9d71de341e72f51436caf71da93a49a5fd5a924f9d3ef9b0103ae7b8d51a2cfe0d6d2ca1a03c91b5b5a3e2f3ae7a0f698c68d6674f
6
+ metadata.gz: 66c47760124957f164c301251435644e6f68a445fa3225bde8c5a363319319500ada9acb9ddb45bbec4a1823e04f281fb3b2abebaa61ee353494891cfea9d674
7
+ data.tar.gz: 2c31deb3251328201b8d69d8414cf165f0ffa6820096cb07acff2651a0b7b903899d4b995d0cc2992e2fc820c28e6da5ff764da81a69c3453dc4719ffdaf83d1
data/.travis.yml CHANGED
@@ -1,5 +1,7 @@
1
1
  sudo: false
2
2
  language: ruby
3
3
  rvm:
4
- - 2.4.1
4
+ - 2.4.2
5
+ - 2.3.5
6
+ - 2.2.8
5
7
  before_install: gem install bundler -v 1.16.0
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'
@@ -27,4 +27,5 @@ Gem::Specification.new do |spec|
27
27
  spec.add_development_dependency "bundler", "~> 1.16"
28
28
  spec.add_development_dependency "rake", "~> 10.0"
29
29
  spec.add_development_dependency "rspec", "~> 3.0"
30
+ spec.add_development_dependency "vcr"
30
31
  end
@@ -9,7 +9,8 @@ module DarkskyRubyClient
9
9
  @@base_url = 'https://api.darksky.net/forecast/'
10
10
 
11
11
  #TODO logger
12
- @log = Logger.new('/tmp/log')
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 + @secret_key + '/' + lat + ',' + long + '/'
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
- if @request_url[-1] == '/'
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
- @log.warn("invalid options key \"#{key}\".")
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
- @log.error("HTTP request failed: " + response.code.to_s)
153
+ @@logger.error("HTTP request failed: " + response.code.to_s)
151
154
  end
152
155
  end
153
156
  hydra.queue @client
@@ -1,3 +1,3 @@
1
1
  module DarkskyRubyClient
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
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.5
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-24 00:00:00.000000000 Z
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