cinch-karma 1.0.3 → 1.0.4

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: 85e1c22bb5600f38351ca7961c075ae56b3e5bd3
4
+ data.tar.gz: aa6e10363e33dc70e45df5b1db8e2bda64103a42
5
+ SHA512:
6
+ metadata.gz: 44e85ba6839c0a853b8ce4436293278d3109962f6757a661607e69eb1b2529f7f8778561beb723abf870d0cfc5336f87e5db71096d98a3fe8d2b73637b463940
7
+ data.tar.gz: 7a1ba7a20611dca1e7273c17e8a40172cecce3ae77e4f9f8a0011dda162b2a5314319e628ca4f8330d49464ffb8890fe0e9ed90eac937c7159751225d58f3734
@@ -1,4 +1,23 @@
1
1
  language: ruby
2
+ env:
3
+ global:
4
+ - "JRUBY_OPTS=-Xcext.enabled=true"
2
5
  rvm:
3
- - 1.9.2
6
+ - 2.1.0
7
+ - 2.0.0
4
8
  - 1.9.3
9
+ - 1.9.2
10
+ - 1.8.7
11
+ - jruby-18mode
12
+ - jruby-19mode
13
+ - ruby-head
14
+ - jruby-head
15
+ - ree
16
+ matrix:
17
+ allow_failures:
18
+ - rvm: 1.8.7
19
+ - rvm: ree
20
+ - rvm: jruby-18mode
21
+ - rvm: jruby-19mode
22
+ - rvm: jruby-head
23
+ fast_finish: true
@@ -8,22 +8,21 @@ Gem::Specification.new do |gem|
8
8
  gem.version = Cinch::Plugins::Karma::VERSION
9
9
  gem.authors = ['Brian Haberer']
10
10
  gem.email = ['bhaberer@gmail.com']
11
- gem.description = %q{Cinch Plugin to track karma (item++ / item--) in the channel}
12
- gem.summary = %q{Cinch Plugin to Track Karma}
11
+ gem.description = %q(Cinch Plugin to track karma (item++ / item--) in the channel)
12
+ gem.summary = %q(Cinch Plugin to Track Karma)
13
13
  gem.homepage = 'https://github.com/bhaberer/cinch-karma'
14
14
  gem.license = 'MIT'
15
15
 
16
16
  gem.files = `git ls-files`.split($/)
17
- gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
18
- gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
17
+ gem.executables = gem.files.grep(/^bin\//).map { |f| File.basename(f) }
18
+ gem.test_files = gem.files.grep(/^(test|spec|features)\//)
19
19
  gem.require_paths = ['lib']
20
20
 
21
- gem.add_development_dependency 'rake'
22
- gem.add_development_dependency 'rspec'
23
- gem.add_development_dependency 'coveralls'
24
- gem.add_development_dependency 'cinch-test'
25
-
26
- gem.add_dependency 'cinch', '~> 2.0.12'
27
- gem.add_dependency 'cinch-cooldown', '~> 1.1.1'
28
- gem.add_dependency 'cinch-storage', '~> 1.1.0'
21
+ gem.add_development_dependency 'rake', '~> 10'
22
+ gem.add_development_dependency 'rspec', '~> 3'
23
+ gem.add_development_dependency 'coveralls', '~> 0.7'
24
+ gem.add_development_dependency 'cinch-test', '~> 0.1', '>= 0.1.0'
25
+ gem.add_dependency 'cinch', '~> 2'
26
+ gem.add_dependency 'cinch-cooldown', '~> 1.1', '>= 1.1.3'
27
+ gem.add_dependency 'cinch-storage', '~> 1.1'
29
28
  end
@@ -3,74 +3,73 @@ require 'cinch'
3
3
  require 'cinch/cooldown'
4
4
  require 'cinch/storage'
5
5
 
6
- module Cinch::Plugins
7
- # Cinch Plugin to monitor karma and report.
8
- class Karma
9
- include Cinch::Plugin
6
+ module Cinch
7
+ module Plugins
8
+ # Cinch Plugin to monitor karma and report.
9
+ class Karma
10
+ include Cinch::Plugin
10
11
 
11
- enforce_cooldown
12
+ enforce_cooldown
12
13
 
13
- self.help = 'Use .karma <item> to see it\'s karma level. You can use ' +
14
- '<item>++ or <item>-- [or (something with spaces)++] to ' +
15
- 'alter karma for an item'
14
+ self.help = 'Use .karma <item> to see it\'s karma level. You can use ' \
15
+ '<item>++ or <item>-- [or (something with spaces)++] to ' \
16
+ 'alter karma for an item'
16
17
 
17
- listen_to :channel
18
+ listen_to :channel
18
19
 
19
- match /karma (.+)/
20
- match /k (.+)/
20
+ match(/(?:k|karma) (.+)/)
21
21
 
22
- def initialize(*args)
23
- super
24
- @storage = Cinch::Storage.new(config[:filename] || 'yaml/karma.yml')
25
- end
22
+ def initialize(*args)
23
+ super
24
+ @storage = Cinch::Storage.new(config[:filename] || 'yaml/karma.yml')
25
+ end
26
26
 
27
- def listen(m)
28
- if m.message.match(/\S+[\+\-]{2}/)
27
+ def listen(m)
28
+ return unless m.message.match(/\S+[\+\-]{2}/)
29
29
  channel = m.channel.name
30
30
 
31
31
  # Scan messages for multiple karma items
32
- m.message.scan(/(\s|\A)(\w+|\(.+?\))(\+\+|--)(\s|\z)/).each do |karma|
33
- process_karma(channel, karma[1].gsub(/\(|\)/, '').downcase, karma[2])
32
+ m.message.scan(/(\s|\A)(\w+|\(.+?\))(\+\+|--)(\s|\z)/).each do |k|
33
+ process_karma(channel, k[1].gsub(/\(|\)/, '').downcase, k[2])
34
34
  end
35
35
 
36
36
  @storage.synced_save(@bot)
37
37
  end
38
- end
39
38
 
40
- def execute(m, item)
41
- return if sent_via_pm?(m)
39
+ def execute(m, item)
40
+ return if sent_via_pm?(m)
42
41
 
43
- channel = m.channel.name
44
- item.downcase!
45
- init_karma(channel, item)
42
+ channel = m.channel.name
43
+ item.downcase!
44
+ init_karma(channel, item)
46
45
 
47
- m.reply "Karma for #{item} is #{@storage.data[channel][item]}"
48
- end
46
+ m.reply "Karma for #{item} is #{@storage.data[channel][item]}"
47
+ end
49
48
 
50
- private
49
+ private
51
50
 
52
- def process_karma(channel, item, operation)
53
- # Ensure the item's Karma has been init
54
- init_karma(channel, item)
51
+ def process_karma(channel, item, operation)
52
+ # Ensure the item's Karma has been init
53
+ init_karma(channel, item)
55
54
 
56
- case operation
57
- when '++'
58
- @storage.data[channel][item] += 1
59
- when '--'
60
- @storage.data[channel][item] -= 1
55
+ case operation
56
+ when '++'
57
+ @storage.data[channel][item] += 1
58
+ when '--'
59
+ @storage.data[channel][item] -= 1
60
+ end
61
61
  end
62
- end
63
62
 
64
- def sent_via_pm?(m)
65
- if m.channel.nil?
63
+ def sent_via_pm?(m)
64
+ return false unless m.channel.nil?
66
65
  m.reply 'You must use that command in the main channel.'
67
- return true
66
+ true
68
67
  end
69
- end
70
68
 
71
- def init_karma(channel, item = nil)
72
- @storage.data[channel] ||= {}
73
- @storage.data[channel][item] ||= 0 unless item.nil?
69
+ def init_karma(channel, item = nil)
70
+ @storage.data[channel] ||= {}
71
+ @storage.data[channel][item] ||= 0 unless item.nil?
72
+ end
74
73
  end
75
74
  end
76
75
  end
@@ -3,7 +3,7 @@ module Cinch
3
3
  module Plugins
4
4
  # Version info
5
5
  class Karma
6
- VERSION = '1.0.3'
6
+ VERSION = '1.0.4'
7
7
  end
8
8
  end
9
9
  end
@@ -4,69 +4,79 @@ describe Cinch::Plugins::Karma do
4
4
  include Cinch::Test
5
5
 
6
6
  before(:each) do
7
- @bot = make_bot(Cinch::Plugins::Karma, { :filename => '/dev/null' })
7
+ @bot = make_bot(Cinch::Plugins::Karma, { filename: '/dev/null' })
8
8
  end
9
9
 
10
10
  it 'should default to zero karma' do
11
- msg = make_message(@bot, '!karma foo', { :channel => '#foo' })
12
- get_replies(msg).first.text.should == "Karma for foo is 0"
11
+ msg = make_message(@bot, '!karma foo', { channel: '#foo' })
12
+ expect(get_replies(msg).first.text)
13
+ .to eq('Karma for foo is 0')
13
14
  end
14
15
 
15
16
  it 'should allow users to add karma' do
16
- msg = make_message(@bot, 'foo++', { :channel => '#foo' })
17
+ msg = make_message(@bot, 'foo++', { channel: '#foo' })
17
18
  get_replies(msg)
18
- msg = make_message(@bot, '!karma foo', { :channel => '#foo' })
19
- get_replies(msg).first.text.should == "Karma for foo is 1"
19
+ msg = make_message(@bot, '!karma foo', { channel: '#foo' })
20
+ expect(get_replies(msg).first.text)
21
+ .to eq('Karma for foo is 1')
20
22
  end
21
23
 
22
24
  it 'should allow users to add karma mid message' do
23
- msg = make_message(@bot, 'd asd asdasd foo++ dasdasd sadasd sad', { :channel => '#foo' })
25
+ msg = make_message(@bot, 'd asd asdasd foo++ dasdasd sadasd sad', { channel: '#foo' })
24
26
  get_replies(msg)
25
- msg = make_message(@bot, '!karma foo', { :channel => '#foo' })
26
- get_replies(msg).first.text.should == "Karma for foo is 1"
27
+ msg = make_message(@bot, '!karma foo', { channel: '#foo' })
28
+ expect(get_replies(msg).first.text)
29
+ .to eq('Karma for foo is 1')
27
30
  end
28
31
 
29
32
  it 'should allow users to add karma with items with spaces via ()' do
30
- msg = make_message(@bot, '(foo bar)++', { :channel => '#foo' })
33
+ msg = make_message(@bot, '(foo bar)++', { channel: '#foo' })
31
34
  get_replies(msg)
32
- msg = make_message(@bot, '!karma foo bar', { :channel => '#foo' })
33
- get_replies(msg).first.text.should == "Karma for foo bar is 1"
35
+ msg = make_message(@bot, '!karma foo bar', { channel: '#foo' })
36
+ expect(get_replies(msg).first.text)
37
+ .to eq('Karma for foo bar is 1')
34
38
  end
35
39
 
36
40
  it 'should allow users to remove karma' do
37
- msg = make_message(@bot, 'foo--', { :channel => '#foo' })
41
+ msg = make_message(@bot, 'foo--', { channel: '#foo' })
38
42
  get_replies(msg)
39
- msg = make_message(@bot, '!karma foo', { :channel => '#foo' })
40
- get_replies(msg).first.text.should == "Karma for foo is -1"
43
+ msg = make_message(@bot, '!karma foo', { channel: '#foo' })
44
+ expect(get_replies(msg).first.text)
45
+ .to eq('Karma for foo is -1')
41
46
  end
42
47
 
43
48
  it 'should allow users to remove karma mid message' do
44
- msg = make_message(@bot, 'd asd asdasd foo-- dasdasd sadasd sad', { :channel => '#foo' })
49
+ msg = make_message(@bot, 'd asd asdasd foo-- dasdasd sadasd sad', { channel: '#foo' })
45
50
  get_replies(msg)
46
- msg = make_message(@bot, '!karma foo', { :channel => '#foo' })
47
- get_replies(msg).first.text.should == "Karma for foo is -1"
51
+ msg = make_message(@bot, '!karma foo', { channel: '#foo' })
52
+ expect(get_replies(msg).first.text)
53
+ .to eq('Karma for foo is -1')
48
54
  end
49
55
 
50
56
  it 'should allow users to remove karma with items with spaces via ()' do
51
- msg = make_message(@bot, '(foo bar)--', { :channel => '#foo' })
57
+ msg = make_message(@bot, '(foo bar)--', { channel: '#foo' })
52
58
  get_replies(msg)
53
- msg = make_message(@bot, '!karma foo bar', { :channel => '#foo' })
54
- get_replies(msg).first.text.should == "Karma for foo bar is -1"
59
+ msg = make_message(@bot, '!karma foo bar', { channel: '#foo' })
60
+ expect(get_replies(msg).first.text)
61
+ .to eq('Karma for foo bar is -1')
55
62
  end
56
63
  it 'should not allow users to check karam via pm' do
57
64
  msg = make_message(@bot, '!karma foo')
58
- get_replies(msg).first.text.should == "You must use that command in the main channel."
65
+ expect(get_replies(msg).first.text)
66
+ .to eq('You must use that command in the main channel.')
59
67
  end
60
68
 
61
69
  it 'should not allow users to add karma via pm' do
62
70
  msg = make_message(@bot, 'foo++')
63
- msg = make_message(@bot, '!karma foo', { :channel => '#foo' })
64
- get_replies(msg).first.text.should == "Karma for foo is 0"
71
+ msg = make_message(@bot, '!karma foo', { channel: '#foo' })
72
+ expect(get_replies(msg).first.text)
73
+ .to eq('Karma for foo is 0')
65
74
  end
66
75
 
67
76
  it 'should not allow users to remove karma via pm' do
68
77
  msg = make_message(@bot, 'foo--')
69
- msg = make_message(@bot, '!karma foo', { :channel => '#foo' })
70
- get_replies(msg).first.text.should == "Karma for foo is 0"
78
+ msg = make_message(@bot, '!karma foo', { channel: '#foo' })
79
+ expect(get_replies(msg).first.text)
80
+ .to eq('Karma for foo is 0')
71
81
  end
72
82
  end
@@ -1,4 +1,5 @@
1
1
  require 'coveralls'
2
2
  Coveralls.wear!
3
+
3
4
  require 'cinch-karma'
4
5
  require 'cinch/test'
metadata CHANGED
@@ -1,128 +1,125 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cinch-karma
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
5
- prerelease:
4
+ version: 1.0.4
6
5
  platform: ruby
7
6
  authors:
8
7
  - Brian Haberer
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-02-19 00:00:00.000000000 Z
11
+ date: 2014-07-31 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rake
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ~>
20
18
  - !ruby/object:Gem::Version
21
- version: '0'
19
+ version: '10'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ~>
28
25
  - !ruby/object:Gem::Version
29
- version: '0'
26
+ version: '10'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ~>
36
32
  - !ruby/object:Gem::Version
37
- version: '0'
33
+ version: '3'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ~>
44
39
  - !ruby/object:Gem::Version
45
- version: '0'
40
+ version: '3'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: coveralls
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - ~>
52
46
  - !ruby/object:Gem::Version
53
- version: '0'
47
+ version: '0.7'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - ~>
60
53
  - !ruby/object:Gem::Version
61
- version: '0'
54
+ version: '0.7'
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: cinch-test
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: '0.1'
67
62
  - - ! '>='
68
63
  - !ruby/object:Gem::Version
69
- version: '0'
64
+ version: 0.1.0
70
65
  type: :development
71
66
  prerelease: false
72
67
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
68
  requirements:
69
+ - - ~>
70
+ - !ruby/object:Gem::Version
71
+ version: '0.1'
75
72
  - - ! '>='
76
73
  - !ruby/object:Gem::Version
77
- version: '0'
74
+ version: 0.1.0
78
75
  - !ruby/object:Gem::Dependency
79
76
  name: cinch
80
77
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
78
  requirements:
83
79
  - - ~>
84
80
  - !ruby/object:Gem::Version
85
- version: 2.0.12
81
+ version: '2'
86
82
  type: :runtime
87
83
  prerelease: false
88
84
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
85
  requirements:
91
86
  - - ~>
92
87
  - !ruby/object:Gem::Version
93
- version: 2.0.12
88
+ version: '2'
94
89
  - !ruby/object:Gem::Dependency
95
90
  name: cinch-cooldown
96
91
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
92
  requirements:
99
93
  - - ~>
100
94
  - !ruby/object:Gem::Version
101
- version: 1.1.1
95
+ version: '1.1'
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: 1.1.3
102
99
  type: :runtime
103
100
  prerelease: false
104
101
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
102
  requirements:
107
103
  - - ~>
108
104
  - !ruby/object:Gem::Version
109
- version: 1.1.1
105
+ version: '1.1'
106
+ - - ! '>='
107
+ - !ruby/object:Gem::Version
108
+ version: 1.1.3
110
109
  - !ruby/object:Gem::Dependency
111
110
  name: cinch-storage
112
111
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
112
  requirements:
115
113
  - - ~>
116
114
  - !ruby/object:Gem::Version
117
- version: 1.1.0
115
+ version: '1.1'
118
116
  type: :runtime
119
117
  prerelease: false
120
118
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
119
  requirements:
123
120
  - - ~>
124
121
  - !ruby/object:Gem::Version
125
- version: 1.1.0
122
+ version: '1.1'
126
123
  description: Cinch Plugin to track karma (item++ / item--) in the channel
127
124
  email:
128
125
  - bhaberer@gmail.com
@@ -145,29 +142,27 @@ files:
145
142
  homepage: https://github.com/bhaberer/cinch-karma
146
143
  licenses:
147
144
  - MIT
145
+ metadata: {}
148
146
  post_install_message:
149
147
  rdoc_options: []
150
148
  require_paths:
151
149
  - lib
152
150
  required_ruby_version: !ruby/object:Gem::Requirement
153
- none: false
154
151
  requirements:
155
152
  - - ! '>='
156
153
  - !ruby/object:Gem::Version
157
154
  version: '0'
158
155
  required_rubygems_version: !ruby/object:Gem::Requirement
159
- none: false
160
156
  requirements:
161
157
  - - ! '>='
162
158
  - !ruby/object:Gem::Version
163
159
  version: '0'
164
160
  requirements: []
165
161
  rubyforge_project:
166
- rubygems_version: 1.8.25
162
+ rubygems_version: 2.2.2
167
163
  signing_key:
168
- specification_version: 3
164
+ specification_version: 4
169
165
  summary: Cinch Plugin to Track Karma
170
166
  test_files:
171
167
  - spec/cinch-karma_spec.rb
172
168
  - spec/spec_helper.rb
173
- has_rdoc: