ratchetio 0.3.2 → 0.4.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.
data/CHANGELOG.md ADDED
@@ -0,0 +1,9 @@
1
+ # Change Log
2
+
3
+ **0.4.0**
4
+
5
+ - Breaking change to make the "person" more configurable. If you were previously relying on your `current_member` method being called to return the person object, you will need to add the following line to `config/initializers/ratchetio.rb`:
6
+
7
+ config.person_method = "current_member"
8
+
9
+ - Person id, username, and email method names are now configurable -- see README for details.
data/README.md CHANGED
@@ -66,19 +66,26 @@ Ratchetio.report_message("Login successful", "info", :user => @user)
66
66
 
67
67
  ## Person tracking
68
68
 
69
- Ratchet will send information about the current user (called a "person" in Ratchet parlance) along with each error report, when available. This works by trying the `current_user` and `current_member` controller methods. The return value should be an object with an `id` property and, optionally, `username` and `email` properties.
69
+ Ratchet will send information about the current user (called a "person" in Ratchet parlance) along with each error report, when available. This works by calling the `current\_user` controller method. The return value should be an object with an `id` method and, optionally, `username` and `email` methods.
70
70
 
71
- If you use different naming, add the following in your controller:
71
+ If the gem should call a controller method besides `current\_user`, add the following in `config/initializers/ratchetio.rb`:
72
72
 
73
73
  ```ruby
74
- alias_method :my_user_method, :current_user
75
- helper_method :my_user_method
74
+ config.person_method = "my_current_user"
75
+ ```
76
+
77
+ If the methods to extract the `id`, `username`, and `email` from the object returned by the `person\_method` have other names, configure like so in `config/initializers/ratchetio.rb`:
78
+
79
+ ```ruby
80
+ config.person_id_method = "user_id" # default is "id"
81
+ config.person_username_method = "user_name" # default is "username"
82
+ config.person_email_method = "email_address" # default is "email"
76
83
  ```
77
84
 
78
85
 
79
86
  ## Exception level filters
80
87
 
81
- By default, all exceptions reported through `Ratchetio.report_exception()` are reporeted at the "error" level, except for the following, which are reported at "warning" level:
88
+ By default, all exceptions reported through `Ratchetio.report\_exception()` are reporeted at the "error" level, except for the following, which are reported at "warning" level:
82
89
 
83
90
  - ActiveRecord::RecordNotFound
84
91
  - AbstractController::ActionNotFound
@@ -89,7 +96,7 @@ If you'd like to customize this list, see the example code in `config/initialize
89
96
 
90
97
  ## Help / Support
91
98
 
92
- If you run into any issues, please email me at brian@ratchet.io
99
+ If you run into any issues, please email me at support@ratchet.io
93
100
 
94
101
  ## Contributing
95
102
 
@@ -2,6 +2,14 @@ require 'ratchetio/rails'
2
2
  Ratchetio.configure do |config|
3
3
  config.access_token = <%= access_token_expr %>
4
4
 
5
+ # By default, Ratchetio will try to call the `current_user` controller method
6
+ # to fetch the logged-in user object, and then call that object's `id`,
7
+ # `username`, and `email` methods to fetch those properties. To customize:
8
+ # config.person_method = "my_current_user"
9
+ # config.person_id_method = "my_id"
10
+ # config.person_username_method = "my_username"
11
+ # config.person_email_method = "my_email"
12
+
5
13
  # Add exception class names to the exception_level_filters hash to
6
14
  # change the level that exception is reported at. Note that if an exception
7
15
  # has already been reported and logged the level will need to be changed
@@ -8,6 +8,10 @@ module Ratchetio
8
8
  attr_accessor :framework
9
9
  attr_accessor :endpoint
10
10
  attr_accessor :exception_level_filters
11
+ attr_accessor :person_method
12
+ attr_accessor :person_id_method
13
+ attr_accessor :person_username_method
14
+ attr_accessor :person_email_method
11
15
 
12
16
  attr_accessor :logger
13
17
 
@@ -21,6 +25,10 @@ module Ratchetio
21
25
  'AbstractController::ActionNotFound' => 'warning',
22
26
  'ActionController::RoutingError' => 'warning'
23
27
  }
28
+ @person_method = "current_user"
29
+ @person_id_method = "id"
30
+ @person_username_method = "username"
31
+ @person_email_method = "email"
24
32
  end
25
33
 
26
34
  # allow params to be read like a hash
@@ -16,17 +16,17 @@ module Ratchetio
16
16
  end
17
17
 
18
18
  def ratchetio_person_data
19
- user = begin current_user rescue current_member end
19
+ user = send(Ratchetio.configuration.person_method)
20
20
  # include id, username, email if non-empty
21
- user.attributes.select do |k, v|
22
- if v.blank?
23
- false
24
- elsif ['id', 'username', 'email'].include? k
25
- true
26
- else
27
- false
28
- end
29
- end.symbolize_keys
21
+ if user
22
+ {
23
+ :id => begin user.send(Ratchetio.configuration.person_id_method) rescue nil end,
24
+ :username => begin user.send(Ratchetio.configuration.person_username_method) rescue nil end,
25
+ :email => begin user.send(Ratchetio.configuration.person_email_method) rescue nil end
26
+ }
27
+ else
28
+ {}
29
+ end
30
30
  rescue NoMethodError, NameError
31
31
  {}
32
32
  end
@@ -1,3 +1,3 @@
1
1
  module Ratchetio
2
- VERSION = "0.3.2"
2
+ VERSION = "0.4.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ratchetio
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-25 00:00:00.000000000 Z
12
+ date: 2012-11-07 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Rails plugin to catch and send exceptions to Ratchet.io
15
15
  email:
@@ -19,6 +19,7 @@ extensions: []
19
19
  extra_rdoc_files: []
20
20
  files:
21
21
  - .gitignore
22
+ - CHANGELOG.md
22
23
  - Gemfile
23
24
  - LICENSE
24
25
  - README.md