ellen 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -0
- data/README.md +24 -16
- data/lib/ellen/action.rb +16 -2
- data/lib/ellen/handlers/base.rb +3 -2
- data/lib/ellen/handlers/help.rb +2 -2
- data/lib/ellen/message.rb +7 -3
- data/lib/ellen/robot.rb +6 -0
- data/lib/ellen/version.rb +1 -1
- 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: f27816fa4aa7300a9b7c35b5827d5940c47088d6
|
4
|
+
data.tar.gz: 1cb192ad3cc6a7f8a29cc07f7907f2958be45077
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5037d6dadd4f679ed7254fd262405367f933d5cb8aa4dbeb114658243d31a0f1e469d460646a5e8e5608ccc087499f3051bed40b928c1065972b7356fea60e40
|
7
|
+
data.tar.gz: 314db415e020045daee42765c201c5faad64a0163a2ad4874d235dcfb12b7896079a882d8da99566539e08a79065af349991c5509ecface10b87d632cf4f5fde
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -4,22 +4,6 @@ A chatterbot framework, inspired by Hubot.
|
|
4
4
|
## Dependencies
|
5
5
|
* Ruby 1.9.3+
|
6
6
|
|
7
|
-
## Usage
|
8
|
-
```sh
|
9
|
-
$ gem install ellen # Install `ellen` gem to your local machine
|
10
|
-
$ ellen --help # Show usage with --help
|
11
|
-
Usage: ellen [options]
|
12
|
-
-a, --adapter Take adapter name.
|
13
|
-
--dotenv Load .env before running.
|
14
|
-
-g, --generate Generate a new chatterbot with ./ellen/ directory if specified.
|
15
|
-
-l, --load Load a ruby file before running.
|
16
|
-
-h, --help Display this help message.
|
17
|
-
$ ellen --generate # Generate your new chatterbot with ./ellen/ directory
|
18
|
-
$ cd ellen # Change to ./ellen/
|
19
|
-
$ vi Gemfile # Add your favorite plugin gems
|
20
|
-
$ bundle exec ellen --adapter=shell # Run your chatterbot with specified adapter
|
21
|
-
```
|
22
|
-
|
23
7
|
## Adapter
|
24
8
|
You can create your own favorite adapter from
|
25
9
|
[Ellen::Adpaters::Base](https://github.com/r7kamura/ellen/blob/master/lib/ellen/adapters/base.rb)
|
@@ -44,3 +28,27 @@ gem "ellen-foo"
|
|
44
28
|
gem "ellen-bar"
|
45
29
|
gem "ellen-baz"
|
46
30
|
```
|
31
|
+
|
32
|
+
## Config
|
33
|
+
Store config in envorinment variables.
|
34
|
+
They are easy to change between deploys without changing any code.
|
35
|
+
We recommend to put `.env` and run with `ellen --dotenv` option to manage them.
|
36
|
+
|
37
|
+
## Deploy
|
38
|
+
Here is the smallest example to deploy a simple chatterbot to Heroku.
|
39
|
+
|
40
|
+
```sh
|
41
|
+
$ gem install ellen
|
42
|
+
$ ellen --generate
|
43
|
+
$ cd ellen
|
44
|
+
$ echo 'gem "ellen-my_adapter"' >> Gemfile
|
45
|
+
$ echo 'bot: bundle exec ellen --adapter my_adapter' >> Procfile
|
46
|
+
$ bundle install
|
47
|
+
$ git init
|
48
|
+
$ git add .
|
49
|
+
$ git commit -m "Initial commit"
|
50
|
+
$ heroku create
|
51
|
+
$ heroku scale bot=1
|
52
|
+
$ heroku config:set FOO=1 BAR=2 BAZ=3
|
53
|
+
$ git push heroku master
|
54
|
+
```
|
data/lib/ellen/action.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Ellen
|
2
2
|
class Action
|
3
|
-
attr_reader :
|
3
|
+
attr_reader :block, :options, :pattern
|
4
4
|
|
5
5
|
def initialize(pattern, options = {}, &block)
|
6
6
|
@pattern = pattern
|
@@ -9,7 +9,21 @@ module Ellen
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def call(handler, message)
|
12
|
-
handler.robot.instance_exec(message, &block) if message.match(
|
12
|
+
handler.robot.instance_exec(message, &block) if message.match pattern_with(handler.robot.name)
|
13
|
+
end
|
14
|
+
|
15
|
+
def all?
|
16
|
+
!!options[:all]
|
17
|
+
end
|
18
|
+
|
19
|
+
private
|
20
|
+
|
21
|
+
def pattern_with(name)
|
22
|
+
if all?
|
23
|
+
/\A#{pattern}/
|
24
|
+
else
|
25
|
+
/\A@?#{Regexp.escape(name)}\s*#{pattern}/
|
26
|
+
end
|
13
27
|
end
|
14
28
|
end
|
15
29
|
end
|
data/lib/ellen/handlers/base.rb
CHANGED
data/lib/ellen/handlers/help.rb
CHANGED
data/lib/ellen/message.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Ellen
|
2
2
|
class Message
|
3
|
-
attr_reader :body, :
|
3
|
+
attr_reader :body, :command, :match_data, :source
|
4
4
|
|
5
5
|
def initialize(options)
|
6
6
|
@body = options[:body]
|
@@ -8,8 +8,12 @@ module Ellen
|
|
8
8
|
@command = options[:command]
|
9
9
|
end
|
10
10
|
|
11
|
-
def match(pattern
|
12
|
-
|
11
|
+
def match(pattern)
|
12
|
+
@match_data = pattern.match(body)
|
13
|
+
end
|
14
|
+
|
15
|
+
def [](index)
|
16
|
+
match_data[index]
|
13
17
|
end
|
14
18
|
end
|
15
19
|
end
|
data/lib/ellen/robot.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
module Ellen
|
2
2
|
class Robot
|
3
|
+
DEFAULT_ROBOT_NAME = "ellen"
|
4
|
+
|
3
5
|
include Mem
|
4
6
|
|
5
7
|
delegate :say, to: :adapter
|
@@ -25,6 +27,10 @@ module Ellen
|
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
30
|
+
def name
|
31
|
+
ENV["ROBOT_NAME"] || DEFAULT_ROBOT_NAME
|
32
|
+
end
|
33
|
+
|
28
34
|
private
|
29
35
|
|
30
36
|
def adapt
|
data/lib/ellen/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ellen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.5
|
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-04-
|
11
|
+
date: 2014-04-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|