raygun4ruby 0.0.5 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +101 -0
- data/lib/raygun/client.rb +10 -4
- data/lib/raygun/version.rb +1 -1
- data/lib/raygun.rb +3 -1
- metadata +3 -18
data/README.md
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
# Raygun 4 Ruby [![Build Status](https://travis-ci.org/MindscapeHQ/raygun4ruby.png?branch=master)](https://travis-ci.org/MindscapeHQ/raygun4ruby)
|
2
|
+
|
3
|
+
This is the Ruby adapter for the Raygun error reporter, http://raygun.io.
|
4
|
+
|
5
|
+
|
6
|
+
## Installation
|
7
|
+
|
8
|
+
Add this line to your application's Gemfile:
|
9
|
+
|
10
|
+
gem 'raygun4ruby'
|
11
|
+
|
12
|
+
And then execute:
|
13
|
+
|
14
|
+
$ bundle
|
15
|
+
|
16
|
+
Or install it yourself as:
|
17
|
+
|
18
|
+
$ gem install raygun4ruby
|
19
|
+
|
20
|
+
## Usage
|
21
|
+
|
22
|
+
###Rails 3/4
|
23
|
+
|
24
|
+
Run:
|
25
|
+
|
26
|
+
rails g raygun:install YOUR_API_KEY_HERE
|
27
|
+
|
28
|
+
You can find your API key on your [Raygun Dashboard](https://app.raygun.io/dashboard/)
|
29
|
+
|
30
|
+
You can then test your Raygun integration by running:
|
31
|
+
|
32
|
+
rake raygun:test
|
33
|
+
|
34
|
+
You should see an "ItWorksException" appear in your Raygun dashboard. You're ready to zap those errors!
|
35
|
+
|
36
|
+
NB: Raygun4Ruby currently requires Ruby >= 1.9
|
37
|
+
|
38
|
+
Note that the generator will create a file in `config/initializers` called "raygun.rb". If you need to do any further configuration or customization of Raygun, that's the place to do it!
|
39
|
+
|
40
|
+
### Rails 2
|
41
|
+
|
42
|
+
Raygun4Ruby doesn't currently support Rails 2. If you'd like Rails 2 support, [drop us a line](http://raygun.io/forums).
|
43
|
+
|
44
|
+
###Standalone / Manual Exception Tracking
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
|
48
|
+
require 'rubygems'
|
49
|
+
require 'raygun4ruby'
|
50
|
+
|
51
|
+
Raygun.setup do |config|
|
52
|
+
config.api_key = "YOUR_RAYGUN_API_KEY"
|
53
|
+
end
|
54
|
+
|
55
|
+
begin
|
56
|
+
# your lovely code here
|
57
|
+
rescue Exception => e
|
58
|
+
Raygun.track_exception(e)
|
59
|
+
end
|
60
|
+
|
61
|
+
```
|
62
|
+
|
63
|
+
(You can also pass a Hash as the second parameter to `track_exception`. It should look like a [Rack Env Hash](http://rack.rubyforge.org/doc/SPEC.html))
|
64
|
+
|
65
|
+
###Ignoring Some Errors
|
66
|
+
|
67
|
+
You can ignore certain types of Exception using the `ignore` option in the setup block, like so:
|
68
|
+
|
69
|
+
```ruby
|
70
|
+
Raygun.setup do |config|
|
71
|
+
config.api_key = "MY_SWEET_API_KEY"
|
72
|
+
config.ignore << [MyApp::AnExceptionIDontCareAbout]
|
73
|
+
end
|
74
|
+
```
|
75
|
+
|
76
|
+
You can also check which [exceptions are ignored by default](https://github.com/MindscapeHQ/raygun4ruby/blob/master/lib/raygun/configuration.rb#L26)
|
77
|
+
|
78
|
+
###Resque Error Tracking
|
79
|
+
|
80
|
+
Raygun4Ruby also includes a Resque failure backend. You should include it inside your Resque initializer (usually something like `config/initializers/load_resque.rb`)
|
81
|
+
|
82
|
+
```ruby
|
83
|
+
require 'resque/failure/multiple'
|
84
|
+
require 'resque/failure/raygun'
|
85
|
+
require 'resque/failure/redis'
|
86
|
+
|
87
|
+
Resque::Failure::Multiple.classes = [Resque::Failure::Redis, Resque::Failure::Raygun]
|
88
|
+
Resque::Failure.backend = Resque::Failure::Multiple
|
89
|
+
```
|
90
|
+
|
91
|
+
## Found a bug?
|
92
|
+
|
93
|
+
Oops! Just let us know by opening an Issue on Github.
|
94
|
+
|
95
|
+
## Contributing
|
96
|
+
|
97
|
+
1. Fork it
|
98
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
99
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
100
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
101
|
+
5. Create new Pull Request
|
data/lib/raygun/client.rb
CHANGED
@@ -7,11 +7,17 @@ module Raygun
|
|
7
7
|
base_uri "https://api.raygun.io/"
|
8
8
|
|
9
9
|
def initialize
|
10
|
+
@api_key = require_api_key!
|
11
|
+
|
10
12
|
@headers = {
|
11
|
-
"X-ApiKey" =>
|
13
|
+
"X-ApiKey" => @api_key
|
12
14
|
}
|
13
15
|
end
|
14
16
|
|
17
|
+
def require_api_key!
|
18
|
+
Raygun.configuration.api_key || raise(ApiKeyRequired.new("Please specify your Raygun API key using Raygun#setup (find yours at https://app.raygun.io)"))
|
19
|
+
end
|
20
|
+
|
15
21
|
def track_exception(exception_instance, env = {})
|
16
22
|
create_entry(build_payload_hash(exception_instance, env))
|
17
23
|
end
|
@@ -53,7 +59,7 @@ module Raygun
|
|
53
59
|
end
|
54
60
|
|
55
61
|
def request_information(env)
|
56
|
-
return {} if env.
|
62
|
+
return {} if env.nil? || env.empty?
|
57
63
|
|
58
64
|
{
|
59
65
|
hostName: env["SERVER_NAME"],
|
@@ -69,7 +75,7 @@ module Raygun
|
|
69
75
|
|
70
76
|
def headers(rack_env)
|
71
77
|
rack_env.select do |k, v|
|
72
|
-
k.to_s.
|
78
|
+
k.to_s.start_with?("HTTP_")
|
73
79
|
end
|
74
80
|
end
|
75
81
|
|
@@ -103,4 +109,4 @@ module Raygun
|
|
103
109
|
end
|
104
110
|
|
105
111
|
end
|
106
|
-
end
|
112
|
+
end
|
data/lib/raygun/version.rb
CHANGED
data/lib/raygun.rb
CHANGED
@@ -6,7 +6,6 @@ require "logger"
|
|
6
6
|
require "json"
|
7
7
|
require "socket"
|
8
8
|
require "rack"
|
9
|
-
require "active_support/core_ext"
|
10
9
|
|
11
10
|
require "raygun/version"
|
12
11
|
require "raygun/configuration"
|
@@ -21,6 +20,9 @@ module Raygun
|
|
21
20
|
CLIENT_URL = "https://github.com/MindscapeHQ/raygun4ruby"
|
22
21
|
CLIENT_NAME = "Raygun4Ruby Gem"
|
23
22
|
|
23
|
+
# Exceptions
|
24
|
+
class ApiKeyRequired < StandardError; end
|
25
|
+
|
24
26
|
class << self
|
25
27
|
|
26
28
|
include Testable
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: raygun4ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2013-
|
13
|
+
date: 2013-09-03 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: httparty
|
@@ -44,22 +44,6 @@ dependencies:
|
|
44
44
|
- - ! '>='
|
45
45
|
- !ruby/object:Gem::Version
|
46
46
|
version: '0'
|
47
|
-
- !ruby/object:Gem::Dependency
|
48
|
-
name: activesupport
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
-
none: false
|
51
|
-
requirements:
|
52
|
-
- - ! '>='
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '0'
|
55
|
-
type: :runtime
|
56
|
-
prerelease: false
|
57
|
-
version_requirements: !ruby/object:Gem::Requirement
|
58
|
-
none: false
|
59
|
-
requirements:
|
60
|
-
- - ! '>='
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: '0'
|
63
47
|
- !ruby/object:Gem::Dependency
|
64
48
|
name: rack
|
65
49
|
requirement: !ruby/object:Gem::Requirement
|
@@ -190,6 +174,7 @@ files:
|
|
190
174
|
- lib/raygun/testable.rb
|
191
175
|
- lib/tasks/raygun.tasks
|
192
176
|
- lib/resque/failure/raygun.rb
|
177
|
+
- README.md
|
193
178
|
homepage: http://raygun.io
|
194
179
|
licenses:
|
195
180
|
- MIT
|