diff --git a/cinch-simplecalc.gemspec b/cinch-simplecalc.gemspec index da99f64..9ad60e6 100644 --- a/cinch-simplecalc.gemspec +++ b/cinch-simplecalc.gemspec @@ -4,18 +4,19 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) require 'cinch/plugins/simplecalc/version' Gem::Specification.new do |gem| - gem.name = "cinch-simplecalc" + gem.name = 'cinch-simplecalc' gem.version = Cinch::Plugins::Simplecalc::VERSION - gem.authors = ["Brian Haberer"] - gem.email = ["bhaberer@gmail.com"] + gem.authors = ['Brian Haberer'] + gem.email = ['bhaberer@gmail.com'] gem.description = %q{Cinch Plugin that passes simple numeric math propblems to the Calc gem} gem.summary = %q{Cinch Plugin to do simple math} - gem.homepage = "https://github.com/bhaberer/cinch-simplecalc" + gem.homepage = 'https://github.com/bhaberer/cinch-simplecalc' + 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.require_paths = ["lib"] + gem.require_paths = ['lib'] gem.add_development_dependency 'rake' gem.add_development_dependency 'rspec' @@ -24,6 +25,6 @@ Gem::Specification.new do |gem| gem.add_dependency 'cinch', '~> 2.0.5' gem.add_dependency 'cinch-test', '~> 0.0.3' gem.add_dependency 'cinch-toolbox', '~> 1.0.0' - gem.add_dependency 'cinch-cooldown', '~> 1.0.0' + gem.add_dependency 'cinch-cooldown', '~> 1.1.1' gem.add_dependency 'calc', '~> 1.0.0' end diff --git a/lib/cinch-simplecalc.rb b/lib/cinch-simplecalc.rb index 5860e5a..1d3503c 100644 --- a/lib/cinch-simplecalc.rb +++ b/lib/cinch-simplecalc.rb @@ -1,2 +1,3 @@ +# -*- encoding : utf-8 -*- require 'cinch/plugins/simplecalc/version' -require 'cinch/plugins/simplecalc/simplecalc' +require 'cinch/plugins/simplecalc' diff --git a/lib/cinch/plugins/simplecalc/simplecalc.rb b/lib/cinch/plugins/simplecalc.rb similarity index 53% rename from lib/cinch/plugins/simplecalc/simplecalc.rb rename to lib/cinch/plugins/simplecalc.rb index 121c57f..7dc58ee 100644 --- a/lib/cinch/plugins/simplecalc/simplecalc.rb +++ b/lib/cinch/plugins/simplecalc.rb @@ -1,14 +1,16 @@ +# -*- encoding : utf-8 -*- require 'calc' require 'cinch' -require 'cinch-cooldown' +require 'cinch/cooldown' module Cinch::Plugins + # Simple Plugin to do quick math class SimpleCalc include Cinch::Plugin enforce_cooldown - self.help = "Use .math to do math. (i.e. .math 2 + 2)" + self.help = 'Use .math to do math. (i.e. .math 2 + 2)' match /math (.+)/ @@ -20,9 +22,10 @@ def execute(m, problem) def calc(problem) answer = Calc.evaluate(problem) - return "#{Calc.evaluate(problem)}" unless answer == problem + answer unless answer == problem rescue ZeroDivisionError - return "Fuck you." + # Rescue against people being cute. + "I'm sorry, Dave, I'm afraid I can't do that." end end end diff --git a/lib/cinch/plugins/simplecalc/version.rb b/lib/cinch/plugins/simplecalc/version.rb index 034de62..913672a 100644 --- a/lib/cinch/plugins/simplecalc/version.rb +++ b/lib/cinch/plugins/simplecalc/version.rb @@ -1,7 +1,9 @@ +# -*- encoding : utf-8 -*- module Cinch module Plugins + # Versioning Info class Simplecalc - VERSION = "1.0.0" + VERSION = '1.0.1' end end end diff --git a/spec/cinch-simplecalc_spec.rb b/spec/cinch-simplecalc_spec.rb index ea590fc..223fd66 100644 --- a/spec/cinch-simplecalc_spec.rb +++ b/spec/cinch-simplecalc_spec.rb @@ -10,19 +10,19 @@ it 'should allow users to perform simple math' do msg = make_message(@bot, '!math 2 + 2') - get_replies(msg).last. - should == 'test: 4' + get_replies(msg).last.text + .should == 'test: 4' end it 'should strip all non numeric information from the string' do msg = make_message(@bot, '!math cos 2') - get_replies(msg).last. - should == 'test: 2' + get_replies(msg).last.text + .should == 'test: 2' end it 'should crack wise if asked to do the impossible' do msg = make_message(@bot, '!math 1 / 0') - get_replies(msg).last. - should == 'test: Fuck you.' + get_replies(msg).last.text + .should == 'test: I\'m sorry, Dave, I\'m afraid I can\'t do that.' end end