weather_by_ip 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +5 -5
- data/lib/weather_by_ip/version.rb +1 -1
- data/lib/weather_by_ip.rb +2 -5
- data/test/unit/weather_by_ip_test.rb +12 -2
- data/weather_by_ip.gemspec +1 -1
- metadata +6 -6
data/Gemfile.lock
CHANGED
@@ -1,9 +1,8 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
weather_by_ip (0.0
|
5
|
-
api_object (>= 0.
|
6
|
-
geo_ip
|
4
|
+
weather_by_ip (0.2.0)
|
5
|
+
api_object (>= 0.5.1)
|
7
6
|
|
8
7
|
GEM
|
9
8
|
remote: https://rubygems.org/
|
@@ -11,8 +10,9 @@ GEM
|
|
11
10
|
activesupport (3.2.6)
|
12
11
|
i18n (~> 0.6)
|
13
12
|
multi_json (~> 1.0)
|
14
|
-
api_object (0.
|
13
|
+
api_object (0.5.1)
|
15
14
|
activesupport
|
15
|
+
geo_ip
|
16
16
|
nori (>= 1.1)
|
17
17
|
rest-client (>= 1.6)
|
18
18
|
geo_ip (0.5.0)
|
@@ -21,7 +21,7 @@ GEM
|
|
21
21
|
i18n (0.6.0)
|
22
22
|
json (1.7.3)
|
23
23
|
mime-types (1.18)
|
24
|
-
minitest (3.0
|
24
|
+
minitest (3.1.0)
|
25
25
|
multi_json (1.3.6)
|
26
26
|
nori (1.1.0)
|
27
27
|
rest-client (1.6.7)
|
data/lib/weather_by_ip.rb
CHANGED
@@ -7,11 +7,8 @@ class WeatherByIp
|
|
7
7
|
|
8
8
|
include WeatherInfo
|
9
9
|
|
10
|
-
def get_weather ip, key
|
11
|
-
Weather.new(Weather.get_results_by_ip(ip, key, :weather => :zip_code))
|
12
|
-
rescue
|
13
|
-
puts "Cannot obtain location or weather. Verify that you've obtained and set the api_key for the ipinfodb.com webservice"
|
14
|
-
return
|
10
|
+
def get_weather ip, key = GeoIp.api_key
|
11
|
+
Weather.new(Weather.get_results_by_ip(ip, :key => key, :weather => :zip_code))
|
15
12
|
end
|
16
13
|
|
17
14
|
end
|
@@ -7,8 +7,18 @@ class WeatherByIpTest < MiniTest::Unit::TestCase
|
|
7
7
|
IP = '99.156.82.20'
|
8
8
|
|
9
9
|
def test_should_get_correct_weather
|
10
|
-
|
11
|
-
|
10
|
+
check_weather WeatherByIp.get_weather(IP, ARGV.last)
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_should_get_correct_weather_with_key_preset
|
15
|
+
GeoIp.api_key = ARGV.last
|
16
|
+
check_weather WeatherByIp.get_weather(IP)
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
def check_weather weather
|
21
|
+
unless weather.nil?
|
12
22
|
refute_nil(weather.forecast_information)
|
13
23
|
refute_nil(weather.current_conditions)
|
14
24
|
refute_nil(weather.forecast_conditions)
|
data/weather_by_ip.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: weather_by_ip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-06-13 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: minitest
|
16
|
-
requirement: &
|
16
|
+
requirement: &73543910 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,18 +21,18 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :development
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *73543910
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: api_object
|
27
|
-
requirement: &
|
27
|
+
requirement: &73543430 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version:
|
32
|
+
version: 0.5.1
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *73543430
|
36
36
|
description: An interface to load weather information based on an approximate user
|
37
37
|
location
|
38
38
|
email:
|