loganb-nestegg 0.0.2
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/History.txt +8 -0
- data/License.txt +20 -0
- data/Manifest.txt +19 -0
- data/README.txt +3 -0
- data/Rakefile +27 -0
- data/VERSION +1 -0
- data/examples/nestegg_example.rb +24 -0
- data/lib/nestegg.rb +2 -0
- data/lib/nestegg/nesting_exception.rb +26 -0
- data/lib/nestegg/version.rb +9 -0
- data/nestegg.gemspec +54 -0
- data/spec/nestegg/nesting_exception_spec.rb +63 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +3 -0
- metadata +69 -0
data/History.txt
ADDED
data/License.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2007 FIXME full name
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
History.txt
|
2
|
+
License.txt
|
3
|
+
Manifest.txt
|
4
|
+
README.txt
|
5
|
+
Rakefile
|
6
|
+
examples/nestegg_example.rb
|
7
|
+
lib/nestegg.rb
|
8
|
+
lib/nestegg/nesting_exception.rb
|
9
|
+
lib/nestegg/version.rb
|
10
|
+
scripts/txt2html
|
11
|
+
setup.rb
|
12
|
+
spec/nestegg/nesting_exception_spec.rb
|
13
|
+
spec/spec.opts
|
14
|
+
spec/spec_helper.rb
|
15
|
+
website/index.html
|
16
|
+
website/index.txt
|
17
|
+
website/javascripts/rounded_corners_lite.inc.js
|
18
|
+
website/stylesheets/screen.css
|
19
|
+
website/template.rhtml
|
data/README.txt
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
begin
|
2
|
+
require 'jeweler'
|
3
|
+
Jeweler::Tasks.new do |gemspec|
|
4
|
+
gemspec.name = "nestegg"
|
5
|
+
gemspec.summary = "Nested exceptions for ruby"
|
6
|
+
gemspec.description = "Module to add a 'cause' field to exceptions and automatically chains exceptions on re-raise"
|
7
|
+
gemspec.email = "duelin dot markers at gmail"
|
8
|
+
gemspec.homepage = "http://nestegg.rubyforge.org"
|
9
|
+
gemspec.authors = ["John D. Hume"]
|
10
|
+
end
|
11
|
+
rescue LoadError
|
12
|
+
puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
|
13
|
+
return
|
14
|
+
end
|
15
|
+
|
16
|
+
begin
|
17
|
+
require 'spec/rake/spectask'
|
18
|
+
rescue LoadError
|
19
|
+
puts 'To use rspec for testing you must install rspec gem:'
|
20
|
+
puts '$ sudo gem install rspec'
|
21
|
+
exit
|
22
|
+
end
|
23
|
+
|
24
|
+
Spec::Rake::SpecTask.new do |t|
|
25
|
+
t.spec_opts = ['--options', "spec/spec.opts"]
|
26
|
+
t.spec_files = FileList['spec/**/*_spec.rb']
|
27
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.2
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'nestegg'
|
3
|
+
|
4
|
+
class ConfigurationError < StandardError
|
5
|
+
include Nestegg::NestingException
|
6
|
+
end
|
7
|
+
|
8
|
+
def read_config_file
|
9
|
+
File.open('missing_config_file') do |f|
|
10
|
+
f.readlines
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def load_config
|
15
|
+
begin
|
16
|
+
lines = read_config_file
|
17
|
+
# ... then use it to do stuff
|
18
|
+
# ... stuff that might fail for other reasons
|
19
|
+
rescue
|
20
|
+
raise ConfigurationError
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
load_config
|
data/lib/nestegg.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
module Nestegg
|
2
|
+
module NestingException
|
3
|
+
|
4
|
+
attr_reader :cause
|
5
|
+
|
6
|
+
def initialize message = nil, cause = $!
|
7
|
+
@cause = cause
|
8
|
+
end
|
9
|
+
|
10
|
+
def set_backtrace bt
|
11
|
+
if cause
|
12
|
+
cause.backtrace.reverse.each do |line|
|
13
|
+
if bt.last == line
|
14
|
+
bt.pop
|
15
|
+
else
|
16
|
+
break
|
17
|
+
end
|
18
|
+
end
|
19
|
+
bt << "cause: #{cause.class.name}: #{cause}"
|
20
|
+
bt.concat cause.backtrace
|
21
|
+
end
|
22
|
+
super bt
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
data/nestegg.gemspec
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{nestegg}
|
8
|
+
s.version = "0.0.2"
|
9
|
+
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
+
s.authors = ["John D. Hume"]
|
12
|
+
s.date = %q{2009-09-22}
|
13
|
+
s.description = %q{Module to add a 'cause' field to exceptions and automatically chains exceptions on re-raise}
|
14
|
+
s.email = %q{duelin dot markers at gmail}
|
15
|
+
s.extra_rdoc_files = [
|
16
|
+
"README.txt"
|
17
|
+
]
|
18
|
+
s.files = [
|
19
|
+
"History.txt",
|
20
|
+
"License.txt",
|
21
|
+
"Manifest.txt",
|
22
|
+
"README.txt",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"examples/nestegg_example.rb",
|
26
|
+
"lib/nestegg.rb",
|
27
|
+
"lib/nestegg/nesting_exception.rb",
|
28
|
+
"lib/nestegg/version.rb",
|
29
|
+
"nestegg.gemspec",
|
30
|
+
"spec/nestegg/nesting_exception_spec.rb",
|
31
|
+
"spec/spec.opts",
|
32
|
+
"spec/spec_helper.rb"
|
33
|
+
]
|
34
|
+
s.homepage = %q{http://nestegg.rubyforge.org}
|
35
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
36
|
+
s.require_paths = ["lib"]
|
37
|
+
s.rubygems_version = %q{1.3.5}
|
38
|
+
s.summary = %q{Nested exceptions for ruby}
|
39
|
+
s.test_files = [
|
40
|
+
"spec/nestegg/nesting_exception_spec.rb",
|
41
|
+
"spec/spec_helper.rb",
|
42
|
+
"examples/nestegg_example.rb"
|
43
|
+
]
|
44
|
+
|
45
|
+
if s.respond_to? :specification_version then
|
46
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
47
|
+
s.specification_version = 3
|
48
|
+
|
49
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
50
|
+
else
|
51
|
+
end
|
52
|
+
else
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
|
2
|
+
|
3
|
+
describe Nestegg::NestingException do
|
4
|
+
|
5
|
+
class TestNestingError < StandardError
|
6
|
+
include Nestegg::NestingException
|
7
|
+
end
|
8
|
+
|
9
|
+
def create_cause(klass = StandardError, message = "cause msg", backtrace = ["line_one", "line_two"])
|
10
|
+
e = klass.new(message)
|
11
|
+
e.set_backtrace backtrace
|
12
|
+
e
|
13
|
+
end
|
14
|
+
|
15
|
+
def with_exception exception
|
16
|
+
begin
|
17
|
+
raise exception
|
18
|
+
rescue exception.class => e
|
19
|
+
yield e
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
it "includes cause in backtrace" do
|
24
|
+
cause = create_cause(StandardError)
|
25
|
+
with_exception TestNestingError.new("some message", cause) do |e|
|
26
|
+
e.backtrace.should include("cause: StandardError: #{cause.message}")
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
it "includes cause's backtrace after cause in backtrace" do
|
31
|
+
cause = create_cause(StandardError)
|
32
|
+
with_exception TestNestingError.new("some message", cause) do |e|
|
33
|
+
e.backtrace[-3..-1].should == ["cause: StandardError: #{cause.message}", "line_one", "line_two"]
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
it "removes duplicated backtrace elements from nesting exception" do
|
38
|
+
cause_bt = caller.unshift "some_other_line"
|
39
|
+
cause = create_cause(StandardError, "msg", cause_bt)
|
40
|
+
begin
|
41
|
+
line = __LINE__ + 1
|
42
|
+
raise TestNestingError.new("msg", cause)
|
43
|
+
rescue TestNestingError => e
|
44
|
+
e.backtrace[0..1].should == ["#{__FILE__}:#{line}", "cause: StandardError: msg"]
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
it "defaults cause to current raised exception ($!)" do
|
49
|
+
expected_cause = StandardError.new
|
50
|
+
raised_error = nil
|
51
|
+
begin
|
52
|
+
begin
|
53
|
+
raise expected_cause
|
54
|
+
rescue
|
55
|
+
raise TestNestingError
|
56
|
+
end
|
57
|
+
rescue TestNestingError => e
|
58
|
+
raised_error = e
|
59
|
+
end
|
60
|
+
raised_error.cause.should == expected_cause
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
data/spec/spec.opts
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--colour -f specdoc
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: loganb-nestegg
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- John D. Hume
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2009-09-22 00:00:00 -07:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Module to add a 'cause' field to exceptions and automatically chains exceptions on re-raise
|
17
|
+
email: duelin dot markers at gmail
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README.txt
|
24
|
+
files:
|
25
|
+
- History.txt
|
26
|
+
- License.txt
|
27
|
+
- Manifest.txt
|
28
|
+
- README.txt
|
29
|
+
- Rakefile
|
30
|
+
- VERSION
|
31
|
+
- examples/nestegg_example.rb
|
32
|
+
- lib/nestegg.rb
|
33
|
+
- lib/nestegg/nesting_exception.rb
|
34
|
+
- lib/nestegg/version.rb
|
35
|
+
- nestegg.gemspec
|
36
|
+
- spec/nestegg/nesting_exception_spec.rb
|
37
|
+
- spec/spec.opts
|
38
|
+
- spec/spec_helper.rb
|
39
|
+
has_rdoc: false
|
40
|
+
homepage: http://nestegg.rubyforge.org
|
41
|
+
licenses:
|
42
|
+
post_install_message:
|
43
|
+
rdoc_options:
|
44
|
+
- --charset=UTF-8
|
45
|
+
require_paths:
|
46
|
+
- lib
|
47
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
requirements:
|
49
|
+
- - ">="
|
50
|
+
- !ruby/object:Gem::Version
|
51
|
+
version: "0"
|
52
|
+
version:
|
53
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
version:
|
59
|
+
requirements: []
|
60
|
+
|
61
|
+
rubyforge_project:
|
62
|
+
rubygems_version: 1.3.5
|
63
|
+
signing_key:
|
64
|
+
specification_version: 3
|
65
|
+
summary: Nested exceptions for ruby
|
66
|
+
test_files:
|
67
|
+
- spec/nestegg/nesting_exception_spec.rb
|
68
|
+
- spec/spec_helper.rb
|
69
|
+
- examples/nestegg_example.rb
|