diff --git a/.travis.yml b/.travis.yml index 46e5d98..ac0b8c9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,7 +10,6 @@ rvm: - 1.8.7 - jruby-18mode - jruby-19mode - - rbx - ruby-head - jruby-head - ree diff --git a/cinch-pax-timer.gemspec b/cinch-pax-timer.gemspec index 1948109..0506484 100644 --- a/cinch-pax-timer.gemspec +++ b/cinch-pax-timer.gemspec @@ -8,21 +8,20 @@ Gem::Specification.new do |gem| gem.version = Cinch::Plugins::PaxTimer::VERSION gem.authors = ['Brian Haberer'] gem.email = ['bhaberer@gmail.com'] - gem.description = %q{Cinch plugin that allows users to see the relative time till the various PAX events} - gem.summary = %q{Cinch Plugin that acts as a PAX countdown} + gem.description = %q(Cinch plugin that allows users to see the relative time till the various PAX events) + gem.summary = %q(Cinch Plugin that acts as a PAX countdown) gem.homepage = 'https://github.com/bhaberer/cinch-pax-timer' gem.license = 'MIT' - gem.files = `git ls-files`.split($/) - gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) } - gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) + gem.executables = gem.files.grep(/^bin\//).map { |f| File.basename(f) } + gem.test_files = gem.files.grep(/^(test|spec|features)\//) gem.require_paths = ['lib'] - gem.add_development_dependency 'rake' - gem.add_development_dependency 'rspec' - gem.add_development_dependency 'coveralls' - gem.add_development_dependency 'cinch-test' - - gem.add_dependency 'cinch-cooldown', '~> 1.1.1' - gem.add_dependency 'cinch-toolbox', '~> 1.1.0' + gem.add_development_dependency 'rake', '~> 10' + gem.add_development_dependency 'rspec', '~> 3' + gem.add_development_dependency 'coveralls', '~> 0.7' + gem.add_development_dependency 'cinch-test', '~> 0.1', '>= 0.1.0' + gem.add_dependency 'cinch', '~> 2' + gem.add_dependency 'cinch-cooldown', '~> 1.1', '>= 1.1.1' + gem.add_dependency 'cinch-toolbox', '~> 1.1' end diff --git a/lib/cinch/plugins/pax-timer.rb b/lib/cinch/plugins/pax-timer.rb index e31c44b..9f6dec5 100644 --- a/lib/cinch/plugins/pax-timer.rb +++ b/lib/cinch/plugins/pax-timer.rb @@ -4,77 +4,79 @@ require 'cinch/toolbox' require 'cinch/cooldown' -module Cinch::Plugins - # Cinch Cooldown for PAX countdowns - class PaxTimer - include Cinch::Plugin +module Cinch + module Plugins + # Cinch Cooldown for PAX countdowns + class PaxTimer + include Cinch::Plugin - enforce_cooldown + enforce_cooldown - self.help = 'Use .pax for the next pax or .east, .prime, .south or .aus ' + - 'for the time to a specific pax.' + self.help = 'Use .pax for the next pax or .east, .prime, .south or ' \ + '.aus for the time to a specific pax.' - match /pax\z/, method: :next_pax + match(/pax\z/, method: :next_pax) - def next_pax(m) - m.reply get_next_pax - end + def next_pax(m) + m.reply get_next_pax + end - PAXES = [ - { type: 'aus', - name: 'PAX Australia', - date: Time.parse('2014-10-31 08:00:00 +11:00'), - estimated: false }, - { type: 'prime', - name: 'PAX Prime', - date: Time.parse('2014-08-29 08:00:00 -08:00'), - estimated: false }, - { type: 'south', - name: 'PAX South', - date: Time.parse('2015-01-23 08:00:00 -06:00'), - estimated: false }, - { type: 'east', - name: 'PAX East', - date: Time.parse('2015-03-06 08:00:00 -05:00'), - estimated: false } - ] - - PAXES.map { |p| p[:type] }.each do |pax| - match /(#{pax}|pax#{pax})\z/, method: "next_#{pax}" - - define_method "next_#{pax}" do |m| - debug "#{pax}" - m.reply get_next_pax(pax.to_s) + PAXES = [ + { type: 'aus', + name: 'PAX Australia', + date: Time.parse('2014-10-31 08:00:00 +11:00'), + estimated: false }, + { type: 'prime', + name: 'PAX Prime', + date: Time.parse('2014-08-29 08:00:00 -08:00'), + estimated: false }, + { type: 'south', + name: 'PAX South', + date: Time.parse('2015-01-23 08:00:00 -06:00'), + estimated: false }, + { type: 'east', + name: 'PAX East', + date: Time.parse('2015-03-06 08:00:00 -05:00'), + estimated: false } + ] + + PAXES.map { |p| p[:type] }.each do |pax| + match(/(#{pax}|pax#{pax})\z/, method: "next_#{pax}") + + define_method "next_#{pax}" do |m| + debug "#{pax}" + m.reply get_next_pax(pax.to_s) + end end - end - private + private - def get_next_pax(type = nil) - @pax = get_next_pax_for(type) + def get_next_pax(type = nil) + @pax = get_next_pax_for(type) - return 'I don\'t have info for the next one of those PAXes' if @pax.nil? + return 'I don\'t have info for the next one of those PAXes' if @pax.nil? - message = ["#{@pax[:name]} is"] - message << 'approximately' if @pax[:estimated] + message = ["#{@pax[:name]} is"] + message << 'approximately' if @pax[:estimated] - # Uncomment this once we can specify granularity in Time Lord. - # message << TimeLord::Period.new(@pax[:date], Time.now).to_words - message << Cinch::Toolbox.time_format(@pax[:date] - Time.now, [:days]) - message << 'from now' + # Uncomment this once we can specify granularity in Time Lord. + # message << TimeLord::Period.new(@pax[:date], Time.now).to_words + message << Cinch::Toolbox.time_format(@pax[:date] - Time.now, [:days]) + message << 'from now' - message << ' (No official date, yet)' if @pax[:estimated] - message.join(' ') - end + message << ' (No official date, yet)' if @pax[:estimated] + message.join(' ') + end - def get_next_pax_for(type) - paxes = PAXES.dup + def get_next_pax_for(type) + paxes = PAXES.dup - paxes.delete_if { |pax| pax[:date] - Time.now < 0 } - paxes.delete_if { |pax| pax[:type] != type } unless type.nil? - paxes.sort! { |a, b| b[:date] <=> a[:date] } + paxes.delete_if { |pax| pax[:date] - Time.now < 0 } + paxes.delete_if { |pax| pax[:type] != type } unless type.nil? + paxes.sort! { |a, b| b[:date] <=> a[:date] } - paxes.last + paxes.last + end end end end diff --git a/lib/cinch/plugins/pax-timer/version.rb b/lib/cinch/plugins/pax-timer/version.rb index cec94c3..3ecc110 100644 --- a/lib/cinch/plugins/pax-timer/version.rb +++ b/lib/cinch/plugins/pax-timer/version.rb @@ -3,7 +3,7 @@ module Cinch module Plugins # Versioning info class PaxTimer - VERSION = '1.0.8' + VERSION = '1.0.9' end end end diff --git a/spec/cinch-pax-timer_spec.rb b/spec/cinch-pax-timer_spec.rb index f741057..f1caf33 100644 --- a/spec/cinch-pax-timer_spec.rb +++ b/spec/cinch-pax-timer_spec.rb @@ -15,50 +15,49 @@ describe :pax do it 'should return the next pax' do msg = make_message(@bot, '!pax') - get_replies(msg).first.text. - should match(/PAX.+is (approximatly )?\d+ days from now/) + msg = get_replies(msg).first + expect(msg.text).to match(/PAX.+is (approximatly )?\d+ days from now/) end it 'should return nothing if there are arguments' do msg = make_message(@bot, '!pax fail') - get_replies(msg).first. - should be_nil + expect(get_replies(msg).first).to be_nil end end it 'should respond to .prime correctly' do msg = make_message(@bot, '!prime') - get_replies(msg).first.text. - should match(/PAX Prime is.+days from now/) + msg = get_replies(msg).first + expect(msg.text).to match(/PAX Prime is.+days from now/) end it 'should respond to .paxprime correctly' do msg = make_message(@bot, '!paxprime') - get_replies(msg).first.text. - should match(/PAX Prime is.+days from now/) + msg = get_replies(msg).first + expect(msg.text).to match(/PAX Prime is.+days from now/) end it 'should respond to .east correctly' do msg = make_message(@bot, '!east') - get_replies(msg).first.text. - should match(/PAX East is.+days from now/) + msg = get_replies(msg).first + expect(msg.text).to match(/PAX East is.+days from now/) end it 'should respond to .paxeast correctly' do msg = make_message(@bot, '!paxeast') - get_replies(msg).first.text. - should match(/PAX East is.+days from now/) + msg = get_replies(msg).first + expect(msg.text).to match(/PAX East is.+days from now/) end it 'should respond to .aus correctly' do msg = make_message(@bot, '!aus') - get_replies(msg).first.text. - should match(/PAX Australia is.+days from now/) + msg = get_replies(msg).first + expect(msg.text).to match(/PAX Australia is.+days from now/) end it 'should respond to .paxaus correctly' do msg = make_message(@bot, '!paxaus') - get_replies(msg).first.text. - should match(/PAX Australia is.+days from now/) + msg = get_replies(msg).first + expect(msg.text).to match(/PAX Australia is.+days from now/) end end