houston-conversations 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -0
  3. data/Gemfile +24 -0
  4. data/Gemfile.lock +351 -0
  5. data/MIT-LICENSE +20 -0
  6. data/README.md +31 -0
  7. data/Rakefile +25 -0
  8. data/app/assets/images/houston/conversations/.keep +0 -0
  9. data/app/assets/javascripts/houston/conversations/application.js +13 -0
  10. data/app/assets/stylesheets/houston/conversations/application.css +13 -0
  11. data/app/controllers/houston/conversations/application_controller.rb +4 -0
  12. data/app/helpers/houston/conversations/application_helper.rb +4 -0
  13. data/app/views/layouts/houston/conversations/application.html.erb +10 -0
  14. data/bin/rails +8 -0
  15. data/config/database.yml +13 -0
  16. data/config/initializers/add_navigation_renderer.rb +3 -0
  17. data/config/routes.rb +2 -0
  18. data/db/.keep +0 -0
  19. data/houston-conversations.gemspec +27 -0
  20. data/lib/houston-conversations.rb +1 -0
  21. data/lib/houston/conversations.rb +56 -0
  22. data/lib/houston/conversations/configuration.rb +14 -0
  23. data/lib/houston/conversations/conversation.rb +47 -0
  24. data/lib/houston/conversations/engine.rb +27 -0
  25. data/lib/houston/conversations/event.rb +80 -0
  26. data/lib/houston/conversations/listener.rb +19 -0
  27. data/lib/houston/conversations/listener_collection.rb +24 -0
  28. data/lib/houston/conversations/message.rb +8 -0
  29. data/lib/houston/conversations/railtie.rb +12 -0
  30. data/lib/houston/conversations/tty/channel.rb +18 -0
  31. data/lib/houston/conversations/tty/message.rb +29 -0
  32. data/lib/houston/conversations/tty/user.rb +17 -0
  33. data/lib/houston/conversations/tty_session.rb +33 -0
  34. data/lib/houston/conversations/version.rb +5 -0
  35. data/lib/tasks/conversations_tasks.rake +6 -0
  36. data/test/acceptance/houston_dummy_test.rb +17 -0
  37. data/test/dummy/houston.rb +23 -0
  38. data/test/fixtures/projects.yml +3 -0
  39. data/test/fixtures/users.yml +10 -0
  40. data/test/test_helper.rb +43 -0
  41. data/test/unit/fixtures_test.rb +11 -0
  42. metadata +159 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: ae170cd102e0f0da8a1c7e9762ee3807fae8f916
4
+ data.tar.gz: 9e36c20c17883eacf58049f51c02014dc32837ce
5
+ SHA512:
6
+ metadata.gz: 8281eeecc1e0a925df53411b25222f99909fbe76e4b3bbca3fb20106b4731a74aa13d7ecda628b00cdd1a0aaa96018983819cbddc1bad292b81bda3ada2463bd
7
+ data.tar.gz: 77b1d12b78cd6396f2bac0a7dcade7a93e3c6283ed44226e131ef0077f6d0bb28172ab7fb69eb3300aac66bba31f21c538a4a9022132a5db048097a6d62655de
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ .bundle/
2
+ log/*.log
3
+ pkg/
4
+ tmp/
data/Gemfile ADDED
@@ -0,0 +1,24 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Declare your gem's dependencies in houston-conversations.gemspec.
4
+ # Bundler will treat runtime dependencies like base dependencies, and
5
+ # development dependencies will be added by default to the :development group.
6
+ gemspec
7
+
8
+ # Declare any dependencies that are still in development here instead of in
9
+ # your gemspec. These might include edge Rails or gems from your path or
10
+ # Git. Remember to move these dependencies to your gemspec before releasing
11
+ # your gem to rubygems.org.
12
+
13
+ group :development, :test do
14
+ gem "pry"
15
+ end
16
+
17
+ group :test do
18
+ gem "minitest"
19
+ gem "capybara"
20
+ gem "shoulda-context"
21
+
22
+ gem "minitest-reporters", require: false
23
+ gem "minitest-reporters-turn_reporter", require: false
24
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,351 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ houston-conversations (0.1.0)
5
+ attentive
6
+ concurrent-ruby
7
+ houston-core (>= 0.7.0.beta3)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ actionmailer (4.2.5.2)
13
+ actionpack (= 4.2.5.2)
14
+ actionview (= 4.2.5.2)
15
+ activejob (= 4.2.5.2)
16
+ mail (~> 2.5, >= 2.5.4)
17
+ rails-dom-testing (~> 1.0, >= 1.0.5)
18
+ actionpack (4.2.5.2)
19
+ actionview (= 4.2.5.2)
20
+ activesupport (= 4.2.5.2)
21
+ rack (~> 1.6)
22
+ rack-test (~> 0.6.2)
23
+ rails-dom-testing (~> 1.0, >= 1.0.5)
24
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
25
+ actionview (4.2.5.2)
26
+ activesupport (= 4.2.5.2)
27
+ builder (~> 3.1)
28
+ erubis (~> 2.7.0)
29
+ rails-dom-testing (~> 1.0, >= 1.0.5)
30
+ rails-html-sanitizer (~> 1.0, >= 1.0.2)
31
+ activejob (4.2.5.2)
32
+ activesupport (= 4.2.5.2)
33
+ globalid (>= 0.3.0)
34
+ activemodel (4.2.5.2)
35
+ activesupport (= 4.2.5.2)
36
+ builder (~> 3.1)
37
+ activerecord (4.2.5.2)
38
+ activemodel (= 4.2.5.2)
39
+ activesupport (= 4.2.5.2)
40
+ arel (~> 6.0)
41
+ activerecord-import (0.14.1)
42
+ activerecord (>= 3.2)
43
+ activerecord-pluck_in_batches (0.1.1)
44
+ activerecord
45
+ activesupport (4.2.5.2)
46
+ i18n (~> 0.7)
47
+ json (~> 1.7, >= 1.7.7)
48
+ minitest (~> 5.1)
49
+ thread_safe (~> 0.3, >= 0.3.4)
50
+ tzinfo (~> 1.1)
51
+ addressable (2.3.8)
52
+ ansi (1.5.0)
53
+ arel (6.0.3)
54
+ attentive (0.3.2)
55
+ thread_safe
56
+ bcrypt (3.1.11)
57
+ boblail-unfuddle (0.7.1)
58
+ activesupport
59
+ builder
60
+ faraday (>= 0.8, < 0.10)
61
+ browser (1.1.0)
62
+ builder (3.2.2)
63
+ cancan (1.6.10)
64
+ capybara (2.7.1)
65
+ addressable
66
+ mime-types (>= 1.16)
67
+ nokogiri (>= 1.3.3)
68
+ rack (>= 1.0.0)
69
+ rack-test (>= 0.5.4)
70
+ xpath (~> 2.0)
71
+ chronic (0.10.2)
72
+ codeclimate-test-reporter (0.4.8)
73
+ simplecov (>= 0.7.1, < 1.0.0)
74
+ coderay (1.1.1)
75
+ coffee-rails (4.1.1)
76
+ coffee-script (>= 2.2.0)
77
+ railties (>= 4.0.0, < 5.1.x)
78
+ coffee-script (2.4.1)
79
+ coffee-script-source
80
+ execjs
81
+ coffee-script-source (1.10.0)
82
+ concurrent-ruby (1.0.2)
83
+ css_parser (1.4.5)
84
+ addressable
85
+ default_value_for (3.0.1)
86
+ activerecord (>= 3.2.0, < 5.0)
87
+ devise (3.5.10)
88
+ bcrypt (~> 3.0)
89
+ orm_adapter (~> 0.1)
90
+ railties (>= 3.2.6, < 5)
91
+ responders
92
+ thread_safe (~> 0.1)
93
+ warden (~> 1.2.3)
94
+ devise_invitable (1.5.5)
95
+ actionmailer (>= 3.2.6, < 5)
96
+ devise (>= 3.2.0)
97
+ docile (1.1.5)
98
+ domain_name (0.5.20160615)
99
+ unf (>= 0.0.5, < 1.0.0)
100
+ engineyard (3.2.1)
101
+ engineyard-cloud-client (~> 2.1)
102
+ engineyard-serverside-adapter (~> 2.2)
103
+ escape (~> 0.0.4)
104
+ highline (~> 1.6.1)
105
+ launchy (~> 2.1)
106
+ net-ssh (~> 2.7)
107
+ engineyard-cloud-client (2.1.1)
108
+ multi_json (~> 1.6)
109
+ rest-client (~> 1.7)
110
+ engineyard-serverside-adapter (2.4.0)
111
+ escape (~> 0.0.4)
112
+ multi_json (~> 1.6)
113
+ erubis (2.7.0)
114
+ escape (0.0.4)
115
+ execjs (2.7.0)
116
+ faraday (0.9.2)
117
+ multipart-post (>= 1.2, < 3)
118
+ faraday-http-cache (1.2.2)
119
+ faraday (~> 0.8)
120
+ faraday-raise-errors (0.2.0)
121
+ faraday
122
+ gemoji (2.1.0)
123
+ globalid (0.3.6)
124
+ activesupport (>= 4.1.0)
125
+ googlecharts (1.6.12)
126
+ handlebars_assets (0.23.0)
127
+ execjs (~> 2.0)
128
+ multi_json (~> 1.0)
129
+ sprockets (>= 2.0.0)
130
+ tilt (>= 1.2)
131
+ highline (1.6.21)
132
+ houston-core (0.7.0.beta3)
133
+ activerecord-import
134
+ activerecord-pluck_in_batches
135
+ addressable (~> 2.3.8)
136
+ boblail-unfuddle
137
+ browser (~> 1.1.0)
138
+ bundler
139
+ cancan (~> 1.6.10)
140
+ codeclimate-test-reporter (= 0.4.8)
141
+ coffee-rails (~> 4.1.0)
142
+ default_value_for (= 3.0.1)
143
+ devise (~> 3.5.0)
144
+ devise_invitable (~> 1.5.3)
145
+ engineyard (~> 3.2.1)
146
+ faraday (~> 0.9.2)
147
+ faraday-http-cache (~> 1.2.2)
148
+ faraday-raise-errors (~> 0.2.0)
149
+ gemoji (~> 2.1.0)
150
+ googlecharts (~> 1.6.12)
151
+ handlebars_assets (~> 0.23.0)
152
+ houston-devise_ldap_authenticatable
153
+ houston-vestal_versions
154
+ hpricot (~> 0.8.6)
155
+ neat-rails
156
+ nested_editor_for
157
+ nokogiri
158
+ oauth2
159
+ octokit (~> 4.3.0)
160
+ oj (~> 2.13)
161
+ openxml-xlsx (>= 0.2.0)
162
+ pg (~> 0.18.3)
163
+ pg_search (~> 1.0.5)
164
+ premailer (~> 1.8.6)
165
+ progressbar
166
+ rack-utf8_sanitizer (~> 1.3.1)
167
+ rails (~> 4.2.5.1)
168
+ redcarpet (~> 3.3.2)
169
+ rufus-scheduler (~> 3.2.0)
170
+ rugged (~> 0.24.0)
171
+ sass-rails (~> 5.0)
172
+ simplecov (~> 0.9.1)
173
+ strongbox (~> 0.7.2)
174
+ thor
175
+ thread_safe (~> 0.3.5)
176
+ uglifier (>= 2.7.2)
177
+ whenever (= 0.9.2)
178
+ houston-devise_ldap_authenticatable (0.7.1)
179
+ devise (>= 3.0.0)
180
+ net-ldap (~> 0.12.1)
181
+ houston-vestal_versions (2.0.0)
182
+ activerecord (>= 3, < 5)
183
+ activesupport (>= 3, < 5)
184
+ hpricot (0.8.6)
185
+ htmlentities (4.3.4)
186
+ http-cookie (1.0.2)
187
+ domain_name (~> 0.5)
188
+ i18n (0.7.0)
189
+ json (1.8.3)
190
+ jwt (1.5.4)
191
+ launchy (2.4.3)
192
+ addressable (~> 2.3)
193
+ loofah (2.0.3)
194
+ nokogiri (>= 1.5.9)
195
+ mail (2.6.4)
196
+ mime-types (>= 1.16, < 4)
197
+ method_source (0.8.2)
198
+ mime-types (2.99.2)
199
+ mini_portile2 (2.1.0)
200
+ minitest (5.9.0)
201
+ minitest-reporters (1.1.9)
202
+ ansi
203
+ builder
204
+ minitest (>= 5.0)
205
+ ruby-progressbar
206
+ minitest-reporters-turn_reporter (0.1.0)
207
+ minitest-reporters
208
+ multi_json (1.12.1)
209
+ multi_xml (0.5.5)
210
+ multipart-post (2.0.0)
211
+ neat-rails (0.5.0)
212
+ nested_editor_for (0.1.0)
213
+ net-ldap (0.12.1)
214
+ net-ssh (2.9.4)
215
+ netrc (0.11.0)
216
+ nokogiri (1.6.8)
217
+ mini_portile2 (~> 2.1.0)
218
+ pkg-config (~> 1.1.7)
219
+ oauth2 (1.2.0)
220
+ faraday (>= 0.8, < 0.10)
221
+ jwt (~> 1.0)
222
+ multi_json (~> 1.3)
223
+ multi_xml (~> 0.5)
224
+ rack (>= 1.2, < 3)
225
+ octokit (4.3.0)
226
+ sawyer (~> 0.7.0, >= 0.5.3)
227
+ oj (2.16.1)
228
+ openxml-package (0.2.4)
229
+ nokogiri
230
+ ox
231
+ rubyzip (~> 1.1.0)
232
+ openxml-xlsx (0.2.3)
233
+ nokogiri
234
+ openxml-package (>= 0.2.0)
235
+ orm_adapter (0.5.0)
236
+ ox (2.4.3)
237
+ pg (0.18.4)
238
+ pg_search (1.0.6)
239
+ activerecord (>= 3.1)
240
+ activesupport (>= 3.1)
241
+ arel
242
+ pkg-config (1.1.7)
243
+ premailer (1.8.7)
244
+ css_parser (>= 1.4.5)
245
+ htmlentities (>= 4.0.0)
246
+ progressbar (0.21.0)
247
+ pry (0.10.3)
248
+ coderay (~> 1.1.0)
249
+ method_source (~> 0.8.1)
250
+ slop (~> 3.4)
251
+ rack (1.6.4)
252
+ rack-test (0.6.3)
253
+ rack (>= 1.0)
254
+ rack-utf8_sanitizer (1.3.2)
255
+ rack (>= 1.0, < 3.0)
256
+ rails (4.2.5.2)
257
+ actionmailer (= 4.2.5.2)
258
+ actionpack (= 4.2.5.2)
259
+ actionview (= 4.2.5.2)
260
+ activejob (= 4.2.5.2)
261
+ activemodel (= 4.2.5.2)
262
+ activerecord (= 4.2.5.2)
263
+ activesupport (= 4.2.5.2)
264
+ bundler (>= 1.3.0, < 2.0)
265
+ railties (= 4.2.5.2)
266
+ sprockets-rails
267
+ rails-deprecated_sanitizer (1.0.3)
268
+ activesupport (>= 4.2.0.alpha)
269
+ rails-dom-testing (1.0.7)
270
+ activesupport (>= 4.2.0.beta, < 5.0)
271
+ nokogiri (~> 1.6.0)
272
+ rails-deprecated_sanitizer (>= 1.0.1)
273
+ rails-html-sanitizer (1.0.3)
274
+ loofah (~> 2.0)
275
+ railties (4.2.5.2)
276
+ actionpack (= 4.2.5.2)
277
+ activesupport (= 4.2.5.2)
278
+ rake (>= 0.8.7)
279
+ thor (>= 0.18.1, < 2.0)
280
+ rake (10.5.0)
281
+ redcarpet (3.3.4)
282
+ responders (2.2.0)
283
+ railties (>= 4.2.0, < 5.1)
284
+ rest-client (1.8.0)
285
+ http-cookie (>= 1.0.2, < 2.0)
286
+ mime-types (>= 1.16, < 3.0)
287
+ netrc (~> 0.7)
288
+ ruby-progressbar (1.8.1)
289
+ rubyzip (1.1.7)
290
+ rufus-scheduler (3.2.1)
291
+ rugged (0.24.0)
292
+ sass (3.4.22)
293
+ sass-rails (5.0.5)
294
+ railties (>= 4.0.0, < 6)
295
+ sass (~> 3.1)
296
+ sprockets (>= 2.8, < 4.0)
297
+ sprockets-rails (>= 2.0, < 4.0)
298
+ tilt (>= 1.1, < 3)
299
+ sawyer (0.7.0)
300
+ addressable (>= 2.3.5, < 2.5)
301
+ faraday (~> 0.8, < 0.10)
302
+ shoulda-context (1.2.1)
303
+ simplecov (0.9.2)
304
+ docile (~> 1.1.0)
305
+ multi_json (~> 1.0)
306
+ simplecov-html (~> 0.9.0)
307
+ simplecov-html (0.9.0)
308
+ slop (3.6.0)
309
+ sprockets (3.6.3)
310
+ concurrent-ruby (~> 1.0)
311
+ rack (> 1, < 3)
312
+ sprockets-rails (3.1.1)
313
+ actionpack (>= 4.0)
314
+ activesupport (>= 4.0)
315
+ sprockets (>= 3.0.0)
316
+ strongbox (0.7.2)
317
+ activerecord
318
+ thor (0.19.1)
319
+ thread_safe (0.3.5)
320
+ tilt (2.0.5)
321
+ tzinfo (1.2.2)
322
+ thread_safe (~> 0.1)
323
+ uglifier (3.0.0)
324
+ execjs (>= 0.3.0, < 3)
325
+ unf (0.1.4)
326
+ unf_ext
327
+ unf_ext (0.0.7.2)
328
+ warden (1.2.6)
329
+ rack (>= 1.0)
330
+ whenever (0.9.2)
331
+ activesupport (>= 2.3.4)
332
+ chronic (>= 0.6.3)
333
+ xpath (2.0.0)
334
+ nokogiri (~> 1.3)
335
+
336
+ PLATFORMS
337
+ ruby
338
+
339
+ DEPENDENCIES
340
+ bundler (~> 1.11.2)
341
+ capybara
342
+ houston-conversations!
343
+ minitest
344
+ minitest-reporters
345
+ minitest-reporters-turn_reporter
346
+ pry
347
+ rake (~> 10.0)
348
+ shoulda-context
349
+
350
+ BUNDLED WITH
351
+ 1.11.2
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2016 Bob Lail
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,31 @@
1
+ # Houston::Conversations
2
+
3
+ TODO: Summary of Houston Conversations.
4
+
5
+
6
+ ## Installation
7
+
8
+ In your `Gemfile`, add:
9
+
10
+ gem "houston-conversations"
11
+
12
+ And in `config/main.rb`, add:
13
+
14
+ ```ruby
15
+ use :conversations do
16
+ # TODO: specify configuration options for Houston::Conversations here
17
+ end
18
+ ```
19
+
20
+ And then execute:
21
+
22
+ $ bundle
23
+
24
+
25
+ ## Contributing
26
+
27
+ 1. Fork it
28
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
29
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
30
+ 4. Push to the branch (`git push origin my-new-feature`)
31
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,25 @@
1
+ begin
2
+ require "bundler/setup"
3
+ rescue LoadError
4
+ puts "You must `gem install bundler` and `bundle install` to run rake tasks"
5
+ end
6
+
7
+
8
+ # `rake test` and `rake test:all` are loaded from Houston
9
+ require_relative "test/dummy/houston"
10
+ Houston::Application.load_tasks
11
+
12
+
13
+ require "rdoc/task"
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = "rdoc"
17
+ rdoc.title = "Conversations"
18
+ rdoc.options << "--line-numbers"
19
+ rdoc.rdoc_files.include("README.rdoc")
20
+ rdoc.rdoc_files.include("lib/**/*.rb")
21
+ end
22
+
23
+
24
+ Bundler::GemHelper.install_tasks
25
+
File without changes
@@ -0,0 +1,13 @@
1
+ // This is a manifest file that'll be compiled into application.js, which will include all the files
2
+ // listed below.
3
+ //
4
+ // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5
+ // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6
+ //
7
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8
+ // the compiled file.
9
+ //
10
+ // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11
+ // GO AFTER THE REQUIRES BELOW.
12
+ //
13
+ //= require_tree .
@@ -0,0 +1,13 @@
1
+ /*
2
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
3
+ * listed below.
4
+ *
5
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7
+ *
8
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
9
+ * compiled file, but it's generally better to create a new file per style scope.
10
+ *
11
+ *= require_self
12
+ *= require_tree .
13
+ */
@@ -0,0 +1,4 @@
1
+ module Houston::Conversations
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Houston::Conversations
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,10 @@
1
+ <% content_for :stylesheets do %>
2
+ <%= stylesheet_link_tag "houston/conversations/application", :media => "all" %>
3
+ <% end %>
4
+
5
+ <% content_for :javascripts do %>
6
+ <%= javascript_include_tag "houston/conversations/application" %>
7
+ <% end %>
8
+
9
+ <%# Houston's default layout %>
10
+ <%= render template: "layouts/application" %>
data/bin/rails ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
3
+
4
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
5
+ ENGINE_PATH = File.expand_path('../../lib/houston/conversations/engine', __FILE__)
6
+
7
+ require 'rails/all'
8
+ require 'rails/engine/commands'
@@ -0,0 +1,13 @@
1
+ development:
2
+ adapter: postgresql
3
+ encoding: utf8
4
+ database: houston_conversations_development
5
+ host: localhost
6
+ prepared_statements: false
7
+
8
+ test:
9
+ adapter: postgresql
10
+ encoding: utf8
11
+ database: houston_conversations_test
12
+ host: localhost
13
+ prepared_statements: false
@@ -0,0 +1,3 @@
1
+ # Houston.add_navigation_renderer :conversations do
2
+ # render_nav_link "Conversations", Houston::Conversations::Engine.routes.url_helpers.root_path, icon: "fa-thumbs-up"
3
+ # end
data/config/routes.rb ADDED
@@ -0,0 +1,2 @@
1
+ Houston::Conversations::Engine.routes.draw do
2
+ end
data/db/.keep ADDED
File without changes
@@ -0,0 +1,27 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ # Maintain your gem's version:
4
+ require "houston/conversations/version"
5
+
6
+ # Describe your gem and declare its dependencies:
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "houston-conversations"
9
+ spec.version = Houston::Conversations::VERSION
10
+ spec.authors = ["Bob Lail"]
11
+ spec.email = ["bob.lailfamily@gmail.com"]
12
+
13
+ spec.summary = "Allows Houston to have conversations"
14
+ spec.description = "Describes a DSL for modeling conversations; supports pluggable backends"
15
+ spec.homepage = "https://github.com/houston/houston-conversations"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.require_paths = ["lib"]
19
+ spec.test_files = Dir["test/**/*"]
20
+
21
+ spec.add_dependency "houston-core", ">= 0.7.0.beta3"
22
+ spec.add_dependency "attentive"
23
+ spec.add_dependency "concurrent-ruby"
24
+
25
+ spec.add_development_dependency "bundler", "~> 1.11.2"
26
+ spec.add_development_dependency "rake", "~> 10.0"
27
+ end
@@ -0,0 +1 @@
1
+ require "houston/conversations"
@@ -0,0 +1,56 @@
1
+ require "houston/conversations/engine"
2
+ require "houston/conversations/configuration"
3
+ require "houston/conversations/listener_collection"
4
+ require "houston/conversations/message"
5
+ require "houston/conversations/event"
6
+
7
+ module Houston
8
+ module Conversations
9
+ extend self
10
+
11
+ def config(&block)
12
+ @configuration ||= Conversations::Configuration.new
13
+ @configuration.instance_eval(&block) if block_given?
14
+ @configuration
15
+ end
16
+
17
+ def listeners
18
+ @listeners ||= Houston::Conversations::ListenerCollection.new
19
+ end
20
+
21
+ # Matches a message against all listeners
22
+ # and invokes the first listener that mathes
23
+ def hear(message, params={})
24
+ raise ArgumentError, "`message` is a #{message.class.name} but must be a subclass of Houston::Conversations::Message" unless message.is_a?(Houston::Conversations::Message)
25
+
26
+ listeners.hear(message).each do |match|
27
+
28
+ event = Houston::Conversations::Event.new(match)
29
+ yield event if block_given?
30
+ invoke! match.listener, event
31
+
32
+ # Invoke only one listener per message
33
+ return true
34
+ end
35
+
36
+ false
37
+ end
38
+
39
+ private
40
+
41
+ def invoke!(listener, event)
42
+ Rails.logger.debug "\e[35m[conversations:hear] #{event.message}\e[0m"
43
+
44
+ Houston.async do
45
+ begin
46
+ listener.call(event)
47
+ rescue Exception # rescues StandardError by default; but we want to rescue and report all errors
48
+ Houston.report_exception $!, parameters: event.to_h
49
+ Rails.logger.error "\e[31m[conversations:exception] (#{$!.class}) #{$!.message}\n #{$!.backtrace.join("\n ")}\e[0m"
50
+ event.reply "An error occurred when I was trying to answer you"
51
+ end
52
+ end
53
+ end
54
+
55
+ end
56
+ end
@@ -0,0 +1,14 @@
1
+ module Houston::Conversations
2
+ class Configuration
3
+
4
+
5
+ def listen_for(*args, &block)
6
+ Houston::Conversations.listeners.listen_for(*args, &block)
7
+ end
8
+
9
+ def overhear(*args, &block)
10
+ Houston::Conversations.listeners.overhear(*args, &block)
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,47 @@
1
+ require "concurrent/array"
2
+
3
+ module Houston
4
+ module Slack
5
+ class Conversation
6
+
7
+ def initialize(channel, sender)
8
+ @channel = channel
9
+ @sender = sender
10
+ @listeners = Concurrent::Array.new
11
+ end
12
+
13
+ def listen_for(*args, &block)
14
+ Houston::Conversations.listen_for(*args, &block).tap do |listener|
15
+ listener.conversation = self
16
+ listeners.push listener
17
+ end
18
+ end
19
+
20
+ def includes?(e)
21
+ e.channel == channel && e.sender == sender
22
+ end
23
+
24
+ def reply(*messages)
25
+ channel.reply(*messages)
26
+ end
27
+ alias :say :reply
28
+
29
+ def ask(question, expect: nil)
30
+ listen_for(*Array(expect)) do |e|
31
+ e.stop_listening!
32
+ yield e
33
+ end
34
+
35
+ reply question
36
+ end
37
+
38
+ def end!
39
+ listeners.each(&:stop_listening!)
40
+ end
41
+
42
+ private
43
+ attr_reader :channel, :sender, :listeners
44
+
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,27 @@
1
+ require "houston/conversations/railtie"
2
+
3
+ module Houston
4
+ module Conversations
5
+ class Engine < ::Rails::Engine
6
+ isolate_namespace Houston::Conversations
7
+
8
+ # Precompile this modules assets
9
+ initializer :assets do |config|
10
+ Rails.application.config.assets.precompile += %w(
11
+ houston/conversations/application.js
12
+ houston/conversations/application.css )
13
+ end
14
+
15
+ # Include the Engine's migrations with the Application
16
+ # http://pivotallabs.com/leave-your-migrations-in-your-rails-engines/
17
+ initializer :append_migrations do |app|
18
+ unless app.root.to_s.match root.to_s
19
+ config.paths["db/migrate"].expanded.each do |expanded_path|
20
+ app.config.paths["db/migrate"] << expanded_path
21
+ end
22
+ end
23
+ end
24
+
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,80 @@
1
+ require "houston/conversations/conversation"
2
+
3
+ module Houston
4
+ module Conversations
5
+ class Event
6
+ attr_reader :match
7
+
8
+ def initialize(match)
9
+ @match = match
10
+ end
11
+
12
+
13
+
14
+ def message
15
+ match.message
16
+ end
17
+
18
+ def channel
19
+ message.channel
20
+ end
21
+
22
+ def sender
23
+ message.sender
24
+ end
25
+
26
+ def user
27
+ sender.user
28
+ end
29
+
30
+
31
+
32
+ def matched?(key)
33
+ match.matched?(key)
34
+ end
35
+
36
+ def stop_listening!
37
+ listener.stop_listening!
38
+ end
39
+
40
+ def responding
41
+ # do nothing; specific backends can implement the appropriate action
42
+ end
43
+
44
+ def reply(*args)
45
+ channel.reply(*args)
46
+ end
47
+
48
+ def random_reply(replies)
49
+ if replies.is_a?(Hash)
50
+ weights = replies.values
51
+ unless weights.reduce(&:+) == 1.0
52
+ raise ArgumentError, "Reply weights don't add up to 1.0"
53
+ end
54
+
55
+ draw = rand
56
+ sum = 0
57
+ pick = nil
58
+ replies.each do |reply, weight|
59
+ pick = reply unless sum > draw
60
+ sum += weight
61
+ end
62
+ reply pick
63
+ else
64
+ reply replies.sample
65
+ end
66
+ end
67
+
68
+ def start_conversation!
69
+ Conversation.new(channel, sender)
70
+ end
71
+
72
+
73
+
74
+ def to_h
75
+ { channel: channel, message: message, sender: sender }
76
+ end
77
+
78
+ end
79
+ end
80
+ end
@@ -0,0 +1,19 @@
1
+ require "attentive/listener"
2
+
3
+ module Houston
4
+ module Conversations
5
+ class Listener < Attentive::Listener
6
+ attr_accessor :conversation
7
+
8
+ def matches_context?(message)
9
+ contexts = message.contexts.dup
10
+ contexts << :conversation if conversation && conversation.includes?(message)
11
+
12
+ return false unless contexts.superset? @required_contexts
13
+ return false unless contexts.disjoint? @prohibited_contexts
14
+ true
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,24 @@
1
+ require "attentive/listener_collection"
2
+ require "houston/conversations/listener"
3
+
4
+ module Houston
5
+ module Conversations
6
+ class ListenerCollection < Attentive::ListenerCollection
7
+
8
+ def overhear(*args, &block)
9
+ options = args.last.is_a?(::Hash) ? args.pop : {}
10
+ options[:context] = { in: :any }
11
+ listen_for(*args, options, &block)
12
+ end
13
+
14
+ def listen_for(*args, &block)
15
+ options = args.last.is_a?(::Hash) ? args.pop : {}
16
+
17
+ Houston::Conversations::Listener.new(self, args, options, block).tap do |listener|
18
+ push listener
19
+ end
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,8 @@
1
+ require "attentive/message"
2
+
3
+ module Houston
4
+ module Conversations
5
+ class Message < ::Attentive::Message
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,12 @@
1
+ module Houston
2
+ module Conversations
3
+ class Railtie < ::Rails::Railtie
4
+
5
+ # The block you pass to this method will run for every request
6
+ # in development mode, but only once in production.
7
+ # config.to_prepare do
8
+ # end
9
+
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,18 @@
1
+ module Houston
2
+ module Conversations
3
+ module Tty
4
+ class Channel
5
+ attr_reader :session
6
+
7
+ def initialize(session)
8
+ @session = session
9
+ end
10
+
11
+ def reply(message)
12
+ session.say message
13
+ end
14
+
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,29 @@
1
+ require "houston/conversations/message"
2
+ require "houston/conversations/tty/channel"
3
+ require "houston/conversations/tty/user"
4
+
5
+ module Houston
6
+ module Conversations
7
+ module Tty
8
+ class Message < ::Houston::Conversations::Message
9
+ attr_reader :session
10
+
11
+ def initialize(session, text, params={})
12
+ @session = session
13
+ super text, params
14
+ contexts << :conversation
15
+ contexts << :tty
16
+ end
17
+
18
+ def channel
19
+ Houston::Conversations::Tty::Channel.new(session)
20
+ end
21
+
22
+ def sender
23
+ Houston::Conversations::Tty::User.new(session)
24
+ end
25
+
26
+ end
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,17 @@
1
+ module Houston
2
+ module Conversations
3
+ module Tty
4
+ class User
5
+ attr_reader :session
6
+
7
+ def initialize(session)
8
+ @session = session
9
+ end
10
+
11
+ def user
12
+ end
13
+
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,33 @@
1
+ require "houston/conversations/tty/message"
2
+ require "etc"
3
+
4
+ module Houston
5
+ module Conversations
6
+ class TtySession
7
+
8
+ def initialize(input=STDIN, output=STDOUT)
9
+ @input = input
10
+ @output = output
11
+ @prompt = "#{Etc.getlogin}> "
12
+ end
13
+
14
+ def listen!
15
+ output.print prompt
16
+ while text = input.gets
17
+ message = Houston::Conversations::Tty::Message.new(self, text)
18
+ unless Houston::Conversations.hear(message)
19
+ output.print prompt
20
+ end
21
+ end
22
+ end
23
+
24
+ def say(message)
25
+ output.puts "houston> #{message}"
26
+ output.print prompt
27
+ end
28
+
29
+ private
30
+ attr_reader :input, :output, :prompt
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,5 @@
1
+ module Houston
2
+ module Conversations
3
+ VERSION = "0.1.0"
4
+ end
5
+ end
@@ -0,0 +1,6 @@
1
+ require "houston/conversations/tty_session"
2
+
3
+ desc "Test conversations with Houston"
4
+ task :talk => :environment do
5
+ Houston::Conversations::TtySession.new.listen!
6
+ end
@@ -0,0 +1,17 @@
1
+ require "test_helper"
2
+
3
+ class DummyHoustonTest < ActionDispatch::IntegrationTest
4
+
5
+ context "The Test Suite" do
6
+ should "be able to interact with a dummy instance of Houston" do
7
+ visit "/users/sign_in"
8
+ fill_in "user_email", with: "admin@example.com"
9
+ fill_in "user_password", with: "password"
10
+ click_button "Sign in"
11
+
12
+ assert page.has_content?("Projects I Follow"),
13
+ "Expected to have been able to log in and to see the Timeline view"
14
+ end
15
+ end
16
+
17
+ end
@@ -0,0 +1,23 @@
1
+ # Load Houston
2
+ require "houston/application"
3
+
4
+ # Configure Houston
5
+ Houston.config do
6
+
7
+ # Houston should load config/database.yml from this module
8
+ # rather than from Houston Core.
9
+ root Pathname.new File.expand_path("../../..", __FILE__)
10
+
11
+ # Give dummy values to these required fields.
12
+ host "houston.test.com"
13
+ mailer_sender "houston@test.com"
14
+
15
+ # Houston still hard-codes knowledge of these Roles.
16
+ # This will eventually be refactored away.
17
+ roles "Developer", "Tester"
18
+ project_roles "Maintainer"
19
+
20
+ # Mount this module on the dummy Houston application.
21
+ use :conversations
22
+
23
+ end
@@ -0,0 +1,3 @@
1
+ test:
2
+ name: Test
3
+ slug: test
@@ -0,0 +1,10 @@
1
+ admin:
2
+ first_name: FirstName
3
+ last_name: LastName
4
+ email: admin@example.com
5
+ email_addresses:
6
+ - admin@example.com
7
+ administrator: true
8
+ role: Developer
9
+ encrypted_password: $2a$10$Pf9Q94yN7t/YGqGS6pBl5uOL8lUvqgWpGeXRMHGbgPU0ixbWzthOG
10
+ # password: password
@@ -0,0 +1,43 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ # Load Houston
5
+ require "dummy/houston"
6
+ Rails.application.initialize! unless Rails.application.initialized?
7
+
8
+ require "rails/test_help"
9
+
10
+ if ENV["CI"] == "true"
11
+ require "minitest/reporters"
12
+ MiniTest::Reporters.use! [MiniTest::Reporters::DefaultReporter.new,
13
+ MiniTest::Reporters::JUnitReporter.new]
14
+ else
15
+ require "minitest/reporters/turn_reporter"
16
+ MiniTest::Reporters.use! Minitest::Reporters::TurnReporter.new
17
+ end
18
+
19
+ # Filter out Minitest backtrace while allowing backtrace
20
+ # from other libraries to be shown.
21
+ Minitest.backtrace_filter = Minitest::BacktraceFilter.new
22
+
23
+ class ActiveSupport::TestCase
24
+
25
+ # Load fixtures from the engine
26
+ self.fixture_path = File.expand_path("../fixtures", __FILE__)
27
+
28
+ # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
29
+ fixtures :all
30
+
31
+ # Add more helper methods to be used by all tests here...
32
+
33
+ end
34
+
35
+ require "capybara/rails"
36
+
37
+ class ActionDispatch::IntegrationTest
38
+ include Capybara::DSL
39
+
40
+ # Load fixtures from the engine
41
+ self.fixture_path = File.expand_path("../fixtures", __FILE__)
42
+
43
+ end
@@ -0,0 +1,11 @@
1
+ require "test_helper"
2
+
3
+ class FixturesTest < ActiveSupport::TestCase
4
+
5
+ context "The Test Suite" do
6
+ should "load the fixtures defined in this engine" do
7
+ assert Project["test"], "Expected to find the 'test' project"
8
+ end
9
+ end
10
+
11
+ end
metadata ADDED
@@ -0,0 +1,159 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: houston-conversations
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Bob Lail
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-07-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: houston-core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.7.0.beta3
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.7.0.beta3
27
+ - !ruby/object:Gem::Dependency
28
+ name: attentive
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: concurrent-ruby
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: bundler
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 1.11.2
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 1.11.2
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ description: Describes a DSL for modeling conversations; supports pluggable backends
84
+ email:
85
+ - bob.lailfamily@gmail.com
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - Gemfile
92
+ - Gemfile.lock
93
+ - MIT-LICENSE
94
+ - README.md
95
+ - Rakefile
96
+ - app/assets/images/houston/conversations/.keep
97
+ - app/assets/javascripts/houston/conversations/application.js
98
+ - app/assets/stylesheets/houston/conversations/application.css
99
+ - app/controllers/houston/conversations/application_controller.rb
100
+ - app/helpers/houston/conversations/application_helper.rb
101
+ - app/views/layouts/houston/conversations/application.html.erb
102
+ - bin/rails
103
+ - config/database.yml
104
+ - config/initializers/add_navigation_renderer.rb
105
+ - config/routes.rb
106
+ - db/.keep
107
+ - houston-conversations.gemspec
108
+ - lib/houston-conversations.rb
109
+ - lib/houston/conversations.rb
110
+ - lib/houston/conversations/configuration.rb
111
+ - lib/houston/conversations/conversation.rb
112
+ - lib/houston/conversations/engine.rb
113
+ - lib/houston/conversations/event.rb
114
+ - lib/houston/conversations/listener.rb
115
+ - lib/houston/conversations/listener_collection.rb
116
+ - lib/houston/conversations/message.rb
117
+ - lib/houston/conversations/railtie.rb
118
+ - lib/houston/conversations/tty/channel.rb
119
+ - lib/houston/conversations/tty/message.rb
120
+ - lib/houston/conversations/tty/user.rb
121
+ - lib/houston/conversations/tty_session.rb
122
+ - lib/houston/conversations/version.rb
123
+ - lib/tasks/conversations_tasks.rake
124
+ - test/acceptance/houston_dummy_test.rb
125
+ - test/dummy/houston.rb
126
+ - test/fixtures/projects.yml
127
+ - test/fixtures/users.yml
128
+ - test/test_helper.rb
129
+ - test/unit/fixtures_test.rb
130
+ homepage: https://github.com/houston/houston-conversations
131
+ licenses: []
132
+ metadata: {}
133
+ post_install_message:
134
+ rdoc_options: []
135
+ require_paths:
136
+ - lib
137
+ required_ruby_version: !ruby/object:Gem::Requirement
138
+ requirements:
139
+ - - ">="
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ required_rubygems_version: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - ">="
145
+ - !ruby/object:Gem::Version
146
+ version: '0'
147
+ requirements: []
148
+ rubyforge_project:
149
+ rubygems_version: 2.5.1
150
+ signing_key:
151
+ specification_version: 4
152
+ summary: Allows Houston to have conversations
153
+ test_files:
154
+ - test/acceptance/houston_dummy_test.rb
155
+ - test/dummy/houston.rb
156
+ - test/fixtures/projects.yml
157
+ - test/fixtures/users.yml
158
+ - test/test_helper.rb
159
+ - test/unit/fixtures_test.rb