lita-karma 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/lita/handlers/karma.rb +10 -6
- data/lita-karma.gemspec +1 -1
- data/spec/lita/handlers/karma_spec.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1058d8d902a48e2300487be5bcb83a79362c5cf7
|
4
|
+
data.tar.gz: 9905b875483165a698b328ca1c3d58e83333e524
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2ef6f131c1e21f047bf40ac38d9d7d41e09a1ffed38c65281e09636f6edd68449bb6df8006c13547533038347e2fddbd51c85af915ab4fe5f3168e863eca46df
|
7
|
+
data.tar.gz: 002042dcd39afd71208297e1b58bcf3b4232c89bc7b3669a0bfdee2fa39655a48118360c1bd028c6186d65a86b0146889f03e25b55bb428c6eea0b747d81fee8
|
data/lib/lita/handlers/karma.rb
CHANGED
@@ -39,7 +39,7 @@ module Lita
|
|
39
39
|
output = []
|
40
40
|
|
41
41
|
response.matches.each do |match|
|
42
|
-
term = match[0]
|
42
|
+
term = normalize_term(match[0])
|
43
43
|
own_score = score = redis.zscore("terms", term).to_i
|
44
44
|
links = []
|
45
45
|
redis.smembers("links:#{term}").each do |link|
|
@@ -69,7 +69,7 @@ module Lita
|
|
69
69
|
|
70
70
|
def link(response)
|
71
71
|
response.matches.each do |match|
|
72
|
-
term1, term2 = match
|
72
|
+
term1, term2 = normalize_term(match[0]), normalize_term(match[1])
|
73
73
|
|
74
74
|
if redis.sadd("links:#{term1}", term2)
|
75
75
|
response.reply "#{term2} has been linked to #{term1}."
|
@@ -81,7 +81,7 @@ module Lita
|
|
81
81
|
|
82
82
|
def unlink(response)
|
83
83
|
response.matches.each do |match|
|
84
|
-
term1, term2 = match
|
84
|
+
term1, term2 = normalize_term(match[0]), normalize_term(match[1])
|
85
85
|
|
86
86
|
if redis.srem("links:#{term1}", term2)
|
87
87
|
response.reply "#{term2} has been unlinked from #{term1}."
|
@@ -92,9 +92,9 @@ module Lita
|
|
92
92
|
end
|
93
93
|
|
94
94
|
def modified(response)
|
95
|
-
term = response.args[1]
|
95
|
+
term = normalize_term(response.args[1])
|
96
96
|
|
97
|
-
if term.
|
97
|
+
if term.empty?
|
98
98
|
response.reply "Format: #{robot.name}: karma modified TERM"
|
99
99
|
return
|
100
100
|
end
|
@@ -115,7 +115,7 @@ module Lita
|
|
115
115
|
|
116
116
|
def modify(response, delta)
|
117
117
|
response.matches.each do |match|
|
118
|
-
term = match[0]
|
118
|
+
term = normalize_term(match[0])
|
119
119
|
|
120
120
|
ttl = redis.ttl("cooldown:#{response.user.id}:#{term}")
|
121
121
|
if ttl >= 0
|
@@ -141,6 +141,10 @@ module Lita
|
|
141
141
|
check(response)
|
142
142
|
end
|
143
143
|
|
144
|
+
def normalize_term(term)
|
145
|
+
term.to_s.downcase.strip
|
146
|
+
end
|
147
|
+
|
144
148
|
def list(response, redis_command)
|
145
149
|
n = (response.args[1] || 5).to_i - 1
|
146
150
|
|
data/lita-karma.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "lita-karma"
|
3
|
-
spec.version = "1.0.
|
3
|
+
spec.version = "1.0.1"
|
4
4
|
spec.authors = ["Jimmy Cuadra"]
|
5
5
|
spec.email = ["jimmy@jimmycuadra.com"]
|
6
6
|
spec.description = %q{A Lita handler for tracking karma points for arbitrary terms.}
|
@@ -36,6 +36,12 @@ describe Lita::Handlers::Karma, lita_handler: true do
|
|
36
36
|
send_message("foo++")
|
37
37
|
expect(replies.last).to match(/cannot modify foo/)
|
38
38
|
end
|
39
|
+
|
40
|
+
it "is case insensitive" do
|
41
|
+
send_message("foo++")
|
42
|
+
send_message("FOO++")
|
43
|
+
expect(replies.last).to eq("foo: 2")
|
44
|
+
end
|
39
45
|
end
|
40
46
|
|
41
47
|
describe "#decrement" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lita-karma
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jimmy Cuadra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-07-
|
11
|
+
date: 2013-07-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: lita
|