edi 0.2.3 → 0.3.0
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 +4 -4
- data/edi.gemspec +1 -2
- data/lib/edi.rb +12 -2
- data/lib/edi/application.rb +4 -11
- data/lib/edi/core.rb +7 -0
- data/lib/edi/service_runner.rb +28 -0
- data/lib/edi/services/img_flip.rb +1 -1
- data/lib/edi/services/tweet_that.rb +1 -1
- data/lib/edi/slack.rb +2 -0
- data/lib/edi/slack/websocket_incoming_message.rb +32 -0
- data/lib/edi/slack/websocket_outgoing_message.rb +21 -0
- data/lib/edi/version.rb +1 -1
- data/lib/edi/websocket.rb +1 -0
- data/lib/edi/websocket/client.rb +47 -0
- data/spec/services/img_flip_spec.rb +14 -14
- data/spec/services/tweet_that_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- metadata +15 -86
- data/features/fact_service.feature +0 -7
- data/features/giphy_service.feature +0 -43
- data/features/i_heart_quotes_service.feature +0 -21
- data/features/img_flip_service.feature +0 -11
- data/features/step_definitions/fact_service_steps.rb +0 -7
- data/features/step_definitions/giphy_steps.rb +0 -3
- data/features/step_definitions/img_flip_steps.rb +0 -3
- data/features/step_definitions/server_steps.rb +0 -3
- data/features/step_definitions/tweet_that_steps.rb +0 -19
- data/features/step_definitions/weather_steps.rb +0 -3
- data/features/support/env.rb +0 -37
- data/features/support/hooks.rb +0 -1
- data/features/support/vcr_cassettes/Fact_Service/EDI_responds_with_a_random_fact.yml +0 -53
- data/features/support/vcr_cassettes/Fact_Service/Jarvis_responds_with_a_random_fact.yml +0 -52
- data/features/support/vcr_cassettes/Giphy_Service/Bacon.yml +0 -58
- data/features/support/vcr_cassettes/Giphy_Service/Cat_GIF_-_Cat_Wording.yml +0 -58
- data/features/support/vcr_cassettes/Giphy_Service/Cat_GIF_-_Kitty_Wording.yml +0 -58
- data/features/support/vcr_cassettes/Giphy_Service/Cat_GIF_-_Kitty_Wording_-_Case_Insensitive.yml +0 -58
- data/features/support/vcr_cassettes/Giphy_Service/Plain_old_GIF.yml +0 -58
- data/features/support/vcr_cassettes/Giphy_Service/Sloth.yml +0 -58
- data/features/support/vcr_cassettes/Giphy_Service/Trippy.yml +0 -58
- data/features/support/vcr_cassettes/I_Heart_Quotes/A_Random_Quote.yml +0 -44
- data/features/support/vcr_cassettes/I_Heart_Quotes/A_Simpsons_Quote.yml +0 -44
- data/features/support/vcr_cassettes/I_Heart_Quotes/A_Star_Wars_Quote.yml +0 -44
- data/features/support/vcr_cassettes/ImgFlip/Success_Kid.yml +0 -54
- data/features/support/vcr_cassettes/Tweet_that/Post_the_last_message_to_twitter.yml +0 -211
- data/features/support/vcr_cassettes/Weather_Service/Use_a_specified_location.yml +0 -86
- data/features/support/vcr_cassettes/Weather_Service/Use_default_location.yml +0 -86
- data/features/tweet_that_service.feature +0 -14
- data/features/weather_service.feature +0 -21
- data/lib/edi/server.rb +0 -45
- data/spec/edi/server_spec.rb +0 -20
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
http_interactions:
|
|
3
|
-
- request:
|
|
4
|
-
method: get
|
|
5
|
-
uri: http://api.zippopotam.us/us/90210
|
|
6
|
-
body:
|
|
7
|
-
encoding: US-ASCII
|
|
8
|
-
string: ''
|
|
9
|
-
headers:
|
|
10
|
-
Accept-Encoding:
|
|
11
|
-
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
12
|
-
Accept:
|
|
13
|
-
- "*/*"
|
|
14
|
-
User-Agent:
|
|
15
|
-
- Ruby
|
|
16
|
-
response:
|
|
17
|
-
status:
|
|
18
|
-
code: 200
|
|
19
|
-
message: OK
|
|
20
|
-
headers:
|
|
21
|
-
Date:
|
|
22
|
-
- Sun, 22 Feb 2015 01:42:27 GMT
|
|
23
|
-
Server:
|
|
24
|
-
- Apache/2.4.7
|
|
25
|
-
Content-Length:
|
|
26
|
-
- '225'
|
|
27
|
-
X-Cache:
|
|
28
|
-
- hit
|
|
29
|
-
Charset:
|
|
30
|
-
- UTF-8
|
|
31
|
-
Vary:
|
|
32
|
-
- Accept-Encoding
|
|
33
|
-
Access-Control-Allow-Origin:
|
|
34
|
-
- "*"
|
|
35
|
-
Content-Type:
|
|
36
|
-
- application/json
|
|
37
|
-
body:
|
|
38
|
-
encoding: UTF-8
|
|
39
|
-
string: '{"post code": "90210", "country": "United States", "country abbreviation":
|
|
40
|
-
"US", "places": [{"place name": "Beverly Hills", "longitude": "-118.4065",
|
|
41
|
-
"state": "California", "state abbreviation": "CA", "latitude": "34.0901"}]}'
|
|
42
|
-
http_version:
|
|
43
|
-
recorded_at: Sun, 22 Feb 2015 01:42:27 GMT
|
|
44
|
-
- request:
|
|
45
|
-
method: get
|
|
46
|
-
uri: http://api.openweathermap.org/data/2.5/weather?q=Beverly%20Hills,%20CA
|
|
47
|
-
body:
|
|
48
|
-
encoding: US-ASCII
|
|
49
|
-
string: ''
|
|
50
|
-
headers:
|
|
51
|
-
Accept-Encoding:
|
|
52
|
-
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
53
|
-
Accept:
|
|
54
|
-
- "*/*"
|
|
55
|
-
User-Agent:
|
|
56
|
-
- Ruby
|
|
57
|
-
response:
|
|
58
|
-
status:
|
|
59
|
-
code: 200
|
|
60
|
-
message: OK
|
|
61
|
-
headers:
|
|
62
|
-
Server:
|
|
63
|
-
- nginx
|
|
64
|
-
Date:
|
|
65
|
-
- Sun, 22 Feb 2015 01:42:27 GMT
|
|
66
|
-
Content-Type:
|
|
67
|
-
- application/json; charset=utf-8
|
|
68
|
-
Transfer-Encoding:
|
|
69
|
-
- chunked
|
|
70
|
-
Connection:
|
|
71
|
-
- keep-alive
|
|
72
|
-
X-Source:
|
|
73
|
-
- back
|
|
74
|
-
Access-Control-Allow-Origin:
|
|
75
|
-
- "*"
|
|
76
|
-
Access-Control-Allow-Credentials:
|
|
77
|
-
- 'true'
|
|
78
|
-
Access-Control-Allow-Methods:
|
|
79
|
-
- GET, POST
|
|
80
|
-
body:
|
|
81
|
-
encoding: UTF-8
|
|
82
|
-
string: |
|
|
83
|
-
{"coord":{"lon":-118.4,"lat":34.07},"sys":{"message":0.0043,"country":"United States of America","sunrise":1424615395,"sunset":1424655844},"weather":[{"id":803,"main":"Clouds","description":"broken clouds","icon":"04n"}],"base":"cmc stations","main":{"temp":284.384,"temp_min":284.384,"temp_max":284.384,"pressure":954.59,"sea_level":1024.84,"grnd_level":954.59,"humidity":86},"wind":{"speed":1.11,"deg":193.001},"clouds":{"all":56},"dt":1424568754,"id":5328041,"name":"Beverly Hills","cod":200}
|
|
84
|
-
http_version:
|
|
85
|
-
recorded_at: Sun, 22 Feb 2015 01:42:27 GMT
|
|
86
|
-
recorded_with: VCR 2.9.3
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
http_interactions:
|
|
3
|
-
- request:
|
|
4
|
-
method: get
|
|
5
|
-
uri: http://api.zippopotam.us/us/43204
|
|
6
|
-
body:
|
|
7
|
-
encoding: US-ASCII
|
|
8
|
-
string: ''
|
|
9
|
-
headers:
|
|
10
|
-
Accept-Encoding:
|
|
11
|
-
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
12
|
-
Accept:
|
|
13
|
-
- "*/*"
|
|
14
|
-
User-Agent:
|
|
15
|
-
- Ruby
|
|
16
|
-
response:
|
|
17
|
-
status:
|
|
18
|
-
code: 200
|
|
19
|
-
message: OK
|
|
20
|
-
headers:
|
|
21
|
-
Date:
|
|
22
|
-
- Sun, 22 Feb 2015 01:41:52 GMT
|
|
23
|
-
Server:
|
|
24
|
-
- Apache/2.4.7
|
|
25
|
-
Content-Length:
|
|
26
|
-
- '212'
|
|
27
|
-
X-Cache:
|
|
28
|
-
- hit
|
|
29
|
-
Charset:
|
|
30
|
-
- UTF-8
|
|
31
|
-
Vary:
|
|
32
|
-
- Accept-Encoding
|
|
33
|
-
Access-Control-Allow-Origin:
|
|
34
|
-
- "*"
|
|
35
|
-
Content-Type:
|
|
36
|
-
- application/json
|
|
37
|
-
body:
|
|
38
|
-
encoding: UTF-8
|
|
39
|
-
string: '{"post code": "43204", "country": "United States", "country abbreviation":
|
|
40
|
-
"US", "places": [{"place name": "Columbus", "longitude": "-83.078", "state":
|
|
41
|
-
"Ohio", "state abbreviation": "OH", "latitude": "39.9523"}]}'
|
|
42
|
-
http_version:
|
|
43
|
-
recorded_at: Sun, 22 Feb 2015 01:41:52 GMT
|
|
44
|
-
- request:
|
|
45
|
-
method: get
|
|
46
|
-
uri: http://api.openweathermap.org/data/2.5/weather?q=Columbus,%20OH
|
|
47
|
-
body:
|
|
48
|
-
encoding: US-ASCII
|
|
49
|
-
string: ''
|
|
50
|
-
headers:
|
|
51
|
-
Accept-Encoding:
|
|
52
|
-
- gzip;q=1.0,deflate;q=0.6,identity;q=0.3
|
|
53
|
-
Accept:
|
|
54
|
-
- "*/*"
|
|
55
|
-
User-Agent:
|
|
56
|
-
- Ruby
|
|
57
|
-
response:
|
|
58
|
-
status:
|
|
59
|
-
code: 200
|
|
60
|
-
message: OK
|
|
61
|
-
headers:
|
|
62
|
-
Server:
|
|
63
|
-
- nginx
|
|
64
|
-
Date:
|
|
65
|
-
- Sun, 22 Feb 2015 01:41:52 GMT
|
|
66
|
-
Content-Type:
|
|
67
|
-
- application/json; charset=utf-8
|
|
68
|
-
Transfer-Encoding:
|
|
69
|
-
- chunked
|
|
70
|
-
Connection:
|
|
71
|
-
- keep-alive
|
|
72
|
-
X-Source:
|
|
73
|
-
- back
|
|
74
|
-
Access-Control-Allow-Origin:
|
|
75
|
-
- "*"
|
|
76
|
-
Access-Control-Allow-Credentials:
|
|
77
|
-
- 'true'
|
|
78
|
-
Access-Control-Allow-Methods:
|
|
79
|
-
- GET, POST
|
|
80
|
-
body:
|
|
81
|
-
encoding: UTF-8
|
|
82
|
-
string: |
|
|
83
|
-
{"coord":{"lon":-83,"lat":39.96},"sys":{"message":0.0235,"country":"United States of America","sunrise":1424607278,"sunset":1424646972},"weather":[{"id":500,"main":"Rain","description":"light rain","icon":"10n"}],"base":"cmc stations","main":{"temp":277.284,"temp_min":277.284,"temp_max":277.284,"pressure":996.01,"sea_level":1029.3,"grnd_level":996.01,"humidity":99},"wind":{"speed":1.66,"deg":140.001},"clouds":{"all":92},"rain":{"3h":2},"dt":1424569257,"id":4509177,"name":"Columbus","cod":200}
|
|
84
|
-
http_version:
|
|
85
|
-
recorded_at: Sun, 22 Feb 2015 01:41:52 GMT
|
|
86
|
-
recorded_with: VCR 2.9.3
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
@vcr
|
|
2
|
-
Feature: Tweet that
|
|
3
|
-
|
|
4
|
-
Because stuff with no context is funny
|
|
5
|
-
As a twitter user
|
|
6
|
-
I want EDI to post the last message to twitter
|
|
7
|
-
|
|
8
|
-
Background:
|
|
9
|
-
Given the Tweet That is configured
|
|
10
|
-
|
|
11
|
-
Scenario: Post the last message to twitter
|
|
12
|
-
Given a server is running with the tweet that service enabled
|
|
13
|
-
When the user DVG post a message to the general channel saying "EDI, tweet that"
|
|
14
|
-
Then EDI will respond with "Here you are, DVG, https://twitter.com/twitter_handle/status/569329768350380032"
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
@vcr
|
|
2
|
-
|
|
3
|
-
Feature: Weather Service
|
|
4
|
-
|
|
5
|
-
Because I live in the midwest
|
|
6
|
-
As a person who doesn't want to get rained on
|
|
7
|
-
I want EDI to tell me if I need an umbrella
|
|
8
|
-
|
|
9
|
-
Background:
|
|
10
|
-
Given a default location of 43240
|
|
11
|
-
|
|
12
|
-
Scenario: Use default location
|
|
13
|
-
Given a server is running with the weather service enabled
|
|
14
|
-
When EDI recieves the message "EDI what's the weather like?"
|
|
15
|
-
Then EDI will respond with "Light rain. The temperature is currently 38"
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
Scenario: Use a specified location
|
|
19
|
-
Given a server is running with the weather service enabled
|
|
20
|
-
When EDI recieves the message "EDI what's the weather like in 90210?"
|
|
21
|
-
Then EDI will respond with "Broken clouds. The temperature is currently 51"
|
data/lib/edi/server.rb
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
require 'sinatra'
|
|
2
|
-
require "sinatra/json"
|
|
3
|
-
require "sinatra/multi_route"
|
|
4
|
-
require 'json'
|
|
5
|
-
|
|
6
|
-
module EDI
|
|
7
|
-
class Server < Sinatra::Base
|
|
8
|
-
register Sinatra::MultiRoute
|
|
9
|
-
|
|
10
|
-
get "/" do
|
|
11
|
-
json text: EDI::ArrayResponder.new(EDI.config.hello_message).respond
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
route :get, :post, "/edi" do
|
|
15
|
-
message = Slack::Message.new(params)
|
|
16
|
-
service = EDI::Interpreter.new(message).determine_service.new(message)
|
|
17
|
-
begin
|
|
18
|
-
json text: run_service(service)
|
|
19
|
-
rescue EDI::UnfitEnvironmentException => e
|
|
20
|
-
json text: EDI::ArrayResponder.new(EDI.config.unfit_environment_response).respond
|
|
21
|
-
rescue EDI::ThirdPartyAPIFailure
|
|
22
|
-
json text: EDI::ArrayResponder.new(EDI.config.third_party_api_failure_respone).respond
|
|
23
|
-
rescue => e
|
|
24
|
-
json text: EDI::ArrayResponder.new(EDI.config.standard_error_response).respond
|
|
25
|
-
end
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
get "/keepalive" do
|
|
29
|
-
json text: "Blah"
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def self.register_services(*args)
|
|
33
|
-
EDI.register_services *args
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
private
|
|
37
|
-
|
|
38
|
-
def run_service(service)
|
|
39
|
-
service.validate_environment
|
|
40
|
-
service.invoke
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
run! if app_file == $0
|
|
44
|
-
end
|
|
45
|
-
end
|
data/spec/edi/server_spec.rb
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
require 'spec_helper'
|
|
2
|
-
|
|
3
|
-
RSpec.describe EDI::Server do
|
|
4
|
-
let(:parsed_response) { JSON.parse(last_response.body) }
|
|
5
|
-
let(:message) { parsed_response["text"] }
|
|
6
|
-
describe "get /" do
|
|
7
|
-
before { get "/" }
|
|
8
|
-
it { expect(last_response).to be_ok }
|
|
9
|
-
it { expect(message).to eq "Hello, I'm EDI" }
|
|
10
|
-
end
|
|
11
|
-
|
|
12
|
-
describe "unfit environment" do
|
|
13
|
-
let(:slack_message) { slack_outgoing_message(text: "EDI, success kid blah blah blah") }
|
|
14
|
-
before { service.environment :blah }
|
|
15
|
-
before { service.phrases "success kid" }
|
|
16
|
-
before { EDI.register_services :test_service }
|
|
17
|
-
before { post "/edi", slack_message }
|
|
18
|
-
it { expect(message).to eq "I'm really sorry, but that service needs to be configured" }
|
|
19
|
-
end
|
|
20
|
-
end
|