lita-your-weather 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.ruby-version +1 -0
- data/.travis.yml +5 -0
- data/CHANGELOG.md +28 -0
- data/README.md +17 -10
- data/Rakefile +4 -2
- data/lib/lita-your-weather.rb +7 -5
- data/lib/lita/handlers/your_weather.rb +29 -27
- data/lita-your-weather.gemspec +19 -17
- data/spec/lita/handlers/your_weather_spec.rb +18 -13
- data/spec/spec_helper.rb +4 -2
- metadata +10 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4e57dcc3d134994c806990317845e133b496ebeb489e55a17f2bae5e409612da
|
4
|
+
data.tar.gz: e64c837d034d8b965f3b871aad4cfdd44d45b54f9d9f9de6084cb9030fa205aa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7fc95e02bbe0a390563043aaac24e0d29f3d65054a71770f4b8f1ff1f8a71245a3cbd1eaa44b583464f61698f9c813af1191ab7d05b4151ade2bdbb82f177fa7
|
7
|
+
data.tar.gz: 5bbfa9bb99dff03bf3b1ce1e364f44f79bd2fb980a3ff988195b7f858fedb7be1f29b79ff16749644176951cf6ff8ffa9089876dbc145d703fbbf30666eb6b54
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
2.5.5
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
## [0.0.5] - Unreleased
|
2
|
+
### Added
|
3
|
+
- Added weather icon for current weather
|
4
|
+
|
5
|
+
### Changed
|
6
|
+
- Separated images to new command `lita weather i <location>`
|
7
|
+
|
8
|
+
### Fixed
|
9
|
+
- Bug forecast broken in non default locations. Thx @ben-tinc
|
10
|
+
|
11
|
+
## [0.0.4] - 2017-01-13
|
12
|
+
### Fixed
|
13
|
+
- Bug calling multiple weather methods
|
14
|
+
|
15
|
+
## [0.0.3] - 2017-01-13
|
16
|
+
### Added
|
17
|
+
- `lita` command required
|
18
|
+
|
19
|
+
## [0.0.2] - 2017-01-12
|
20
|
+
### Added
|
21
|
+
- Images added of Edmonton, AB, Canada
|
22
|
+
- Added `weather <location>` command
|
23
|
+
|
24
|
+
## 0.0.1 - 2016-11-21
|
25
|
+
### Added
|
26
|
+
- Initial release
|
27
|
+
- Added `weather c <location> and weather f <location>` for current weather and 7-day forecast
|
28
|
+
- `lita` command not required
|
data/README.md
CHANGED
@@ -7,9 +7,9 @@ lita-your-weather provides the ability to ask for the current weather conditions
|
|
7
7
|
Add lita-your-weather to your Lita instance's Gemfile:
|
8
8
|
|
9
9
|
``` ruby
|
10
|
-
gem
|
10
|
+
gem 'lita-your-weather'
|
11
11
|
```
|
12
|
-
|
12
|
+
`$ bundle install`
|
13
13
|
|
14
14
|
## Configuration
|
15
15
|
|
@@ -25,12 +25,19 @@ config.handlers.your_weather.api_key = 'www.apixu.com Api Key'
|
|
25
25
|
|
26
26
|
Commands include:
|
27
27
|
|
28
|
-
<!--
|
29
|
-
|
30
|
-
<!-- For current weather of specified location-->
|
31
|
-
$ lita weather c Your_Location,Your_State,Your_Country
|
28
|
+
<!-- Current weather of default location -->
|
29
|
+
`$ lita weather`
|
32
30
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
31
|
+
`$ lita weather c`
|
32
|
+
<!-- Current weather of specified location-->
|
33
|
+
`$ lita weather c <location>`
|
34
|
+
|
35
|
+
<!-- Weather forecast of default location-->
|
36
|
+
`$ lita weather f`
|
37
|
+
<!-- Weather forecast of specified location-->
|
38
|
+
`$ lita weather f <location>`
|
39
|
+
|
40
|
+
<!-- Weather images from default location-->
|
41
|
+
`$ lita weather i <location>`
|
42
|
+
<!-- Weather images-->
|
43
|
+
`$ lita weather i <location>`
|
data/Rakefile
CHANGED
data/lib/lita-your-weather.rb
CHANGED
@@ -1,12 +1,14 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'lita'
|
2
4
|
|
3
5
|
Lita.load_locales Dir[File.expand_path(
|
4
|
-
File.join(
|
6
|
+
File.join('..', '..', 'locales', '*.yml'), __FILE__
|
5
7
|
)]
|
6
8
|
|
7
|
-
require
|
9
|
+
require 'lita/handlers/your_weather'
|
8
10
|
|
9
11
|
Lita::Handlers::YourWeather.template_root File.expand_path(
|
10
|
-
File.join(
|
11
|
-
|
12
|
+
File.join('..', '..', 'templates'),
|
13
|
+
__FILE__
|
12
14
|
)
|
@@ -1,3 +1,5 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'json'
|
2
4
|
|
3
5
|
module Lita
|
@@ -11,49 +13,49 @@ module Lita
|
|
11
13
|
config :api_key, type: String, required: true
|
12
14
|
|
13
15
|
# Routes
|
14
|
-
route(/^weather\s?[c?|f?]?\s?(.*)/, :weather, command: true, help: {
|
16
|
+
route(/^weather\s?[c?|f?|i?]?\s?(.*)/, :weather, command: true, help: { 'lita weather CITY,STATE,COUNTRY or lita weather c CITY,STATE,COUNTRY or lita weather f CITY,STATE,COUNTRY' => "Responds with the specified city's current weather or 7-day forecast." })
|
15
17
|
|
16
18
|
# Current Weather
|
17
19
|
def weather(response)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
location = get_location(response.matches[0][0])
|
21
|
+
|
22
|
+
if response.message.body.include? 'weather f'
|
23
|
+
data = request('/forecast.json?key=' + config.api_key + '&days=7', location)
|
24
|
+
elsif response.message.body.include? 'weather i'
|
25
|
+
if location.downcase.include? 'edmonton,alberta'
|
26
|
+
response.reply('https://ssl.eas.ualberta.ca/sitecore/camera/live/camera-ne.jpg')
|
27
|
+
response.reply('https://ssl.eas.ualberta.ca/sitecore/camera/live/camera-nw.jpg')
|
28
|
+
response.reply('https://ssl.eas.ualberta.ca/sitecore/camera/live/camera-w.jpg')
|
24
29
|
end
|
30
|
+
else
|
31
|
+
data = request('/current.json?key=' + config.api_key, location)
|
32
|
+
end
|
25
33
|
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
end
|
34
|
-
else
|
35
|
-
response.reply( data['location']['name'] + ', ' + data['location']['region'] + ', ' + data['location']['country'] + ' currently is ' + data['current']['condition']['text'] + ' and ' + data['current']['temp_c'].to_s + "\xC2\xB0" + 'C. It feels like ' + data['current']['feelslike_c'].to_s + "\xC2\xB0" + 'C' )
|
36
|
-
if location.downcase.include? "edmonton"
|
37
|
-
response.reply('https://ssl.eas.ualberta.ca/sitecore/camera/live/camera-ne.jpg')
|
38
|
-
response.reply('https://ssl.eas.ualberta.ca/sitecore/camera/live/camera-nw.jpg')
|
39
|
-
response.reply('https://ssl.eas.ualberta.ca/sitecore/camera/live/camera-w.jpg')
|
40
|
-
end
|
34
|
+
unless data.nil?
|
35
|
+
return response.reply('Error: ' + data['error']['message']) if data['error']
|
36
|
+
|
37
|
+
if response.message.body.include? 'weather f'
|
38
|
+
response.reply('The forecast for ' + data['location']['name'] + ', ' + data['location']['region'] + ', ' + data['location']['country'] + ':')
|
39
|
+
data['forecast']['forecastday'].each do |object|
|
40
|
+
response.reply('On ' + object['date'] + ' forecasted is a high of ' + object['day']['maxtemp_c'].to_s + "\xC2\xB0" + 'C' + ' and a low of ' + object['day']['mintemp_c'].to_s + "\xC2\xB0" + 'C It is expected to be ' + object['day']['condition']['text'])
|
41
41
|
end
|
42
|
+
else
|
43
|
+
response.reply('http:' + data['current']['condition']['icon'])
|
44
|
+
response.reply(data['location']['name'] + ', ' + data['location']['region'] + ', ' + data['location']['country'] + ' currently is ' + data['current']['condition']['text'] + ' and ' + data['current']['temp_c'].to_s + "\xC2\xB0" + 'C. It feels like ' + data['current']['feelslike_c'].to_s + "\xC2\xB0" + 'C')
|
42
45
|
end
|
46
|
+
end
|
43
47
|
end
|
44
48
|
|
45
49
|
# Get location
|
46
50
|
def get_location(location)
|
47
|
-
if location.eql? ''
|
48
|
-
location = config.default_location
|
49
|
-
end
|
51
|
+
location = config.default_location if location.eql? ''
|
50
52
|
location
|
51
53
|
end
|
52
54
|
|
53
55
|
# Request method
|
54
56
|
def request(url, location)
|
55
|
-
http_response = http.get(
|
56
|
-
|
57
|
+
http_response = http.get(URL + url, q: location)
|
58
|
+
JSON.parse(http_response.body)
|
57
59
|
end
|
58
60
|
end
|
59
61
|
end
|
data/lita-your-weather.gemspec
CHANGED
@@ -1,24 +1,26 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
Gem::Specification.new do |spec|
|
2
|
-
spec.name =
|
3
|
-
spec.version =
|
4
|
-
spec.authors = [
|
5
|
-
spec.email = [
|
6
|
-
spec.description =
|
7
|
-
spec.summary =
|
8
|
-
spec.homepage =
|
9
|
-
spec.license =
|
10
|
-
spec.metadata = {
|
4
|
+
spec.name = 'lita-your-weather'
|
5
|
+
spec.version = '0.0.5'
|
6
|
+
spec.authors = ['Zoie Carnegie']
|
7
|
+
spec.email = ['zoie.carnegie@gmail.com']
|
8
|
+
spec.description = 'lita-your-weather provides the ability to ask for the current weather conditions or for a 7 day forecast.'
|
9
|
+
spec.summary = 'lita-your-weather provides the ability to ask for the current weather conditions or for a 7 day forecast.'
|
10
|
+
spec.homepage = 'http://zoiecarnegie.com'
|
11
|
+
spec.license = 'MIT'
|
12
|
+
spec.metadata = { 'lita_plugin_type' => 'handler' }
|
11
13
|
|
12
|
-
spec.files = `git ls-files`.split(
|
14
|
+
spec.files = `git ls-files`.split($INPUT_RECORD_SEPARATOR)
|
13
15
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
14
16
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
15
|
-
spec.require_paths = [
|
17
|
+
spec.require_paths = ['lib']
|
16
18
|
|
17
|
-
spec.add_runtime_dependency
|
19
|
+
spec.add_runtime_dependency 'lita', '>= 4.7'
|
18
20
|
|
19
|
-
spec.add_development_dependency
|
20
|
-
spec.add_development_dependency
|
21
|
-
spec.add_development_dependency
|
22
|
-
spec.add_development_dependency
|
23
|
-
spec.add_development_dependency
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1'
|
22
|
+
spec.add_development_dependency 'pry-byebug'
|
23
|
+
spec.add_development_dependency 'rack-test'
|
24
|
+
spec.add_development_dependency 'rake'
|
25
|
+
spec.add_development_dependency 'rspec', '>= 3.0.0'
|
24
26
|
end
|
@@ -1,28 +1,33 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
2
4
|
|
3
5
|
describe Lita::Handlers::YourWeather, lita_handler: true do
|
6
|
+
it 'will route lita weather to the weather method' do
|
7
|
+
is_expected.to route('lita weather').to(:weather)
|
8
|
+
end
|
4
9
|
|
5
|
-
it
|
6
|
-
is_expected.
|
10
|
+
it 'will route lita weather c to the weather method' do
|
11
|
+
is_expected.to route('lita weather c').to(:weather)
|
7
12
|
end
|
8
13
|
|
9
|
-
it
|
10
|
-
is_expected.
|
14
|
+
it 'will route lita weather f to the weather method' do
|
15
|
+
is_expected.to route('lita weather f').to(:weather)
|
11
16
|
end
|
12
17
|
|
13
|
-
it
|
14
|
-
is_expected.
|
18
|
+
it 'will route lita weather i to the weather method' do
|
19
|
+
is_expected.to route('lita weather i').to(:weather)
|
15
20
|
end
|
16
21
|
|
17
|
-
it
|
18
|
-
is_expected.to_not route(
|
22
|
+
it 'will not route weather' do
|
23
|
+
is_expected.to_not route('weather')
|
19
24
|
end
|
20
25
|
|
21
|
-
it
|
22
|
-
is_expected.to_not route(
|
26
|
+
it 'will not route weather c' do
|
27
|
+
is_expected.to_not route('weather c')
|
23
28
|
end
|
24
29
|
|
25
|
-
it
|
26
|
-
is_expected.to_not route(
|
30
|
+
it 'will not route weather f' do
|
31
|
+
is_expected.to_not route('weather f')
|
27
32
|
end
|
28
33
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'lita-your-weather'
|
4
|
+
require 'lita/rspec'
|
3
5
|
|
4
6
|
# A compatibility mode is provided for older plugins upgrading from Lita 3. Since this plugin
|
5
7
|
# was generated with Lita 4, the compatibility mode should be left disabled.
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-your-weather
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Zoie Carnegie
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-10-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '1
|
33
|
+
version: '1'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '1
|
40
|
+
version: '1'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: pry-byebug
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,7 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: rack-test
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
@@ -67,7 +67,7 @@ dependencies:
|
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
70
|
+
name: rake
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
@@ -103,6 +103,9 @@ extensions: []
|
|
103
103
|
extra_rdoc_files: []
|
104
104
|
files:
|
105
105
|
- ".gitignore"
|
106
|
+
- ".ruby-version"
|
107
|
+
- ".travis.yml"
|
108
|
+
- CHANGELOG.md
|
106
109
|
- Gemfile
|
107
110
|
- README.md
|
108
111
|
- Rakefile
|
@@ -134,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
134
137
|
version: '0'
|
135
138
|
requirements: []
|
136
139
|
rubyforge_project:
|
137
|
-
rubygems_version: 2.6.
|
140
|
+
rubygems_version: 2.7.6.2
|
138
141
|
signing_key:
|
139
142
|
specification_version: 4
|
140
143
|
summary: lita-your-weather provides the ability to ask for the current weather conditions
|