cinch-weatherman 0.0.1 → 1.0.0
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/.travis.yml +4 -0
- data/README.md +6 -2
- data/Rakefile +6 -0
- data/cinch-weatherman.gemspec +9 -4
- data/lib/cinch-weatherman.rb +0 -4
- data/lib/cinch/plugins/weatherman/version.rb +1 -1
- data/lib/cinch/plugins/weatherman/weatherman.rb +24 -19
- data/spec/cinch-weatherman_spec.rb +34 -0
- data/spec/spec_helper.rb +5 -0
- metadata +80 -9
data/.travis.yml
ADDED
data/README.md
CHANGED
@@ -1,6 +1,10 @@
|
|
1
|
-
# Cinch::Weatherman
|
1
|
+
# Cinch::Plugins::Weatherman
|
2
2
|
|
3
|
-
|
3
|
+
[](http://badge.fury.io/rb/cinch-weatherman)
|
4
|
+
[](https://gemnasium.com/canonical-hackers/cinch-weatherman)
|
5
|
+
[](https://travis-ci.org/canonical-hackers/cinch-weatherman)
|
6
|
+
[](https://coveralls.io/r/canonical-hackers/cinch-weatherman?branch=master)
|
7
|
+
[](https://codeclimate.com/github/canonical-hackers/cinch-weatherman)
|
4
8
|
|
5
9
|
## Installation
|
6
10
|
|
data/Rakefile
CHANGED
data/cinch-weatherman.gemspec
CHANGED
@@ -6,7 +6,7 @@ require 'cinch/plugins/weatherman/version'
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
7
|
gem.name = "cinch-weatherman"
|
8
8
|
gem.version = Cinch::Weatherman::VERSION
|
9
|
-
gem.authors = ["Brian Haberer"]
|
9
|
+
gem.authors = ["Brian Haberer", "Paul Visscher"]
|
10
10
|
gem.email = ["bhaberer@gmail.com"]
|
11
11
|
gem.description = %q{Cinch Plugin to get Weather data using the Weather-Underground gem}
|
12
12
|
gem.summary = %q{Cinch Plugin to get Weather data}
|
@@ -17,8 +17,13 @@ Gem::Specification.new do |gem|
|
|
17
17
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
18
|
gem.require_paths = ["lib"]
|
19
19
|
|
20
|
-
gem.
|
21
|
-
gem.
|
22
|
-
gem.
|
20
|
+
gem.add_development_dependency 'rake'
|
21
|
+
gem.add_development_dependency 'rspec'
|
22
|
+
gem.add_development_dependency 'coveralls'
|
23
|
+
gem.add_development_dependency 'cinch-test'
|
24
|
+
|
25
|
+
gem.add_dependency 'cinch', '~> 2.0.5'
|
26
|
+
gem.add_dependency 'weather-underground', '>= 1.1.1'
|
27
|
+
gem.add_dependency 'time-lord', '~> 1.0.1'
|
23
28
|
gem.add_dependency 'cinch-cooldown'
|
24
29
|
end
|
data/lib/cinch-weatherman.rb
CHANGED
@@ -1,4 +1,9 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
+
require 'cinch'
|
3
|
+
require 'cinch-cooldown'
|
4
|
+
require 'time-lord'
|
5
|
+
require 'weather-underground'
|
6
|
+
|
2
7
|
module Cinch::Plugins
|
3
8
|
class Weatherman
|
4
9
|
include Cinch::Plugin
|
@@ -7,8 +12,8 @@ module Cinch::Plugins
|
|
7
12
|
|
8
13
|
self.help = "Use .w <location> to see information on the weather. (e.g. .w 94062)"
|
9
14
|
|
10
|
-
match /weather (.*)/
|
11
15
|
match /w (.*)/
|
16
|
+
match /weather (.*)/
|
12
17
|
|
13
18
|
def execute(m, query)
|
14
19
|
m.reply get_weather(query)
|
@@ -17,24 +22,24 @@ module Cinch::Plugins
|
|
17
22
|
private
|
18
23
|
|
19
24
|
def get_weather(query)
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
25
|
+
location, temp_f, conditions, updated = get_forcast(query)
|
26
|
+
|
27
|
+
message = "In #{location} it is #{conditions} "
|
28
|
+
message << "and #{temp_f}°F "
|
29
|
+
message << "(last updated about #{updated})"
|
30
|
+
|
31
|
+
return message
|
32
|
+
rescue ArgumentError
|
33
|
+
return "Sorry, couldn't find #{query}."
|
34
|
+
end
|
35
|
+
|
36
|
+
def get_forcast(query)
|
37
|
+
data = WeatherUnderground::Base.new.CurrentObservations(query)
|
38
|
+
weather = [ data.display_location.first.full,
|
39
|
+
data.temp_f,
|
40
|
+
data.weather.downcase,
|
41
|
+
Time.parse(data.observation_time).ago.to_words ]
|
42
|
+
return weather
|
38
43
|
end
|
39
44
|
end
|
40
45
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cinch::Plugins::Weatherman do
|
4
|
+
|
5
|
+
include Cinch::Test
|
6
|
+
|
7
|
+
before(:each) do
|
8
|
+
@bot = make_bot(Cinch::Plugins::Weatherman, {})
|
9
|
+
end
|
10
|
+
|
11
|
+
it 'should allow users to ask for weather by zip' do
|
12
|
+
msg = make_message(@bot, '!weather 94062')
|
13
|
+
get_replies(msg).last.chomp.
|
14
|
+
should include('In Redwood City, CA it is')
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should allow users to ask for weather by city, state' do
|
18
|
+
msg = make_message(@bot, '!weather redwood city, ca')
|
19
|
+
get_replies(msg).last.chomp.
|
20
|
+
should include('In Redwood City, CA it is')
|
21
|
+
end
|
22
|
+
|
23
|
+
it 'should allow users to ask for weather by airport code' do
|
24
|
+
msg = make_message(@bot, '!weather SFO')
|
25
|
+
get_replies(msg).last.chomp.
|
26
|
+
should include('In San Francisco International, CA it is')
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'should return an error when location not found' do
|
30
|
+
msg = make_message(@bot, '!weather 34')
|
31
|
+
get_replies(msg).last.chomp.
|
32
|
+
should include('Sorry, couldn\'t find 34.')
|
33
|
+
end
|
34
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
CHANGED
@@ -1,32 +1,97 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cinch-weatherman
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Brian Haberer
|
9
|
+
- Paul Visscher
|
9
10
|
autorequire:
|
10
11
|
bindir: bin
|
11
12
|
cert_chain: []
|
12
|
-
date: 2013-
|
13
|
+
date: 2013-06-26 00:00:00.000000000 Z
|
13
14
|
dependencies:
|
14
15
|
- !ruby/object:Gem::Dependency
|
15
|
-
name:
|
16
|
+
name: rake
|
16
17
|
requirement: !ruby/object:Gem::Requirement
|
17
18
|
none: false
|
18
19
|
requirements:
|
19
20
|
- - ! '>='
|
20
21
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
22
|
-
type: :
|
22
|
+
version: '0'
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0'
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: rspec
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: '0'
|
39
|
+
type: :development
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '0'
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: coveralls
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
type: :development
|
23
56
|
prerelease: false
|
24
57
|
version_requirements: !ruby/object:Gem::Requirement
|
25
58
|
none: false
|
26
59
|
requirements:
|
27
60
|
- - ! '>='
|
28
61
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
62
|
+
version: '0'
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: cinch-test
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: '0'
|
71
|
+
type: :development
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
name: cinch
|
81
|
+
requirement: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ~>
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 2.0.5
|
87
|
+
type: :runtime
|
88
|
+
prerelease: false
|
89
|
+
version_requirements: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ~>
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 2.0.5
|
30
95
|
- !ruby/object:Gem::Dependency
|
31
96
|
name: weather-underground
|
32
97
|
requirement: !ruby/object:Gem::Requirement
|
@@ -48,7 +113,7 @@ dependencies:
|
|
48
113
|
requirement: !ruby/object:Gem::Requirement
|
49
114
|
none: false
|
50
115
|
requirements:
|
51
|
-
- -
|
116
|
+
- - ~>
|
52
117
|
- !ruby/object:Gem::Version
|
53
118
|
version: 1.0.1
|
54
119
|
type: :runtime
|
@@ -56,7 +121,7 @@ dependencies:
|
|
56
121
|
version_requirements: !ruby/object:Gem::Requirement
|
57
122
|
none: false
|
58
123
|
requirements:
|
59
|
-
- -
|
124
|
+
- - ~>
|
60
125
|
- !ruby/object:Gem::Version
|
61
126
|
version: 1.0.1
|
62
127
|
- !ruby/object:Gem::Dependency
|
@@ -83,6 +148,7 @@ extensions: []
|
|
83
148
|
extra_rdoc_files: []
|
84
149
|
files:
|
85
150
|
- .gitignore
|
151
|
+
- .travis.yml
|
86
152
|
- Gemfile
|
87
153
|
- LICENSE.txt
|
88
154
|
- README.md
|
@@ -91,6 +157,8 @@ files:
|
|
91
157
|
- lib/cinch-weatherman.rb
|
92
158
|
- lib/cinch/plugins/weatherman/version.rb
|
93
159
|
- lib/cinch/plugins/weatherman/weatherman.rb
|
160
|
+
- spec/cinch-weatherman_spec.rb
|
161
|
+
- spec/spec_helper.rb
|
94
162
|
homepage: https://github.com/canonical-hackers/cinch-weatherman
|
95
163
|
licenses: []
|
96
164
|
post_install_message:
|
@@ -115,4 +183,7 @@ rubygems_version: 1.8.24
|
|
115
183
|
signing_key:
|
116
184
|
specification_version: 3
|
117
185
|
summary: Cinch Plugin to get Weather data
|
118
|
-
test_files:
|
186
|
+
test_files:
|
187
|
+
- spec/cinch-weatherman_spec.rb
|
188
|
+
- spec/spec_helper.rb
|
189
|
+
has_rdoc:
|