lita-onewheel-karma 1.0.1 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 42ae1410e0bdde8cc5111a8c7ac1a0b03b1dc817
4
- data.tar.gz: 6c3234a8e4c1235703a52945a872a3a6a59c4ab3
3
+ metadata.gz: ec98c100fa2a65e5b145f46a23c5fad1423f1706
4
+ data.tar.gz: 60767f33f515f36418d497da4d3931a1537dfcac
5
5
  SHA512:
6
- metadata.gz: daf1c3d4891a26c701a2d2ecb398486c0d34c83467d7837fb9729063f1b53e2b1b3815dea169f11b62ad1810271c9d1e6ab23abc041bb982da3bb5c2fdbed7b5
7
- data.tar.gz: 5a15861f83f57f8ac9e0c95a755df442853cca4ddf99cff5c8f7eea525733ac6624a964d76c651ba3543d65066b7e4d323a1d8b436d125c2bf8468e035235b2f
6
+ metadata.gz: f8fe93a052bfc0cb8c106956e93485890178da3b6d6b49fe8de8753475451abaa3b971ddd254b0b6e34e87d7317e3dd4491871748955f63915ca0e42ff5cc286
7
+ data.tar.gz: 5e66253d6142e5914a3fe52b185e563765a892474f8e0578e50db1199dbd3715f102d3af0a061005c76fad469bd3d707772af5721ee49a16a4d0a121dbc3a72f
@@ -11,6 +11,8 @@ module Lita
11
11
  help: {'object+=n:' => 'Add n karma to [object].'}
12
12
  route /([^\s]+)-=\s*([-\d]+)/, :remove_arbitrary_karma,
13
13
  help: {'object-=n:' => 'Remove n karma from [object].'}
14
+ route /karma\s+(.*)$/, :display_karma, command: true,
15
+ help: {'karma what' => 'Display karma for what.'}
14
16
 
15
17
  def add_one_karma(response)
16
18
  karma_object = response.matches[0][0]
@@ -45,18 +47,21 @@ module Lita
45
47
  response.reply reply_with_karma(karma_object, karma)
46
48
  end
47
49
 
50
+ def display_karma(response)
51
+ karma_object = response.matches[0][0]
52
+ karma = find_karma karma_object
53
+ response.reply reply_with_karma(karma_object, karma)
54
+ end
55
+
56
+ # Helpers
57
+
48
58
  def reply_with_karma(karma_object, karma)
49
- # if karma >= 0
50
59
  "#{karma_object} has #{karma} karma!"
51
- # else
52
- # "#{karma_object} has #{RomanNumerals.to_roman(karma * -1)}💩 karma!"
53
- # "#{karma_object} has #{RomanNumerals.to_roman(karma * -1)}💩 karma!"
54
- # end
55
60
  end
56
61
 
57
62
  # Find the karma object from redis and increment appropriately.
58
63
  def find_and_set_karma(karma_object, increment_value = 1, multiply = false)
59
- karma = redis.get(karma_object).to_i
64
+ karma = find_karma(karma_object)
60
65
 
61
66
  if multiply
62
67
  karma *= increment_value.to_i
@@ -68,6 +73,10 @@ module Lita
68
73
  karma
69
74
  end
70
75
 
76
+ def find_karma(karma_object)
77
+ redis.get(karma_object).to_i
78
+ end
79
+
71
80
  end
72
81
 
73
82
  Lita.register_handler(OnewheelKarma)
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = 'lita-onewheel-karma'
3
- spec.version = '1.0.1'
3
+ spec.version = '1.1.1'
4
4
  spec.authors = ['Andrew Kreps']
5
5
  spec.email = ['andrew.kreps@gmail.com']
6
6
  spec.description = 'Karma with a maths-focused twist.'
@@ -134,4 +134,17 @@ describe Lita::Handlers::OnewheelKarma, lita_handler: true do
134
134
  send_message 'a ++'
135
135
  expect(replies.last).to eq nil
136
136
  end
137
+
138
+ it 'will list for an item' do
139
+ send_message 'dooby++'
140
+ send_message 'dooby++'
141
+ send_command 'karma dooby'
142
+ expect(replies.count).to eq(3)
143
+ expect(replies.last).to eq('dooby has 2 karma!')
144
+ end
145
+
146
+ it 'will not just karma' do
147
+ send_command 'karma'
148
+ expect(replies.last).to eq nil
149
+ end
137
150
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lita-onewheel-karma
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kreps