exception-ketchup 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -4,7 +4,7 @@ source "http://rubygems.org"
4
4
  # gem "activesupport", ">= 2.3.5"
5
5
 
6
6
  gem 'rails'
7
- gem 'mongoid'
7
+ gem "mongoid"
8
8
  gem 'bson_ext'
9
9
 
10
10
  # Add dependencies to develop your gem here.
@@ -12,7 +12,7 @@ gem 'bson_ext'
12
12
  group :development do
13
13
  gem "rspec", "~> 2.8.0"
14
14
  gem 'rspec-rails'
15
- gem 'mongoid-rspec'
15
+ #gem 'mongoid-rspec'
16
16
  gem 'database_cleaner'
17
17
  gem "rdoc", "~> 3.12"
18
18
  gem "bundler"
@@ -1,45 +1,45 @@
1
1
  GEM
2
2
  remote: http://rubygems.org/
3
3
  specs:
4
- actionmailer (3.2.1)
5
- actionpack (= 3.2.1)
6
- mail (~> 2.4.0)
7
- actionpack (3.2.1)
8
- activemodel (= 3.2.1)
9
- activesupport (= 3.2.1)
4
+ actionmailer (3.2.10)
5
+ actionpack (= 3.2.10)
6
+ mail (~> 2.4.4)
7
+ actionpack (3.2.10)
8
+ activemodel (= 3.2.10)
9
+ activesupport (= 3.2.10)
10
10
  builder (~> 3.0.0)
11
11
  erubis (~> 2.7.0)
12
- journey (~> 1.0.1)
12
+ journey (~> 1.0.4)
13
13
  rack (~> 1.4.0)
14
- rack-cache (~> 1.1)
14
+ rack-cache (~> 1.2)
15
15
  rack-test (~> 0.6.1)
16
- sprockets (~> 2.1.2)
17
- activemodel (3.2.1)
18
- activesupport (= 3.2.1)
16
+ sprockets (~> 2.2.1)
17
+ activemodel (3.2.10)
18
+ activesupport (= 3.2.10)
19
19
  builder (~> 3.0.0)
20
- activerecord (3.2.1)
21
- activemodel (= 3.2.1)
22
- activesupport (= 3.2.1)
23
- arel (~> 3.0.0)
20
+ activerecord (3.2.10)
21
+ activemodel (= 3.2.10)
22
+ activesupport (= 3.2.10)
23
+ arel (~> 3.0.2)
24
24
  tzinfo (~> 0.3.29)
25
- activeresource (3.2.1)
26
- activemodel (= 3.2.1)
27
- activesupport (= 3.2.1)
28
- activesupport (3.2.1)
25
+ activeresource (3.2.10)
26
+ activemodel (= 3.2.10)
27
+ activesupport (= 3.2.10)
28
+ activesupport (3.2.10)
29
29
  i18n (~> 0.6)
30
30
  multi_json (~> 1.0)
31
31
  arel (3.0.2)
32
- bson (1.7.1)
33
- bson_ext (1.7.1)
34
- bson (~> 1.7.1)
32
+ bson (1.8.1)
33
+ bson_ext (1.8.1)
34
+ bson (~> 1.8.1)
35
35
  builder (3.0.4)
36
- database_cleaner (0.7.2)
36
+ database_cleaner (0.9.1)
37
37
  diff-lcs (1.1.3)
38
38
  erubis (2.7.0)
39
- fuubar (1.0.0)
39
+ fuubar (1.1.0)
40
40
  rspec (~> 2.0)
41
41
  rspec-instafail (~> 0.2.0)
42
- ruby-progressbar (~> 0.0.10)
42
+ ruby-progressbar (~> 1.0.0)
43
43
  git (1.2.5)
44
44
  hike (1.2.1)
45
45
  i18n (0.6.1)
@@ -48,46 +48,44 @@ GEM
48
48
  git (>= 1.2.5)
49
49
  rake
50
50
  rdoc
51
- journey (1.0.3)
51
+ journey (1.0.4)
52
52
  json (1.7.6)
53
53
  mail (2.4.4)
54
54
  i18n (>= 0.4.0)
55
55
  mime-types (~> 1.16)
56
56
  treetop (~> 1.4.8)
57
- mime-types (1.18)
58
- mongo (1.7.1)
59
- bson (~> 1.7.1)
60
- mongoid (2.5.0)
57
+ mime-types (1.19)
58
+ mongoid (3.0.16)
61
59
  activemodel (~> 3.1)
62
- mongo (~> 1.7)
60
+ moped (~> 1.1)
61
+ origin (~> 1.0)
63
62
  tzinfo (~> 0.3.22)
64
- mongoid-rspec (1.4.4)
65
- mongoid (~> 2.0)
66
- rspec (~> 2)
67
- multi_json (1.3.7)
63
+ moped (1.3.2)
64
+ multi_json (1.5.0)
65
+ origin (1.0.11)
68
66
  polyglot (0.3.3)
69
- rack (1.4.1)
67
+ rack (1.4.2)
70
68
  rack-cache (1.2)
71
69
  rack (>= 0.4)
72
70
  rack-ssl (1.3.2)
73
71
  rack
74
- rack-test (0.6.1)
72
+ rack-test (0.6.2)
75
73
  rack (>= 1.0)
76
- rails (3.2.1)
77
- actionmailer (= 3.2.1)
78
- actionpack (= 3.2.1)
79
- activerecord (= 3.2.1)
80
- activeresource (= 3.2.1)
81
- activesupport (= 3.2.1)
74
+ rails (3.2.10)
75
+ actionmailer (= 3.2.10)
76
+ actionpack (= 3.2.10)
77
+ activerecord (= 3.2.10)
78
+ activeresource (= 3.2.10)
79
+ activesupport (= 3.2.10)
82
80
  bundler (~> 1.0)
83
- railties (= 3.2.1)
84
- railties (3.2.1)
85
- actionpack (= 3.2.1)
86
- activesupport (= 3.2.1)
81
+ railties (= 3.2.10)
82
+ railties (3.2.10)
83
+ actionpack (= 3.2.10)
84
+ activesupport (= 3.2.10)
87
85
  rack-ssl (~> 1.3.2)
88
86
  rake (>= 0.8.7)
89
87
  rdoc (~> 3.4)
90
- thor (~> 0.14.6)
88
+ thor (>= 0.14.6, < 2.0)
91
89
  rake (10.0.3)
92
90
  rdoc (3.12)
93
91
  json (~> 1.4)
@@ -105,14 +103,15 @@ GEM
105
103
  activesupport (>= 3.0)
106
104
  railties (>= 3.0)
107
105
  rspec (~> 2.8.0)
108
- ruby-progressbar (0.0.10)
109
- sprockets (2.1.2)
106
+ ruby-progressbar (1.0.2)
107
+ sprockets (2.2.2)
110
108
  hike (~> 1.2)
109
+ multi_json (~> 1.0)
111
110
  rack (~> 1.0)
112
111
  tilt (~> 1.1, != 1.3.0)
113
- thor (0.14.6)
112
+ thor (0.16.0)
114
113
  tilt (1.3.3)
115
- treetop (1.4.10)
114
+ treetop (1.4.12)
116
115
  polyglot
117
116
  polyglot (>= 0.3.1)
118
117
  tzinfo (0.3.35)
@@ -127,7 +126,6 @@ DEPENDENCIES
127
126
  fuubar
128
127
  jeweler (~> 1.8.4)
129
128
  mongoid
130
- mongoid-rspec
131
129
  rails
132
130
  rdoc (~> 3.12)
133
131
  rspec (~> 2.8.0)
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  ## Ketchup exception handling
2
2
 
3
- Rails exception handling happens with ActionController extension and Mongoid support.
3
+ Rails exception handling happens with ActionController extension and Mongoid support.
4
+
5
+ With version 0.2 comes Mongoid 3 support.
4
6
 
5
7
  ## Install & Configuration
6
8
 
@@ -95,7 +97,7 @@ If <code>config.persist</code> is set to false, <code>:remember</code> will be i
95
97
  * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
96
98
  * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
97
99
 
98
- == Copyright
100
+ ## Copyright
99
101
 
100
102
  Copyright (c) 2012 Daniel Schmidt. See LICENSE.txt for
101
103
  further details.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
@@ -5,17 +5,16 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "exception-ketchup"
8
- s.version = "0.1.0"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Daniel Schmidt"]
12
- s.date = "2013-01-04"
13
- s.description = "TODO: longer description of your gem"
11
+ s.authors = ["Daniel Schmidt", "Lars M\u{fc}ller"]
12
+ s.date = "2013-01-07"
13
+ s.description = "Rails exception handling happens with ActionController extension and Mongoid support."
14
14
  s.email = "dsci@code79.net"
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE.txt",
17
- "README.md",
18
- "README.rdoc"
17
+ "README.md"
19
18
  ]
20
19
  s.files = [
21
20
  ".document",
@@ -24,14 +23,15 @@ Gem::Specification.new do |s|
24
23
  "Gemfile.lock",
25
24
  "LICENSE.txt",
26
25
  "README.md",
27
- "README.rdoc",
28
26
  "Rakefile",
29
27
  "VERSION",
28
+ "exception-ketchup.gemspec",
30
29
  "lib/exception-ketchup.rb",
31
30
  "lib/rails/controller.rb",
32
31
  "lib/rails/error.rb",
33
32
  "lib/rails/mailer.rb",
34
33
  "lib/util/handler.rb",
34
+ "lib/util/support.rb",
35
35
  "spec/dummy/README.rdoc",
36
36
  "spec/dummy/Rakefile",
37
37
  "spec/dummy/app/assets/javascripts/application.js",
@@ -75,7 +75,7 @@ Gem::Specification.new do |s|
75
75
  s.licenses = ["MIT"]
76
76
  s.require_paths = ["lib"]
77
77
  s.rubygems_version = "1.8.24"
78
- s.summary = "TODO: one-line summary of your gem"
78
+ s.summary = "Rails exception handling happens with ActionController extension and Mongoid support."
79
79
 
80
80
  if s.respond_to? :specification_version then
81
81
  s.specification_version = 3
@@ -86,7 +86,6 @@ Gem::Specification.new do |s|
86
86
  s.add_runtime_dependency(%q<bson_ext>, [">= 0"])
87
87
  s.add_development_dependency(%q<rspec>, ["~> 2.8.0"])
88
88
  s.add_development_dependency(%q<rspec-rails>, [">= 0"])
89
- s.add_development_dependency(%q<mongoid-rspec>, [">= 0"])
90
89
  s.add_development_dependency(%q<database_cleaner>, [">= 0"])
91
90
  s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
92
91
  s.add_development_dependency(%q<bundler>, [">= 0"])
@@ -98,7 +97,6 @@ Gem::Specification.new do |s|
98
97
  s.add_dependency(%q<bson_ext>, [">= 0"])
99
98
  s.add_dependency(%q<rspec>, ["~> 2.8.0"])
100
99
  s.add_dependency(%q<rspec-rails>, [">= 0"])
101
- s.add_dependency(%q<mongoid-rspec>, [">= 0"])
102
100
  s.add_dependency(%q<database_cleaner>, [">= 0"])
103
101
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
104
102
  s.add_dependency(%q<bundler>, [">= 0"])
@@ -111,7 +109,6 @@ Gem::Specification.new do |s|
111
109
  s.add_dependency(%q<bson_ext>, [">= 0"])
112
110
  s.add_dependency(%q<rspec>, ["~> 2.8.0"])
113
111
  s.add_dependency(%q<rspec-rails>, [">= 0"])
114
- s.add_dependency(%q<mongoid-rspec>, [">= 0"])
115
112
  s.add_dependency(%q<database_cleaner>, [">= 0"])
116
113
  s.add_dependency(%q<rdoc>, ["~> 3.12"])
117
114
  s.add_dependency(%q<bundler>, [">= 0"])
@@ -109,6 +109,7 @@ module Ketchup
109
109
  end
110
110
 
111
111
  # require extensions.
112
+ require_relative "util/support"
112
113
  require_relative "rails/error"
113
114
  require_relative "rails/controller"
114
115
  require_relative "rails/mailer.rb"
@@ -4,8 +4,7 @@ module Ketchup
4
4
 
5
5
  class Error
6
6
  include Mongoid::Document
7
-
8
- store_in :errors
7
+ include Ketchup::Exception::SupportedMongos
9
8
 
10
9
  field :kind, :type => String
11
10
  field :message, :type => String
@@ -0,0 +1,20 @@
1
+ module Ketchup
2
+ module Exception
3
+ module SupportedMongos
4
+ extend ActiveSupport::Concern
5
+
6
+ # Checks which Mongoid is used and adjusts the store in a collection
7
+ # method.
8
+ included do
9
+ major,minor,path = Mongoid::VERSION.split(".")
10
+ if major.match(/3/)
11
+ store_in collection: Ketchup::Exception.exception_collection
12
+ elsif major.match(/2/)
13
+ store_in Ketchup::Exception.exception_collection
14
+ end
15
+
16
+ end
17
+
18
+ end
19
+ end
20
+ end
@@ -30,6 +30,11 @@ FakeTestController = Class.new(ApplicationController) do
30
30
 
31
31
  end
32
32
 
33
+ Rails.application.routes.draw do
34
+ match '/show_author/:id' => "fake_test#show"
35
+ end
36
+
37
+
33
38
  describe "exception handling within controller", :type => :controller do
34
39
  let(:recipients){ %W(ds@test.com da@test.com) }
35
40
 
@@ -42,10 +47,17 @@ describe "exception handling within controller", :type => :controller do
42
47
  config.environment = :test
43
48
  end
44
49
 
45
- Author = Class.new do
46
- include Mongoid::Document
50
+ mongo_major = Mongoid::VERSION.split(".").first
47
51
 
48
- store_in :authors
52
+ unless defined?(Author)
53
+ Author = Class.new do
54
+ include Mongoid::Document
55
+ if mongo_major.eql?("3")
56
+ store_in :collection => :authors
57
+ else
58
+ store_in :authors
59
+ end
60
+ end
49
61
  end
50
62
 
51
63
  end
@@ -24,6 +24,10 @@ describe Ketchup::Exception::Error do
24
24
 
25
25
  its(:kind){should eq "StandardError"}
26
26
 
27
+ it "collection name matches configuration" do
28
+ subject.collection.name.to_sym.should eq Ketchup::Exception.exception_collection
29
+ end
30
+
27
31
  end
28
32
 
29
33
  end
@@ -18,7 +18,7 @@ describe Ketchup::Exception do
18
18
  context "for environment" do
19
19
 
20
20
  it "is production" do
21
- subject.environment.should eq :production
21
+ subject.environment.should eq [:production]
22
22
  end
23
23
 
24
24
  end
@@ -6,7 +6,6 @@ ENV["RAILS_ENV"] = "test"
6
6
  require File.expand_path("../dummy/config/environment.rb", __FILE__)
7
7
 
8
8
  require 'rspec/rails'
9
- require 'mongoid-rspec'
10
9
  require 'database_cleaner'
11
10
 
12
11
  ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: exception-ketchup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
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-01-04 00:00:00.000000000 Z
13
+ date: 2013-01-07 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
@@ -92,22 +92,6 @@ dependencies:
92
92
  - - ! '>='
93
93
  - !ruby/object:Gem::Version
94
94
  version: '0'
95
- - !ruby/object:Gem::Dependency
96
- name: mongoid-rspec
97
- requirement: !ruby/object:Gem::Requirement
98
- none: false
99
- requirements:
100
- - - ! '>='
101
- - !ruby/object:Gem::Version
102
- version: '0'
103
- type: :development
104
- prerelease: false
105
- version_requirements: !ruby/object:Gem::Requirement
106
- none: false
107
- requirements:
108
- - - ! '>='
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
95
  - !ruby/object:Gem::Dependency
112
96
  name: database_cleaner
113
97
  requirement: !ruby/object:Gem::Requirement
@@ -196,16 +180,13 @@ extensions: []
196
180
  extra_rdoc_files:
197
181
  - LICENSE.txt
198
182
  - README.md
199
- - README.rdoc
200
183
  files:
201
184
  - .document
202
185
  - .rspec
203
- - .rvmrc
204
186
  - Gemfile
205
187
  - Gemfile.lock
206
188
  - LICENSE.txt
207
189
  - README.md
208
- - README.rdoc
209
190
  - Rakefile
210
191
  - VERSION
211
192
  - exception-ketchup.gemspec
@@ -214,6 +195,7 @@ files:
214
195
  - lib/rails/error.rb
215
196
  - lib/rails/mailer.rb
216
197
  - lib/util/handler.rb
198
+ - lib/util/support.rb
217
199
  - spec/dummy/README.rdoc
218
200
  - spec/dummy/Rakefile
219
201
  - spec/dummy/app/assets/javascripts/application.js
@@ -267,7 +249,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
267
249
  version: '0'
268
250
  segments:
269
251
  - 0
270
- hash: 987405559075421703
252
+ hash: 4275328440188607377
271
253
  required_rubygems_version: !ruby/object:Gem::Requirement
272
254
  none: false
273
255
  requirements:
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm use 1.9.3@ovula
@@ -1,102 +0,0 @@
1
- ## Ketchup exception handling
2
-
3
- Rails exception handling happens with ActionController extension and Mongoid support.
4
-
5
- ## Install & Configuration
6
-
7
- Add
8
-
9
- ```ruby
10
- gem "exception-ketchup"
11
- ```
12
-
13
- to your Gemfile.
14
-
15
- Add a file to <code>Rails.root/initializers/</code>.
16
-
17
- Configure <code>Ketchup::Exception</code>:
18
-
19
- ```ruby
20
-
21
- # Config Exception handling here.
22
- Ketchup::Exception.setup do |config|
23
- # A list email of addresses to which the exception notification should be mailed.
24
- config.recipients = %W(daniel.schmidt@datenspiel.com lars.mueller@datenspiel.com)
25
- # Subject to use for email.
26
- config.subject = "Error happens at myovulasens"
27
- # The path to the mail template
28
- config.template_path = "notifications"
29
- # The following are optional configurations
30
- # Disables or enables delivering of exception messages. Defaults to true.
31
- # config.deliver_mail = false
32
- # Disables or enables persisting of exception messages. Defaults to true
33
- # config.persist = false
34
- # Define the collection name hwere to exception messages should be stored.
35
- # Defaults to :errors
36
- # config.exception_collection = :errors
37
- # Define a Proc here that is responsible for logging messages.
38
- # See exception-ketchup.rb for details about.
39
- # config.log_error = lambda do |error|
40
- # # do something with err.
41
- # end
42
- # The Rails env(s) to use. Optional for configuration, defaults to :production
43
- # config.environment = [:production]
44
- end
45
- ```
46
-
47
- ## Make it available
48
-
49
- Add to your controller class:
50
-
51
- ```ruby
52
-
53
- class ApplicationController
54
-
55
- ketchup_exceptions do |c|
56
- c.rescue_errors = [
57
- {:error => RestClient::ServerBrokeConnection, :with => :server_not_responding},
58
- {:error => CanCan::AccessDenied, :with => :unauthorized,
59
- :notify => false,
60
- :remember => false,
61
- :log => true}
62
- ]
63
- end
64
-
65
- end
66
-
67
- ```
68
-
69
- <code>rescue_errors</code> - Configure which exceptions you want to treat in a special way by using the following options
70
- * <code>error</code>: Class, mandatory.
71
- Error-Class to handle
72
- * <code>with</code>: Symbol|Proc.
73
- Method to execute for individual error handling. This method should take
74
- one argument which is the error that was raised.
75
- If this is omitted, be sure to implement a <code>:respond_with_error</code> method.
76
- * <code>remember</code>: Boolean, default: <code>true</code>
77
- Wether or not write the error to the database
78
- * <code>notify</code>: Boolean, default: <code>true</code>
79
- Wether or not to send an email to the configured recipients
80
- * <code>log</code>: Boolean, default: <code>true</code>
81
- Wether or not to log the exception
82
-
83
- **Note:**
84
-
85
- If <code>config.deliver_mail</code> is set to false, <code>:notify</code> will be ignored.
86
- If <code>config.persist</code> is set to false, <code>:remember</code> will be ignored.
87
-
88
- ## Contributing to exception-ketchup
89
-
90
- * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
91
- * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
92
- * Fork the project.
93
- * Start a feature/bugfix branch.
94
- * Commit and push until you are happy with your contribution.
95
- * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
96
- * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
97
-
98
- ## Copyright
99
-
100
- Copyright (c) 2012 Datenspiel GmbH. Contributors Daniel Schmidt (@dsci), Lars Müller (@lmue)
101
- See LICENSE.txt forfurther details.
102
-