toadhopper-sinatra 0.1 → 0.3

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2009 Tim Lucas
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/Rakefile CHANGED
@@ -10,5 +10,14 @@ begin
10
10
  gem "sr-mg", "<= 0.0.5"
11
11
  require "mg"
12
12
  MG.new("toadhopper-sinatra.gemspec")
13
- rescue LoadError
13
+ rescue Gem::LoadError
14
+ end
15
+
16
+ begin
17
+ gem "yard"
18
+ require 'yard'
19
+ YARD::Rake::YardocTask.new do |t|
20
+ t.options = ['-r', 'Readme.md', '--files', 'LICENSE'] # optional
21
+ end
22
+ rescue Gem::LoadError
14
23
  end
data/Readme.md CHANGED
@@ -1,12 +1,26 @@
1
- A Sinatra plugin for [Hoptoad](http://www.hoptoadapp.com/) error reporting that uses the toadhopper gem.
1
+ [Hoptoad](http://www.hoptoadapp.com/) meets [Sinatra](http://www.sinatrarb.com/).
2
2
 
3
- You configure the Toadhopper gem as-per usual, this plugin simply adds a `report_error_to_hoptoad!` method.
3
+ _____ ,
4
+ / \______ |\ __
5
+ | o | \____ | | |--| __
6
+ /\_____/ \___ |/ | | |~'
7
+ / \ /|_ () () |
8
+ |_______/ \ //| \ |\ ()
9
+ \______ _ ___ \ | \|_ | | \
10
+ /\_// / \ | \_|_/ () |
11
+ // //______/ /___/ | |
12
+ /\/\/\ \ / \ \ @' ()
13
+ \ \ \ \
14
+ \ \ \ \
15
+ \ \ \ \
16
+ \ \ /\/\
17
+ /\/\
4
18
 
5
- ## Example
19
+ How?
6
20
 
7
21
  require 'sinatra/toadhopper'
8
22
 
9
- set :toadhopper, :api_key => "YOURAPIKEY"
23
+ set :toadhopper, :api_key => "your hoptoad API key", :filters => /password/
10
24
 
11
25
  get "/" do
12
26
  raise "Kaboom!"
@@ -16,3 +30,7 @@ You configure the Toadhopper gem as-per usual, this plugin simply adds a `report
16
30
  post_error_to_hoptoad!
17
31
  "Ouch, that hurt."
18
32
  end
33
+
34
+ Install it via rubygems:
35
+
36
+ gem install toadhopper-sinatra
@@ -2,14 +2,17 @@ require 'sinatra/base'
2
2
  require 'toadhopper'
3
3
 
4
4
  module Sinatra
5
+ # The Toadhopper helper methods
5
6
  module Toadhopper
6
- # Reports the current sinatra error to Hoptoad.
7
+ # Reports the current sinatra error to Hoptoad
7
8
  def post_error_to_hoptoad!
8
- unless api_key = options.respond_to?(:toadhopper) && options.toadhopper[:api_key]
9
- STDERR.puts "WARNING: Ignoring post_error_to_hoptoad! - :api_key not set"
9
+ if options.respond_to?(:toadhopper)
10
+ options.toadhopper.each_pair {|k, v| ::Toadhopper.__send__("#{k}=", v)}
11
+ end
12
+ unless ::Toadhopper.api_key
13
+ STDERR.puts "WARNING: Ignoring hoptoad notification - :api_key not set"
10
14
  return
11
15
  end
12
- ::Toadhopper.api_key = api_key
13
16
  ::Toadhopper.post!(
14
17
  env['sinatra.error'],
15
18
  {
@@ -8,6 +8,16 @@ require 'toadhopper/test/methods'
8
8
  $:.unshift File.dirname(__FILE__) + "/../lib"
9
9
  require 'sinatra/toadhopper'
10
10
 
11
+ # Stub the Toadhopper posting
12
+
13
+ def Toadhopper.post!(*args)
14
+ instance_variable_set(:@last_post_arguments, args)
15
+ end
16
+
17
+ def Toadhopper.last_post_arguments
18
+ instance_variable_get(:@last_post_arguments)
19
+ end
20
+
11
21
  class TestReportErrorToHoptoad < Test::Unit::TestCase
12
22
 
13
23
  class AppThatGoesBoom < Sinatra::Base
@@ -17,7 +27,7 @@ class TestReportErrorToHoptoad < Test::Unit::TestCase
17
27
  set :raise_errors, false
18
28
  set :sessions, true
19
29
 
20
- set :toadhopper, :api_key => "apikey"
30
+ set :toadhopper, :api_key => "apikey", :filters => /afilter/
21
31
 
22
32
  get "/:id" do
23
33
  session["id"] = "sessionid"
@@ -31,19 +41,20 @@ class TestReportErrorToHoptoad < Test::Unit::TestCase
31
41
  end
32
42
 
33
43
  include Rack::Test::Methods
34
- include Toadhopper::Test::Methods
35
44
 
36
45
  def app; AppThatGoesBoom end
37
46
 
38
47
  def setup
39
- stub_toadhopper_post!
40
48
  get "/theid"
41
- @error, @options, @header_options = last_toadhopper_post_arguments
49
+ @error, @options, @header_options = Toadhopper.last_post_arguments
42
50
  end
43
51
 
44
52
  def test_api_key_set
45
53
  assert_equal "apikey", Toadhopper.api_key
46
54
  end
55
+ def test_filter_set
56
+ assert_equal [/afilter/], Toadhopper.filters
57
+ end
47
58
 
48
59
  def test_reported_error
49
60
  assert_equal RuntimeError, @error.class
@@ -73,12 +84,10 @@ class TestFailsSilentWithoutApiKey < Test::Unit::TestCase
73
84
  end
74
85
 
75
86
  include Rack::Test::Methods
76
- include Toadhopper::Test::Methods
77
87
 
78
88
  def app; AppWithoutApiKey end
79
89
 
80
90
  def test_doesnt_raise_an_error
81
- stub_toadhopper_post!
82
91
  assert_nothing_raised { get "/" }
83
92
  end
84
93
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: toadhopper-sinatra
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.1"
4
+ version: "0.3"
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Lucas
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-09-16 00:00:00 +10:00
12
+ date: 2009-09-17 00:00:00 +10:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
@@ -20,7 +20,7 @@ dependencies:
20
20
  requirements:
21
21
  - - ">="
22
22
  - !ruby/object:Gem::Version
23
- version: "0.4"
23
+ version: "0.5"
24
24
  version:
25
25
  description: Post Hoptoad notifications from Sinatra
26
26
  email: t.lucas@toolmantim.com
@@ -33,6 +33,7 @@ extra_rdoc_files:
33
33
  files:
34
34
  - Readme.md
35
35
  - Rakefile
36
+ - LICENSE
36
37
  - lib/sinatra/toadhopper.rb
37
38
  - test/test_report_error_to_hoptoad.rb
38
39
  has_rdoc: true
@@ -56,7 +57,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
56
57
  version:
57
58
  requirements: []
58
59
 
59
- rubyforge_project:
60
+ rubyforge_project: th-sinatra
60
61
  rubygems_version: 1.3.1
61
62
  signing_key:
62
63
  specification_version: 2