robut-weather 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/Gemfile +18 -0
- data/README.rdoc +44 -0
- data/Rakefile +46 -0
- data/VERSION +1 -0
- data/lib/robut-weather.rb +78 -0
- data/robut-weather.gemspec +73 -0
- data/test/connection_mock.rb +22 -0
- data/test/fixtures/0.json +14 -0
- data/test/fixtures/12345.json +92 -0
- data/test/presence_mock.rb +25 -0
- data/test/simplecov_helper.rb +2 -0
- data/test/test_helper.rb +9 -0
- data/test/test_weather.rb +88 -0
- metadata +170 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 38cba8c65e2f1479a030057e78eb0d42c0a73bad
|
4
|
+
data.tar.gz: 7e3fb10e09c35816cd0944068a903754f504cef7
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d3dd5b862de4a1a41d97d7050004ea650bef28b61aa5cf168c9ad4adce926cf514bbdfa8e8155cd59dedbd678cd3ce172085189d038ba52ef59f93a453bb5524
|
7
|
+
data.tar.gz: 60a69af90af8132f97a17273399a08aab6d3f8a5ae595b5fa47b1ea07efb82fcde5358efdb8c8c1009dcc5090a9d0a05416125ab32151fdcfb895aae1efe5b0e
|
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
gem "robut", ">= 0.4"
|
7
|
+
gem "json"
|
8
|
+
gem "wunderground"
|
9
|
+
|
10
|
+
# Add dependencies to develop your gem here.
|
11
|
+
# Include everything needed to run rake, tests, features, etc.
|
12
|
+
group :development do
|
13
|
+
gem "simplecov"
|
14
|
+
gem 'webmock'
|
15
|
+
gem "rdoc", "~> 3.12"
|
16
|
+
gem "bundler", "~> 1.0"
|
17
|
+
gem "jeweler", "~> 1.8.7"
|
18
|
+
end
|
data/README.rdoc
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
= robut-weather
|
2
|
+
|
3
|
+
A {Weather Underground}[http://www.wunderground.com] based weather module for robut[https://github.com/justinweiss/robut]
|
4
|
+
|
5
|
+
== Installation and usage
|
6
|
+
|
7
|
+
Robut can be installed by running <tt>gem install robut-weather</tt>. This will require the additional gems <tt>robut</tt>, <tt>json</tt>, and <tt>{wunderground}[https://github.com/wnadeau/wunderground]</tt>, which may or may not require their own dependencies.
|
8
|
+
|
9
|
+
Your Chatfile will need to have the Weather plugin loaded.
|
10
|
+
|
11
|
+
require 'robut-weather'
|
12
|
+
Robut::Plugin::Weather.default_location = "DEFAULT LOCATION"
|
13
|
+
Robut::Plugin::Weather.api_key = "[API KEY]"
|
14
|
+
Robut::Plugin.plugins << Robut::Plugin::Weather
|
15
|
+
|
16
|
+
[DEFAULT LOCATION] must be in an acceptible Weather Underground format. See Location Formats below.
|
17
|
+
[API KEY] must be obtained through Weather Underground. The Weather Underground API is only available to registered members. For light use, there is no charge. A key can be obtained from http://api.wunderground.com/weather/api/
|
18
|
+
|
19
|
+
== Location Formats
|
20
|
+
|
21
|
+
Locations must be in the format expected by {Weather Underground's API}[http://api.wunderground.com/weather/api/d/docs?d=data/geolookup#examples]
|
22
|
+
|
23
|
+
* STATE/CITY
|
24
|
+
* COUNTRY/CITY
|
25
|
+
* AUTOIP
|
26
|
+
* Zip Code
|
27
|
+
* Airport Code
|
28
|
+
|
29
|
+
See http://api.wunderground.com/weather/api/d/docs?d=data/geolookup#examples for further examples.
|
30
|
+
|
31
|
+
== Contributing to robut-weather
|
32
|
+
|
33
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
34
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
35
|
+
* Fork the project.
|
36
|
+
* Start a feature/bugfix branch.
|
37
|
+
* Commit and push until you are happy with your contribution.
|
38
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
39
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
40
|
+
|
41
|
+
== Weather Underground API Usage
|
42
|
+
|
43
|
+
The data provided by this module comes from {Weather Underground}[http://www.wunderground.com].
|
44
|
+
http://icons.wxug.com/logos/images/wundergroundLogo_4c_horz.jpg
|
data/Rakefile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "robut-weather"
|
18
|
+
gem.homepage = "http://github.com/richard4339/robut-weather"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{A weather plugin for robut}
|
21
|
+
gem.description = %Q{A Wunderground based weather plugin for robut}
|
22
|
+
gem.email = "richard@mozor.net"
|
23
|
+
gem.authors = ["Richard Lynskey"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rake/testtask'
|
29
|
+
Rake::TestTask.new(:test) do |test|
|
30
|
+
test.libs << 'lib' << 'test'
|
31
|
+
test.ruby_opts = ["-rsimplecov_helper"]
|
32
|
+
test.pattern = 'test/**/test_*.rb'
|
33
|
+
test.verbose = true
|
34
|
+
end
|
35
|
+
|
36
|
+
task :default => :test
|
37
|
+
|
38
|
+
require 'rdoc/task'
|
39
|
+
Rake::RDocTask.new do |rdoc|
|
40
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
41
|
+
|
42
|
+
rdoc.rdoc_dir = 'rdoc'
|
43
|
+
rdoc.title = "robut-weather #{version}"
|
44
|
+
rdoc.rdoc_files.include('README*')
|
45
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
46
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.1.2
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'wunderground'
|
3
|
+
|
4
|
+
# What's the weather?
|
5
|
+
class Robut::Plugin::Weather
|
6
|
+
include Robut::Plugin
|
7
|
+
|
8
|
+
class << self
|
9
|
+
attr_accessor :default_location
|
10
|
+
attr_accessor :api_key
|
11
|
+
end
|
12
|
+
|
13
|
+
# Returns a description of how to use this plugin
|
14
|
+
def usage
|
15
|
+
[
|
16
|
+
"#{at_nick} weather - returns the current conditions in the default location",
|
17
|
+
"#{at_nick} weather <location> - returns the current conditions for <location>"
|
18
|
+
]
|
19
|
+
end
|
20
|
+
|
21
|
+
def handle(time, sender_nick, message)
|
22
|
+
words = words(message)
|
23
|
+
|
24
|
+
i = words.index("weather")
|
25
|
+
# ignore messages that don't have "weather" in them
|
26
|
+
return if i.nil?
|
27
|
+
|
28
|
+
l = location(words(message)[i + 1])
|
29
|
+
if l.nil?
|
30
|
+
error_output "I don't have a default location!"
|
31
|
+
return
|
32
|
+
end
|
33
|
+
|
34
|
+
begin
|
35
|
+
o = current_conditions(l)
|
36
|
+
reply o unless o.nil? || o == ""
|
37
|
+
rescue Exception => msg
|
38
|
+
puts msg
|
39
|
+
error_output(msg)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def location(x)
|
44
|
+
x = self.class.default_location if x.nil?
|
45
|
+
x
|
46
|
+
end
|
47
|
+
|
48
|
+
def error_output(m)
|
49
|
+
reply "Error getting weather: #{m}"
|
50
|
+
end
|
51
|
+
|
52
|
+
# Get today's current_conditions
|
53
|
+
def current_conditions(l)
|
54
|
+
current_conditions = "Unknown"
|
55
|
+
w_api = Wunderground.new(self.class.api_key)
|
56
|
+
begin
|
57
|
+
parsed = w_api.conditions_for(l)
|
58
|
+
w = parsed["current_observation"]
|
59
|
+
|
60
|
+
rescue => e
|
61
|
+
case e
|
62
|
+
when Wunderground::MissingAPIKey
|
63
|
+
error_output "API Key has not been set."
|
64
|
+
return ""
|
65
|
+
else
|
66
|
+
raise e
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
if w.nil?
|
71
|
+
error_output "Invalid Location"
|
72
|
+
return ""
|
73
|
+
end
|
74
|
+
|
75
|
+
current_conditions = "Weather for #{w['display_location']['full']}: #{w['weather']}, Current Temperature #{w['temperature_string']}, Wind #{w['wind_string']}. Full forecast: #{w['forecast_url']}"
|
76
|
+
current_conditions
|
77
|
+
end
|
78
|
+
end
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = "robut-weather"
|
8
|
+
s.version = "0.1.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["Richard Lynskey"]
|
12
|
+
s.date = "2013-12-21"
|
13
|
+
s.description = "A Wunderground based weather plugin for robut"
|
14
|
+
s.email = "richard@mozor.net"
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.rdoc"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
".document",
|
20
|
+
"Gemfile",
|
21
|
+
"README.rdoc",
|
22
|
+
"Rakefile",
|
23
|
+
"VERSION",
|
24
|
+
"lib/robut-weather.rb",
|
25
|
+
"robut-weather.gemspec",
|
26
|
+
"test/connection_mock.rb",
|
27
|
+
"test/fixtures/0.json",
|
28
|
+
"test/fixtures/12345.json",
|
29
|
+
"test/presence_mock.rb",
|
30
|
+
"test/simplecov_helper.rb",
|
31
|
+
"test/test_helper.rb",
|
32
|
+
"test/test_weather.rb"
|
33
|
+
]
|
34
|
+
s.homepage = "http://github.com/richard4339/robut-weather"
|
35
|
+
s.licenses = ["MIT"]
|
36
|
+
s.require_paths = ["lib"]
|
37
|
+
s.rubygems_version = "2.0.3"
|
38
|
+
s.summary = "A weather plugin for robut"
|
39
|
+
|
40
|
+
if s.respond_to? :specification_version then
|
41
|
+
s.specification_version = 4
|
42
|
+
|
43
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
44
|
+
s.add_runtime_dependency(%q<robut>, [">= 0.4"])
|
45
|
+
s.add_runtime_dependency(%q<json>, [">= 0"])
|
46
|
+
s.add_runtime_dependency(%q<wunderground>, [">= 0"])
|
47
|
+
s.add_development_dependency(%q<simplecov>, [">= 0"])
|
48
|
+
s.add_development_dependency(%q<webmock>, [">= 0"])
|
49
|
+
s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
|
50
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.0"])
|
51
|
+
s.add_development_dependency(%q<jeweler>, ["~> 1.8.7"])
|
52
|
+
else
|
53
|
+
s.add_dependency(%q<robut>, [">= 0.4"])
|
54
|
+
s.add_dependency(%q<json>, [">= 0"])
|
55
|
+
s.add_dependency(%q<wunderground>, [">= 0"])
|
56
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
57
|
+
s.add_dependency(%q<webmock>, [">= 0"])
|
58
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
59
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
60
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
|
61
|
+
end
|
62
|
+
else
|
63
|
+
s.add_dependency(%q<robut>, [">= 0.4"])
|
64
|
+
s.add_dependency(%q<json>, [">= 0"])
|
65
|
+
s.add_dependency(%q<wunderground>, [">= 0"])
|
66
|
+
s.add_dependency(%q<simplecov>, [">= 0"])
|
67
|
+
s.add_dependency(%q<webmock>, [">= 0"])
|
68
|
+
s.add_dependency(%q<rdoc>, ["~> 3.12"])
|
69
|
+
s.add_dependency(%q<bundler>, ["~> 1.0"])
|
70
|
+
s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'robut/storage/hash_store'
|
2
|
+
|
3
|
+
class Robut::ConnectionMock < Robut::Connection
|
4
|
+
|
5
|
+
attr_accessor :messages
|
6
|
+
|
7
|
+
def initialize(config = nil)
|
8
|
+
self.messages = []
|
9
|
+
self.config = config || self.class.config
|
10
|
+
self.store = Robut::Storage::HashStore
|
11
|
+
self.client = Jabber::Client.new ''
|
12
|
+
end
|
13
|
+
|
14
|
+
def connect
|
15
|
+
self.rooms = []
|
16
|
+
self
|
17
|
+
end
|
18
|
+
|
19
|
+
def reply(message, to)
|
20
|
+
self.messages << [message, to]
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
{
|
2
|
+
"response": {
|
3
|
+
"version":"0.1",
|
4
|
+
"termsofService":"http://www.wunderground.com/weather/api/d/terms.html",
|
5
|
+
"features": {
|
6
|
+
"conditions": 1
|
7
|
+
}
|
8
|
+
,
|
9
|
+
"error": {
|
10
|
+
"type": "querynotfound"
|
11
|
+
,"description": "No cities match your search query"
|
12
|
+
}
|
13
|
+
}
|
14
|
+
}
|
@@ -0,0 +1,92 @@
|
|
1
|
+
{
|
2
|
+
"response": {
|
3
|
+
"version": "0.1",
|
4
|
+
"termsofService": "http://www.wunderground.com/weather/api/d/terms.html",
|
5
|
+
"features": {
|
6
|
+
"conditions": 1
|
7
|
+
}
|
8
|
+
}, "current_observation": {
|
9
|
+
"image": {
|
10
|
+
"url": "http://icons-ak.wxug.com/graphics/wu2/logo_130x80.png",
|
11
|
+
"title": "Weather Underground",
|
12
|
+
"link": "http://www.wunderground.com"
|
13
|
+
},
|
14
|
+
"display_location": {
|
15
|
+
"full": "Schenectady, NY",
|
16
|
+
"city": "Schenectady",
|
17
|
+
"state": "NY",
|
18
|
+
"state_name": "New York",
|
19
|
+
"country": "US",
|
20
|
+
"country_iso3166": "US",
|
21
|
+
"zip": "12345",
|
22
|
+
"magic": "1",
|
23
|
+
"wmo": "99999",
|
24
|
+
"latitude": "42.81407928",
|
25
|
+
"longitude": "-73.93997955",
|
26
|
+
"elevation": "78.00000000"
|
27
|
+
},
|
28
|
+
"observation_location": {
|
29
|
+
"full": "Stockade, Schenectady, New York",
|
30
|
+
"city": "Stockade, Schenectady",
|
31
|
+
"state": "New York",
|
32
|
+
"country": "US",
|
33
|
+
"country_iso3166": "US",
|
34
|
+
"latitude": "42.817513",
|
35
|
+
"longitude": "-73.948425",
|
36
|
+
"elevation": "249 ft"
|
37
|
+
},
|
38
|
+
"estimated": {
|
39
|
+
},
|
40
|
+
"station_id": "KNYSCHEN23",
|
41
|
+
"observation_time": "Last Updated on November 5, 1:27 PM EST",
|
42
|
+
"observation_time_rfc822": "Tue, 05 Nov 2013 13:27:03 -0500",
|
43
|
+
"observation_epoch": "1383676023",
|
44
|
+
"local_time_rfc822": "Tue, 05 Nov 2013 13:32:02 -0500",
|
45
|
+
"local_epoch": "1383676322",
|
46
|
+
"local_tz_short": "EST",
|
47
|
+
"local_tz_long": "America/New_York",
|
48
|
+
"local_tz_offset": "-0500",
|
49
|
+
"weather": "Mostly Cloudy",
|
50
|
+
"temperature_string": "51.1 F (10.6 C)",
|
51
|
+
"temp_f": 51.1,
|
52
|
+
"temp_c": 10.6,
|
53
|
+
"relative_humidity": "42%",
|
54
|
+
"wind_string": "From the South at 1.0 MPH Gusting to 5.0 MPH",
|
55
|
+
"wind_dir": "South",
|
56
|
+
"wind_degrees": 180,
|
57
|
+
"wind_mph": 1.0,
|
58
|
+
"wind_gust_mph": "5.0",
|
59
|
+
"wind_kph": 1.6,
|
60
|
+
"wind_gust_kph": "8.0",
|
61
|
+
"pressure_mb": "1036",
|
62
|
+
"pressure_in": "30.58",
|
63
|
+
"pressure_trend": "-",
|
64
|
+
"dewpoint_string": "29 F (-2 C)",
|
65
|
+
"dewpoint_f": 29,
|
66
|
+
"dewpoint_c": -2,
|
67
|
+
"heat_index_string": "NA",
|
68
|
+
"heat_index_f": "NA",
|
69
|
+
"heat_index_c": "NA",
|
70
|
+
"windchill_string": "NA",
|
71
|
+
"windchill_f": "NA",
|
72
|
+
"windchill_c": "NA",
|
73
|
+
"feelslike_string": "51.1 F (10.6 C)",
|
74
|
+
"feelslike_f": "51.1",
|
75
|
+
"feelslike_c": "10.6",
|
76
|
+
"visibility_mi": "10.0",
|
77
|
+
"visibility_km": "16.1",
|
78
|
+
"solarradiation": "--",
|
79
|
+
"UV": "2",
|
80
|
+
"precip_1hr_string": "0.00 in ( 0 mm)",
|
81
|
+
"precip_1hr_in": "0.00",
|
82
|
+
"precip_1hr_metric": " 0",
|
83
|
+
"precip_today_string": "0.00 in (0 mm)",
|
84
|
+
"precip_today_in": "0.00",
|
85
|
+
"precip_today_metric": "0",
|
86
|
+
"icon": "mostlycloudy",
|
87
|
+
"icon_url": "http://icons-ak.wxug.com/i/c/k/mostlycloudy.gif",
|
88
|
+
"forecast_url": "http://www.wunderground.com/US/NY/Schenectady.html",
|
89
|
+
"history_url": "http://www.wunderground.com/weatherstation/WXDailyHistory.asp?ID=KNYSCHEN23",
|
90
|
+
"ob_url": "http://www.wunderground.com/cgi-bin/findweather/getForecast?query=42.817513,-73.948425"
|
91
|
+
}
|
92
|
+
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'robut/storage/hash_store'
|
2
|
+
|
3
|
+
class Robut::PresenceMock < Robut::Room
|
4
|
+
|
5
|
+
def initialize(connection)
|
6
|
+
self.connection = connection
|
7
|
+
end
|
8
|
+
|
9
|
+
def replies
|
10
|
+
@replies ||= []
|
11
|
+
end
|
12
|
+
|
13
|
+
def reply(msg, to = nil)
|
14
|
+
replies << msg
|
15
|
+
end
|
16
|
+
|
17
|
+
def handle_message(plugins, time, nick, message)
|
18
|
+
messages << [time, nick, message]
|
19
|
+
end
|
20
|
+
|
21
|
+
def messages
|
22
|
+
@messages ||= []
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
require 'webmock/test_unit'
|
3
|
+
require 'robut'
|
4
|
+
require 'robut-weather'
|
5
|
+
|
6
|
+
class Robut::Plugin::WeatherTest < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@connection = Robut::ConnectionMock.new
|
10
|
+
@presence = Robut::PresenceMock.new(@connection)
|
11
|
+
@plugin = Robut::Plugin::Weather.new(@presence)
|
12
|
+
end
|
13
|
+
|
14
|
+
def teardown
|
15
|
+
Robut::Plugin::Weather.default_location = nil
|
16
|
+
Robut::Plugin::Weather.api_key = nil
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_handle_no_weather
|
20
|
+
@plugin.handle(Time.now, "John", "lunch?")
|
21
|
+
assert_equal( [], @plugin.reply_to.replies )
|
22
|
+
|
23
|
+
@plugin.handle(Time.now, "John", "?")
|
24
|
+
assert_equal( [], @plugin.reply_to.replies )
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_handle_no_location_no_default
|
28
|
+
@plugin.handle(Time.now, "John", "weather")
|
29
|
+
assert_equal( ["Error getting weather: I don't have a default location!"], @plugin.reply_to.replies )
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_handle_no_api_key
|
33
|
+
Robut::Plugin::Weather.default_location = "12345"
|
34
|
+
@plugin.handle(Time.now, "John", "weather")
|
35
|
+
assert_equal( ["Error getting weather: API Key has not been set."], @plugin.reply_to.replies )
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_handle_default_location_zip
|
39
|
+
Robut::Plugin::Weather.default_location = "12345"
|
40
|
+
Robut::Plugin::Weather.api_key = ""
|
41
|
+
|
42
|
+
stub_request(:get, "http://api.wunderground.com/api//conditions/q/12345.json").to_return(:body => File.open(File.expand_path("../fixtures/12345.json", __FILE__), "r").read)
|
43
|
+
|
44
|
+
@plugin.handle(Time.now, "John", "weather")
|
45
|
+
assert_equal( ["Weather for Schenectady, NY: Mostly Cloudy, Current Temperature 51.1 F (10.6 C), Wind From the South at 1.0 MPH Gusting to 5.0 MPH. Full forecast: http://www.wunderground.com/US/NY/Schenectady.html"], @plugin.reply_to.replies )
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_handle_default_location_city_state
|
49
|
+
Robut::Plugin::Weather.default_location = "NY/Schenectady"
|
50
|
+
Robut::Plugin::Weather.api_key = ""
|
51
|
+
|
52
|
+
stub_request(:get, "http://api.wunderground.com/api//conditions/q/NY/Schenectady.json").to_return(:body => File.open(File.expand_path("../fixtures/12345.json", __FILE__), "r").read)
|
53
|
+
|
54
|
+
@plugin.handle(Time.now, "John", "weather")
|
55
|
+
assert_equal( ["Weather for Schenectady, NY: Mostly Cloudy, Current Temperature 51.1 F (10.6 C), Wind From the South at 1.0 MPH Gusting to 5.0 MPH. Full forecast: http://www.wunderground.com/US/NY/Schenectady.html"], @plugin.reply_to.replies )
|
56
|
+
end
|
57
|
+
|
58
|
+
def test_handle_location_zip
|
59
|
+
Robut::Plugin::Weather.default_location = ""
|
60
|
+
Robut::Plugin::Weather.api_key = ""
|
61
|
+
|
62
|
+
stub_request(:get, "http://api.wunderground.com/api//conditions/q/12345.json").to_return(:body => File.open(File.expand_path("../fixtures/12345.json", __FILE__), "r").read)
|
63
|
+
|
64
|
+
@plugin.handle(Time.now, "John", "weather 12345")
|
65
|
+
assert_equal( ["Weather for Schenectady, NY: Mostly Cloudy, Current Temperature 51.1 F (10.6 C), Wind From the South at 1.0 MPH Gusting to 5.0 MPH. Full forecast: http://www.wunderground.com/US/NY/Schenectady.html"], @plugin.reply_to.replies )
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_handle_location_city_state
|
69
|
+
Robut::Plugin::Weather.default_location = ""
|
70
|
+
Robut::Plugin::Weather.api_key = ""
|
71
|
+
|
72
|
+
stub_request(:get, "http://api.wunderground.com/api//conditions/q/NY/Schenectady.json").to_return(:body => File.open(File.expand_path("../fixtures/12345.json", __FILE__), "r").read)
|
73
|
+
|
74
|
+
@plugin.handle(Time.now, "John", "weather NY/Schenectady")
|
75
|
+
assert_equal( ["Weather for Schenectady, NY: Mostly Cloudy, Current Temperature 51.1 F (10.6 C), Wind From the South at 1.0 MPH Gusting to 5.0 MPH. Full forecast: http://www.wunderground.com/US/NY/Schenectady.html"], @plugin.reply_to.replies )
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_handle_invalid_location
|
79
|
+
Robut::Plugin::Weather.default_location = ""
|
80
|
+
Robut::Plugin::Weather.api_key = ""
|
81
|
+
|
82
|
+
stub_request(:get, "http://api.wunderground.com/api//conditions/q/0.json").to_return(:body => File.open(File.expand_path("../fixtures/0.json", __FILE__), "r").read)
|
83
|
+
|
84
|
+
@plugin.handle(Time.now, "John", "weather 0")
|
85
|
+
assert_equal( ["Error getting weather: Invalid Location"], @plugin.reply_to.replies )
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
metadata
ADDED
@@ -0,0 +1,170 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: robut-weather
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Richard Lynskey
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-12-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: robut
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.4'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: json
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: wunderground
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '>='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: simplecov
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: webmock
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rdoc
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ~>
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '3.12'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ~>
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '3.12'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: bundler
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ~>
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '1.0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '1.0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: jeweler
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: 1.8.7
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ~>
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: 1.8.7
|
125
|
+
description: A Wunderground based weather plugin for robut
|
126
|
+
email: richard@mozor.net
|
127
|
+
executables: []
|
128
|
+
extensions: []
|
129
|
+
extra_rdoc_files:
|
130
|
+
- README.rdoc
|
131
|
+
files:
|
132
|
+
- .document
|
133
|
+
- Gemfile
|
134
|
+
- README.rdoc
|
135
|
+
- Rakefile
|
136
|
+
- VERSION
|
137
|
+
- lib/robut-weather.rb
|
138
|
+
- robut-weather.gemspec
|
139
|
+
- test/connection_mock.rb
|
140
|
+
- test/fixtures/0.json
|
141
|
+
- test/fixtures/12345.json
|
142
|
+
- test/presence_mock.rb
|
143
|
+
- test/simplecov_helper.rb
|
144
|
+
- test/test_helper.rb
|
145
|
+
- test/test_weather.rb
|
146
|
+
homepage: http://github.com/richard4339/robut-weather
|
147
|
+
licenses:
|
148
|
+
- MIT
|
149
|
+
metadata: {}
|
150
|
+
post_install_message:
|
151
|
+
rdoc_options: []
|
152
|
+
require_paths:
|
153
|
+
- lib
|
154
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
155
|
+
requirements:
|
156
|
+
- - '>='
|
157
|
+
- !ruby/object:Gem::Version
|
158
|
+
version: '0'
|
159
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
160
|
+
requirements:
|
161
|
+
- - '>='
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '0'
|
164
|
+
requirements: []
|
165
|
+
rubyforge_project:
|
166
|
+
rubygems_version: 2.0.3
|
167
|
+
signing_key:
|
168
|
+
specification_version: 4
|
169
|
+
summary: A weather plugin for robut
|
170
|
+
test_files: []
|