isis-plugin-weather 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.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/.travis.yml +3 -0
- data/Gemfile +4 -0
- data/README.md +27 -0
- data/Rakefile +1 -0
- data/bin/console +14 -0
- data/bin/setup +7 -0
- data/config/weather.csv.example +1 -0
- data/isis-plugin-weather.gemspec +25 -0
- data/lib/isis/plugin/weather.rb +91 -0
- metadata +97 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7e4d293b91fcf13453ddd4b9644a56d6ef8ae24f
|
4
|
+
data.tar.gz: e93a3bf06b541540bba5f61c7225b1340a617de5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3c952cbe372430ee63a82370e6681b9ec733a8e5ea05e9552af12d1ffe55909860eba562fb1f1853c77856137e15a39bd153f09c1b43e599a5d429d2f62f808c
|
7
|
+
data.tar.gz: 15035b90d6eb72252ff28096b5faa2a7ae687497bfcd81b24fde7647add21dff07bb6e63f24bee8b91d8916411b531e835741b560477a3f7c78c37430921b2db
|
data/.gitignore
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/README.md
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# Isis plugin: Weather Report
|
2
|
+
|
3
|
+
This plugin adds a weather command to the [Isis chatbot](https://github.com/silentgrowl/isis)
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Copy config/weather.csv.example from the gem repo and save as ```config/weather.csv``` in your Isis installation.
|
8
|
+
|
9
|
+
Edit the config/weather.csv file to be a comma-separated list of ZIP codes to include in the weather report.
|
10
|
+
|
11
|
+
Add this line to your Isis installation's Gemfile:
|
12
|
+
|
13
|
+
``ruby
|
14
|
+
gem 'isis-plugin-weather'
|
15
|
+
``
|
16
|
+
|
17
|
+
And then execute:
|
18
|
+
|
19
|
+
$ bundle
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
Post the latest weather forecast into a room by typing ```!weather``` in chat.
|
24
|
+
|
25
|
+
## Links
|
26
|
+
|
27
|
+
* [isis-plugin-weather on RubyGems](https://rubygems.org/gems/isis-plugin-weather)
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "isis/plugin/weather"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
91409,93448,10124
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "isis-plugin-weather"
|
7
|
+
spec.version = "1.0.0"
|
8
|
+
spec.authors = ["Brendon Rapp"]
|
9
|
+
spec.email = ["brendon@silentgrowl.com"]
|
10
|
+
spec.license = 'MIT'
|
11
|
+
|
12
|
+
spec.summary = %q{Isis plugin: Weather}
|
13
|
+
spec.description = %q{Isis plugin: Weather}
|
14
|
+
spec.homepage = "https://github.com/silentgrowl/isis-plugin-weather"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_runtime_dependency "barometer", '0.7.3'
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.9"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
end
|
@@ -0,0 +1,91 @@
|
|
1
|
+
require "barometer"
|
2
|
+
require "csv"
|
3
|
+
|
4
|
+
module Isis
|
5
|
+
module Plugin
|
6
|
+
class Weather < Isis::Plugin::Base
|
7
|
+
TRIGGERS = %w(!weather)
|
8
|
+
|
9
|
+
def respond_to_msg?(msg, speaker)
|
10
|
+
TRIGGERS.include? msg.downcase
|
11
|
+
end
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def setup
|
16
|
+
Barometer.config = { 1 => :wunderground }
|
17
|
+
@zip_codes = CSV.read(File.expand_path(File.join('config', 'weather.csv'))).flatten
|
18
|
+
end
|
19
|
+
|
20
|
+
def response_html
|
21
|
+
output = %Q[<img src="http://i.imgur.com/wJwbW5q.png"> ISIS Weather Report - #{timestamp} #{zone}] +
|
22
|
+
%Q[ (powered by Weather Underground)<br>]
|
23
|
+
@zip_codes.reduce(output) do |a, e|
|
24
|
+
loc = Barometer.new(e).measure
|
25
|
+
a += "#{forecast_html(loc)}<br>"
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def response_md
|
30
|
+
output = %Q[ISIS Weather Report - #{timestamp} #{zone} (powered by Weather Underground)\n]
|
31
|
+
@zip_codes.reduce(output) do |a, e|
|
32
|
+
loc = Barometer.new(e).measure
|
33
|
+
a += "#{forecast_md(loc)}\n"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def response_text
|
38
|
+
output = ["ISIS Weather Report - #{timestamp} #{zone} (powered by Weather Underground"]
|
39
|
+
@zip_codes.reduce(output) do |a, e|
|
40
|
+
loc = Barometer.new(e).measure
|
41
|
+
a.push forecast_text(loc)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
# Parse wunderground's icon codes into a text weather condition
|
46
|
+
def parse_icon_codes(code)
|
47
|
+
case code
|
48
|
+
when 'flurries', 'rain', 'sleet', 'snow', 'clear', 'sunny', 'cloudy', 'fog', 'hazy'
|
49
|
+
code.capitalize
|
50
|
+
when 'chancerain', 'chanceflurries', 'chancesleet', 'chancesnow'
|
51
|
+
"Chance of #{code.split('chance')[1].capitalize}"
|
52
|
+
when 'nt_flurries', 'nt_rain', 'nt_sleet', 'nt_snow'
|
53
|
+
"#{code.split('_')[1].capitalize}"
|
54
|
+
when 'mostlysunny', 'mostlycloudy'
|
55
|
+
"Mostly #{code.split('mostly')[1].capitalize}"
|
56
|
+
when 'partlysunny', 'partlycloudy'
|
57
|
+
"Partly #{code.split('partly')[1].capitalize}"
|
58
|
+
when 'chancetstorms'
|
59
|
+
'Chance of Thunderstorms'
|
60
|
+
when 'tstorms'
|
61
|
+
'Thunderstorms'
|
62
|
+
when 'nt_tstorms'
|
63
|
+
'Thunderstorms at Night'
|
64
|
+
else
|
65
|
+
'(no condition info)'
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def forecast_html(w)
|
70
|
+
city = w.measurements.last.location.to_s.split(',')[0..1].join(',')
|
71
|
+
%Q[#{city} - <b>Forecast:</b> #{parse_icon_codes(w.today.icon)}, High #{w.today.high}, Low #{w.today.low}.] +
|
72
|
+
%Q[ <b>Current Conditions:</b> #{parse_icon_codes(w.now.icon)}, #{w.now.temperature}, wind #{w.now.wind}] +
|
73
|
+
%Q[ #{w.now.wind.direction}]
|
74
|
+
end
|
75
|
+
|
76
|
+
def forecast_md(w)
|
77
|
+
city = w.measurements.last.location.to_s.split(',')[0..1].join(',')
|
78
|
+
%Q[#{city} - *Forecast:* #{parse_icon_codes(w.today.icon)}, High #{w.today.high}, Low #{w.today.low}.] +
|
79
|
+
%Q[ *Current Conditions:* #{parse_icon_codes(w.now.icon)}, #{w.now.temperature}, wind #{w.now.wind}] +
|
80
|
+
%Q[ #{w.now.wind.direction}]
|
81
|
+
end
|
82
|
+
|
83
|
+
def forecast_text(w)
|
84
|
+
city = w.measurements.last.location.to_s.split(',')[0..1].join(',')
|
85
|
+
%Q[#{city} - Forecast: #{parse_icon_codes(w.today.icon)}, High #{w.today.high}, Low #{w.today.low}.] +
|
86
|
+
%Q[ Current Conditions: #{parse_icon_codes(w.now.icon)}, #{w.now.temperature}, wind #{w.now.wind}] +
|
87
|
+
%Q[ #{w.now.wind.direction}]
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: isis-plugin-weather
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Brendon Rapp
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-05-15 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: barometer
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 0.7.3
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 0.7.3
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.9'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.9'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: 'Isis plugin: Weather'
|
56
|
+
email:
|
57
|
+
- brendon@silentgrowl.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- ".travis.yml"
|
64
|
+
- Gemfile
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- bin/console
|
68
|
+
- bin/setup
|
69
|
+
- config/weather.csv.example
|
70
|
+
- isis-plugin-weather.gemspec
|
71
|
+
- lib/isis/plugin/weather.rb
|
72
|
+
homepage: https://github.com/silentgrowl/isis-plugin-weather
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.2.2
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: 'Isis plugin: Weather'
|
96
|
+
test_files: []
|
97
|
+
has_rdoc:
|