lita-karma 1.1.0 → 1.2.0

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: eff0e837f671bde9d5e8aa0acb7fedb9cf5a399d
4
- data.tar.gz: 8e2d58873e7e7d2da780193be606efc79c42f884
3
+ metadata.gz: c32b6338811ce3ca6a1a5c9abf1dbb591bfe90a3
4
+ data.tar.gz: f83476d892d5f67a37510a60c1a33e53d6d5c3a1
5
5
  SHA512:
6
- metadata.gz: 46c2b87191633815ab73907f2920e7d7e458a23f5bd7583320a030ddd0bcc31309eb116ab26526b4e452660986d913fd6b103a9be3bb189b9ebf5710f56bfb1f
7
- data.tar.gz: a960284ee22b60b646f99cea70df8221fafeb0ffdff00a3725be167acabed0a701cb816da69a51303a1eed180c763b672af6e4c356864ae5f7b93d2b3a9bf905
6
+ metadata.gz: 110bbb250b54efc45e554bf135b05c19d50a4a3eaedb2b0b2dcd4339a750ae83c49dfe80f44f9d104c6cea49757a7720c900c632774bc1df8720c8ed67977b2d
7
+ data.tar.gz: 0990210987a83902b7f661fe77591d2a3b9bb814b33b49f62865128030e67c75709f08c03a3f658cc656235a77172e09572e203f29921b8b51e020b3f9e23b41
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2013 Jimmy Cuadra
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.md CHANGED
@@ -32,6 +32,14 @@ Lita will add a karma point whenever it hears a term upvoted:
32
32
  term++
33
33
  ```
34
34
 
35
+ You can also give karma to multi-worded terms or terms with symbols by bounding them with `<>` or `::`:
36
+
37
+ ```
38
+ :Linus Torvalds:++
39
+
40
+ <C++>++
41
+ ```
42
+
35
43
  It will subtract a karma point whenever it hears a term downvoted:
36
44
 
37
45
  ```
@@ -3,7 +3,7 @@ require "lita"
3
3
  module Lita
4
4
  module Handlers
5
5
  class Karma < Handler
6
- TERM_REGEX = /[\[\]\w\._\-|\{\}]{2,}/
6
+ TERM_REGEX = /[<:][^>:]+[>:]|[\[\]\w\._\-|\{\}]{2,}/
7
7
 
8
8
  route %r{(#{TERM_REGEX.source})\+\+}, :increment, help: {
9
9
  "TERM++" => "Increments TERM by one."
@@ -172,7 +172,7 @@ HELP
172
172
  end
173
173
 
174
174
  def normalize_term(term)
175
- term.to_s.downcase.strip
175
+ term.to_s.downcase.strip.sub(/[<:]([^>:]+)[>:]/, '\1')
176
176
  end
177
177
 
178
178
  def list(response, redis_command)
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.1.0"
3
+ spec.version = "1.2.0"
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.}
@@ -43,6 +43,16 @@ describe Lita::Handlers::Karma, lita_handler: true do
43
43
  send_message("FOO++")
44
44
  expect(replies.last).to eq("foo: 2")
45
45
  end
46
+
47
+ it "matches multi-word terms bounded by delimeters" do
48
+ send_message(":Some Thing:++")
49
+ expect(replies.last).to eq("some thing: 1")
50
+ end
51
+
52
+ it "matches terms with symbols that are bounded by delimeters" do
53
+ send_message("<C++>++")
54
+ expect(replies.last).to eq("c++: 1")
55
+ end
46
56
  end
47
57
 
48
58
  describe "#decrement" do
@@ -68,6 +78,11 @@ describe Lita::Handlers::Karma, lita_handler: true do
68
78
  send_message("foo--")
69
79
  expect(replies.last).to match(/cannot modify foo/)
70
80
  end
81
+
82
+ it "matches multi-word terms bounded by delimeters" do
83
+ send_message(":Some Thing:--")
84
+ expect(replies.last).to eq("some thing: -1")
85
+ end
71
86
  end
72
87
 
73
88
  describe "#check" do
@@ -80,6 +95,11 @@ describe Lita::Handlers::Karma, lita_handler: true do
80
95
  send_message("foo~~ bar~~")
81
96
  expect(replies).to eq(["foo: 0", "bar: 0"])
82
97
  end
98
+
99
+ it "matches multi-word terms bounded by delimeters" do
100
+ send_message(":Some Thing:~~")
101
+ expect(replies.last).to eq("some thing: 0")
102
+ end
83
103
  end
84
104
 
85
105
  describe "#list" 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.1.0
4
+ version: 1.2.0
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 00:00:00.000000000 Z
11
+ date: 2013-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita
@@ -104,6 +104,7 @@ files:
104
104
  - .gitignore
105
105
  - .travis.yml
106
106
  - Gemfile
107
+ - LICENSE
107
108
  - README.md
108
109
  - Rakefile
109
110
  - lib/lita-karma.rb