ellen 0.2.5 → 0.2.6

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: b48f797e2220337f5bceb478fa8543b9754d47f6
4
- data.tar.gz: a1fd533f05151b984481e700e53604c5e10bfb77
3
+ metadata.gz: 42106e5b3f728f10699b2df58912880a79c5d7db
4
+ data.tar.gz: c1eaf31cb606523ad78ba27aee2c6307e19294da
5
5
  SHA512:
6
- metadata.gz: 4deb83f98d8366059279d4a4eaf86333e838138398655760f6b56e391176efa041a7d42077f8b18dafcca36fffa82037a70b9b30fbf5af736e267eca6f17c639
7
- data.tar.gz: f6fa7db604b6de626bcdbeb0a57389815f5231795e4d37cc9bae99c08cbe677db166c22b4ac3e4c8950f6311291f01d11461373937ae85f0950d58ec1c9156e8
6
+ metadata.gz: eb5824e7ccd1d278e83fbe1e897bd2fa34232434ad38cb49955789c23739fdf20431043343871226896403e1b06c598b4a2dfb15b2d630e960a8097e48eeeb71
7
+ data.tar.gz: e77767ace69af879d7d0effe41e24ae1c24c1cc7ed663d9233001025c08d0f7807c0a98f813743f4ede6690c68a84c9105f8e8d6883d2823fb28d10f7a85a4e0
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.2.6
2
+ * Add `who am i?` handler
3
+ * Sort commands in help message
4
+
1
5
  ## 0.2.5
2
6
  * Hide action defined with `:hidden` option in Help message
3
7
 
data/lib/ellen/action.rb CHANGED
@@ -31,6 +31,10 @@ module Ellen
31
31
  options[:name]
32
32
  end
33
33
 
34
+ def <=>(action)
35
+ pattern.to_s <=> action.pattern.to_s
36
+ end
37
+
34
38
  private
35
39
 
36
40
  def pattern_with(robot_name)
@@ -12,7 +12,7 @@ module Ellen
12
12
  end
13
13
 
14
14
  def action_descriptions
15
- Ellen.actions.reject(&:hidden?).map do |action|
15
+ Ellen.actions.reject(&:hidden?).sort.map do |action|
16
16
  prefix = ""
17
17
  prefix << message.robot.name << " " unless action.all?
18
18
  "%-#{pattern_max_length + prefix.size}s - #{action.description}" % "#{prefix}#{action.pattern.inspect}"
@@ -0,0 +1,9 @@
1
+ module Ellen
2
+ module Actions
3
+ class Whoami < Base
4
+ def call
5
+ message.reply(message.from)
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+ module Ellen
2
+ module Handlers
3
+ class Whoami < Base
4
+ on(
5
+ /who am i\?/i,
6
+ name: "whoami",
7
+ description: "Answer who you are",
8
+ )
9
+
10
+ def whoami(message)
11
+ Ellen::Actions::Whoami.new(message).call
12
+ end
13
+ end
14
+ end
15
+ end
data/lib/ellen/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ellen
2
- VERSION = "0.2.5"
2
+ VERSION = "0.2.6"
3
3
  end
data/lib/ellen.rb CHANGED
@@ -34,6 +34,7 @@ require "ellen/action"
34
34
  require "ellen/actions/base"
35
35
  require "ellen/actions/help"
36
36
  require "ellen/actions/ping"
37
+ require "ellen/actions/whoami"
37
38
  require "ellen/adapter_builder"
38
39
  require "ellen/env"
39
40
  require "ellen/env/missing_required_key_error"
@@ -50,6 +51,7 @@ require "ellen/commands/run"
50
51
  require "ellen/handlers/base"
51
52
  require "ellen/handlers/help"
52
53
  require "ellen/handlers/ping"
54
+ require "ellen/handlers/whoami"
53
55
  require "ellen/logger"
54
56
  require "ellen/message"
55
57
  require "ellen/robot"
@@ -18,6 +18,7 @@ describe Ellen::Handlers::Help do
18
18
  <<-EOS.strip_heredoc.strip
19
19
  ellen /help( me)?\\z/i - Show this help message
20
20
  ellen /ping\\z/i - Return PONG to PING
21
+ ellen /who am i\\?/i - Answer who you are
21
22
  EOS
22
23
  end
23
24
 
@@ -0,0 +1,36 @@
1
+ require "spec_helper"
2
+
3
+ describe Ellen::Handlers::Whoami do
4
+ let(:robot) do
5
+ Ellen::Robot.new
6
+ end
7
+
8
+ describe "#ping" do
9
+ let(:from) do
10
+ "alice"
11
+ end
12
+
13
+ let(:to) do
14
+ "#general"
15
+ end
16
+
17
+ let(:said) do
18
+ "@ellen Who am I?"
19
+ end
20
+
21
+ it "returns PONG to PING" do
22
+ robot.should_receive(:say).with(
23
+ body: from,
24
+ from: to,
25
+ to: from,
26
+ original: {
27
+ body: said,
28
+ from: from,
29
+ robot: robot,
30
+ to: to,
31
+ },
32
+ )
33
+ robot.receive(body: said, from: from, to: to)
34
+ end
35
+ end
36
+ 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.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryo Nakamura
@@ -173,6 +173,7 @@ files:
173
173
  - lib/ellen/actions/base.rb
174
174
  - lib/ellen/actions/help.rb
175
175
  - lib/ellen/actions/ping.rb
176
+ - lib/ellen/actions/whoami.rb
176
177
  - lib/ellen/adapter_builder.rb
177
178
  - lib/ellen/adapters/base.rb
178
179
  - lib/ellen/adapters/shell.rb
@@ -189,6 +190,7 @@ files:
189
190
  - lib/ellen/handlers/base.rb
190
191
  - lib/ellen/handlers/help.rb
191
192
  - lib/ellen/handlers/ping.rb
193
+ - lib/ellen/handlers/whoami.rb
192
194
  - lib/ellen/logger.rb
193
195
  - lib/ellen/message.rb
194
196
  - lib/ellen/robot.rb
@@ -201,6 +203,7 @@ files:
201
203
  - spec/ellen/handlers/base_spec.rb
202
204
  - spec/ellen/handlers/help_spec.rb
203
205
  - spec/ellen/handlers/ping_spec.rb
206
+ - spec/ellen/handlers/whoami_spec.rb
204
207
  - spec/ellen/robot_spec.rb
205
208
  - spec/spec_helper.rb
206
209
  - templates/Gemfile
@@ -237,6 +240,7 @@ test_files:
237
240
  - spec/ellen/handlers/base_spec.rb
238
241
  - spec/ellen/handlers/help_spec.rb
239
242
  - spec/ellen/handlers/ping_spec.rb
243
+ - spec/ellen/handlers/whoami_spec.rb
240
244
  - spec/ellen/robot_spec.rb
241
245
  - spec/spec_helper.rb
242
246
  has_rdoc: