lita-karma 1.0.1 → 1.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1058d8d902a48e2300487be5bcb83a79362c5cf7
4
- data.tar.gz: 9905b875483165a698b328ca1c3d58e83333e524
3
+ metadata.gz: eff0e837f671bde9d5e8aa0acb7fedb9cf5a399d
4
+ data.tar.gz: 8e2d58873e7e7d2da780193be606efc79c42f884
5
5
  SHA512:
6
- metadata.gz: 2ef6f131c1e21f047bf40ac38d9d7d41e09a1ffed38c65281e09636f6edd68449bb6df8006c13547533038347e2fddbd51c85af915ab4fe5f3168e863eca46df
7
- data.tar.gz: 002042dcd39afd71208297e1b58bcf3b4232c89bc7b3669a0bfdee2fa39655a48118360c1bd028c6186d65a86b0146889f03e25b55bb428c6eea0b747d81fee8
6
+ metadata.gz: 46c2b87191633815ab73907f2920e7d7e458a23f5bd7583320a030ddd0bcc31309eb116ab26526b4e452660986d913fd6b103a9be3bb189b9ebf5710f56bfb1f
7
+ data.tar.gz: a960284ee22b60b646f99cea70df8221fafeb0ffdff00a3725be167acabed0a701cb816da69a51303a1eed180c763b672af6e4c356864ae5f7b93d2b3a9bf905
@@ -3,25 +3,55 @@ require "lita"
3
3
  module Lita
4
4
  module Handlers
5
5
  class Karma < Handler
6
- route %r{([^\s]{2,})\+\+}, :increment, help: { "TERM++" => "Increments TERM by one." }
7
- route %r{([^\s]{2,})\-\-}, :decrement, help: { "TERM--" => "Decrements TERM by one." }
8
- route %r{([^\s]{2,})~~}, :check, help: { "TERM~~" => "Shows the current karma of TERM." }
6
+ TERM_REGEX = /[\[\]\w\._\-|\{\}]{2,}/
7
+
8
+ route %r{(#{TERM_REGEX.source})\+\+}, :increment, help: {
9
+ "TERM++" => "Increments TERM by one."
10
+ }
11
+ route %r{(#{TERM_REGEX.source})\-\-}, :decrement, help: {
12
+ "TERM--" => "Decrements TERM by one."
13
+ }
14
+ route %r{(#{TERM_REGEX.source})~~}, :check, help: {
15
+ "TERM~~" => "Shows the current karma of TERM."
16
+ }
9
17
  route %r{^karma\s+worst}, :list_worst, command: true, help: {
10
- "karma worst [N]" => "Lists the bottom N terms by karma. N defaults to 5."
18
+ "karma worst [N]" => <<-HELP.chomp
19
+ Lists the bottom N terms by karma. N defaults to 5.
20
+ HELP
11
21
  }
12
22
  route %r{^karma\s+best}, :list_best, command: true, help: {
13
- "karma best [N]" => "Lists the top N terms by karma. N defaults to 5."
23
+ "karma best [N]" => <<-HELP.chomp
24
+ Lists the top N terms by karma. N defaults to 5.
25
+ HELP
14
26
  }
15
27
  route %r{^karma\s+modified}, :modified, command: true, help: {
16
- "karma modified TERM" => "Lists the names of users who have upvoted or downvoted TERM."
28
+ "karma modified TERM" => <<-HELP.chomp
29
+ Lists the names of users who have upvoted or downvoted TERM.
30
+ HELP
17
31
  }
18
32
  route %r{^karma\s*$}, :list_best, command: true
19
- route %r{^([^\s]{2,})\s*\+=\s*([^\s]{2,})}, :link, command: true, help: {
20
- "TERM1 += TERM2" => "Links TERM2 to TERM1. TERM1's karma will then be displayed as the sum of its own and TERM2's karma."
21
- }
22
- route %r{^([^\s]{2,})\s*-=\s*([^\s]{2,})}, :unlink, command: true, help: {
23
- "TERM1 -= TERM2" => "Unlinks TERM2 from TERM1. TERM1's karma will no longer be displayed as the sum of its own and TERM2's karma."
24
- }
33
+ route(
34
+ %r{^(#{TERM_REGEX.source})\s*\+=\s*(#{TERM_REGEX.source})},
35
+ :link,
36
+ command: true,
37
+ help: {
38
+ "TERM1 += TERM2" => <<-HELP.chomp
39
+ Links TERM2 to TERM1. TERM1's karma will then be displayed as the sum of its \
40
+ own and TERM2's karma.
41
+ HELP
42
+ }
43
+ )
44
+ route(
45
+ %r{^(#{TERM_REGEX.source})\s*-=\s*(#{TERM_REGEX.source})},
46
+ :unlink,
47
+ command: true,
48
+ help: {
49
+ "TERM1 -= TERM2" => <<-HELP.chomp
50
+ Unlinks TERM2 from TERM1. TERM1's karma will no longer be displayed as the sum \
51
+ of its own and TERM2's karma.
52
+ HELP
53
+ }
54
+ )
25
55
 
26
56
  def self.default_config(config)
27
57
  config.cooldown = 300
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.1"
3
+ spec.version = "1.1.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.}
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
 
18
18
  spec.add_development_dependency "bundler", "~> 1.3"
19
19
  spec.add_development_dependency "rake"
20
- spec.add_development_dependency "rspec", ">= 2.14.0rc1"
20
+ spec.add_development_dependency "rspec", "~> 2.14"
21
21
  spec.add_development_dependency "simplecov"
22
22
  spec.add_development_dependency "coveralls"
23
23
  end
@@ -12,6 +12,7 @@ describe Lita::Handlers::Karma, lita_handler: true do
12
12
  it { routes_command("karma").to(:list_best) }
13
13
  it { routes_command("foo += bar").to(:link) }
14
14
  it { routes_command("foo -= bar").to(:unlink) }
15
+ it { doesnt_route("+++++").to(:increment) }
15
16
 
16
17
  describe "#increment" do
17
18
  it "increases the term's score by one and says the new score" 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.1
4
+ version: 1.1.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-08 00:00:00.000000000 Z
11
+ date: 2013-07-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: lita
@@ -56,16 +56,16 @@ dependencies:
56
56
  name: rspec
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - '>='
59
+ - - ~>
60
60
  - !ruby/object:Gem::Version
61
- version: 2.14.0rc1
61
+ version: '2.14'
62
62
  type: :development
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - '>='
66
+ - - ~>
67
67
  - !ruby/object:Gem::Version
68
- version: 2.14.0rc1
68
+ version: '2.14'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: simplecov
71
71
  requirement: !ruby/object:Gem::Requirement