ruboty 1.1.9 → 1.2.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 +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +8 -4
- data/lib/ruboty.rb +6 -3
- data/lib/ruboty/actions/help.rb +10 -8
- data/lib/ruboty/handlers/help.rb +5 -1
- data/lib/ruboty/version.rb +1 -1
- data/spec/ruboty/handlers/help_spec.rb +33 -20
- 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: f8fa99671812ea3fb3ca4541c5e22e6a8fc1c4f0
|
4
|
+
data.tar.gz: 596a20f944f7506272dd1224c7a442521139476f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a23023bdd0c46d0d7dfb70d14f676606918278d03f9d63c8956c99560a67e72679084e3fb1f91927bace84ac4a34af7aa81dcc508512639e9d9c33617495927e
|
7
|
+
data.tar.gz: 8c9a43f69e001eb4d91f732f8b8cfc91b2f65f5735d5c97800ce6d93fc67b65faacba9731982a45b9bd709367c8a218b387dc03ea6b3d38a7184051cc0637e15
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -16,6 +16,7 @@ Adapter hooks up your robot to chat services.
|
|
16
16
|
## Brain
|
17
17
|
Brain persists your robot's memory.
|
18
18
|
|
19
|
+
* [ruboty-leveldb](https://github.com/nownabe/ruboty-leveldb)
|
19
20
|
* [ruboty-redis](https://github.com/r7kamura/ruboty-redis)
|
20
21
|
|
21
22
|
## Handler
|
@@ -32,6 +33,8 @@ Handler provides various behaviors to your robot.
|
|
32
33
|
* [ruboty-syoboi_calendar](https://github.com/r7kamura/ruboty-syoboi_calendar)
|
33
34
|
* [ruboty-talk](https://github.com/r7kamura/ruboty-talk)
|
34
35
|
|
36
|
+
[Other plugins are hosted on Rubygems.](https://rubygems.org/search?utf8=%E2%9C%93&query=ruboty-)
|
37
|
+
|
35
38
|
## Configuration
|
36
39
|
Store configuration value in envorinment variables.
|
37
40
|
They are easy to change between deploys without changing any code.
|
@@ -48,11 +51,12 @@ gem "ruboty-redis"
|
|
48
51
|
gem "ruboty-slack"
|
49
52
|
```
|
50
53
|
|
51
|
-
##
|
54
|
+
## ENV
|
52
55
|
```
|
53
|
-
|
54
|
-
|
55
|
-
RUBOTY_ENV
|
56
|
+
DISABLE_DEFAULT_HANDLERS - Pass 1 to disable default handlers (default: nil)
|
57
|
+
LOG_LEVEL - Log level for debug (default: 3)
|
58
|
+
RUBOTY_ENV - Loaded gem group name (default: development)
|
59
|
+
RUBOTY_NAME - Name to respond to mention (default: ruboty)
|
56
60
|
```
|
57
61
|
|
58
62
|
## Deploy
|
data/lib/ruboty.rb
CHANGED
@@ -55,10 +55,13 @@ require "ruboty/commands/generate"
|
|
55
55
|
require "ruboty/commands/help"
|
56
56
|
require "ruboty/commands/run"
|
57
57
|
require "ruboty/handlers/base"
|
58
|
-
require "ruboty/handlers/help"
|
59
|
-
require "ruboty/handlers/ping"
|
60
|
-
require "ruboty/handlers/whoami"
|
61
58
|
require "ruboty/logger"
|
62
59
|
require "ruboty/message"
|
63
60
|
require "ruboty/robot"
|
64
61
|
require "ruboty/version"
|
62
|
+
|
63
|
+
if ENV["DISABLE_DEFAULT_HANDLERS"] != "1"
|
64
|
+
require "ruboty/handlers/help"
|
65
|
+
require "ruboty/handlers/ping"
|
66
|
+
require "ruboty/handlers/whoami"
|
67
|
+
end
|
data/lib/ruboty/actions/help.rb
CHANGED
@@ -8,20 +8,22 @@ module Ruboty
|
|
8
8
|
private
|
9
9
|
|
10
10
|
def body
|
11
|
-
|
11
|
+
descriptions = all_descriptions
|
12
|
+
if message[:filter]
|
13
|
+
descriptions.select! do |description|
|
14
|
+
description.include?(message[:filter])
|
15
|
+
end
|
16
|
+
end
|
17
|
+
descriptions.join("\n")
|
12
18
|
end
|
13
19
|
|
14
|
-
def
|
15
|
-
Ruboty.actions.reject(&:hidden?).sort.map do |action|
|
20
|
+
def all_descriptions
|
21
|
+
_descriptions = Ruboty.actions.reject(&:hidden?).sort.map do |action|
|
16
22
|
prefix = ""
|
17
23
|
prefix << message.robot.name << " " unless action.all?
|
18
|
-
"
|
24
|
+
"#{prefix}#{action.pattern.inspect} - #{action.description}"
|
19
25
|
end
|
20
26
|
end
|
21
|
-
|
22
|
-
def pattern_max_length
|
23
|
-
Ruboty.actions.map {|action| action.pattern.inspect }.map(&:size).max
|
24
|
-
end
|
25
27
|
end
|
26
28
|
end
|
27
29
|
end
|
data/lib/ruboty/handlers/help.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
1
|
module Ruboty
|
2
2
|
module Handlers
|
3
3
|
class Help < Base
|
4
|
-
on(
|
4
|
+
on(
|
5
|
+
/help( me)?(?: (?<filter>.+))?\z/i,
|
6
|
+
description: "Show this help message",
|
7
|
+
name: "help",
|
8
|
+
)
|
5
9
|
|
6
10
|
def help(message)
|
7
11
|
Ruboty::Actions::Help.new(message).call
|
data/lib/ruboty/version.rb
CHANGED
@@ -14,28 +14,41 @@ describe Ruboty::Handlers::Help do
|
|
14
14
|
"#general"
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
17
|
+
context "with valid condition" do
|
18
|
+
let(:body) do
|
19
|
+
<<-EOS.strip_heredoc.strip
|
20
|
+
ruboty /help( me)?(?: (?<filter>.+))?\\z/i - Show this help message
|
21
|
+
ruboty /ping\\z/i - Return PONG to PING
|
22
|
+
ruboty /who am i\\?/i - Answer who you are
|
23
|
+
EOS
|
24
|
+
end
|
25
|
+
|
26
|
+
it "responds to `@ruboty help` and says each handler's description" do
|
27
|
+
robot.should_receive(:say).with(
|
28
|
+
body: body,
|
29
|
+
code: true,
|
30
|
+
from: to,
|
31
|
+
to: from,
|
32
|
+
original: {
|
33
|
+
body: "@ruboty help",
|
34
|
+
from: from,
|
35
|
+
robot: robot,
|
36
|
+
to: to,
|
37
|
+
},
|
38
|
+
)
|
39
|
+
robot.receive(body: "@ruboty help", from: from, to: to)
|
40
|
+
end
|
23
41
|
end
|
24
42
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
robot: robot,
|
35
|
-
to: to,
|
36
|
-
},
|
37
|
-
)
|
38
|
-
robot.receive(body: "@ruboty help", from: from, to: to)
|
43
|
+
context "with filter" do
|
44
|
+
it "filters descriptions by given filter" do
|
45
|
+
robot.should_receive(:say).with(
|
46
|
+
hash_including(
|
47
|
+
body: "ruboty /ping\\z/i - Return PONG to PING",
|
48
|
+
),
|
49
|
+
)
|
50
|
+
robot.receive(body: "@ruboty help ping", from: from, to: to)
|
51
|
+
end
|
39
52
|
end
|
40
53
|
end
|
41
54
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruboty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-03-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|