ruboty 1.0.4 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +2 -16
- data/lib/ruboty/action.rb +12 -2
- data/lib/ruboty/handlers/base.rb +3 -3
- data/lib/ruboty/robot.rb +4 -2
- data/lib/ruboty/version.rb +1 -1
- metadata +2 -3
- data/images/screenshot.png +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d0316cbee1696f16412c5dec59ff9a9acf2889c
|
4
|
+
data.tar.gz: 5cbc28c375c29492d59c02a8a269c7e65358e4ae
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0d47aaf46c28343f8ed9a390c2112ffef02cbf10a1378998047d55eedbc7ebebc5807ae1952143e16f21ae8db6f59ee2de82ce9dc3857c727845eb6879f2b805
|
7
|
+
data.tar.gz: 82d6b8b70b6be452b4d9b8924e984440fbf51a024f37141c9dc504b78e31823825dc4df325e47949ec14d5db676ddc8a3fd7bf4b4413eae47e239199b6433aec
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -68,20 +68,6 @@ end
|
|
68
68
|
```
|
69
69
|
|
70
70
|
## Deploy
|
71
|
-
|
71
|
+
See [r7kamura/ruboty-template](https://github.com/r7kamura/ruboty-template) for example.
|
72
72
|
|
73
|
-
|
74
|
-
$ echo 'source "https://rubygems.org"' >> Gemfile
|
75
|
-
$ echo 'gem "ruboty"' >> Gemfile
|
76
|
-
$ echo 'bot: bundle exec ruboty' >> Procfile
|
77
|
-
$ bundle install
|
78
|
-
$ git init
|
79
|
-
$ git add .
|
80
|
-
$ git commit -m "Initial commit"
|
81
|
-
$ heroku create
|
82
|
-
$ git push heroku master
|
83
|
-
$ heroku scale bot=1
|
84
|
-
```
|
85
|
-
|
86
|
-
## Screenshot
|
87
|
-
![](https://raw.githubusercontent.com/r7kamura/ruboty/master/images/screenshot.png)
|
73
|
+
[![Deploy](https://www.herokucdn.com/deploy/button.png)](https://heroku.com/deploy?template=https://github.com/r7kamura/ruboty-template)
|
data/lib/ruboty/action.rb
CHANGED
@@ -11,8 +11,13 @@ module Ruboty
|
|
11
11
|
@options = options
|
12
12
|
end
|
13
13
|
|
14
|
-
def call(handler, message)
|
15
|
-
|
14
|
+
def call(handler, message, options = {})
|
15
|
+
if !!options[:missing] == missing? && message.match(pattern_with(handler.robot.name))
|
16
|
+
handler.send(name, message)
|
17
|
+
true
|
18
|
+
else
|
19
|
+
false
|
20
|
+
end
|
16
21
|
end
|
17
22
|
|
18
23
|
def all?
|
@@ -27,6 +32,11 @@ module Ruboty
|
|
27
32
|
!!options[:hidden]
|
28
33
|
end
|
29
34
|
|
35
|
+
# @note :missing action is called only when any handler doesn't match given message.
|
36
|
+
def missing?
|
37
|
+
!!options[:missing]
|
38
|
+
end
|
39
|
+
|
30
40
|
def name
|
31
41
|
options[:name]
|
32
42
|
end
|
data/lib/ruboty/handlers/base.rb
CHANGED
@@ -27,9 +27,9 @@ module Ruboty
|
|
27
27
|
validate!
|
28
28
|
end
|
29
29
|
|
30
|
-
def call(message)
|
31
|
-
self.class.actions.
|
32
|
-
action.call(self, message)
|
30
|
+
def call(message, options = {})
|
31
|
+
self.class.actions.inject(false) do |matched, action|
|
32
|
+
matched | action.call(self, message, options)
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
data/lib/ruboty/robot.rb
CHANGED
@@ -24,8 +24,10 @@ module Ruboty
|
|
24
24
|
|
25
25
|
def receive(attributes)
|
26
26
|
message = Message.new(attributes.merge(robot: self))
|
27
|
-
handlers.
|
28
|
-
handler
|
27
|
+
unless handlers.inject(false) { |matched, handler| matched | handler.call(message) }
|
28
|
+
handlers.each do |handler|
|
29
|
+
handler.call(message, missing: true)
|
30
|
+
end
|
29
31
|
end
|
30
32
|
end
|
31
33
|
|
data/lib/ruboty/version.rb
CHANGED
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.0
|
4
|
+
version: 1.1.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: 2014-
|
11
|
+
date: 2014-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -166,7 +166,6 @@ files:
|
|
166
166
|
- README.md
|
167
167
|
- Rakefile
|
168
168
|
- bin/ruboty
|
169
|
-
- images/screenshot.png
|
170
169
|
- lib/ruboty.rb
|
171
170
|
- lib/ruboty/action.rb
|
172
171
|
- lib/ruboty/actions/base.rb
|
data/images/screenshot.png
DELETED
Binary file
|