edi 0.3.4 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 49b443b32994361ff1476b80c9170b541165d7c2
4
- data.tar.gz: 3393b9b90969d9619a08e9c132f84cc5e535859e
3
+ metadata.gz: e58b16b135e152636c1cac5801c1202469b77775
4
+ data.tar.gz: ebb7220b6e05bb58c838fa677e33f6a05e41316b
5
5
  SHA512:
6
- metadata.gz: d62316c9aa4da46aad19d6d1ff4df57fb9b0c3faefe2519903131fce135a20e35587883650cba2568788ef499dd4dc31cc37eaf1cdf0ef831a6ee28c3c787f89
7
- data.tar.gz: bd9580510b9280dabd57e8340e1ab9008c77ba155a17750d525a3ac14ba4d8e9e197a73ff7c941b2c1ffe1ddbbc8ceed86e9c85a88aff34a0e25fcaeb4d33589
6
+ metadata.gz: 811b359111df50176f17dbfdb47a65e50ff57387df17dbfa8c6b9181c4c18c339cee953d782bb551c4a48139caae5ce4e91119b8d1139ef7c2b3f6b46f76a766
7
+ data.tar.gz: 973f43e01e447e95117d1b214acb8ddb215693b6f0762fb10575f379ecdf17460e17ba7177e0a827287fb9cc96f5e60a5db1cb4be750f4aedde6031925628311
data/README.md CHANGED
@@ -106,6 +106,16 @@ class Joke < EDI::Service
106
106
  end
107
107
  ```
108
108
 
109
+ ## Deployment
110
+
111
+ Since EDI is, under the hood, a web socket client, it can be deployed to any internet connected computer, and does not require a web server. Simple run
112
+
113
+ ```shell
114
+ $ edi start -D
115
+ ```
116
+
117
+ And EDI will connect to slack and will stay connected for the life of the process.
118
+
109
119
  ## Ship List
110
120
 
111
121
  When these things are done, we'll be ready for 1.0
@@ -117,6 +127,7 @@ When these things are done, we'll be ready for 1.0
117
127
  - [x] Service Generator
118
128
  - [x] Configure All The Things
119
129
  - [x] Boot Process for the Generated App
130
+ - [x] Switch from sinatra-based incoming and outgoing webhooks to websocket-based implementation
120
131
 
121
132
  ## Upcoming Features
122
133
 
@@ -128,7 +139,7 @@ You can make special classes that model special messages you'd like EDI to send
128
139
 
129
140
  ```ruby
130
141
  class CiMessage < EDI::Message
131
- channel "#general":w
142
+ channel "#general"
132
143
 
133
144
  end
134
145
  ```
@@ -1,5 +1,5 @@
1
1
  class NullService < EDI::Service
2
2
  def run
3
- EDI::ArrayResponder.new(EDI.config.default_response).respond
3
+ nil
4
4
  end
5
5
  end
@@ -23,7 +23,7 @@ module Slack
23
23
 
24
24
  def mentions_edi?
25
25
  if text
26
- text.match /#{EDI.bot_name}/i
26
+ !!text.match(/#{EDI.bot_name}(\W|$)/i)
27
27
  else
28
28
  false
29
29
  end
@@ -1,3 +1,3 @@
1
1
  module EDI
2
- VERSION = "0.3.4"
2
+ VERSION = "0.3.5"
3
3
  end
@@ -25,7 +25,7 @@ module Websocket
25
25
  if incoming_message.should_respond?
26
26
  response_text = ""
27
27
  service = Proc.new { response_text = EDI.runner.new(message: incoming_message).execute }
28
- response = Proc.new { client.send Slack::WebsocketOutgoingMessage.new(text: response_text, channel: incoming_message.channel, id: id).to_json }
28
+ response = Proc.new { client.send Slack::WebsocketOutgoingMessage.new(text: response_text, channel: incoming_message.channel, id: id).to_json if response_text }
29
29
  EM.defer service, response
30
30
  increment_id
31
31
  end
@@ -0,0 +1,42 @@
1
+ require 'spec_helper'
2
+ require 'json'
3
+
4
+ RSpec.describe Slack::WebsocketIncomingMessage do
5
+ subject { described_class.new params }
6
+ describe "Case Insensitive" do
7
+ context "Lowercase" do
8
+ let(:params) { {type: "message", text: "hello edi"}.to_json }
9
+ it { expect(subject.mentions_edi?).to eq true }
10
+ end
11
+
12
+ context "uppercase" do
13
+ let(:params) { {type: "message", text: "hello EDI"}.to_json }
14
+ it { expect(subject.mentions_edi?).to eq true }
15
+ end
16
+ end
17
+
18
+ describe "Responds when edi is followed by !" do
19
+ let(:params) { {type: "message", text: "hello edi!"}.to_json }
20
+ it { expect(subject.mentions_edi?).to eq true }
21
+ end
22
+
23
+ describe "Responds when edi is followed by ." do
24
+ let(:params) { {type: "message", text: "hello edi."}.to_json }
25
+ it { expect(subject.mentions_edi?).to eq true }
26
+ end
27
+
28
+ describe "Responds when edi is followed by ?" do
29
+ let(:params) { {type: "message", text: "hello edi?"}.to_json }
30
+ it { expect(subject.mentions_edi?).to eq true }
31
+ end
32
+
33
+ describe "Responds when edi is followed by ," do
34
+ let(:params) { {type: "message", text: "hello edi,"}.to_json }
35
+ it { expect(subject.mentions_edi?).to eq true }
36
+ end
37
+
38
+ describe "Doesn't respond when edi is part of a larger word" do
39
+ let(:params) { {type: "message", text: "I should edit that file"}.to_json }
40
+ it { expect(subject.mentions_edi?).to eq false }
41
+ end
42
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: edi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.4
4
+ version: 0.3.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - DVG
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-21 00:00:00.000000000 Z
11
+ date: 2015-03-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -365,6 +365,7 @@ files:
365
365
  - spec/services/null_service_spec.rb
366
366
  - spec/services/tweet_that_spec.rb
367
367
  - spec/services/weather_spec.rb
368
+ - spec/slack/websocket_incoming_message_spec.rb
368
369
  - spec/spec_helper.rb
369
370
  - spec/support/fixtures/vcr_cassettes/fact.yml
370
371
  - spec/support/fixtures/vcr_cassettes/giphy.yml
@@ -434,6 +435,7 @@ test_files:
434
435
  - spec/services/null_service_spec.rb
435
436
  - spec/services/tweet_that_spec.rb
436
437
  - spec/services/weather_spec.rb
438
+ - spec/slack/websocket_incoming_message_spec.rb
437
439
  - spec/spec_helper.rb
438
440
  - spec/support/fixtures/vcr_cassettes/fact.yml
439
441
  - spec/support/fixtures/vcr_cassettes/giphy.yml