lita-onewheel-odot-tripcheck-web-hack 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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 985b7671fade98b897a592452ec5f38ff7bc0a54
|
4
|
+
data.tar.gz: 9197cd2686b802ec539fe9a885b44a9570fb7b93
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e951399d1d5fcbdb8b58a2aa6a073a4b2dc5abde53dc1fdd0fa30b0bb0083d2cc5b5db2c2bee441b317d26210a1311345d4c372db3653de7eacac9389f40e6b
|
7
|
+
data.tar.gz: c45e8bdf96eae5ebeeeeb1691fb6b0ae422ce720120776423cb636ea59aec699daa4ed4c60cc1deb90d5cfef58270b6749a598e66e82eaf5d8be883612e9948d
|
@@ -5,32 +5,43 @@ module Lita
|
|
5
5
|
route(/^tripcheck\s+(.*)/i, :handle_tripcheck, command: true,
|
6
6
|
help: { 'tripcheck 35': 'Displays an image of hwy 26 @ hwy 35'})
|
7
7
|
|
8
|
+
route(/^tripcheck$/i, :handle_tripcheck_list, command: true,
|
9
|
+
help: { 'tripcheck': 'Display a list of tripcheck cameras covered.'})
|
10
|
+
|
11
|
+
def get_cameras
|
12
|
+
{
|
13
|
+
# 'Hood River': %w(Hood%20River%20Exit%2064a_pid1863.JPG Hood%20River%20Exit%2063_pid1860.JPG),
|
14
|
+
'Hood River': 'Hood%20River%20Exit%2064a_pid1863.JPG',
|
15
|
+
'26 at 35': 'US26%20at%20Hwy35_pid1881.JPG',
|
16
|
+
'26 at Snow Bunny': 'US26%20at%20Snow%20Bunny_pid1887.JPG',
|
17
|
+
# '26 at Govy': %w(GovernmentCamp_pid624.jpg US26%20at%20Govn%20Camp%20Maint_pid1899.JPG),
|
18
|
+
'26 at Govy': 'US26%20at%20Govn%20Camp%20Maint_pid1899.JPG',
|
19
|
+
'26 at Govy Loop Rd': 'US26%20at%20Govt%20Camp%20Lp%20Rd_pid1776.JPG',
|
20
|
+
'26 at Frog Lake': 'US26%20at%20Frog%20Lake%20VMS_pid1773.JPG',
|
21
|
+
'26 at Blue Box Pass': 'Blue%20Box%20Pass_pid1919.JPG'
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
8
25
|
def handle_tripcheck(response)
|
9
26
|
input = response.matches[0][0]
|
10
27
|
Lita.logger.debug "Looking for '#{input}'"
|
11
28
|
|
12
29
|
uri_base = 'https://tripcheck.com/RoadCams/cams/'
|
13
|
-
cameras = {
|
14
|
-
# 'Hood River': %w(Hood%20River%20Exit%2064a_pid1863.JPG Hood%20River%20Exit%2063_pid1860.JPG),
|
15
|
-
'Hood River': 'Hood%20River%20Exit%2064a_pid1863.JPG',
|
16
|
-
'26 at 35': 'US26%20at%20Hwy35_pid1881.JPG',
|
17
|
-
'26 at Snow Bunny': 'US26%20at%20Snow%20Bunny_pid1887.JPG',
|
18
|
-
# '26 at Govy': %w(GovernmentCamp_pid624.jpg US26%20at%20Govn%20Camp%20Maint_pid1899.JPG),
|
19
|
-
'26 at Govy': 'US26%20at%20Govn%20Camp%20Maint_pid1899.JPG',
|
20
|
-
'26 at Govy Loop Rd': 'US26%20at%20Govt%20Camp%20Lp%20Rd_pid1776.JPG',
|
21
|
-
'26 at Frog Lake': 'US26%20at%20Frog%20Lake%20VMS_pid1773.JPG',
|
22
|
-
'26 at Blue Box Pass': 'Blue%20Box%20Pass_pid1919.JPG'
|
23
|
-
}
|
24
30
|
|
25
|
-
|
31
|
+
get_cameras.keys.each do |camera_key|
|
26
32
|
Lita.logger.debug "Trying to match '#{input.downcase}' to '#{camera_key.downcase}'"
|
27
33
|
if camera_key.to_s.downcase.include? input.downcase
|
28
|
-
response.reply "#{uri_base}#{
|
34
|
+
response.reply "#{uri_base}#{get_cameras[camera_key]}?rand=#{Time.now.to_i}123"
|
29
35
|
return # Quick exit.
|
30
36
|
end
|
31
37
|
end
|
32
38
|
end
|
33
39
|
|
40
|
+
def handle_tripcheck_list(response)
|
41
|
+
Lita.logger.debug "Replying with: Cameras available include: #{get_cameras.keys.join ', '}"
|
42
|
+
response.reply "Cameras available include: #{get_cameras.keys.join ', '}"
|
43
|
+
end
|
44
|
+
|
34
45
|
end
|
35
46
|
Lita.register_handler(OnewheelOdotTripcheckWebHack)
|
36
47
|
end
|
@@ -5,9 +5,15 @@ describe Lita::Handlers::OnewheelOdotTripcheckWebHack, lita_handler: true do
|
|
5
5
|
end
|
6
6
|
|
7
7
|
it { is_expected.to route_command('tripcheck blue') }
|
8
|
+
it { is_expected.to route_command('tripcheck') }
|
8
9
|
|
9
10
|
it 'will respond to tripcheck' do
|
10
11
|
send_command 'tripcheck govy'
|
11
12
|
expect(replies.last).to include('https://tripcheck.com/RoadCams/cams/US26%20at%20Govn%20Camp%20Maint_pid1899.JPG')
|
12
13
|
end
|
14
|
+
|
15
|
+
it 'will list tripchecks' do
|
16
|
+
send_command 'tripcheck'
|
17
|
+
expect(replies.last).to eq('Cameras available include: Hood River, 26 at 35, 26 at Snow Bunny, 26 at Govy, 26 at Govy Loop Rd, 26 at Frog Lake, 26 at Blue Box Pass')
|
18
|
+
end
|
13
19
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-onewheel-odot-tripcheck-web-hack
|
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
|
- Andrew Kreps
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-12-
|
11
|
+
date: 2016-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|