ruboty-karma 0.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 +7 -0
- data/.gitignore +9 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +46 -0
- data/Rakefile +7 -0
- data/lib/ruboty/karma/actions/increase.rb +29 -0
- data/lib/ruboty/karma/actions/list.rb +18 -0
- data/lib/ruboty/karma/version.rb +5 -0
- data/lib/ruboty/karma.rb +29 -0
- data/ruboty-karma.gemspec +22 -0
- metadata +96 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0f5c0b008f039d8af4df01be6fd97a08992e4f60
|
4
|
+
data.tar.gz: 1d8ddceb87db293b36bb82a2ef1c9c5094b5d070
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: ea36006ef2c0f1804909eec13e3a91022861bfb5d8d5b8d7e763c4bd085b2da0753ec6665559bc2aded4950a7abbf52402372f418f8c379817e0a16ad87f373f
|
7
|
+
data.tar.gz: 44c2047068263916b7aa381830c64a09ca8613dadb9e9a40b6b4827d5f24ad8fefb8d56f71d0faf122e6497a751eb9a4036533c3df2ce939201da92f39bf8cae
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 hkdnet
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Ruboty::Karma
|
2
|
+
|
3
|
+
A plugin for Ruboty which manage members' karma.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem 'ruboty-karma'
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
$ bundle
|
16
|
+
|
17
|
+
Or install it yourself as:
|
18
|
+
|
19
|
+
$ gem install ruboty-karma
|
20
|
+
|
21
|
+
## Usage
|
22
|
+
|
23
|
+
### increase
|
24
|
+
|
25
|
+
```
|
26
|
+
@ruboty @username ++
|
27
|
+
```
|
28
|
+
|
29
|
+
@ruboty will increase @username's karma.
|
30
|
+
|
31
|
+
### list
|
32
|
+
|
33
|
+
```
|
34
|
+
@ruboty list karma
|
35
|
+
```
|
36
|
+
|
37
|
+
@ruboty will show you list of members' karma.
|
38
|
+
|
39
|
+
## Contributing
|
40
|
+
|
41
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/hkdnet/ruboty-karma. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
|
42
|
+
|
43
|
+
|
44
|
+
## License
|
45
|
+
|
46
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Karma
|
3
|
+
module Actions
|
4
|
+
class Increase < Ruboty::Actions::Base
|
5
|
+
def call
|
6
|
+
name = message[:username]
|
7
|
+
add_user(name)
|
8
|
+
updated_karma = increment(name)
|
9
|
+
message.reply("#{name}: #{updated_karma}")
|
10
|
+
end
|
11
|
+
|
12
|
+
def add_user(name)
|
13
|
+
brain = message.robot.brain
|
14
|
+
key = 'karma-list'
|
15
|
+
brain.data[key] ||= []
|
16
|
+
users = brain.data[key]
|
17
|
+
brain.data[key] = users.push(name).uniq
|
18
|
+
end
|
19
|
+
|
20
|
+
def increment(name)
|
21
|
+
brain = message.robot.brain
|
22
|
+
key = "karma-@#{name}"
|
23
|
+
brain.data[key] ||= 0
|
24
|
+
brain.data[key] += 1
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Ruboty
|
2
|
+
module Karma
|
3
|
+
module Actions
|
4
|
+
class List < Ruboty::Actions::Base
|
5
|
+
def call
|
6
|
+
key = 'karma-list'
|
7
|
+
brain = message.robot.brain
|
8
|
+
brain.data[key] ||= []
|
9
|
+
lists = brain.data[key].map do |user|
|
10
|
+
[user, brain.data["karma-@#{user}"]]
|
11
|
+
end
|
12
|
+
text = lists.sort_by { |e| -e[1] }.map { |e| e.join(': ') }.join("\n")
|
13
|
+
message.reply(text)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/ruboty/karma.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'ruboty'
|
2
|
+
require 'ruboty/karma/version'
|
3
|
+
require 'ruboty/karma/actions/increase'
|
4
|
+
require 'ruboty/karma/actions/list'
|
5
|
+
|
6
|
+
module Ruboty
|
7
|
+
module Handlers
|
8
|
+
class Karma < Base
|
9
|
+
on(
|
10
|
+
/@?(?<username>\S+)\s*\+\+/m,
|
11
|
+
name: 'increment',
|
12
|
+
description: "increment a user's karma"
|
13
|
+
)
|
14
|
+
on(
|
15
|
+
/list karma/m,
|
16
|
+
name: 'list',
|
17
|
+
description: "list all menber's karma"
|
18
|
+
)
|
19
|
+
|
20
|
+
def increment(message)
|
21
|
+
Ruboty::Karma::Actions::Increase.new(message).call
|
22
|
+
end
|
23
|
+
|
24
|
+
def list(message)
|
25
|
+
Ruboty::Karma::Actions::List.new(message).call
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'ruboty/karma/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = 'ruboty-karma'
|
8
|
+
spec.version = Ruboty::Karma::VERSION
|
9
|
+
spec.authors = ['hkdnet']
|
10
|
+
spec.email = ['hkdnet@users.noreply.github.com']
|
11
|
+
|
12
|
+
spec.files = `git ls-files -z`.split("\x0")
|
13
|
+
spec.summary = "manage members' karma"
|
14
|
+
spec.homepage = 'https://github.com/hkdnet/ruboty-karma'
|
15
|
+
spec.license = 'MIT'
|
16
|
+
|
17
|
+
spec.require_paths = ['lib']
|
18
|
+
|
19
|
+
spec.add_dependency 'ruboty'
|
20
|
+
spec.add_development_dependency 'bundler', '~> 1.10'
|
21
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruboty-karma
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- hkdnet
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-12-02 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: ruboty
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.10'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.10'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description:
|
56
|
+
email:
|
57
|
+
- hkdnet@users.noreply.github.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- ".gitignore"
|
63
|
+
- Gemfile
|
64
|
+
- LICENSE.txt
|
65
|
+
- README.md
|
66
|
+
- Rakefile
|
67
|
+
- lib/ruboty/karma.rb
|
68
|
+
- lib/ruboty/karma/actions/increase.rb
|
69
|
+
- lib/ruboty/karma/actions/list.rb
|
70
|
+
- lib/ruboty/karma/version.rb
|
71
|
+
- ruboty-karma.gemspec
|
72
|
+
homepage: https://github.com/hkdnet/ruboty-karma
|
73
|
+
licenses:
|
74
|
+
- MIT
|
75
|
+
metadata: {}
|
76
|
+
post_install_message:
|
77
|
+
rdoc_options: []
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
requirements: []
|
91
|
+
rubyforge_project:
|
92
|
+
rubygems_version: 2.4.5.1
|
93
|
+
signing_key:
|
94
|
+
specification_version: 4
|
95
|
+
summary: manage members' karma
|
96
|
+
test_files: []
|