cinch-pax-timer 1.0.8 → 1.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -1
- data/cinch-pax-timer.gemspec +11 -12
- data/lib/cinch/plugins/pax-timer.rb +58 -56
- data/lib/cinch/plugins/pax-timer/version.rb +1 -1
- data/spec/cinch-pax-timer_spec.rb +15 -16
- metadata +44 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f1c898bd1fa9cd896337dd1ca310ce4ce59e015
|
4
|
+
data.tar.gz: 4b0f01fb4682f35579180021a165c1dcf8660959
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53cd0490621d4603869ec1948b908648d925fde67e451b2219309e2ea438e6591482343b4d1d3dcdc5b0470bf313d5357e4acb0810d5e34c55ddf18ec9eadff9
|
7
|
+
data.tar.gz: a6fb22aea22530de1c2f623c205c482b0fc1b379abb022a094a6f76fe19c2a483566c2e5b2e6aff138cbb0b28c25bb4b526ca710dfbe04f73db4ff68defa4ef3
|
data/.travis.yml
CHANGED
data/cinch-pax-timer.gemspec
CHANGED
@@ -8,21 +8,20 @@ Gem::Specification.new do |gem|
|
|
8
8
|
gem.version = Cinch::Plugins::PaxTimer::VERSION
|
9
9
|
gem.authors = ['Brian Haberer']
|
10
10
|
gem.email = ['bhaberer@gmail.com']
|
11
|
-
gem.description = %q
|
12
|
-
gem.summary = %q
|
11
|
+
gem.description = %q(Cinch plugin that allows users to see the relative time till the various PAX events)
|
12
|
+
gem.summary = %q(Cinch Plugin that acts as a PAX countdown)
|
13
13
|
gem.homepage = 'https://github.com/bhaberer/cinch-pax-timer'
|
14
14
|
gem.license = 'MIT'
|
15
|
-
|
16
15
|
gem.files = `git ls-files`.split($/)
|
17
|
-
gem.executables = gem.files.grep(
|
18
|
-
gem.test_files = gem.files.grep(
|
16
|
+
gem.executables = gem.files.grep(/^bin\//).map { |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(/^(test|spec|features)\//)
|
19
18
|
gem.require_paths = ['lib']
|
20
19
|
|
21
|
-
gem.add_development_dependency
|
22
|
-
gem.add_development_dependency
|
23
|
-
gem.add_development_dependency
|
24
|
-
gem.add_development_dependency
|
25
|
-
|
26
|
-
gem.add_dependency
|
27
|
-
gem.add_dependency
|
20
|
+
gem.add_development_dependency 'rake', '~> 10'
|
21
|
+
gem.add_development_dependency 'rspec', '~> 3'
|
22
|
+
gem.add_development_dependency 'coveralls', '~> 0.7'
|
23
|
+
gem.add_development_dependency 'cinch-test', '~> 0.1', '>= 0.1.0'
|
24
|
+
gem.add_dependency 'cinch', '~> 2'
|
25
|
+
gem.add_dependency 'cinch-cooldown', '~> 1.1', '>= 1.1.1'
|
26
|
+
gem.add_dependency 'cinch-toolbox', '~> 1.1'
|
28
27
|
end
|
@@ -4,77 +4,79 @@ require 'time-lord'
|
|
4
4
|
require 'cinch/toolbox'
|
5
5
|
require 'cinch/cooldown'
|
6
6
|
|
7
|
-
module Cinch
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
module Cinch
|
8
|
+
module Plugins
|
9
|
+
# Cinch Cooldown for PAX countdowns
|
10
|
+
class PaxTimer
|
11
|
+
include Cinch::Plugin
|
11
12
|
|
12
|
-
|
13
|
+
enforce_cooldown
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
self.help = 'Use .pax for the next pax or .east, .prime, .south or ' \
|
16
|
+
'.aus for the time to a specific pax.'
|
16
17
|
|
17
|
-
|
18
|
+
match(/pax\z/, method: :next_pax)
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
20
|
+
def next_pax(m)
|
21
|
+
m.reply get_next_pax
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
24
|
+
PAXES = [
|
25
|
+
{ type: 'aus',
|
26
|
+
name: 'PAX Australia',
|
27
|
+
date: Time.parse('2014-10-31 08:00:00 +11:00'),
|
28
|
+
estimated: false },
|
29
|
+
{ type: 'prime',
|
30
|
+
name: 'PAX Prime',
|
31
|
+
date: Time.parse('2014-08-29 08:00:00 -08:00'),
|
32
|
+
estimated: false },
|
33
|
+
{ type: 'south',
|
34
|
+
name: 'PAX South',
|
35
|
+
date: Time.parse('2015-01-23 08:00:00 -06:00'),
|
36
|
+
estimated: false },
|
37
|
+
{ type: 'east',
|
38
|
+
name: 'PAX East',
|
39
|
+
date: Time.parse('2015-03-06 08:00:00 -05:00'),
|
40
|
+
estimated: false }
|
41
|
+
]
|
42
|
+
|
43
|
+
PAXES.map { |p| p[:type] }.each do |pax|
|
44
|
+
match(/(#{pax}|pax#{pax})\z/, method: "next_#{pax}")
|
45
|
+
|
46
|
+
define_method "next_#{pax}" do |m|
|
47
|
+
debug "#{pax}"
|
48
|
+
m.reply get_next_pax(pax.to_s)
|
49
|
+
end
|
48
50
|
end
|
49
|
-
end
|
50
51
|
|
51
|
-
|
52
|
+
private
|
52
53
|
|
53
|
-
|
54
|
-
|
54
|
+
def get_next_pax(type = nil)
|
55
|
+
@pax = get_next_pax_for(type)
|
55
56
|
|
56
|
-
|
57
|
+
return 'I don\'t have info for the next one of those PAXes' if @pax.nil?
|
57
58
|
|
58
|
-
|
59
|
-
|
59
|
+
message = ["#{@pax[:name]} is"]
|
60
|
+
message << 'approximately' if @pax[:estimated]
|
60
61
|
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
62
|
+
# Uncomment this once we can specify granularity in Time Lord.
|
63
|
+
# message << TimeLord::Period.new(@pax[:date], Time.now).to_words
|
64
|
+
message << Cinch::Toolbox.time_format(@pax[:date] - Time.now, [:days])
|
65
|
+
message << 'from now'
|
65
66
|
|
66
|
-
|
67
|
-
|
68
|
-
|
67
|
+
message << ' (No official date, yet)' if @pax[:estimated]
|
68
|
+
message.join(' ')
|
69
|
+
end
|
69
70
|
|
70
|
-
|
71
|
-
|
71
|
+
def get_next_pax_for(type)
|
72
|
+
paxes = PAXES.dup
|
72
73
|
|
73
|
-
|
74
|
-
|
75
|
-
|
74
|
+
paxes.delete_if { |pax| pax[:date] - Time.now < 0 }
|
75
|
+
paxes.delete_if { |pax| pax[:type] != type } unless type.nil?
|
76
|
+
paxes.sort! { |a, b| b[:date] <=> a[:date] }
|
76
77
|
|
77
|
-
|
78
|
+
paxes.last
|
79
|
+
end
|
78
80
|
end
|
79
81
|
end
|
80
82
|
end
|
@@ -15,50 +15,49 @@ describe Cinch::Plugins::PaxTimer do
|
|
15
15
|
describe :pax do
|
16
16
|
it 'should return the next pax' do
|
17
17
|
msg = make_message(@bot, '!pax')
|
18
|
-
get_replies(msg).first
|
19
|
-
|
18
|
+
msg = get_replies(msg).first
|
19
|
+
expect(msg.text).to match(/PAX.+is (approximatly )?\d+ days from now/)
|
20
20
|
end
|
21
21
|
|
22
22
|
it 'should return nothing if there are arguments' do
|
23
23
|
msg = make_message(@bot, '!pax fail')
|
24
|
-
get_replies(msg).first.
|
25
|
-
should be_nil
|
24
|
+
expect(get_replies(msg).first).to be_nil
|
26
25
|
end
|
27
26
|
end
|
28
27
|
|
29
28
|
it 'should respond to .prime correctly' do
|
30
29
|
msg = make_message(@bot, '!prime')
|
31
|
-
get_replies(msg).first
|
32
|
-
|
30
|
+
msg = get_replies(msg).first
|
31
|
+
expect(msg.text).to match(/PAX Prime is.+days from now/)
|
33
32
|
end
|
34
33
|
|
35
34
|
it 'should respond to .paxprime correctly' do
|
36
35
|
msg = make_message(@bot, '!paxprime')
|
37
|
-
get_replies(msg).first
|
38
|
-
|
36
|
+
msg = get_replies(msg).first
|
37
|
+
expect(msg.text).to match(/PAX Prime is.+days from now/)
|
39
38
|
end
|
40
39
|
|
41
40
|
it 'should respond to .east correctly' do
|
42
41
|
msg = make_message(@bot, '!east')
|
43
|
-
get_replies(msg).first
|
44
|
-
|
42
|
+
msg = get_replies(msg).first
|
43
|
+
expect(msg.text).to match(/PAX East is.+days from now/)
|
45
44
|
end
|
46
45
|
|
47
46
|
it 'should respond to .paxeast correctly' do
|
48
47
|
msg = make_message(@bot, '!paxeast')
|
49
|
-
get_replies(msg).first
|
50
|
-
|
48
|
+
msg = get_replies(msg).first
|
49
|
+
expect(msg.text).to match(/PAX East is.+days from now/)
|
51
50
|
end
|
52
51
|
|
53
52
|
it 'should respond to .aus correctly' do
|
54
53
|
msg = make_message(@bot, '!aus')
|
55
|
-
get_replies(msg).first
|
56
|
-
|
54
|
+
msg = get_replies(msg).first
|
55
|
+
expect(msg.text).to match(/PAX Australia is.+days from now/)
|
57
56
|
end
|
58
57
|
|
59
58
|
it 'should respond to .paxaus correctly' do
|
60
59
|
msg = make_message(@bot, '!paxaus')
|
61
|
-
get_replies(msg).first
|
62
|
-
|
60
|
+
msg = get_replies(msg).first
|
61
|
+
expect(msg.text).to match(/PAX Australia is.+days from now/)
|
63
62
|
end
|
64
63
|
end
|
metadata
CHANGED
@@ -1,76 +1,99 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cinch-pax-timer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Haberer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-08-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ~>
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '10'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ~>
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '10'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- -
|
31
|
+
- - ~>
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '3'
|
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: '
|
40
|
+
version: '3'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: coveralls
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ~>
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '0'
|
47
|
+
version: '0.7'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- -
|
52
|
+
- - ~>
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
54
|
+
version: '0.7'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: cinch-test
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.1'
|
59
62
|
- - ! '>='
|
60
63
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
64
|
+
version: 0.1.0
|
62
65
|
type: :development
|
63
66
|
prerelease: false
|
64
67
|
version_requirements: !ruby/object:Gem::Requirement
|
65
68
|
requirements:
|
69
|
+
- - ~>
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
version: '0.1'
|
66
72
|
- - ! '>='
|
67
73
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
74
|
+
version: 0.1.0
|
75
|
+
- !ruby/object:Gem::Dependency
|
76
|
+
name: cinch
|
77
|
+
requirement: !ruby/object:Gem::Requirement
|
78
|
+
requirements:
|
79
|
+
- - ~>
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '2'
|
82
|
+
type: :runtime
|
83
|
+
prerelease: false
|
84
|
+
version_requirements: !ruby/object:Gem::Requirement
|
85
|
+
requirements:
|
86
|
+
- - ~>
|
87
|
+
- !ruby/object:Gem::Version
|
88
|
+
version: '2'
|
69
89
|
- !ruby/object:Gem::Dependency
|
70
90
|
name: cinch-cooldown
|
71
91
|
requirement: !ruby/object:Gem::Requirement
|
72
92
|
requirements:
|
73
93
|
- - ~>
|
94
|
+
- !ruby/object:Gem::Version
|
95
|
+
version: '1.1'
|
96
|
+
- - ! '>='
|
74
97
|
- !ruby/object:Gem::Version
|
75
98
|
version: 1.1.1
|
76
99
|
type: :runtime
|
@@ -78,6 +101,9 @@ dependencies:
|
|
78
101
|
version_requirements: !ruby/object:Gem::Requirement
|
79
102
|
requirements:
|
80
103
|
- - ~>
|
104
|
+
- !ruby/object:Gem::Version
|
105
|
+
version: '1.1'
|
106
|
+
- - ! '>='
|
81
107
|
- !ruby/object:Gem::Version
|
82
108
|
version: 1.1.1
|
83
109
|
- !ruby/object:Gem::Dependency
|
@@ -86,14 +112,14 @@ dependencies:
|
|
86
112
|
requirements:
|
87
113
|
- - ~>
|
88
114
|
- !ruby/object:Gem::Version
|
89
|
-
version: 1.1
|
115
|
+
version: '1.1'
|
90
116
|
type: :runtime
|
91
117
|
prerelease: false
|
92
118
|
version_requirements: !ruby/object:Gem::Requirement
|
93
119
|
requirements:
|
94
120
|
- - ~>
|
95
121
|
- !ruby/object:Gem::Version
|
96
|
-
version: 1.1
|
122
|
+
version: '1.1'
|
97
123
|
description: Cinch plugin that allows users to see the relative time till the various
|
98
124
|
PAX events
|
99
125
|
email:
|