ellen 0.0.9 → 0.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 +6 -5
- data/lib/ellen/adapter_builder.rb +8 -17
- data/lib/ellen/adapters/base.rb +4 -5
- data/lib/ellen/command_builder.rb +0 -1
- data/lib/ellen/robot.rb +1 -1
- data/lib/ellen/version.rb +1 -1
- data/spec/ellen/adapter_builder_spec.rb +40 -0
- data/spec/ellen/commands/run_spec.rb +4 -32
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2de2c293649270b33753969b8e1b504eb63ca821
|
4
|
+
data.tar.gz: 2f0cbbadad308168ca053235d503c86dfca3a7f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 652d8b2f4d97172ef2d72c2877528eeca0f0e4a8cd0b10c7a18aa8f7b3cdbe769fa58033f3f4f748a6e44335173d8d6d639e629836954ccfed5868dd3425d0d4
|
7
|
+
data.tar.gz: 1b04c2c135b32f78fa9a7765718477345d5fd0b6d4b72fefb454253597b0e64c635f0a2e42bca14ead4a9128f189f7905accd6916b29897a6a29132d923c9b74
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -11,6 +11,7 @@ You can create your own favorite adapter from
|
|
11
11
|
class with #run method. Please see the following real examples for more details.
|
12
12
|
|
13
13
|
* [Ellen::Adapters::Shell](https://github.com/r7kamura/ellen/blob/master/lib/ellen/adapters/shell.rb)
|
14
|
+
* [Ellen::Adapters::Slack](https://github.com/r7kamura/ellen-slack)
|
14
15
|
* [Ellen::Adapters::Hipchat](https://github.com/r7kamura/ellen-hipchat)
|
15
16
|
* [Ellen::Adapters::Twitter](https://github.com/r7kamura/ellen-twitter)
|
16
17
|
|
@@ -29,9 +30,9 @@ Ellen will load them before running.
|
|
29
30
|
|
30
31
|
```ruby
|
31
32
|
# Gemfile
|
32
|
-
gem "ellen-
|
33
|
-
gem "ellen-
|
34
|
-
gem "ellen-
|
33
|
+
gem "ellen-cron"
|
34
|
+
gem "ellen-google_image"
|
35
|
+
gem "ellen-slack"
|
35
36
|
```
|
36
37
|
|
37
38
|
## Config
|
@@ -47,15 +48,15 @@ $ gem install ellen
|
|
47
48
|
$ ellen --generate
|
48
49
|
$ cd ellen
|
49
50
|
$ echo 'gem "ellen-my_adapter"' >> Gemfile
|
50
|
-
$ echo 'bot: bundle exec ellen
|
51
|
+
$ echo 'bot: bundle exec ellen' >> Procfile
|
51
52
|
$ bundle install
|
52
53
|
$ git init
|
53
54
|
$ git add .
|
54
55
|
$ git commit -m "Initial commit"
|
55
56
|
$ heroku create
|
56
|
-
$ heroku scale bot=1
|
57
57
|
$ heroku config:set FOO=1 BAR=2 BAZ=3
|
58
58
|
$ git push heroku master
|
59
|
+
$ heroku scale bot=1
|
59
60
|
```
|
60
61
|
|
61
62
|
## Screenshot
|
@@ -1,32 +1,23 @@
|
|
1
1
|
module Ellen
|
2
2
|
class AdapterBuilder
|
3
|
-
|
3
|
+
def self.adapter_classes
|
4
|
+
@adapter_classes ||= []
|
5
|
+
end
|
6
|
+
|
7
|
+
attr_reader :robot
|
4
8
|
|
5
|
-
def initialize(robot
|
9
|
+
def initialize(robot)
|
6
10
|
@robot = robot
|
7
|
-
@options = options
|
8
11
|
end
|
9
12
|
|
10
13
|
def build
|
11
|
-
adapter_class.new(robot
|
14
|
+
adapter_class.new(robot)
|
12
15
|
end
|
13
16
|
|
14
17
|
private
|
15
18
|
|
16
19
|
def adapter_class
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
def name
|
21
|
-
options[:adapter] || default_name
|
22
|
-
end
|
23
|
-
|
24
|
-
def default_name
|
25
|
-
"shell"
|
26
|
-
end
|
27
|
-
|
28
|
-
def die
|
29
|
-
Ellen.die("No adapter is defined for `#{name}`")
|
20
|
+
self.class.adapter_classes.last
|
30
21
|
end
|
31
22
|
end
|
32
23
|
end
|
data/lib/ellen/adapters/base.rb
CHANGED
@@ -13,8 +13,8 @@ module Ellen
|
|
13
13
|
module Adapters
|
14
14
|
class Base
|
15
15
|
class << self
|
16
|
-
def inherited(
|
17
|
-
Ellen
|
16
|
+
def inherited(child_class)
|
17
|
+
Ellen::AdapterBuilder.adapter_classes << child_class
|
18
18
|
end
|
19
19
|
|
20
20
|
def env(key, description, options = {})
|
@@ -30,11 +30,10 @@ module Ellen
|
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
33
|
-
attr_reader :robot
|
33
|
+
attr_reader :robot
|
34
34
|
|
35
|
-
def initialize(robot
|
35
|
+
def initialize(robot)
|
36
36
|
@robot = robot
|
37
|
-
@options = options
|
38
37
|
end
|
39
38
|
|
40
39
|
def say(body, options = {})
|
@@ -20,7 +20,6 @@ module Ellen
|
|
20
20
|
|
21
21
|
def options
|
22
22
|
Slop.parse!(arguments, help: true) do
|
23
|
-
on("a", "adapter=", "Take adapter name.")
|
24
23
|
on("dotenv", "Load .env before running.")
|
25
24
|
on("g", "generate", "Generate a new chatterbot with ./ellen/ directory if specified.")
|
26
25
|
on("l", "load=", "Load a ruby file before running.")
|
data/lib/ellen/robot.rb
CHANGED
data/lib/ellen/version.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Ellen::AdapterBuilder do
|
4
|
+
let(:builder) do
|
5
|
+
described_class.new(robot)
|
6
|
+
end
|
7
|
+
|
8
|
+
let(:robot) do
|
9
|
+
Ellen::Robot.new(options)
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:options) do
|
13
|
+
{}
|
14
|
+
end
|
15
|
+
|
16
|
+
describe "#build" do
|
17
|
+
context "with no other adapter class definition" do
|
18
|
+
it "returns a Ellen::Adapters::Shell as a default adapter" do
|
19
|
+
builder.build.should be_a Ellen::Adapters::Shell
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context "with another adapter class definition" do
|
24
|
+
after do
|
25
|
+
Ellen::AdapterBuilder.adapter_classes.pop
|
26
|
+
end
|
27
|
+
|
28
|
+
let!(:another_adapter_class) do
|
29
|
+
Class.new(Ellen::Adapters::Base) do
|
30
|
+
def run
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
it "returns an instance of that adapter class" do
|
36
|
+
builder.build.should be_a another_adapter_class
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -11,40 +11,12 @@ describe Ellen::Commands::Run do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
let(:arguments) do
|
14
|
-
[
|
14
|
+
[]
|
15
15
|
end
|
16
16
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
context "with no adapter name" do
|
22
|
-
before do
|
23
|
-
arguments.clear
|
24
|
-
end
|
25
|
-
|
26
|
-
it "defaults to shell adapter" do
|
27
|
-
Ellen::Adapters::Shell.any_instance.should_receive(:run)
|
28
|
-
call
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
context "with registered name" do
|
33
|
-
it "runs the adapter" do
|
34
|
-
Ellen::Adapters::Shell.any_instance.should_receive(:run)
|
35
|
-
call
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
context "with unregistered adapter name" do
|
40
|
-
let(:adapter_name) do
|
41
|
-
"unregistered"
|
42
|
-
end
|
43
|
-
|
44
|
-
it "exits with dying message" do
|
45
|
-
Ellen.logger.should_receive(:error).with("Error: No adapter is defined for `unregistered`")
|
46
|
-
expect { call }.to raise_error(SystemExit)
|
47
|
-
end
|
17
|
+
it "creates an adapter and calls .run to it" do
|
18
|
+
Ellen::Adapters::Shell.any_instance.should_receive(:run)
|
19
|
+
call
|
48
20
|
end
|
49
21
|
end
|
50
22
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ellen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryo Nakamura
|
@@ -187,6 +187,7 @@ files:
|
|
187
187
|
- lib/ellen/message.rb
|
188
188
|
- lib/ellen/robot.rb
|
189
189
|
- lib/ellen/version.rb
|
190
|
+
- spec/ellen/adapter_builder_spec.rb
|
190
191
|
- spec/ellen/commands/generate_spec.rb
|
191
192
|
- spec/ellen/commands/run_spec.rb
|
192
193
|
- spec/ellen/robot_spec.rb
|
@@ -217,6 +218,7 @@ signing_key:
|
|
217
218
|
specification_version: 4
|
218
219
|
summary: A chatterbot framework, inspired by Hubot
|
219
220
|
test_files:
|
221
|
+
- spec/ellen/adapter_builder_spec.rb
|
220
222
|
- spec/ellen/commands/generate_spec.rb
|
221
223
|
- spec/ellen/commands/run_spec.rb
|
222
224
|
- spec/ellen/robot_spec.rb
|