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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 274074486378b9e899d7164d374f3e62c2e3fae2
4
- data.tar.gz: 804452f1f34e007e568c4d91c5b408e76f3f57d2
3
+ metadata.gz: f8fa99671812ea3fb3ca4541c5e22e6a8fc1c4f0
4
+ data.tar.gz: 596a20f944f7506272dd1224c7a442521139476f
5
5
  SHA512:
6
- metadata.gz: f11a4a22e2fd00e7d3da38b983989c55dc8da696445f22c6f5828bd2189e068ff23d880d1f504ce286ee406175219b96af054cfdbe1024117f1f46bff70bc410
7
- data.tar.gz: 2f99b6f695c31c3c19e257d34fa72223cf1fb65ba8eafc899fc91cf75a4938db82ca1ac08cb551391350b65203808b8d0338ba2bc4dd6d2d340ab9a212d879ef
6
+ metadata.gz: a23023bdd0c46d0d7dfb70d14f676606918278d03f9d63c8956c99560a67e72679084e3fb1f91927bace84ac4a34af7aa81dcc508512639e9d9c33617495927e
7
+ data.tar.gz: 8c9a43f69e001eb4d91f732f8b8cfc91b2f65f5735d5c97800ce6d93fc67b65faacba9731982a45b9bd709367c8a218b387dc03ea6b3d38a7184051cc0637e15
@@ -1,3 +1,8 @@
1
+ ## 1.2.0
2
+ - Add DISABLE_DEFAULT_HANDLERS env
3
+ - Get away from help message indentation
4
+ - Support filter query on help handler (e.g. `@ruboty help ping`)
5
+
1
6
  ## 1.1.9
2
7
  - Support slop both version 3 and 4
3
8
 
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
- ## Environment
54
+ ## ENV
52
55
  ```
53
- LOG_LEVEL - Log level for debug (default: 3)
54
- RUBOTY_NAME - Name to respond to mention (default: ruboty)
55
- RUBOTY_ENV - Loaded gem group name (default: development)
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
@@ -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
@@ -8,20 +8,22 @@ module Ruboty
8
8
  private
9
9
 
10
10
  def body
11
- action_descriptions.join("\n")
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 action_descriptions
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
- "%-#{pattern_max_length + prefix.size}s - #{action.description}" % "#{prefix}#{action.pattern.inspect}"
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
@@ -1,7 +1,11 @@
1
1
  module Ruboty
2
2
  module Handlers
3
3
  class Help < Base
4
- on(/help( me)?\z/i, name: "help", description: "Show this help message")
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
@@ -1,3 +1,3 @@
1
1
  module Ruboty
2
- VERSION = "1.1.9"
2
+ VERSION = "1.2.0"
3
3
  end
@@ -14,28 +14,41 @@ describe Ruboty::Handlers::Help do
14
14
  "#general"
15
15
  end
16
16
 
17
- let(:body) do
18
- <<-EOS.strip_heredoc.strip
19
- ruboty /help( me)?\\z/i - Show this help message
20
- ruboty /ping\\z/i - Return PONG to PING
21
- ruboty /who am i\\?/i - Answer who you are
22
- EOS
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
- it "responds to `@ruboty help` and says each handler's usage" do
26
- robot.should_receive(:say).with(
27
- body: body,
28
- code: true,
29
- from: to,
30
- to: from,
31
- original: {
32
- body: "@ruboty help",
33
- from: from,
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.1.9
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-02-28 00:00:00.000000000 Z
11
+ date: 2015-03-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport