cinch-pax-timer 1.0.2 → 1.0.3
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.
data/cinch-pax-timer.gemspec
CHANGED
@@ -4,24 +4,25 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'cinch/plugins/pax-timer/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |gem|
|
7
|
-
gem.name =
|
7
|
+
gem.name = 'cinch-pax-timer'
|
8
8
|
gem.version = Cinch::Plugins::PaxTimer::VERSION
|
9
|
-
gem.authors = [
|
10
|
-
gem.email = [
|
9
|
+
gem.authors = ['Brian Haberer']
|
10
|
+
gem.email = ['bhaberer@gmail.com']
|
11
11
|
gem.description = %q{Cinch plugin that allows users to see the relative time till the various PAX events}
|
12
12
|
gem.summary = %q{Cinch Plugin that acts as a PAX countdown}
|
13
|
-
gem.homepage =
|
13
|
+
gem.homepage = 'https://github.com/bhaberer/cinch-pax-timer'
|
14
|
+
gem.license = 'MIT'
|
14
15
|
|
15
16
|
gem.files = `git ls-files`.split($/)
|
16
17
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
18
|
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
-
gem.require_paths = [
|
19
|
+
gem.require_paths = ['lib']
|
19
20
|
|
20
21
|
gem.add_development_dependency 'rake'
|
21
22
|
gem.add_development_dependency 'rspec'
|
22
23
|
gem.add_development_dependency 'coveralls'
|
23
24
|
gem.add_development_dependency 'cinch-test'
|
24
25
|
|
25
|
-
gem.add_dependency 'cinch-cooldown', '~> 1.
|
26
|
+
gem.add_dependency 'cinch-cooldown', '~> 1.1.1'
|
26
27
|
gem.add_dependency 'cinch-toolbox', '~> 1.0.3'
|
27
28
|
end
|
data/lib/cinch-pax-timer.rb
CHANGED
@@ -0,0 +1,76 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require 'cinch'
|
3
|
+
require 'time-lord'
|
4
|
+
require 'cinch/toolbox'
|
5
|
+
require 'cinch/cooldown'
|
6
|
+
|
7
|
+
module Cinch::Plugins
|
8
|
+
# Cinch Cooldown for PAX countdowns
|
9
|
+
class PaxTimer
|
10
|
+
include Cinch::Plugin
|
11
|
+
|
12
|
+
enforce_cooldown
|
13
|
+
|
14
|
+
self.help = 'Use .pax for the next pax or .east, .prime, or .aus for ' +
|
15
|
+
'the time to a specific pax.'
|
16
|
+
|
17
|
+
match /pax\z/, method: :next_pax
|
18
|
+
|
19
|
+
def next_pax(m)
|
20
|
+
m.reply get_next_pax
|
21
|
+
end
|
22
|
+
|
23
|
+
PAXES = [
|
24
|
+
{ type: 'prime',
|
25
|
+
name: 'PAX Prime',
|
26
|
+
date: Time.parse('2014-08-30 08:00:00 -08:00'),
|
27
|
+
estimated: true },
|
28
|
+
{ type: 'aus',
|
29
|
+
name: 'PAX Australia',
|
30
|
+
date: Time.parse('2014-10-31 08:00:00 +11:00'),
|
31
|
+
estimated: false },
|
32
|
+
{ type: 'east',
|
33
|
+
name: 'PAX East',
|
34
|
+
date: Time.parse('2014-04-11 08:00:00 -05:00'),
|
35
|
+
estimated: false }
|
36
|
+
]
|
37
|
+
|
38
|
+
PAXES.map { |p| p[:type] }.each do |pax|
|
39
|
+
match /#{pax}|pax#{pax}/, method: "next_#{pax}"
|
40
|
+
|
41
|
+
define_method "next_#{pax}" do |m|
|
42
|
+
debug "#{pax}"
|
43
|
+
m.reply get_next_pax(pax.to_s)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def get_next_pax(type = nil)
|
50
|
+
@pax = get_next_pax_for(type)
|
51
|
+
|
52
|
+
return 'I don\'t have info for the next one of those PAXes' if @pax.nil?
|
53
|
+
|
54
|
+
message = ["#{@pax[:name]} is"]
|
55
|
+
message << 'approximately' if @pax[:estimated]
|
56
|
+
|
57
|
+
# Uncomment this once we can specify granularity in Time Lord.
|
58
|
+
# message << TimeLord::Period.new(@pax[:date], Time.now).to_words
|
59
|
+
message << Cinch::Toolbox.time_format(@pax[:date] - Time.now, [:days])
|
60
|
+
message << 'from now'
|
61
|
+
|
62
|
+
message << ' (No official date, yet)' if @pax[:estimated]
|
63
|
+
message.join(' ')
|
64
|
+
end
|
65
|
+
|
66
|
+
def get_next_pax_for(type)
|
67
|
+
paxes = PAXES.dup
|
68
|
+
|
69
|
+
paxes.delete_if { |pax| pax[:date] - Time.now < 0 }
|
70
|
+
paxes.delete_if { |pax| pax[:type] != type } unless type.nil?
|
71
|
+
paxes.sort! { |a, b| b[:date] <=> a[:date] }
|
72
|
+
|
73
|
+
paxes.last
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
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.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2014-02-18 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|
@@ -82,7 +82,7 @@ dependencies:
|
|
82
82
|
requirements:
|
83
83
|
- - ~>
|
84
84
|
- !ruby/object:Gem::Version
|
85
|
-
version: 1.
|
85
|
+
version: 1.1.1
|
86
86
|
type: :runtime
|
87
87
|
prerelease: false
|
88
88
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -90,7 +90,7 @@ dependencies:
|
|
90
90
|
requirements:
|
91
91
|
- - ~>
|
92
92
|
- !ruby/object:Gem::Version
|
93
|
-
version: 1.
|
93
|
+
version: 1.1.1
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
95
|
name: cinch-toolbox
|
96
96
|
requirement: !ruby/object:Gem::Requirement
|
@@ -123,12 +123,13 @@ files:
|
|
123
123
|
- Rakefile
|
124
124
|
- cinch-pax-timer.gemspec
|
125
125
|
- lib/cinch-pax-timer.rb
|
126
|
-
- lib/cinch/plugins/pax-timer
|
126
|
+
- lib/cinch/plugins/pax-timer.rb
|
127
127
|
- lib/cinch/plugins/pax-timer/version.rb
|
128
128
|
- spec/cinch-pax-timer_spec.rb
|
129
129
|
- spec/spec_helper.rb
|
130
130
|
homepage: https://github.com/bhaberer/cinch-pax-timer
|
131
|
-
licenses:
|
131
|
+
licenses:
|
132
|
+
- MIT
|
132
133
|
post_install_message:
|
133
134
|
rdoc_options: []
|
134
135
|
require_paths:
|
@@ -1,74 +0,0 @@
|
|
1
|
-
require 'cinch'
|
2
|
-
require 'time-lord'
|
3
|
-
require 'cinch/toolbox'
|
4
|
-
require 'cinch/cooldown'
|
5
|
-
|
6
|
-
module Cinch::Plugins
|
7
|
-
class PaxTimer
|
8
|
-
include Cinch::Plugin
|
9
|
-
|
10
|
-
enforce_cooldown
|
11
|
-
|
12
|
-
self.help = "Use .pax for the next pax or .east, .prime, or .aus for the time to a specific pax."
|
13
|
-
|
14
|
-
match /pax\z/, method: :next_pax
|
15
|
-
|
16
|
-
def next_pax(m)
|
17
|
-
m.reply get_next_pax
|
18
|
-
end
|
19
|
-
|
20
|
-
PAXES = [
|
21
|
-
{ :type => 'prime',
|
22
|
-
:name => 'PAX Prime',
|
23
|
-
:date => Time.parse('2014-08-30 08:00:00 -08:00'),
|
24
|
-
:estimated => true },
|
25
|
-
{ :type => 'aus',
|
26
|
-
:name => 'PAX Australia',
|
27
|
-
:date => Time.parse('2014-10-31 08:00:00 +11:00'),
|
28
|
-
:estimated => false },
|
29
|
-
{ :type => 'east',
|
30
|
-
:name => 'PAX East',
|
31
|
-
:date => Time.parse('2014-04-11 08:00:00 -05:00'),
|
32
|
-
:estimated => false }
|
33
|
-
]
|
34
|
-
|
35
|
-
PAXES.map{ |p| p[:type] }.each do |pax|
|
36
|
-
match /#{pax}|pax#{pax}/, :method => "next_#{pax}"
|
37
|
-
|
38
|
-
define_method "next_#{pax}" do |m|
|
39
|
-
debug "#{pax}"
|
40
|
-
m.reply get_next_pax(pax.to_s)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
private
|
45
|
-
|
46
|
-
def get_next_pax(type = nil)
|
47
|
-
@pax = get_next_pax_for(type)
|
48
|
-
|
49
|
-
if @pax.nil?
|
50
|
-
return 'I don\'t have info for the next one of those PAXes'
|
51
|
-
else
|
52
|
-
message = "#{@pax[:name]} is "
|
53
|
-
message << 'approximately ' if @pax[:estimated]
|
54
|
-
|
55
|
-
# Uncomment this once we can specify granularity in Time Lord.
|
56
|
-
# message << TimeLord::Period.new(@pax[:date], Time.now).to_words
|
57
|
-
message << "#{Cinch::Toolbox.time_format(@pax[:date] - Time.now, [:days])} from now"
|
58
|
-
|
59
|
-
message << " (No official date, yet)" if @pax[:estimated]
|
60
|
-
return message
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def get_next_pax_for(type)
|
65
|
-
paxes = PAXES.dup
|
66
|
-
|
67
|
-
paxes.delete_if { |pax| pax[:date] - Time.now < 0 }
|
68
|
-
paxes.delete_if { |pax| pax[:type] != type } unless type.nil?
|
69
|
-
paxes.sort! { |a,b| b[:date] <=> a[:date] }
|
70
|
-
|
71
|
-
return paxes.last
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|