lita-onewheel-karma 1.1.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lita/handlers/onewheel_karma.rb +13 -9
- data/lita-onewheel-karma.gemspec +1 -1
- data/spec/lita/handlers/onewheel_karma_spec.rb +22 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 230911b7d2cac8f91c7e24e9e7909f062b44934c
|
4
|
+
data.tar.gz: 07501a884dda9a3d7a64e68b07e840e471dd102e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 177163ef26c90ee1bd11f5bf2454947091689348ed6e5fe7219ed6a94972fe007381c2a0865d751d84ef4dc7778160c5e5a5e59563d1b8795714c9def5bb2f74
|
7
|
+
data.tar.gz: 0498073764f1ff415e2e0b585ae8f161a64352801209bb47716ee976c37041c65a5670cbd4ce8d2d0387bbb00858d3d6887a5d6e3ac33568836e8043b1ca30df
|
@@ -5,50 +5,54 @@ module Lita
|
|
5
5
|
help: {'object++:' => 'Add one karma to [object].'}
|
6
6
|
route /([^\s]+)--(\s|$)/, :remove_one_karma,
|
7
7
|
help: {'object++:' => 'Remove one karma from [object].'}
|
8
|
-
route /([^\s]+)
|
8
|
+
route /([^\s]+)\s*\*=\s*([-\d]+)/, :multiply_karma,
|
9
9
|
help: {'object*=n:' => 'Multiply karma by n'}
|
10
|
-
route /([^\s]+)
|
10
|
+
route /([^\s]+)\s*\+=\s*([-\d]+)/, :add_arbitrary_karma,
|
11
11
|
help: {'object+=n:' => 'Add n karma to [object].'}
|
12
|
-
route /([^\s]+)
|
12
|
+
route /([^\s]+)\s*-=\s*([-\d]+)/, :remove_arbitrary_karma,
|
13
13
|
help: {'object-=n:' => 'Remove n karma from [object].'}
|
14
14
|
route /karma\s+(.*)$/, :display_karma, command: true,
|
15
15
|
help: {'karma what' => 'Display karma for what.'}
|
16
16
|
|
17
17
|
def add_one_karma(response)
|
18
|
-
karma_object = response
|
18
|
+
karma_object = get_karma_object(response)
|
19
19
|
karma = find_and_set_karma(karma_object)
|
20
20
|
response.reply reply_with_karma(karma_object, karma)
|
21
21
|
end
|
22
22
|
|
23
|
+
def get_karma_object(response)
|
24
|
+
response.matches[0][0].sub /^@/, ''
|
25
|
+
end
|
26
|
+
|
23
27
|
def remove_one_karma(response)
|
24
|
-
karma_object = response
|
28
|
+
karma_object = get_karma_object(response)
|
25
29
|
karma = find_and_set_karma(karma_object, -1)
|
26
30
|
response.reply reply_with_karma(karma_object, karma)
|
27
31
|
end
|
28
32
|
|
29
33
|
def add_arbitrary_karma(response)
|
30
|
-
karma_object = response
|
34
|
+
karma_object = get_karma_object(response)
|
31
35
|
increment_value = response.matches[0][1].to_i
|
32
36
|
karma = find_and_set_karma(karma_object, increment_value)
|
33
37
|
response.reply reply_with_karma(karma_object, karma)
|
34
38
|
end
|
35
39
|
|
36
40
|
def remove_arbitrary_karma(response)
|
37
|
-
karma_object = response
|
41
|
+
karma_object = get_karma_object(response)
|
38
42
|
increment_value = response.matches[0][1].to_i * -1 # -= means we negate the increment_value. - -9 = + 9
|
39
43
|
karma = find_and_set_karma(karma_object, increment_value)
|
40
44
|
response.reply reply_with_karma(karma_object, karma)
|
41
45
|
end
|
42
46
|
|
43
47
|
def multiply_karma(response)
|
44
|
-
karma_object = response
|
48
|
+
karma_object = get_karma_object(response)
|
45
49
|
multiplier = response.matches[0][1]
|
46
50
|
karma = find_and_set_karma(karma_object, multiplier, true)
|
47
51
|
response.reply reply_with_karma(karma_object, karma)
|
48
52
|
end
|
49
53
|
|
50
54
|
def display_karma(response)
|
51
|
-
karma_object = response
|
55
|
+
karma_object = get_karma_object(response)
|
52
56
|
karma = find_karma karma_object
|
53
57
|
response.reply reply_with_karma(karma_object, karma)
|
54
58
|
end
|
data/lita-onewheel-karma.gemspec
CHANGED
@@ -41,6 +41,12 @@ describe Lita::Handlers::OnewheelKarma, lita_handler: true do
|
|
41
41
|
expect(replies.last).to eq get_positive(2)
|
42
42
|
end
|
43
43
|
|
44
|
+
it 'will multiply one karma with spaces' do
|
45
|
+
send_message 'a++'
|
46
|
+
send_message 'a *= 2'
|
47
|
+
expect(replies.last).to eq get_positive(2)
|
48
|
+
end
|
49
|
+
|
44
50
|
it 'will multiply many karma' do
|
45
51
|
send_message 'a++'
|
46
52
|
send_message 'a++'
|
@@ -147,4 +153,20 @@ describe Lita::Handlers::OnewheelKarma, lita_handler: true do
|
|
147
153
|
send_command 'karma'
|
148
154
|
expect(replies.last).to eq nil
|
149
155
|
end
|
156
|
+
|
157
|
+
it 'will ignore @\'s' do
|
158
|
+
send_message '@one++'
|
159
|
+
send_message 'one++'
|
160
|
+
expect(replies.last).to eq('one has 2 karma!')
|
161
|
+
end
|
162
|
+
|
163
|
+
it 'will *= 1' do
|
164
|
+
send_message 'karma_bot++'
|
165
|
+
send_message 'karma_bot++'
|
166
|
+
send_message 'karma_bot++'
|
167
|
+
send_message 'karma_bot++'
|
168
|
+
send_message 'karma_bot *= 1'
|
169
|
+
expect(replies.count).to eq(5)
|
170
|
+
expect(replies.last).to eq('karma_bot has 4 karma!')
|
171
|
+
end
|
150
172
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-onewheel-karma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Andrew Kreps
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|
@@ -148,7 +148,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
148
148
|
version: '0'
|
149
149
|
requirements: []
|
150
150
|
rubyforge_project:
|
151
|
-
rubygems_version: 2.5.1
|
151
|
+
rubygems_version: 2.4.5.1
|
152
152
|
signing_key:
|
153
153
|
specification_version: 4
|
154
154
|
summary: Karma shouldn't be bound by simple increment and decrement operations.
|