jarvis-cli 0.0.5 → 0.0.6

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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/Guardfile +47 -0
  3. data/Rakefile +9 -0
  4. data/features/giphy_service.feature +3 -0
  5. data/features/i_heart_quotes_service.feature +21 -0
  6. data/features/step_definitions/giphy_steps.rb +3 -0
  7. data/features/step_definitions/server_steps.rb +1 -1
  8. data/features/step_definitions/weather_steps.rb +3 -0
  9. data/features/support/env.rb +1 -2
  10. data/features/support/vcr_cassettes/Giphy_Service/Bacon.yml +2 -2
  11. data/features/support/vcr_cassettes/Giphy_Service/Cat_GIF_-_Cat_Wording.yml +2 -2
  12. data/features/support/vcr_cassettes/Giphy_Service/Cat_GIF_-_Kitty_Wording.yml +2 -2
  13. data/features/support/vcr_cassettes/Giphy_Service/Cat_GIF_-_Kitty_Wording_-_Case_Insensitive.yml +2 -2
  14. data/features/support/vcr_cassettes/Giphy_Service/Plain_old_GIF.yml +2 -2
  15. data/features/support/vcr_cassettes/Giphy_Service/Sloth.yml +2 -2
  16. data/features/support/vcr_cassettes/Giphy_Service/Trippy.yml +2 -2
  17. data/features/support/vcr_cassettes/I_Heart_Quotes/A_Random_Quote.yml +44 -0
  18. data/features/support/vcr_cassettes/I_Heart_Quotes/A_Simpsons_Quote.yml +44 -0
  19. data/features/support/vcr_cassettes/I_Heart_Quotes/A_Star_Wars_Quote.yml +44 -0
  20. data/features/support/vcr_cassettes/Weather_Service/Use_a_specified_location.yml +86 -0
  21. data/features/support/vcr_cassettes/Weather_Service/Use_default_location.yml +86 -0
  22. data/features/weather_service.feature +21 -0
  23. data/jarvis-cli.gemspec +4 -0
  24. data/lib/jarvis.rb +8 -0
  25. data/lib/jarvis/api/response.rb +11 -1
  26. data/lib/jarvis/refinements.rb +1 -0
  27. data/lib/jarvis/refinements/zip_refinement.rb +11 -0
  28. data/lib/jarvis/server.rb +1 -1
  29. data/lib/jarvis/service.rb +2 -2
  30. data/lib/jarvis/services.rb +2 -0
  31. data/lib/jarvis/services/fact.rb +1 -1
  32. data/lib/jarvis/services/i_heart_quotes.rb +29 -0
  33. data/lib/jarvis/services/weather.rb +42 -0
  34. data/lib/jarvis/test_support/cucumber.rb +1 -0
  35. data/lib/jarvis/test_support/test_support.rb +7 -0
  36. data/lib/jarvis/version.rb +1 -1
  37. data/spec/jarvis/jarvis_spec.rb +6 -0
  38. data/spec/services/giphy_spec.rb +1 -0
  39. data/spec/services/i_heart_quotes_spec.rb +50 -0
  40. data/spec/services/weather_spec.rb +17 -0
  41. data/spec/spec_helper.rb +0 -6
  42. data/spec/support/fixtures/vcr_cassettes/giphy.yml +240 -5
  43. data/spec/support/fixtures/vcr_cassettes/i_heart_quotes.yml +222 -0
  44. data/spec/support/fixtures/vcr_cassettes/weather.yml +346 -0
  45. data/templates/project/bot/server.rb +1 -1
  46. metadata +90 -2
@@ -0,0 +1,222 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api.giphy.com//gifs/random?api_key=
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: 404
19
+ message: Not Found
20
+ headers:
21
+ Accept-Ranges:
22
+ - bytes
23
+ Age:
24
+ - '0'
25
+ Content-Type:
26
+ - application/json
27
+ Date:
28
+ - Sat, 21 Feb 2015 02:10:01 GMT
29
+ Server:
30
+ - nginx/1.4.6 (Ubuntu)
31
+ Vary:
32
+ - Accept-Encoding
33
+ Via:
34
+ - 1.1 varnish
35
+ X-Powered-By:
36
+ - PHP/5.5.9-1ubuntu4
37
+ X-Varnish:
38
+ - '1468789280'
39
+ Content-Length:
40
+ - '63'
41
+ Connection:
42
+ - keep-alive
43
+ body:
44
+ encoding: UTF-8
45
+ string: |2-
46
+
47
+ {"meta":{"status":404,"msg":"Not Found!"}}
48
+ http_version:
49
+ recorded_at: Sat, 21 Feb 2015 02:10:05 GMT
50
+ - request:
51
+ method: get
52
+ uri: http://iheartquotes.com/api/v1/random?format=json
53
+ body:
54
+ encoding: US-ASCII
55
+ string: ''
56
+ headers:
57
+ Accept-Encoding:
58
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
59
+ Accept:
60
+ - "*/*"
61
+ User-Agent:
62
+ - Ruby
63
+ response:
64
+ status:
65
+ code: 200
66
+ message: OK
67
+ headers:
68
+ Connection:
69
+ - close
70
+ Etag:
71
+ - '"19231bcf5bbdafee30ecabf324dad23e"'
72
+ X-Ua-Compatible:
73
+ - IE=Edge,chrome=1
74
+ Date:
75
+ - Sat, 21 Feb 2015 02:12:55 GMT
76
+ X-Runtime:
77
+ - '0.074872'
78
+ Content-Type:
79
+ - application/json; charset=utf-8
80
+ Cache-Control:
81
+ - max-age=0, private, must-revalidate
82
+ Server:
83
+ - thin 1.2.6 codename Crazy Delicious
84
+ Via:
85
+ - 1.1 vegur
86
+ body:
87
+ encoding: UTF-8
88
+ string: '{"json_class":"Fortune","tags":["platitudes","publilius_syrus"],"quote":"Prosperity
89
+ makes friends, adversity tries them.\n\t\t-- Publilius Syrus","link":"http://iheartquotes.com/fortune/show/51230","source":"fortune"}'
90
+ http_version:
91
+ recorded_at: Sat, 21 Feb 2015 02:12:55 GMT
92
+ - request:
93
+ method: get
94
+ uri: http://iheartquotes.com/api/v1/random?format=json
95
+ body:
96
+ encoding: US-ASCII
97
+ string: ''
98
+ headers:
99
+ Accept-Encoding:
100
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
101
+ Accept:
102
+ - "*/*"
103
+ User-Agent:
104
+ - Ruby
105
+ response:
106
+ status:
107
+ code: 200
108
+ message: OK
109
+ headers:
110
+ Connection:
111
+ - close
112
+ Etag:
113
+ - '"65fb4535baef9c1655272f94a923fb71"'
114
+ X-Ua-Compatible:
115
+ - IE=Edge,chrome=1
116
+ Date:
117
+ - Sat, 21 Feb 2015 02:39:02 GMT
118
+ X-Runtime:
119
+ - '0.074269'
120
+ Content-Type:
121
+ - application/json; charset=utf-8
122
+ Cache-Control:
123
+ - max-age=0, private, must-revalidate
124
+ Server:
125
+ - thin 1.2.6 codename Crazy Delicious
126
+ Via:
127
+ - 1.1 vegur
128
+ body:
129
+ encoding: UTF-8
130
+ string: '{"json_class":"Fortune","tags":["codehappy"],"quote":"If you will practice
131
+ being fictional for a while, you will understand that\r\nfictional characters
132
+ are sometimes more real than people with bodies and\r\nheartbeats.","link":"http://iheartquotes.com/fortune/show/30552","source":"codehappy"}'
133
+ http_version:
134
+ recorded_at: Sat, 21 Feb 2015 02:39:02 GMT
135
+ - request:
136
+ method: get
137
+ uri: http://iheartquotes.com/api/v1/random?format=json&source=simpsons_homer
138
+ body:
139
+ encoding: US-ASCII
140
+ string: ''
141
+ headers:
142
+ Accept-Encoding:
143
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
144
+ Accept:
145
+ - "*/*"
146
+ User-Agent:
147
+ - Ruby
148
+ response:
149
+ status:
150
+ code: 200
151
+ message: OK
152
+ headers:
153
+ Connection:
154
+ - close
155
+ Etag:
156
+ - '"499fdfbaa6284d08f3b1f84d5dc92547"'
157
+ X-Ua-Compatible:
158
+ - IE=Edge,chrome=1
159
+ Date:
160
+ - Sat, 21 Feb 2015 03:00:33 GMT
161
+ X-Runtime:
162
+ - '0.008960'
163
+ Content-Type:
164
+ - application/json; charset=utf-8
165
+ Cache-Control:
166
+ - max-age=0, private, must-revalidate
167
+ Server:
168
+ - thin 1.2.6 codename Crazy Delicious
169
+ Via:
170
+ - 1.1 vegur
171
+ body:
172
+ encoding: UTF-8
173
+ string: '{"json_class":"Fortune","tags":["simpsons_homer"],"quote":"Homer:\tI
174
+ don''t want you to see me sitting on my worthless butt.\n\nBart:\tWe''ve seen
175
+ it, Dad.\n\n\t\t Homer at the Bat","link":"http://iheartquotes.com/fortune/show/5519","source":"simpsons_homer"}'
176
+ http_version:
177
+ recorded_at: Sat, 21 Feb 2015 03:00:33 GMT
178
+ - request:
179
+ method: get
180
+ uri: http://iheartquotes.com/api/v1/random?format=json&source=starwars
181
+ body:
182
+ encoding: US-ASCII
183
+ string: ''
184
+ headers:
185
+ Accept-Encoding:
186
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
187
+ Accept:
188
+ - "*/*"
189
+ User-Agent:
190
+ - Ruby
191
+ response:
192
+ status:
193
+ code: 200
194
+ message: OK
195
+ headers:
196
+ Connection:
197
+ - close
198
+ Etag:
199
+ - '"59651e5c2e7322c2f642af48dc409df9"'
200
+ X-Ua-Compatible:
201
+ - IE=Edge,chrome=1
202
+ Date:
203
+ - Sat, 21 Feb 2015 03:02:10 GMT
204
+ X-Runtime:
205
+ - '0.013754'
206
+ Content-Type:
207
+ - application/json; charset=utf-8
208
+ Cache-Control:
209
+ - max-age=0, private, must-revalidate
210
+ Server:
211
+ - thin 1.2.6 codename Crazy Delicious
212
+ Via:
213
+ - 1.1 vegur
214
+ body:
215
+ encoding: UTF-8
216
+ string: '{"json_class":"Fortune","tags":["starwars"],"quote":"Han Solo:\n\tAfraid
217
+ I was gonna leave without giving you a\n\tgoodbye kiss?\nPrincess Leia:\n\tI''d
218
+ just as soon kiss a Wookiee!\nHan Solo:\n\tI can arrange that! You could use
219
+ a good kiss!","link":"http://iheartquotes.com/fortune/show/1293","source":"starwars"}'
220
+ http_version:
221
+ recorded_at: Sat, 21 Feb 2015 03:02:10 GMT
222
+ recorded_with: VCR 2.9.3
@@ -0,0 +1,346 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: http://api.zippopotam.us/us/90201
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 00:06:30 GMT
23
+ Server:
24
+ - Apache/2.4.7
25
+ Content-Length:
26
+ - '216'
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": "90201", "country": "United States", "country abbreviation":
40
+ "US", "places": [{"place name": "Bell", "longitude": "-118.1689", "state":
41
+ "California", "state abbreviation": "CA", "latitude": "33.9767"}]}'
42
+ http_version:
43
+ recorded_at: Sun, 22 Feb 2015 00:06:30 GMT
44
+ - request:
45
+ method: get
46
+ uri: http://api.zippopotam.us/us/90201
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
+ Date:
63
+ - Sun, 22 Feb 2015 01:11:54 GMT
64
+ Server:
65
+ - Apache/2.2.15 (CentOS)
66
+ Content-Length:
67
+ - '216'
68
+ X-Cache:
69
+ - hit
70
+ Charset:
71
+ - UTF-8
72
+ Vary:
73
+ - Accept-Encoding
74
+ Access-Control-Allow-Origin:
75
+ - "*"
76
+ Connection:
77
+ - close
78
+ Content-Type:
79
+ - application/json
80
+ body:
81
+ encoding: UTF-8
82
+ string: '{"post code": "90201", "country": "United States", "country abbreviation":
83
+ "US", "places": [{"place name": "Bell", "longitude": "-118.1689", "state":
84
+ "California", "state abbreviation": "CA", "latitude": "33.9767"}]}'
85
+ http_version:
86
+ recorded_at: Sun, 22 Feb 2015 00:08:25 GMT
87
+ - request:
88
+ method: get
89
+ uri: http://api.zippopotam.us/us/90201
90
+ body:
91
+ encoding: US-ASCII
92
+ string: ''
93
+ headers:
94
+ Accept-Encoding:
95
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
96
+ Accept:
97
+ - "*/*"
98
+ User-Agent:
99
+ - Ruby
100
+ response:
101
+ status:
102
+ code: 200
103
+ message: OK
104
+ headers:
105
+ Date:
106
+ - Sun, 22 Feb 2015 00:08:30 GMT
107
+ Server:
108
+ - Apache/2.4.7
109
+ Content-Length:
110
+ - '216'
111
+ X-Cache:
112
+ - hit
113
+ Charset:
114
+ - UTF-8
115
+ Vary:
116
+ - Accept-Encoding
117
+ Access-Control-Allow-Origin:
118
+ - "*"
119
+ Content-Type:
120
+ - application/json
121
+ body:
122
+ encoding: UTF-8
123
+ string: '{"post code": "90201", "country": "United States", "country abbreviation":
124
+ "US", "places": [{"place name": "Bell", "longitude": "-118.1689", "state":
125
+ "California", "state abbreviation": "CA", "latitude": "33.9767"}]}'
126
+ http_version:
127
+ recorded_at: Sun, 22 Feb 2015 00:08:30 GMT
128
+ - request:
129
+ method: get
130
+ uri: http://api.zippopotam.us/us/90210
131
+ body:
132
+ encoding: US-ASCII
133
+ string: ''
134
+ headers:
135
+ Accept-Encoding:
136
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
137
+ Accept:
138
+ - "*/*"
139
+ User-Agent:
140
+ - Ruby
141
+ response:
142
+ status:
143
+ code: 200
144
+ message: OK
145
+ headers:
146
+ Date:
147
+ - Sun, 22 Feb 2015 00:10:03 GMT
148
+ Server:
149
+ - Apache/2.4.7
150
+ Content-Length:
151
+ - '225'
152
+ X-Cache:
153
+ - hit
154
+ Charset:
155
+ - UTF-8
156
+ Vary:
157
+ - Accept-Encoding
158
+ Access-Control-Allow-Origin:
159
+ - "*"
160
+ Content-Type:
161
+ - application/json
162
+ body:
163
+ encoding: UTF-8
164
+ string: '{"post code": "90210", "country": "United States", "country abbreviation":
165
+ "US", "places": [{"place name": "Beverly Hills", "longitude": "-118.4065",
166
+ "state": "California", "state abbreviation": "CA", "latitude": "34.0901"}]}'
167
+ http_version:
168
+ recorded_at: Sun, 22 Feb 2015 00:10:03 GMT
169
+ - request:
170
+ method: get
171
+ uri: http://api.openweathermap.org/data/2.5/weather?q=Beverly%20Hills,%20CA
172
+ body:
173
+ encoding: US-ASCII
174
+ string: ''
175
+ headers:
176
+ Accept-Encoding:
177
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
178
+ Accept:
179
+ - "*/*"
180
+ User-Agent:
181
+ - Ruby
182
+ response:
183
+ status:
184
+ code: 200
185
+ message: OK
186
+ headers:
187
+ Server:
188
+ - nginx
189
+ Date:
190
+ - Sun, 22 Feb 2015 00:24:09 GMT
191
+ Content-Type:
192
+ - application/json; charset=utf-8
193
+ Transfer-Encoding:
194
+ - chunked
195
+ Connection:
196
+ - keep-alive
197
+ X-Source:
198
+ - back
199
+ Access-Control-Allow-Origin:
200
+ - "*"
201
+ Access-Control-Allow-Credentials:
202
+ - 'true'
203
+ Access-Control-Allow-Methods:
204
+ - GET, POST
205
+ body:
206
+ encoding: UTF-8
207
+ string: |
208
+ {"coord":{"lon":-118.4,"lat":34.07},"sys":{"message":0.0204,"country":"United States of America","sunrise":1424615395,"sunset":1424655844},"weather":[{"id":800,"main":"Clear","description":"Sky is Clear","icon":"01n"}],"base":"cmc stations","main":{"temp":289.548,"temp_min":289.548,"temp_max":289.548,"pressure":953.79,"sea_level":1023.75,"grnd_level":953.79,"humidity":59},"wind":{"speed":1.22,"deg":208},"clouds":{"all":0},"dt":1424564559,"id":5328041,"name":"Beverly Hills","cod":200}
209
+ http_version:
210
+ recorded_at: Sun, 22 Feb 2015 00:24:10 GMT
211
+ - request:
212
+ method: get
213
+ uri: http://api.zippopotam.us/us/
214
+ body:
215
+ encoding: US-ASCII
216
+ string: ''
217
+ headers:
218
+ Accept-Encoding:
219
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
220
+ Accept:
221
+ - "*/*"
222
+ User-Agent:
223
+ - Ruby
224
+ response:
225
+ status:
226
+ code: 404
227
+ message: Not Found
228
+ headers:
229
+ Date:
230
+ - Sun, 22 Feb 2015 02:37:32 GMT
231
+ Server:
232
+ - Apache/2.2.15 (CentOS)
233
+ Content-Length:
234
+ - '729'
235
+ Connection:
236
+ - close
237
+ Content-Type:
238
+ - text/html; charset=UTF-8
239
+ body:
240
+ encoding: UTF-8
241
+ string: |2
242
+
243
+ <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
244
+ <html>
245
+ <head>
246
+ <title>Error: 404 Not Found</title>
247
+ <style type="text/css">
248
+ html {background-color: #eee; font-family: sans;}
249
+ body {background-color: #fff; border: 1px solid #ddd;
250
+ padding: 15px; margin: 15px;}
251
+ pre {background-color: #eee; border: 1px solid #ddd; padding: 5px;}
252
+ </style>
253
+ </head>
254
+ <body>
255
+ <h1>Error: 404 Not Found</h1>
256
+ <p>Sorry, the requested URL <tt>&#039;http://api.zippopotam.us/us/&#039;</tt>
257
+ caused an error:</p>
258
+ <pre>Not found: &#039;/us/&#039;</pre>
259
+ </body>
260
+ </html>
261
+ http_version:
262
+ recorded_at: Sun, 22 Feb 2015 01:34:01 GMT
263
+ - request:
264
+ method: get
265
+ uri: http://api.zippopotam.us/us/43123
266
+ body:
267
+ encoding: US-ASCII
268
+ string: ''
269
+ headers:
270
+ Accept-Encoding:
271
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
272
+ Accept:
273
+ - "*/*"
274
+ User-Agent:
275
+ - Ruby
276
+ response:
277
+ status:
278
+ code: 200
279
+ message: OK
280
+ headers:
281
+ Date:
282
+ - Sun, 22 Feb 2015 01:35:25 GMT
283
+ Server:
284
+ - Apache/2.4.7
285
+ Content-Length:
286
+ - '215'
287
+ X-Cache:
288
+ - hit
289
+ Charset:
290
+ - UTF-8
291
+ Vary:
292
+ - Accept-Encoding
293
+ Access-Control-Allow-Origin:
294
+ - "*"
295
+ Content-Type:
296
+ - application/json
297
+ body:
298
+ encoding: UTF-8
299
+ string: '{"post code": "43123", "country": "United States", "country abbreviation":
300
+ "US", "places": [{"place name": "Grove City", "longitude": "-83.0839", "state":
301
+ "Ohio", "state abbreviation": "OH", "latitude": "39.8814"}]}'
302
+ http_version:
303
+ recorded_at: Sun, 22 Feb 2015 01:35:25 GMT
304
+ - request:
305
+ method: get
306
+ uri: http://api.openweathermap.org/data/2.5/weather?q=Grove%20City,%20OH
307
+ body:
308
+ encoding: US-ASCII
309
+ string: ''
310
+ headers:
311
+ Accept-Encoding:
312
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
313
+ Accept:
314
+ - "*/*"
315
+ User-Agent:
316
+ - Ruby
317
+ response:
318
+ status:
319
+ code: 200
320
+ message: OK
321
+ headers:
322
+ Server:
323
+ - nginx
324
+ Date:
325
+ - Sun, 22 Feb 2015 01:35:26 GMT
326
+ Content-Type:
327
+ - application/json; charset=utf-8
328
+ Transfer-Encoding:
329
+ - chunked
330
+ Connection:
331
+ - keep-alive
332
+ X-Source:
333
+ - back
334
+ Access-Control-Allow-Origin:
335
+ - "*"
336
+ Access-Control-Allow-Credentials:
337
+ - 'true'
338
+ Access-Control-Allow-Methods:
339
+ - GET, POST
340
+ body:
341
+ encoding: UTF-8
342
+ string: |
343
+ {"coord":{"lon":-83.07,"lat":39.87},"sys":{"message":0.0192,"country":"United States of America","sunrise":1424607288,"sunset":1424646995},"weather":[{"id":500,"main":"Rain","description":"light rain","icon":"10n"}],"base":"cmc stations","main":{"temp":275.184,"temp_min":275.184,"temp_max":275.184,"pressure":993.5,"sea_level":1029.58,"grnd_level":993.5,"humidity":94},"wind":{"speed":2.16,"deg":359.501},"clouds":{"all":88},"rain":{"3h":2},"dt":1424568926,"id":4513409,"name":"Grove City","cod":200}
344
+ http_version:
345
+ recorded_at: Sun, 22 Feb 2015 01:35:26 GMT
346
+ recorded_with: VCR 2.9.3