rack-campfire 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -47,9 +47,8 @@ run Sinatra::Application
47
47
  ```
48
48
 
49
49
  ```subdomain``` and ```api_key``` are strings that correspond to your
50
- bot. ```rooms``` is a list of rooms you'd like your bot to join. It can
51
- be a single string if you like, or nil if you'd like it to join the
52
- first room.
50
+ bot. ```rooms``` is a list of rooms you'd like your bot to join or a
51
+ single room. It can be omitted if you only have one room.
53
52
 
54
53
  After running ```rackup```, you should see 'Hello, campfire!' in one of the
55
54
  rooms your campfire bot has joined, after posting any message in that
@@ -172,11 +171,12 @@ Add rack-campfire to the middleware stack.
172
171
  config.middleware.use Rack::Campfire, subdomain, api_key, rooms
173
172
  ```
174
173
 
175
- Add a route for campfire.
174
+ Add a route for campfire. You'll probably want to set it to render
175
+ textual versions of views by default.
176
176
 
177
177
  ```ruby
178
178
  # config/routes.rb
179
- match '/campfire' => 'campfire#campfire'
179
+ match '/campfire' => 'campfire#campfire', :defaults => { :format => :text }
180
180
  ```
181
181
 
182
182
  And finally, create your controller. You can include the hooks here too
@@ -18,16 +18,17 @@ class Rack::Campfire
18
18
  end
19
19
 
20
20
  def listen
21
- Thread.abort_on_exception = true
22
21
  @rooms.each { |r| Thread.new { r.listen { |m| respond(m, r) } } }
23
22
  end
24
23
 
25
24
  def respond(message, room)
26
- log(message)
25
+ log_message(message)
27
26
  return if originated_from_me?(message)
28
27
  env = mock_environment.merge('campfire.message' => message)
29
28
  response = coerce_body(@app.call(env).last)
30
29
  room.speak response unless response.empty?
30
+ rescue => e
31
+ log_error(e)
31
32
  end
32
33
 
33
34
  def params
@@ -1,8 +1,12 @@
1
1
  class Rack::Campfire
2
2
  module Logging
3
- def log(message)
3
+ def log_message(message)
4
4
  return unless message.user
5
5
  puts "[rack-campfire] #{message.user.name}: #{message.body}"
6
6
  end
7
+
8
+ def log_error(error)
9
+ puts "[rack-campfire] #{error}"
10
+ end
7
11
  end
8
12
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-campfire
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 1
10
- version: 0.0.1
9
+ - 2
10
+ version: 0.0.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Christopher Patuzzo
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2012-07-28 00:00:00 Z
18
+ date: 2012-07-29 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: rack