swissforecast 0.1.0 → 0.2.0

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: 42a20bdb0da0d27b58423bd27ac6cba4d165a22a
4
- data.tar.gz: c7bfffa86ac5b1d86d3ef4ecdf8d6186884043ad
3
+ metadata.gz: 698c03fa9ebfbee03e8b8d757f79478a9deb37d0
4
+ data.tar.gz: 877b13a02a47ffdbdc840e0853b1bc9af3e442bd
5
5
  SHA512:
6
- metadata.gz: 8123ca5d5152f3ddb4f14c7585e9ac904734451d0f7fd1a5957ac925693592b70c4b4c5d17e048f5b5103d110c3bcc7573752f000a0610d4283be3e7f9f66b9f
7
- data.tar.gz: 252d5b15f5d1bdbc0387447e2f4b292e042fa0b382d1ce7792374270450545278ef2aca3d95f3251bb9350fb07453aa8e2ca066239a9d3b82141263342e658b1
6
+ metadata.gz: 73bb069957f3bb9feb0f28f790e293aee688be289302b2fc5d8ec45252686e4394a3c40548a6ab38ff010b003b486f2a4ed559c93ad9e06958ea3fc42fd83eff
7
+ data.tar.gz: a3eeea1ea12e3d4461814ba170abe2dc3a1806620f1ae3f7392f270be7c58a54f1143bbfe16edf6c823f77ae7f5adb42e893b3bf88b303598167a410c7b6246a
data/Gemfile.lock CHANGED
@@ -2,8 +2,6 @@ PATH
2
2
  remote: .
3
3
  specs:
4
4
  swissforecast (0.1.0)
5
- json
6
- rest-client
7
5
 
8
6
  GEM
9
7
  remote: http://rubygems.org/
@@ -11,26 +9,10 @@ GEM
11
9
  addressable (2.4.0)
12
10
  crack (0.4.3)
13
11
  safe_yaml (~> 1.0.0)
14
- domain_name (0.5.20160615)
15
- unf (>= 0.0.5, < 1.0.0)
16
12
  hashdiff (0.3.0)
17
- http-cookie (1.0.2)
18
- domain_name (~> 0.5)
19
- json (2.0.1)
20
- mime-types (3.1)
21
- mime-types-data (~> 3.2015)
22
- mime-types-data (3.2016.0521)
23
- minitest (5.8.4)
24
- netrc (0.11.0)
13
+ minitest (5.9.0)
25
14
  rake (11.2.2)
26
- rest-client (2.0.0)
27
- http-cookie (>= 1.0.2, < 2.0)
28
- mime-types (>= 1.16, < 4.0)
29
- netrc (~> 0.8)
30
15
  safe_yaml (1.0.4)
31
- unf (0.1.4)
32
- unf_ext
33
- unf_ext (0.0.7.2)
34
16
  webmock (2.1.0)
35
17
  addressable (>= 2.3.6)
36
18
  crack (>= 0.3.2)
@@ -40,11 +22,10 @@ PLATFORMS
40
22
  ruby
41
23
 
42
24
  DEPENDENCIES
43
- bundler
44
- minitest (~> 5.8.4)
45
- rake
25
+ minitest (~> 5.8)
26
+ rake (~> 11.2)
46
27
  swissforecast!
47
- webmock (~> 2.1.0)
28
+ webmock (~> 2.1)
48
29
 
49
30
  BUNDLED WITH
50
31
  1.10.6
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  #swissforecast
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/swissforecast.svg)](https://badge.fury.io/rb/swissforecast)
4
+ [![Build Status](https://travis-ci.org/ghn/swissforecast.svg?branch=master)](https://travis-ci.org/ghn/swissforecast)
5
+
3
6
  Ruby client for the Swiss weather forecast API
4
7
 
5
8
  ##Installation
@@ -22,13 +25,13 @@ See below how to use this client.
22
25
  ###Find by city
23
26
 
24
27
  ```ruby
25
- client.find_by_city 'Lausanne'
28
+ client.find_by city: 'Lausanne'
26
29
  ```
27
30
 
28
31
  ###Find by position
29
32
 
30
33
  ```ruby
31
- client.find_by_position '46.58', '6.60'
34
+ client.find_by lat: '46.58', lng: '6.60'
32
35
  ```
33
36
 
34
37
  ## Development
@@ -42,3 +45,5 @@ rake test
42
45
  ## License
43
46
 
44
47
  MIT License (MIT)
48
+
49
+ Thanks to [Prevision meteo](http://www.prevision-meteo.ch) for opening their data
data/lib/swissforecast.rb CHANGED
@@ -7,19 +7,15 @@ module Swissforecast
7
7
  DEFAULT_DOMAIN = 'http://www.prevision-meteo.ch/services/json'.freeze
8
8
 
9
9
  #
10
- # => find weather by city
10
+ # => find weather by city or by gps position
11
11
  #
12
12
 
13
- def find_by_city(city)
14
- perform(city.sub(' ', '-'))
15
- end
16
-
17
- #
18
- # => find weather by gps position
19
- #
20
-
21
- def find_by_position(lat, lng)
22
- perform("lat=#{lat}lng=#{lng}")
13
+ def find_by(param)
14
+ if param.key?(:city)
15
+ perform(param[:city].sub(' ', '-'))
16
+ elsif param.key?(:lat) && param.key?(:lng)
17
+ perform("lat=#{param[:lat]}lng=#{param[:lng]}")
18
+ end
23
19
  end
24
20
 
25
21
  private
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |gem|
2
2
  gem.name = 'swissforecast'
3
- gem.version = '0.1.0'
3
+ gem.version = '0.2.0'
4
4
  gem.authors = ['ghn']
5
5
  gem.email = ['ghugon@gmail.com']
6
6
  gem.description = 'Swissforecast helps you query the swiss weather forecast
@@ -14,7 +14,6 @@ Gem::Specification.new do |gem|
14
14
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
15
15
  gem.require_paths = ['lib']
16
16
 
17
- gem.add_development_dependency('bundler', '~> 1.12')
18
17
  gem.add_development_dependency('rake', '~> 11.2')
19
18
  gem.add_development_dependency('minitest', '~> 5.8')
20
19
  gem.add_development_dependency('webmock', '~> 2.1')
data/test/client_test.rb CHANGED
@@ -11,7 +11,7 @@ class ClientTest < Minitest::Test
11
11
  def test_find_by_city
12
12
  stub_response('client_test_city.json')
13
13
 
14
- weather = @client.find_by_city 'lausanne'
14
+ weather = @client.find_by city: 'lausanne'
15
15
 
16
16
  assert weather.city_info.name == 'Lausanne'
17
17
  assert weather.city_info.country == 'Suisse'
@@ -20,7 +20,7 @@ class ClientTest < Minitest::Test
20
20
  def test_find_by_position
21
21
  stub_response('client_test_position.json')
22
22
 
23
- weather = @client.find_by_position '46.58', '6.60'
23
+ weather = @client.find_by lat: '46.58', lng: '6.60'
24
24
 
25
25
  assert weather.city_info.name == 'NA'
26
26
  assert weather.city_info.country == '--'
@@ -30,7 +30,7 @@ class ClientTest < Minitest::Test
30
30
  def test_errors
31
31
  stub_response('client_test_failure.json')
32
32
 
33
- weather = @client.find_by_city 'not_existing_city'
33
+ weather = @client.find_by city: 'not_existing_city'
34
34
 
35
35
  assert weather.errors.count == 1
36
36
  assert weather.errors.first.code == '11'
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: swissforecast
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ghn
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-07-24 00:00:00.000000000 Z
11
+ date: 2016-08-04 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: bundler
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.12'
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: '1.12'
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: rake
29
15
  requirement: !ruby/object:Gem::Requirement