Skip to content

Commit

Permalink
Removed some of the bleeding-edge features.
Browse files Browse the repository at this point in the history
  • Loading branch information
onewheelskyward committed Oct 16, 2015
1 parent 73508d6 commit 2f78af1
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 17 deletions.
21 changes: 11 additions & 10 deletions lib/lita/handlers/onewheel_karma.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
module Lita
module Handlers
class OnewheelKarma < Handler
route /([^\s]+)\s*\+\+(\s|$)/, :add_one_karma,
route /([^\s]+)\+\+(\s|$)/, :add_one_karma,
help: 'object++: Add one karma to [object].'
route /([^\s]+)\s*--(\s|$)/, :remove_one_karma,
route /([^\s]+)--(\s|$)/, :remove_one_karma,
help: 'object++: Remove one karma from [object].'
route /([^\s]+)\s*\*=\s*([-\d]+)/, :multiply_karma,
route /([^\s]+)\*=\s*([-\d]+)/, :multiply_karma,
help: 'object*=n: Multiply karma by n'
route /([^\s]+)\s*\+=\s*([-\d]+)/, :add_arbitrary_karma,
route /([^\s]+)\+=\s*([-\d]+)/, :add_arbitrary_karma,
help: 'object+=n: Add n karma to [object].'
route /([^\s]+)\s*-=\s*([-\d]+)/, :remove_arbitrary_karma,
help: 'object+=n: Remove n karma from [object].'
route /([^\s]+)-=\s*([-\d]+)/, :remove_arbitrary_karma,
help: 'object-=n: Remove n karma from [object].'

def add_one_karma(response)
karma_object = response.matches[0][0]
Expand Down Expand Up @@ -48,11 +48,12 @@ def multiply_karma(response)
end

def reply_with_karma(karma_object, karma)
if karma >= 0
# if karma >= 0
"#{karma_object} has #{karma} karma!"
else
"#{karma_object} has #{RomanNumerals.to_roman(karma * -1)}💩 karma!"
end
# else
# "#{karma_object} has #{RomanNumerals.to_roman(karma * -1)}💩 karma!"
# "#{karma_object} has #{RomanNumerals.to_roman(karma * -1)}💩 karma!"
# end
end

# Find the karma object from redis and increment appropriately.
Expand Down
2 changes: 1 addition & 1 deletion lita-onewheel-karma.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |spec|
spec.name = 'lita-onewheel-karma'
spec.version = '0.0.1'
spec.version = '1.0.0'
spec.authors = ['Andrew Kreps']
spec.email = ['andrew.kreps@gmail.com']
spec.description = 'Karma with a maths-focused twist.'
Expand Down
18 changes: 12 additions & 6 deletions spec/lita/handlers/onewheel_karma_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

describe Lita::Handlers::OnewheelKarma, lita_handler: true do
def get_negative(num)
"a has #{RomanNumerals.to_roman(num)}💩 karma!"
# "a has #{RomanNumerals.to_roman(num)}💩 karma!"
"a has -#{num} karma!"
end

def get_positive(num)
Expand Down Expand Up @@ -83,22 +84,22 @@ def get_positive(num)
end

it 'will spacing' do
send_message 'a -= -9'
send_message 'a-= -9'
expect(replies.last).to eq get_positive(9)
end

it 'will spacing 2' do
send_message 'a += -9'
send_message 'a+= -9'
expect(replies.last).to eq get_negative(9)
end

it 'will spacing 3' do
send_message 'a ++'
send_message 'a++'
expect(replies.last).to eq get_positive(1)
end

it 'will spacing 4' do
send_message 'a --'
send_message 'a--'
expect(replies.last).to eq get_negative(1)
end

Expand Down Expand Up @@ -127,6 +128,11 @@ def get_positive(num)
send_message 'a--'
send_message 'a--'
send_message 'a--'
expect(replies.last).to include 'a has IV'
expect(replies.last).to include 'a has -4'
end

it 'will not space' do
send_message 'a ++'
expect(replies.last).to eq nil
end
end

0 comments on commit 2f78af1

Please sign in to comment.