weather_underground 0.0.1
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.
- data/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.md +18 -0
- data/Rakefile +1 -0
- data/lib/weather_underground/version.rb +3 -0
- data/lib/weather_underground.rb +32 -0
- data/weather_underground.gemspec +25 -0
- metadata +74 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Weather Underground
|
2
|
+
===================
|
3
|
+
|
4
|
+
A simple Ruby wrapper for the Weather Underground API
|
5
|
+
|
6
|
+
Usage
|
7
|
+
-----
|
8
|
+
|
9
|
+
w = WeatherUnderground::Base.new(API_KEY)
|
10
|
+
|
11
|
+
GeoLookup:
|
12
|
+
|
13
|
+
w.geolookup('63108')
|
14
|
+
|
15
|
+
IP Geolocation
|
16
|
+
|
17
|
+
w.autoip('127.0.0.1')
|
18
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require "weather_underground/version"
|
2
|
+
require "json"
|
3
|
+
require "rest_client"
|
4
|
+
require "uri"
|
5
|
+
|
6
|
+
module WeatherUnderground
|
7
|
+
URL = "http://api.wunderground.com/api/%s/"
|
8
|
+
|
9
|
+
class Base
|
10
|
+
def initialize(apikey)
|
11
|
+
@apikey = apikey
|
12
|
+
end
|
13
|
+
|
14
|
+
def geolookup(location)
|
15
|
+
make_request url_with_key + "/geolookup/conditions/q/%s.json" % URI.escape(location)
|
16
|
+
end
|
17
|
+
|
18
|
+
def autoip(ip)
|
19
|
+
make_request url_with_key + "/geolookup/conditions/q/autoip.json?" + ip
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def make_request(uri)
|
25
|
+
JSON.parse RestClient.get(uri)
|
26
|
+
end
|
27
|
+
|
28
|
+
def url_with_key
|
29
|
+
WeatherUnderground::URL % @apikey
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "weather_underground/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "weather_underground"
|
7
|
+
s.version = WeatherUnderground::VERSION
|
8
|
+
s.authors = ["Chris Oliver"]
|
9
|
+
s.email = ["excid3@gmail.com"]
|
10
|
+
s.homepage = ""
|
11
|
+
s.summary = %q{A Ruby gem for the Weather Underground API}
|
12
|
+
s.description = %q{A Ruby gem for the Weather Underground API}
|
13
|
+
|
14
|
+
s.rubyforge_project = "weather_underground"
|
15
|
+
|
16
|
+
s.files = `git ls-files`.split("\n")
|
17
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
19
|
+
s.require_paths = ["lib"]
|
20
|
+
|
21
|
+
# specify any dependencies here; for example:
|
22
|
+
# s.add_development_dependency "rspec"
|
23
|
+
s.add_runtime_dependency "rest-client", "~> 1.6.7"
|
24
|
+
s.add_runtime_dependency "json", "~> 1.6.5"
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: weather_underground
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Chris Oliver
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-03-08 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rest-client
|
16
|
+
requirement: &70366091595040 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 1.6.7
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70366091595040
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: json
|
27
|
+
requirement: &70366091594040 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ~>
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.6.5
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70366091594040
|
36
|
+
description: A Ruby gem for the Weather Underground API
|
37
|
+
email:
|
38
|
+
- excid3@gmail.com
|
39
|
+
executables: []
|
40
|
+
extensions: []
|
41
|
+
extra_rdoc_files: []
|
42
|
+
files:
|
43
|
+
- .gitignore
|
44
|
+
- Gemfile
|
45
|
+
- README.md
|
46
|
+
- Rakefile
|
47
|
+
- lib/weather_underground.rb
|
48
|
+
- lib/weather_underground/version.rb
|
49
|
+
- weather_underground.gemspec
|
50
|
+
homepage: ''
|
51
|
+
licenses: []
|
52
|
+
post_install_message:
|
53
|
+
rdoc_options: []
|
54
|
+
require_paths:
|
55
|
+
- lib
|
56
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
63
|
+
none: false
|
64
|
+
requirements:
|
65
|
+
- - ! '>='
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
requirements: []
|
69
|
+
rubyforge_project: weather_underground
|
70
|
+
rubygems_version: 1.8.10
|
71
|
+
signing_key:
|
72
|
+
specification_version: 3
|
73
|
+
summary: A Ruby gem for the Weather Underground API
|
74
|
+
test_files: []
|