Skip to content

Commit

Permalink
v1.0.1 - Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
bhaberer committed Feb 18, 2014
1 parent c79836d commit 0575857
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 18 deletions.
13 changes: 7 additions & 6 deletions cinch-simplecalc.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
3 changes: 2 additions & 1 deletion lib/cinch-simplecalc.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
# -*- encoding : utf-8 -*-
require 'cinch/plugins/simplecalc/version'
require 'cinch/plugins/simplecalc/simplecalc'
require 'cinch/plugins/simplecalc'
Original file line number Diff line number Diff line change
@@ -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 <problem> to do math. (i.e. .math 2 + 2)"
self.help = 'Use .math <problem> to do math. (i.e. .math 2 + 2)'

match /math (.+)/

Expand All @@ -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
4 changes: 3 additions & 1 deletion lib/cinch/plugins/simplecalc/version.rb
Original file line number Diff line number Diff line change
@@ -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
12 changes: 6 additions & 6 deletions spec/cinch-simplecalc_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 0575857

Please sign in to comment.