lita-onewheel-garfield 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -3
- data/LICENSE +19 -0
- data/README.md +6 -6
- data/lib/lita/handlers/onewheel_garfield.rb +31 -11
- data/lita-onewheel-garfield.gemspec +1 -1
- data/spec/lita/handlers/onewheel_garfield_spec.rb +17 -15
- data/spec/spec_helper.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cab694c7faf1d00df56fa248dae0f59cb29c867
|
4
|
+
data.tar.gz: cda98aeb96c5f74802338feca22c4987395a493c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55a60db7fe7905eba17570d8cb87a6bab142d72f1fbabe3c82cb0d0026d9c073098707173a270818c73dca7c33413c7ff715850ee29ba14b45bf80ab8b3b66f6
|
7
|
+
data.tar.gz: 8316f772ee6d78f7884b70b11c3d9e88c97cf7c2a5985f95bd89e5bb7f32d6a83014eb86f373957b9b969c9b7dcdd361853337debac7ba50daccffb8b4a247a0
|
data/.travis.yml
CHANGED
data/LICENSE
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2016 Andrew Kreps
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
CHANGED
@@ -1,17 +1,17 @@
|
|
1
|
-
# lita-garfield
|
1
|
+
# lita-onewheel-garfield
|
2
2
|
|
3
|
-
[![Build Status](https://travis-ci.org/onewheelskyward/lita-garfield.png?branch=master)](https://travis-ci.org/onewheelskyward/lita-garfield)
|
4
|
-
[![Coverage Status](https://coveralls.io/repos/onewheelskyward/lita-garfield/badge.png)](https://coveralls.io/r/onewheelskyward/lita-garfield)
|
5
|
-
[![Documentation Status](https://readthedocs.org/projects/lita-garfield/badge/?version=latest)](https://readthedocs.org/projects/lita-garfield/?badge=latest)
|
3
|
+
[![Build Status](https://travis-ci.org/onewheelskyward/lita-onewheel-garfield.png?branch=master)](https://travis-ci.org/onewheelskyward/lita-onewheel-garfield)
|
4
|
+
[![Coverage Status](https://coveralls.io/repos/onewheelskyward/lita-onewheel-garfield/badge.png)](https://coveralls.io/r/onewheelskyward/lita-onewheel-garfield)
|
5
|
+
[![Documentation Status](https://readthedocs.org/projects/lita-onewheel-garfield/badge/?version=latest)](https://readthedocs.org/projects/lita-onewheel-garfield/?badge=latest)
|
6
6
|
|
7
7
|
Display a Garfield™® comic in IRC. http://www.garfield.com
|
8
8
|
|
9
9
|
## Installation
|
10
10
|
|
11
|
-
Add lita-garfield to your Lita instance's Gemfile:
|
11
|
+
Add lita-onewheel-garfield to your Lita instance's Gemfile:
|
12
12
|
|
13
13
|
``` ruby
|
14
|
-
gem 'lita-garfield'
|
14
|
+
gem 'lita-onewheel-garfield'
|
15
15
|
```
|
16
16
|
|
17
17
|
## Usage, command mode (e.g. directed at bot or using config.robot.alias = '!')
|
@@ -1,25 +1,45 @@
|
|
1
1
|
module Lita
|
2
2
|
module Handlers
|
3
3
|
class OnewheelGarfield < Handler
|
4
|
-
route(/^garfield random$/i,
|
4
|
+
route(/^garfield random$/i,
|
5
|
+
:handle_random_garfield,
|
6
|
+
command: true,
|
5
7
|
help: { 'garfield random' => 'Get a random garfield comic.'})
|
6
|
-
route(/^garfield$/i,
|
8
|
+
route(/^garfield$/i,
|
9
|
+
:handle_default_garfield,
|
10
|
+
command: true,
|
7
11
|
help: { 'garfield' => 'Get today\'s garfield, or a random one if you\'ve already seen today\'s.'})
|
8
|
-
route(/^garfield (\d{1,2})-(\d{1,2})-(\d{2,4})$/i,
|
12
|
+
route(/^garfield (\d{1,2})-(\d{1,2})-(\d{2,4})$/i,
|
13
|
+
:handle_mdy_garfield,
|
14
|
+
command: true,
|
9
15
|
help: { 'garfield' => 'Get a garfield for a m/d/y date.'})
|
10
|
-
route(/^garfield (\d{2,4})-(\d{1,2})-(\d{1,2})$/i,
|
16
|
+
route(/^garfield (\d{2,4})-(\d{1,2})-(\d{1,2})$/i,
|
17
|
+
:handle_ymd_garfield,
|
18
|
+
command: true,
|
11
19
|
help: { 'garfield' => 'Get a garfield for a y-m-d date.'})
|
12
|
-
route(/^garfield (\d{1,2})\/(\d{1,2})\/(\d{2,4})$/i,
|
20
|
+
route(/^garfield (\d{1,2})\/(\d{1,2})\/(\d{2,4})$/i,
|
21
|
+
:handle_mdy_garfield,
|
22
|
+
command: true,
|
13
23
|
help: { 'garfield' => 'Get a garfield for a m-d-y date.'})
|
14
|
-
route(/^garfield first$/i,
|
24
|
+
route(/^garfield first$/i,
|
25
|
+
:handle_first_garfield,
|
26
|
+
command: true,
|
15
27
|
help: { 'garfield first' => 'Get the first garfield comic.'})
|
16
|
-
route(/^garfield last$/i,
|
28
|
+
route(/^garfield last$/i,
|
29
|
+
:handle_today_garfield,
|
30
|
+
command: true,
|
17
31
|
help: { 'garfield last' => 'Get the last garfield comic.'})
|
18
|
-
route(/^garfield today$/i,
|
32
|
+
route(/^garfield today$/i,
|
33
|
+
:handle_today_garfield,
|
34
|
+
command: true,
|
19
35
|
help: { 'garfield today' => 'Get today\'s garfield comic.'})
|
20
|
-
route(/^garfield prev$/i,
|
36
|
+
route(/^garfield prev$/i,
|
37
|
+
:handle_prev_garfield,
|
38
|
+
command: true,
|
21
39
|
help: { 'garfield prev' => 'Get the previous garfield comic.'})
|
22
|
-
route(/^garfield next$/i,
|
40
|
+
route(/^garfield next$/i,
|
41
|
+
:handle_next_garfield,
|
42
|
+
command: true,
|
23
43
|
help: { 'garfield next' => 'Get next garfield comic.'})
|
24
44
|
|
25
45
|
def get_garfield_for_today(username)
|
@@ -29,7 +49,7 @@ module Lita
|
|
29
49
|
|
30
50
|
def get_garfield_for_date(date, username)
|
31
51
|
redis.set(username, date)
|
32
|
-
"https://
|
52
|
+
"https://d1ejxu6vysztl5.cloudfront.net/comics/garfield/#{date.year}/#{date.year}-#{zero_prefix date.month}-#{zero_prefix date.day}.gif"
|
33
53
|
end
|
34
54
|
|
35
55
|
def zero_prefix(dat)
|
@@ -13,6 +13,8 @@ describe Lita::Handlers::OnewheelGarfield, lita_handler: true do
|
|
13
13
|
it { is_expected.to route_command('garfield prev') }
|
14
14
|
it { is_expected.to route_command('garfield next') }
|
15
15
|
|
16
|
+
IMAGE_BASE = 'https://d1ejxu6vysztl5.cloudfront.net/comics/garfield'
|
17
|
+
|
16
18
|
def zero_prefix(dat)
|
17
19
|
if dat.to_i < 10
|
18
20
|
"0#{dat}"
|
@@ -23,66 +25,66 @@ describe Lita::Handlers::OnewheelGarfield, lita_handler: true do
|
|
23
25
|
|
24
26
|
def get_todays_image_filename
|
25
27
|
date = Date.today
|
26
|
-
"#{date.year}-#{zero_prefix date.month}-#{zero_prefix date.day}"
|
28
|
+
"#{date.year}/#{date.year}-#{zero_prefix date.month}-#{zero_prefix date.day}"
|
27
29
|
end
|
28
30
|
|
29
31
|
it 'will return a random garfield comic' do
|
30
32
|
send_command 'garfield random'
|
31
|
-
expect(replies.last).to include(
|
33
|
+
expect(replies.last).to include(IMAGE_BASE)
|
32
34
|
end
|
33
35
|
|
34
36
|
it 'will return a today\'s then a random garfield comic' do
|
35
37
|
send_command 'garfield'
|
36
|
-
expect(replies.last).to include("
|
38
|
+
expect(replies.last).to include("#{IMAGE_BASE}/#{get_todays_image_filename}.gif")
|
37
39
|
send_command 'garfield'
|
38
|
-
expect(replies.last).to include(
|
40
|
+
expect(replies.last).to include(IMAGE_BASE)
|
39
41
|
end
|
40
42
|
|
41
43
|
it 'will return today\'s garfield comic' do
|
42
44
|
send_command 'garfield today'
|
43
|
-
expect(replies.last).to include("
|
45
|
+
expect(replies.last).to include("#{IMAGE_BASE}/#{get_todays_image_filename}.gif")
|
44
46
|
end
|
45
47
|
|
46
48
|
it 'will return today\'s garfield comic' do
|
47
49
|
send_command 'garfield last'
|
48
|
-
expect(replies.last).to include("
|
50
|
+
expect(replies.last).to include("#{IMAGE_BASE}/#{get_todays_image_filename}.gif")
|
49
51
|
end
|
50
52
|
|
51
53
|
it 'will return the first garfield comic' do
|
52
54
|
send_command 'garfield first'
|
53
|
-
expect(replies.last).to include(
|
55
|
+
expect(replies.last).to include("#{IMAGE_BASE}/1978/1978-06-19.gif")
|
54
56
|
end
|
55
57
|
|
56
58
|
it 'will return a garfield comic for a specific y-m-d date' do
|
57
59
|
send_command 'garfield 1998-5-5'
|
58
|
-
expect(replies.last).to include(
|
60
|
+
expect(replies.last).to include("#{IMAGE_BASE}/1998/1998-05-05.gif")
|
59
61
|
end
|
60
62
|
|
61
63
|
it 'will return a garfield comic for a specific m-d-y date' do
|
62
64
|
send_command 'garfield 5-5-1998'
|
63
|
-
expect(replies.last).to include(
|
65
|
+
expect(replies.last).to include("#{IMAGE_BASE}/1998/1998-05-05.gif")
|
64
66
|
end
|
65
67
|
|
66
68
|
it 'will return a garfield comic for a specific / date' do
|
67
69
|
send_command 'garfield 5/5/1998'
|
68
|
-
expect(replies.last).to include(
|
70
|
+
expect(replies.last).to include("#{IMAGE_BASE}/1998/1998-05-05.gif")
|
69
71
|
end
|
70
72
|
|
71
73
|
# Test the saved state of the last comic you requested.
|
72
74
|
it 'will return the first and then the next and then the previous garfield comic' do
|
73
75
|
send_command 'garfield first'
|
74
|
-
expect(replies.last).to include(
|
76
|
+
expect(replies.last).to include("#{IMAGE_BASE}/1978/1978-06-19.gif")
|
75
77
|
send_command 'garfield next'
|
76
|
-
expect(replies.last).to include(
|
78
|
+
expect(replies.last).to include("#{IMAGE_BASE}/1978/1978-06-20.gif")
|
77
79
|
send_command 'garfield prev'
|
78
|
-
expect(replies.last).to include(
|
80
|
+
expect(replies.last).to include("#{IMAGE_BASE}/1978/1978-06-19.gif")
|
79
81
|
end
|
80
82
|
|
81
83
|
it 'will edge case prev and next' do
|
82
84
|
today = Date.today
|
83
85
|
|
84
|
-
first =
|
85
|
-
last = "
|
86
|
+
first = "#{IMAGE_BASE}/1978/1978-06-19.gif"
|
87
|
+
last = "#{IMAGE_BASE}/#{today.year}/#{today.year}-#{zero_prefix today.month}-#{zero_prefix today.day}.gif"
|
86
88
|
|
87
89
|
send_command 'garfield first'
|
88
90
|
expect(replies.last).to include(first)
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-onewheel-garfield
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kreps
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-04-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -118,6 +118,7 @@ files:
|
|
118
118
|
- ".gitignore"
|
119
119
|
- ".travis.yml"
|
120
120
|
- Gemfile
|
121
|
+
- LICENSE
|
121
122
|
- README.md
|
122
123
|
- Rakefile
|
123
124
|
- lib/lita-onewheel-garfield.rb
|
@@ -146,7 +147,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
146
147
|
version: '0'
|
147
148
|
requirements: []
|
148
149
|
rubyforge_project:
|
149
|
-
rubygems_version: 2.
|
150
|
+
rubygems_version: 2.5.1
|
150
151
|
signing_key:
|
151
152
|
specification_version: 4
|
152
153
|
summary: An alternative way to get your comic fix.
|