cinch-pax-timer 0.0.2 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/.travis.yml ADDED
@@ -0,0 +1,4 @@
1
+ nguage: ruby
2
+ rvm:
3
+ - 1.9.2
4
+ - 1.9.3
data/README.md CHANGED
@@ -1,6 +1,16 @@
1
- # Cinch::Pax::Timer
1
+ # Cinch::Plugins::PaxTimer
2
2
 
3
- Cinch Plugin to track th time till PAX.
3
+ [![Gem Version](https://badge.fury.io/rb/cinch-pax-timer.png)](http://badge.fury.io/rb/cinch-pax-timer)
4
+ [![Dependency Status](https://gemnasium.com/bhaberer/cinch-pax-timer.png)](https://gemnasium.com/bhaberer/cinch-pax-timer)
5
+ [![Build Status](https://travis-ci.org/bhaberer/cinch-pax-timer.png?branch=master)](https://travis-ci.org/bhaberer/cinch-pax-timer)
6
+ [![Coverage Status](https://coveralls.io/repos/bhaberer/cinch-pax-timer/badge.png?branch=master)](https://coveralls.io/r/bhaberer/cinch-pax-timer?branch=master)
7
+ [![Code Climate](https://codeclimate.com/github/bhaberer/cinch-pax-timer.png)](https://codeclimate.com/github/bhaberer/cinch-pax-timer)
8
+
9
+ Cinch Plugin to track the time till PAX.
10
+
11
+ I will eventually try to expand this into an event agnostic EventTimer
12
+ plugin, but issues with how cince scopes config values with plugins are
13
+ slowing down that effort.
4
14
 
5
15
  ## Installation
6
16
 
data/Rakefile CHANGED
@@ -1 +1,7 @@
1
1
  require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new
5
+
6
+ task :default => :spec
7
+ task :test => :spec
@@ -17,7 +17,11 @@ Gem::Specification.new do |gem|
17
17
  gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
18
  gem.require_paths = ["lib"]
19
19
 
20
+ gem.add_development_dependency 'rake'
21
+ gem.add_development_dependency 'rspec'
22
+ gem.add_development_dependency 'coveralls'
23
+ gem.add_development_dependency 'cinch-test'
24
+
20
25
  gem.add_dependency 'cinch-cooldown', '>= 1.0.0'
21
26
  gem.add_dependency 'cinch-toolbox', '~> 1.0.1'
22
-
23
27
  end
@@ -1,6 +1,7 @@
1
+ require 'cinch'
1
2
  require 'time-lord'
2
- require 'cinch-cooldown'
3
3
  require 'cinch-toolbox'
4
+ require 'cinch-cooldown'
4
5
 
5
6
  module Cinch::Plugins
6
7
  class PaxTimer
@@ -10,31 +11,44 @@ module Cinch::Plugins
10
11
 
11
12
  self.help = "Use .pax for the next pax or .east, .prime, or .aus for the time to a specific pax."
12
13
 
13
- match /(time|pax|timetillpax)\z/, method: :next_pax
14
- match /east|paxeast/, method: :next_east
15
- match /prime|paxprime/, method: :next_prime
16
- match /aus|paxaus/, method: :next_aus
14
+ match /pax\z/, method: :next_pax
17
15
 
18
16
  def next_pax(m)
19
17
  m.reply get_next_pax
20
18
  end
21
19
 
22
- ['east', 'aus', 'prime'].each do |pax_type|
23
- define_method "next_#{pax_type}" do |m|
24
- m.reply get_next_pax(pax_type)
20
+ PAXES = [
21
+ { :type => 'prime',
22
+ :name => 'PAX Prime',
23
+ :date => Time.parse('2013-08-30 08:00:00 -08:00'),
24
+ :estimated => false },
25
+ { :type => 'aus',
26
+ :name => 'PAX Australia',
27
+ :date => Time.parse('2013-07-19 08:00:00 -08:00'),
28
+ :estimated => false },
29
+ { :type => 'east',
30
+ :name => 'PAX East',
31
+ :date => Time.parse('2014-04-11 08:00:00 -08: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)
25
41
  end
26
42
  end
27
43
 
28
- def get_next_pax(type = nil)
29
- @filename = File.join(File.dirname(__FILE__), "../../../../config/pax.yml")
30
- if File::exist?(@filename)
31
- @paxes = YAML::load(File.open(@filename))
44
+ private
32
45
 
33
- @paxes.delete_if { |pax| pax[:date] - Time.now < 0 }
34
- @paxes.delete_if { |pax| pax[:type] != type } unless type.nil?
35
- @paxes.sort! { |a,b| b[:date] <=> a[:date] }
46
+ def get_next_pax(type = nil)
47
+ @pax = get_next_pax_for(type)
36
48
 
37
- @pax = @paxes.pop
49
+ if @pax.nil?
50
+ return 'I don\'t have info for the next one of those PAXes'
51
+ else
38
52
  message = "#{@pax[:name]} is "
39
53
  message << 'approximately ' if @pax[:estimated]
40
54
 
@@ -46,5 +60,15 @@ module Cinch::Plugins
46
60
  return message
47
61
  end
48
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
49
73
  end
50
74
  end
@@ -1,7 +1,7 @@
1
1
  module Cinch
2
2
  module Plugins
3
3
  class PaxTimer
4
- VERSION = "0.0.2"
4
+ VERSION = "1.0.0"
5
5
  end
6
6
  end
7
7
  end
@@ -0,0 +1,64 @@
1
+ require 'spec_helper'
2
+
3
+ describe Cinch::Plugins::PaxTimer do
4
+
5
+ include Cinch::Test
6
+
7
+ before(:each) do
8
+ @bot = make_bot(Cinch::Plugins::PaxTimer, {})
9
+ end
10
+
11
+ before(:all) do
12
+ # @plugin = Cinch::Plugins::PaxTimer.new
13
+ end
14
+
15
+ describe :pax do
16
+ it 'should return the next pax' do
17
+ msg = make_message(@bot, '!pax')
18
+ get_replies(msg).first.
19
+ should match(/PAX.+is \d+ days from now/)
20
+ end
21
+
22
+ it 'should return nothing if there are arguments' do
23
+ msg = make_message(@bot, '!pax fail')
24
+ get_replies(msg).first.
25
+ should be_nil
26
+ end
27
+ end
28
+
29
+ it 'should respond to .prime correctly' do
30
+ msg = make_message(@bot, '!prime')
31
+ get_replies(msg).first.
32
+ should match(/PAX Prime is \d+ days from now/)
33
+ end
34
+
35
+ it 'should respond to .paxprime correctly' do
36
+ msg = make_message(@bot, '!paxprime')
37
+ get_replies(msg).first.
38
+ should match(/PAX Prime is \d+ days from now/)
39
+ end
40
+
41
+ it 'should respond to .east correctly' do
42
+ msg = make_message(@bot, '!east')
43
+ get_replies(msg).first.
44
+ should match(/PAX East is \d+ days from now/)
45
+ end
46
+
47
+ it 'should respond to .paxeast correctly' do
48
+ msg = make_message(@bot, '!paxeast')
49
+ get_replies(msg).first.
50
+ should match(/PAX East is \d+ days from now/)
51
+ end
52
+
53
+ it 'should respond to .aus correctly' do
54
+ msg = make_message(@bot, '!aus')
55
+ get_replies(msg).first.
56
+ should match(/PAX Australia is \d+ days from now/)
57
+ end
58
+
59
+ it 'should respond to .paxaus correctly' do
60
+ msg = make_message(@bot, '!paxaus')
61
+ get_replies(msg).first.
62
+ should match(/PAX Australia is \d+ days from now/)
63
+ end
64
+ end
@@ -0,0 +1,25 @@
1
+ require 'coveralls'
2
+ Coveralls.wear!
3
+ require 'cinch-pax-timer'
4
+
5
+ require 'cinch/test'
6
+ =begin
7
+ def fake_bot
8
+ bot = Cinch::Bot.new
9
+ bot.loggers.level = :fatal
10
+ bot
11
+ return bot
12
+ end
13
+
14
+ module Cinch
15
+ module Plugin
16
+ def initialize(opts = {})
17
+ @bot = fake_bot
18
+ @handlers = []
19
+ @timers = []
20
+ # Don't init the bot
21
+ # __register
22
+ end
23
+ end
24
+ end
25
+ =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: 0.0.2
4
+ version: 1.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,8 +9,72 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-06-24 00:00:00.000000000 Z
12
+ date: 2013-06-25 00:00:00.000000000 Z
13
13
  dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rake
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rspec
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: coveralls
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: cinch-test
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
14
78
  - !ruby/object:Gem::Dependency
15
79
  name: cinch-cooldown
16
80
  requirement: !ruby/object:Gem::Requirement
@@ -52,15 +116,17 @@ extensions: []
52
116
  extra_rdoc_files: []
53
117
  files:
54
118
  - .gitignore
119
+ - .travis.yml
55
120
  - Gemfile
56
121
  - LICENSE.txt
57
122
  - README.md
58
123
  - Rakefile
59
124
  - cinch-pax-timer.gemspec
60
- - config/pax.yml
61
125
  - lib/cinch-pax-timer.rb
62
126
  - lib/cinch/plugins/pax-timer/pax-timer.rb
63
127
  - lib/cinch/plugins/pax-timer/version.rb
128
+ - spec/cinch-pax-timer_spec.rb
129
+ - spec/spec_helper.rb
64
130
  homepage: https://github.com/bhaberer/cinch-pax-timer
65
131
  licenses: []
66
132
  post_install_message:
@@ -85,5 +151,7 @@ rubygems_version: 1.8.24
85
151
  signing_key:
86
152
  specification_version: 3
87
153
  summary: Cinch Plugin that acts as a PAX countdown
88
- test_files: []
154
+ test_files:
155
+ - spec/cinch-pax-timer_spec.rb
156
+ - spec/spec_helper.rb
89
157
  has_rdoc:
data/config/pax.yml DELETED
@@ -1,17 +0,0 @@
1
- ---
2
- - :type: east
3
- :name: PAX East
4
- :date: 2013-03-21 08:00:00 -08:00
5
- :estimated: false
6
- - :type: prime
7
- :name: PAX Prime
8
- :date: 2013-08-30 08:00:00 -08:00
9
- :estimated: false
10
- - :type: aus
11
- :name: PAX Australia
12
- :date: 2013-07-19 08:00:00 -08:00
13
- :estimated: false
14
- - :type: east
15
- :name: PAX East
16
- :date: 2014-04-11 08:00:00 -08:00
17
- :estimated: false