exceptional 2.0.23 → 2.0.24

Sign up to get free protection for your applications and to get access to all the features.
data/bin/exceptional CHANGED
@@ -9,6 +9,7 @@ case command
9
9
  puts <<USAGE
10
10
  help # Show this usage.
11
11
  test # Send a test exception to Exceptional.
12
+ alert <message> # Send a message to Exceptional. Exits 0 for success, 1 for config error, and 2 for report failure
12
13
  install <api_key> # Create config/exceptional.yml with your api_key. Overrites existing one.
13
14
  install <api_key> <environment> # Create config/exceptional.yml with your api_key and enabled for a specific environment. Overrites existing config file.
14
15
  install <api_key> <environment>,<environment> # Create config/exceptional.yml with your api_key enabled for multiple environments (comma seperated). Overrites existing config file.
@@ -30,7 +31,18 @@ USAGE
30
31
  Exceptional::Integration.test
31
32
  else
32
33
  puts 'API key not configured'
33
- end
34
+ end
35
+ when 'alert'
36
+ require "exceptional"
37
+ require "exceptional/alert_data"
38
+ require "exceptional/integration/alerter"
39
+ Exceptional::Config.load('config/exceptional.yml')
40
+ if Exceptional::Config.api_key
41
+ exit(Exceptional::Integration.alert(args[0]) ? 0 : 2)
42
+ else
43
+ puts 'API key not configured. Put exceptional.yml in current directory or /config'
44
+ exit(1)
45
+ end
34
46
  when 'install'
35
47
  api_key = args[0]
36
48
  environments = args[1]
data/lib/exceptional.rb CHANGED
@@ -9,9 +9,11 @@ require 'exceptional/application_environment'
9
9
  require 'exceptional/exception_data'
10
10
  require 'exceptional/controller_exception_data'
11
11
  require 'exceptional/rack_exception_data'
12
+ require 'exceptional/alert_data'
12
13
  require 'exceptional/remote'
13
14
  require 'exceptional/integration/rack'
14
15
  require 'exceptional/integration/rack_rails'
16
+ require 'exceptional/integration/alerter'
15
17
  require 'exceptional/version'
16
18
 
17
19
  require 'exceptional/railtie' if defined?(Rails::Railtie)
@@ -0,0 +1,15 @@
1
+ module Exceptional
2
+ class AlertData < ExceptionData
3
+ # Overwrite backtrace, since it is irrelevant
4
+ def extra_data
5
+ {
6
+ 'exception' => {
7
+ 'exception_class' => @exception.class.to_s,
8
+ 'message' => @exception.message,
9
+ 'backtrace' => "",
10
+ 'occurred_at' => Time.now
11
+ }
12
+ }
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,11 @@
1
+ module Exceptional
2
+ class Alert <StandardError;
3
+ end
4
+
5
+ module Integration
6
+ def self.alert(msg, env={})
7
+ return Exceptional::Remote.error(Exceptional::AlertData.new(Alert.new(msg), "Alert"))
8
+ end
9
+ end
10
+ end
11
+
@@ -1,3 +1,3 @@
1
1
  module Exceptional
2
- VERSION = '2.0.23'
2
+ VERSION = '2.0.24'
3
3
  end
@@ -0,0 +1,12 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Exceptional::AlertData do
4
+ it "raises error" do
5
+ data = Exceptional::AlertData.new(Exceptional::Alert.new("A string"), "Alert")
6
+ result_json = JSON.parse(data.to_json)
7
+ puts result_json.inspect
8
+ result_json['rescue_block']['name'].should == 'Alert'
9
+ result_json['exception']['message'].should == "A string"
10
+ result_json['exception']['exception_class'] == 'Exceptional::Alert'
11
+ end
12
+ end
@@ -0,0 +1,26 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+ require 'digest/md5'
3
+
4
+
5
+ class Exceptional::FunkyError < StandardError
6
+ def backtrace
7
+ 'backtrace'
8
+ end
9
+ end
10
+
11
+ class BrokenJSON
12
+ def to_json
13
+ boom.time!
14
+ end
15
+ end
16
+
17
+ describe Exceptional::ControllerExceptionData do
18
+ it "raises useful error when to_json isn't available on to_hash" do
19
+ request = ActionController::TestRequest.new
20
+ brokenJson = BrokenJSON.new
21
+ session = {:boom => brokenJson}
22
+ request.stub!(:session).and_return(session)
23
+ data = Exceptional::ControllerExceptionData.new(Exceptional::FunkyError.new, nil, request)
24
+ JSON.parse(data.to_json)['request']['session']['data'].should == {"boom" => brokenJson.to_s}
25
+ end
26
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exceptional
3
3
  version: !ruby/object:Gem::Version
4
- hash: 33
4
+ hash: 63
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 0
9
- - 23
10
- version: 2.0.23
9
+ - 24
10
+ version: 2.0.24
11
11
  platform: ruby
12
12
  authors:
13
13
  - Contrast
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-08-11 00:00:00 +01:00
18
+ date: 2010-08-17 00:00:00 +01:00
19
19
  default_executable:
20
20
  dependencies: []
21
21
 
@@ -28,11 +28,13 @@ extensions: []
28
28
  extra_rdoc_files: []
29
29
 
30
30
  files:
31
+ - lib/exceptional/alert_data.rb
31
32
  - lib/exceptional/application_environment.rb
32
33
  - lib/exceptional/catcher.rb
33
34
  - lib/exceptional/config.rb
34
35
  - lib/exceptional/controller_exception_data.rb
35
36
  - lib/exceptional/exception_data.rb
37
+ - lib/exceptional/integration/alerter.rb
36
38
  - lib/exceptional/integration/dj.rb
37
39
  - lib/exceptional/integration/rack.rb
38
40
  - lib/exceptional/integration/rack_rails.rb
@@ -49,8 +51,10 @@ files:
49
51
  - lib/exceptional.rb
50
52
  - spec/bin/ginger
51
53
  - spec/dj_integration_spec.rb
54
+ - spec/exceptional/alert_exception_data_spec.rb
52
55
  - spec/exceptional/catcher_spec.rb
53
56
  - spec/exceptional/config_spec.rb
57
+ - spec/exceptional/controller_exception_data_spec.rb
54
58
  - spec/exceptional/exception_data_spec.rb
55
59
  - spec/exceptional/monkeypatches_spec.rb
56
60
  - spec/exceptional/rack_exception_data_spec.rb