maser-hoptoad-notifier-client 1.0.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.
@@ -0,0 +1,6 @@
1
+ === 1.0.0 / 2008-10-22
2
+
3
+ * 1 Created
4
+
5
+ * Birthday!
6
+
@@ -0,0 +1,7 @@
1
+ History.txt
2
+ Manifest.txt
3
+ README.txt
4
+ Rakefile
5
+ bin/hoptoad-notifier-client
6
+ lib/hoptoad-notifier-client
7
+ test/hoptoad-notifier-client
@@ -0,0 +1,89 @@
1
+ = hoptoad-notifier-client
2
+
3
+ Posts exceptions to http://www.optoadapp.com using their api: http://wesmaldonado.hoptoadapp.com/pages/api
4
+
5
+ == DESCRIPTION:
6
+
7
+ Sends exceptions to Hoptoad [http://www.hoptoadapp.com/]. Supports reporting against multiple api keys and customized error_types/messages when you're too lazy to subclass exception but still want to report something.
8
+
9
+ or...
10
+
11
+ A standalone tiny HoptoadNotifier. Supports posting to multiple projects (aka api keys). Posting exceptions or information ala Eugene Bolshakov's post http://www.taknado.com/2008/10/19/hoptoad-as-an-online-events-log with ease.
12
+
13
+ == FEATURES/PROBLEMS:
14
+
15
+ === Features ===
16
+
17
+ * Easy to use in non-rails apps and less code than doing it yourself.
18
+ * Matches the HoptoadNotifier API
19
+ * Supports multiple projects (api keys) so you can configure it once via an intializer in rails and have it report against many projects (or business units/features/etc.)
20
+
21
+ === Problems ===
22
+
23
+ * Its only a few lines of code, so why use it at all? :)
24
+ * I'm lazy and need to move the specs from the work project into this branch.
25
+
26
+ == SYNOPSIS:
27
+
28
+ HoptoadNotifierClient.configure do |toad|
29
+ # Only have one project on Hoptoad?
30
+ # Register a default and you can use the shorter HoptoadNotifierClient.notify(exception) method
31
+ toad.register(:default, 'default-api-key')
32
+
33
+ # What!?!? Several projects or sub components you want to report via separate projects?
34
+ # Register them with a names like :profitable_feature
35
+ toad.register(:profitable_feature, 'profitable-feature-api-key')
36
+
37
+ end
38
+
39
+ Sometime later in your code...
40
+
41
+ begin
42
+ raise 'Not a happy camper!'
43
+ rescue => ex
44
+ # reports using :default project
45
+ HoptoadNotifierClient.notify(ex)
46
+
47
+ # reports using profitable feature project, unbelievable!
48
+ HoptoadNotifierClient.create(:profitable_feature).notify(exception)
49
+
50
+ # reports random information for the profitable feature project, unbelievable!
51
+ error_report = OpenStruct.new(:error_type => 'random thing', :custom_message => 'where am I?')
52
+ # Hoptoad Notifcation Subject Line looks like this
53
+ # [Profitable Feature] : #{error_type}: #{custom_message}
54
+ HoptoadNotifierClient.create(:profitable_feature).notify(error_report, more_detail_as_request_parameter)
55
+
56
+ end
57
+
58
+ == REQUIREMENTS:
59
+
60
+ * HTTParty
61
+
62
+ == INSTALL:
63
+
64
+ * TODO (sudo gem install, anything else)
65
+
66
+ == LICENSE:
67
+
68
+ (The MIT License)
69
+
70
+ Copyright (c) 2008 Wes Maldonado
71
+
72
+ Permission is hereby granted, free of charge, to any person obtaining
73
+ a copy of this software and associated documentation files (the
74
+ 'Software'), to deal in the Software without restriction, including
75
+ without limitation the rights to use, copy, modify, merge, publish,
76
+ distribute, sublicense, and/or sell copies of the Software, and to
77
+ permit persons to whom the Software is furnished to do so, subject to
78
+ the following conditions:
79
+
80
+ The above copyright notice and this permission notice shall be
81
+ included in all copies or substantial portions of the Software.
82
+
83
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
84
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
85
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
86
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
87
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
88
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
89
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,13 @@
1
+ begin
2
+ require 'jeweler'
3
+ Jeweler::Tasks.new do |s|
4
+ s.name = "hoptoad-notifier-client"
5
+ s.summary = "Simple class that sends data to Hoptoad using HTTParty"
6
+ s.homepage = "http://github.com/maser/hoptoad-notifier-client/tree/master"
7
+ s.authors = ["Wes Maldonado (code)", "Martin Luder (rubygem)"]
8
+ s.files = FileList["[A-Z]*", "lib/**/*"]
9
+ s.add_dependency 'httparty'
10
+ end
11
+ rescue LoadError
12
+ puts "Jeweler, or one of its dependencies, is not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
13
+ end
@@ -0,0 +1,4 @@
1
+ ---
2
+ :major: 1
3
+ :minor: 0
4
+ :patch: 0
@@ -0,0 +1,64 @@
1
+ class HoptoadNotifierClient
2
+
3
+ require 'rubygems'
4
+ require 'httparty'
5
+ include HTTParty
6
+
7
+ base_uri "http://hoptoadapp.com"
8
+ format :xml
9
+ @instances = {}
10
+
11
+ class << self
12
+ attr_accessor :instances
13
+ def configure
14
+ yield self
15
+ end
16
+ end
17
+
18
+ def self.register(name, key)
19
+ @instances[name] = HoptoadNotifierClient.new(key)
20
+ end
21
+
22
+ def self.create(name)
23
+ @instances[name]
24
+ end
25
+
26
+ # proxy existing class level calls to original api key
27
+ def self.notify(error, request = {}, session = {})
28
+ raise "No :default project registered, register one to use this call." unless @instances.has_key?(:default)
29
+ @instances[:default].notify(error, request, session)
30
+ end
31
+
32
+ def initialize(key)
33
+ raise "API Key required." unless key
34
+ @api_key = key
35
+ end
36
+
37
+ def notify(error, request = {}, session = {})
38
+
39
+ error_type = error.respond_to?(:error_type) ? error.error_type : error.class.name
40
+ error_message = error.respond_to?(:custom_message) ? error.custom_message : "#{error.class.name}: #{error.message}"
41
+
42
+ data = {'notice' => {
43
+ 'api_key' => @api_key,
44
+ 'request' => request,
45
+ 'error_class' => error_type,
46
+ 'error_message' => error_message,
47
+ 'backtrace' => error.backtrace ||= [],
48
+ 'environment' => ENV.to_hash,
49
+ 'session' => session
50
+ }}
51
+ begin
52
+ response = self.class.post "/notices/",
53
+ :body => data.to_yaml,
54
+ :headers => {
55
+ "Content-type" => "application/x-yaml",
56
+ "Accept" => "text/xml, application/xml"
57
+ }
58
+
59
+ rescue Exception => e
60
+ puts "Something went wrong, is your API key correct? Exception was #{e}"
61
+ # logger.error "HoptoadNotificationClient FAILED during notification: Exception was [#{e.to_s}]" if logger
62
+ end
63
+ end
64
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: maser-hoptoad-notifier-client
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Wes Maldonado (code)
8
+ - Martin Luder (rubygem)
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2009-06-25 00:00:00 -07:00
14
+ default_executable:
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
17
+ name: httparty
18
+ type: :runtime
19
+ version_requirement:
20
+ version_requirements: !ruby/object:Gem::Requirement
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: "0"
25
+ version:
26
+ description:
27
+ email:
28
+ executables: []
29
+
30
+ extensions: []
31
+
32
+ extra_rdoc_files:
33
+ - README.txt
34
+ files:
35
+ - History.txt
36
+ - Manifest.txt
37
+ - README.txt
38
+ - Rakefile
39
+ - VERSION.yml
40
+ - lib/hoptoad_notifier_client.rb
41
+ has_rdoc: true
42
+ homepage: http://github.com/maser/hoptoad-notifier-client/tree/master
43
+ post_install_message:
44
+ rdoc_options:
45
+ - --charset=UTF-8
46
+ require_paths:
47
+ - lib
48
+ required_ruby_version: !ruby/object:Gem::Requirement
49
+ requirements:
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: "0"
53
+ version:
54
+ required_rubygems_version: !ruby/object:Gem::Requirement
55
+ requirements:
56
+ - - ">="
57
+ - !ruby/object:Gem::Version
58
+ version: "0"
59
+ version:
60
+ requirements: []
61
+
62
+ rubyforge_project:
63
+ rubygems_version: 1.2.0
64
+ signing_key:
65
+ specification_version: 3
66
+ summary: Simple class that sends data to Hoptoad using HTTParty
67
+ test_files: []
68
+