ellen 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4d5eded192c9ddbe27cc1945a8244b5cc74dbbcb
4
- data.tar.gz: 028bc33be16675edf0edaf6f9c17a375ec472441
3
+ metadata.gz: 203a4ce23b6169ee603f302c4cf4cb63c34aab9c
4
+ data.tar.gz: a72e3c466c75837836ea97bc6c27045c01cbf200
5
5
  SHA512:
6
- metadata.gz: 9f20921ead795cb4723da0952ed672b9ad453c98fb51a1e50e426837442b660f3dcf59c79ee060b3e6f74a6795f7096e29d34f66531379a08c23f61531174ef5
7
- data.tar.gz: f9e3d431ddb0eafc577bdfe94d10937ae23d33e1de38252ca9737c64516de134d619fca53ac3aef23d03e682ec4e01840e25309e960fbdc38431e991e9f35395
6
+ metadata.gz: 65b6421c0d520df08c9f9b47477dd2fb5e493f6b73c7586a68b260a9397b6c1a180f65e4f45066473e272869e9ca3fb02585d7fc8f54efef18e6d17efb211673
7
+ data.tar.gz: 0d27c7bad49d35166039e765cfeb61399456b9e31c68d0e08f1d08fcce071b3c412b3ff6fad9e49e3cc7cdb64eedf0b3e1a62a5a3714327a5db49e1f983079f3
data/.travis.yml ADDED
@@ -0,0 +1,10 @@
1
+ rvm:
2
+ - 1.9.3
3
+ - 2.0.0
4
+ - 2.1.0
5
+ branches:
6
+ only:
7
+ - master
8
+ env:
9
+ global:
10
+ secure: IFNYget7BZa+hDw+q0QZDtwkwwngTz/F96pB9gvE+U5y7UUAk6cI3dPEj0LYxRQZyLLi8R+aQ+MXY5Vw2q3vSQCUc/IGt6N/7O5L+X0ef8BzEiud4sLAGP3kXVgyAg1UtLjtLZcFWlQGvgj590r7X+1CgYHeLsnmXhXBVeBBYag=
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.0.8
2
+ * Mount Brain
3
+ * Change handler interface
4
+
1
5
  ## 0.0.7
2
6
  * Add PING handler
3
7
 
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
- # Ellen
1
+ # Ellen [![Build Status](https://travis-ci.org/r7kamura/ellen.png)](https://travis-ci.org/r7kamura/ellen) [![Code Climate](https://codeclimate.com/github/r7kamura/ellen.png)](https://codeclimate.com/github/r7kamura/ellen) [![Code Climate](https://codeclimate.com/github/r7kamura/ellen/coverage.png)](https://codeclimate.com/github/r7kamura/ellen)
2
+
2
3
  A chatterbot framework, inspired by Hubot.
3
4
 
4
5
  ## Dependencies
@@ -18,6 +19,7 @@ You can create your own handlers to add new behaviors from
18
19
  [Ellen::Handlers::Base](https://github.com/r7kamura/ellen/blob/master/lib/ellen/handlers/base.rb) DSL.
19
20
 
20
21
  * [Ellen::Handlers::Help](https://github.com/r7kamura/ellen/blob/master/lib/ellen/handlers/help.rb)
22
+ * [Ellen::Handlers::Ping](https://github.com/r7kamura/ellen/blob/master/lib/ellen/handlers/ping.rb)
21
23
  * [Ellen::Handlers::GoogleImage](https://github.com/r7kamura/ellen-google_image)
22
24
 
23
25
  ## Bundler
@@ -54,3 +56,6 @@ $ heroku scale bot=1
54
56
  $ heroku config:set FOO=1 BAR=2 BAZ=3
55
57
  $ git push heroku master
56
58
  ```
59
+
60
+ ## Screenshot
61
+ ![](https://raw.githubusercontent.com/r7kamura/ellen/master/images/screenshot.png)
data/ellen.gemspec CHANGED
@@ -21,7 +21,9 @@ Gem::Specification.new do |spec|
21
21
  spec.add_dependency "dotenv"
22
22
  spec.add_dependency "mem"
23
23
  spec.add_dependency "slop"
24
+ spec.add_development_dependency "codeclimate-test-reporter", ">= 0.3.0"
24
25
  spec.add_development_dependency "pry"
25
26
  spec.add_development_dependency "rake"
26
27
  spec.add_development_dependency "rspec", "2.14.1"
28
+ spec.add_development_dependency "simplecov"
27
29
  end
Binary file
data/lib/ellen/action.rb CHANGED
@@ -1,15 +1,14 @@
1
1
  module Ellen
2
2
  class Action
3
- attr_reader :block, :options, :pattern
3
+ attr_reader :options, :pattern
4
4
 
5
- def initialize(pattern, options = {}, &block)
5
+ def initialize(pattern, options = {})
6
6
  @pattern = pattern
7
7
  @options = options
8
- @block = block
9
8
  end
10
9
 
11
10
  def call(handler, message)
12
- handler.robot.instance_exec(message, &block) if message.match pattern_with(handler.robot.name)
11
+ handler.send(name, message) if message.match pattern_with(handler.robot.name)
13
12
  end
14
13
 
15
14
  def all?
@@ -20,6 +19,10 @@ module Ellen
20
19
  options[:description] || "(no description)"
21
20
  end
22
21
 
22
+ def name
23
+ options[:name]
24
+ end
25
+
23
26
  private
24
27
 
25
28
  def pattern_with(name)
@@ -0,0 +1,25 @@
1
+ module Ellen
2
+ module Brains
3
+ class Base
4
+ class << self
5
+ def inherited(child)
6
+ brain_classes << child
7
+ end
8
+
9
+ def find_class
10
+ brain_classes.last
11
+ end
12
+
13
+ private
14
+
15
+ def brain_classes
16
+ @brain_classes ||= []
17
+ end
18
+ end
19
+
20
+ def data
21
+ @data ||= {}
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,8 @@
1
+ module Ellen
2
+ module Brains
3
+ class Null < Base
4
+ def save
5
+ end
6
+ end
7
+ end
8
+ end
@@ -19,8 +19,8 @@ module Ellen
19
19
  Ellen.handlers << child
20
20
  end
21
21
 
22
- def on(pattern, options = {}, &block)
23
- actions << Action.new(pattern, options, &block)
22
+ def on(pattern, options = {})
23
+ actions << Action.new(pattern, options)
24
24
  end
25
25
 
26
26
  def actions
@@ -1,13 +1,15 @@
1
1
  module Ellen
2
2
  module Handlers
3
3
  class Help < Base
4
- on /help\z/i, description: "Show this help message" do |message|
4
+ on /help\z/i, name: "help", description: "Show this help message"
5
+
6
+ def help(message)
5
7
  lines = Ellen.handlers.map(&:actions).flatten.sort_by(&:all?).map do |action|
6
- prefix = "@#{name} " unless action.all?
8
+ prefix = "@#{robot.name} " unless action.all?
7
9
  line = "%-30s - #{action.description}" % "#{prefix}#{action.pattern.inspect}"
8
10
  line
9
11
  end
10
- say lines.join("\n")
12
+ robot.say lines.join("\n")
11
13
  end
12
14
  end
13
15
  end
@@ -1,8 +1,10 @@
1
1
  module Ellen
2
2
  module Handlers
3
3
  class Ping < Base
4
- on /ping\z/i, description: "Return PONG to PING" do |message|
5
- say message.body[-4..-1].gsub(/i/i, "i" => "o", "I" => "O")
4
+ on /ping\z/i, name: "ping", description: "Return PONG to PING"
5
+
6
+ def ping(message)
7
+ robot.say message.body[-4..-1].gsub(/i/i, "i" => "o", "I" => "O")
6
8
  end
7
9
  end
8
10
  end
data/lib/ellen/robot.rb CHANGED
@@ -31,6 +31,11 @@ module Ellen
31
31
  ENV["ROBOT_NAME"] || DEFAULT_ROBOT_NAME
32
32
  end
33
33
 
34
+ def brain
35
+ Brains::Base.find_class.new
36
+ end
37
+ memoize :brain
38
+
34
39
  private
35
40
 
36
41
  def adapt
data/lib/ellen/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ellen
2
- VERSION = "0.0.7"
2
+ VERSION = "0.0.8"
3
3
  end
data/lib/ellen.rb CHANGED
@@ -34,6 +34,8 @@ require "ellen/action"
34
34
  require "ellen/adapter_builder"
35
35
  require "ellen/adapters/base"
36
36
  require "ellen/adapters/shell"
37
+ require "ellen/brains/base"
38
+ require "ellen/brains/null"
37
39
  require "ellen/command_builder"
38
40
  require "ellen/commands/base"
39
41
  require "ellen/commands/generate"
@@ -0,0 +1,19 @@
1
+ require "spec_helper"
2
+
3
+ describe Ellen::Robot do
4
+ let(:instance) do
5
+ described_class.new(options)
6
+ end
7
+
8
+ let(:options) do
9
+ {}
10
+ end
11
+
12
+ describe "#brain" do
13
+ context "without any brain extension gem" do
14
+ it "returns a Ellen::Brains::Base" do
15
+ instance.brain.should be_a Ellen::Brains::Base
16
+ end
17
+ end
18
+ end
19
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,3 +1,11 @@
1
+ require "simplecov"
2
+ SimpleCov.start
3
+
4
+ if ENV["CI"]
5
+ require "codeclimate-test-reporter"
6
+ CodeClimate::TestReporter.start
7
+ end
8
+
1
9
  require "ellen"
2
10
 
3
11
  RSpec.configure do |config|
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.7
4
+ version: 0.0.8
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-16 00:00:00.000000000 Z
11
+ date: 2014-04-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: codeclimate-test-reporter
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: 0.3.0
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 0.3.0
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: pry
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -122,6 +136,20 @@ dependencies:
122
136
  - - '='
123
137
  - !ruby/object:Gem::Version
124
138
  version: 2.14.1
139
+ - !ruby/object:Gem::Dependency
140
+ name: simplecov
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
125
153
  description:
126
154
  email:
127
155
  - r7kamura@gmail.com
@@ -131,6 +159,7 @@ extensions: []
131
159
  extra_rdoc_files: []
132
160
  files:
133
161
  - ".gitignore"
162
+ - ".travis.yml"
134
163
  - CHANGELOG.md
135
164
  - Gemfile
136
165
  - LICENSE.txt
@@ -138,11 +167,14 @@ files:
138
167
  - Rakefile
139
168
  - bin/ellen
140
169
  - ellen.gemspec
170
+ - images/screenshot.png
141
171
  - lib/ellen.rb
142
172
  - lib/ellen/action.rb
143
173
  - lib/ellen/adapter_builder.rb
144
174
  - lib/ellen/adapters/base.rb
145
175
  - lib/ellen/adapters/shell.rb
176
+ - lib/ellen/brains/base.rb
177
+ - lib/ellen/brains/null.rb
146
178
  - lib/ellen/command_builder.rb
147
179
  - lib/ellen/commands/base.rb
148
180
  - lib/ellen/commands/generate.rb
@@ -157,6 +189,7 @@ files:
157
189
  - lib/ellen/version.rb
158
190
  - spec/ellen/commands/generate_spec.rb
159
191
  - spec/ellen/commands/run_spec.rb
192
+ - spec/ellen/robot_spec.rb
160
193
  - spec/spec_helper.rb
161
194
  - templates/Gemfile
162
195
  homepage: https://github.com/r7kamura/ellen
@@ -186,4 +219,5 @@ summary: A chatterbot framework, inspired by Hubot
186
219
  test_files:
187
220
  - spec/ellen/commands/generate_spec.rb
188
221
  - spec/ellen/commands/run_spec.rb
222
+ - spec/ellen/robot_spec.rb
189
223
  - spec/spec_helper.rb