loganb-nestegg 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ #gem specs
2
+ *.gemspec
3
+ pkg
4
+
5
+ #IDE related
6
+ .idea
@@ -1,3 +1,11 @@
1
+ == 0.0.4 2009-10-07
2
+
3
+ * Message defaults to cause's message
4
+
5
+ == 0.0.3
6
+
7
+ * Can pass message to Nesting Exception
8
+
1
9
  == 0.0.2 2007-06-26
2
10
 
3
11
  * Minor tweaks to backtrace formatting and addition of example code.
data/Rakefile CHANGED
@@ -1,12 +1,12 @@
1
1
  begin
2
2
  require 'jeweler'
3
3
  Jeweler::Tasks.new do |gemspec|
4
- gemspec.name = "nestegg"
4
+ gemspec.name = "loganb-nestegg"
5
5
  gemspec.summary = "Nested exceptions for ruby"
6
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"]
7
+ gemspec.email = "logan@datacurrent.com"
8
+ gemspec.homepage = "http://github.com/loganb/nestegg"
9
+ gemspec.authors = ["John D. Hume", "Logan Bowers", "Matt Scilipoti"]
10
10
  end
11
11
  rescue LoadError
12
12
  puts "Jeweler not available. Install it with: sudo gem install technicalpickles-jeweler -s http://gems.github.com"
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.3
1
+ 0.0.4
@@ -1,13 +1,13 @@
1
1
  module Nestegg
2
2
  module NestingException
3
-
3
+
4
4
  attr_reader :cause
5
-
5
+
6
6
  def initialize message = nil, cause = $!
7
7
  @cause = cause
8
- super(message)
8
+ super(message ||= cause.message)
9
9
  end
10
-
10
+
11
11
  def set_backtrace bt
12
12
  if cause
13
13
  cause.backtrace.reverse.each do |line|
@@ -22,6 +22,6 @@ module Nestegg
22
22
  end
23
23
  super bt
24
24
  end
25
-
25
+
26
26
  end
27
27
  end
@@ -1,17 +1,17 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/../spec_helper.rb')
2
2
 
3
3
  describe Nestegg::NestingException do
4
-
4
+
5
5
  class TestNestingError < StandardError
6
6
  include Nestegg::NestingException
7
7
  end
8
-
8
+
9
9
  def create_cause(klass = StandardError, message = "cause msg", backtrace = ["line_one", "line_two"])
10
10
  e = klass.new(message)
11
11
  e.set_backtrace backtrace
12
12
  e
13
13
  end
14
-
14
+
15
15
  def with_exception exception
16
16
  begin
17
17
  raise exception
@@ -19,21 +19,21 @@ describe Nestegg::NestingException do
19
19
  yield e
20
20
  end
21
21
  end
22
-
22
+
23
23
  it "includes cause in backtrace" do
24
24
  cause = create_cause(StandardError)
25
25
  with_exception TestNestingError.new("some message", cause) do |e|
26
26
  e.backtrace.should include("cause: StandardError: #{cause.message}")
27
27
  end
28
28
  end
29
-
29
+
30
30
  it "includes cause's backtrace after cause in backtrace" do
31
31
  cause = create_cause(StandardError)
32
32
  with_exception TestNestingError.new("some message", cause) do |e|
33
33
  e.backtrace[-3..-1].should == ["cause: StandardError: #{cause.message}", "line_one", "line_two"]
34
34
  end
35
35
  end
36
-
36
+
37
37
  it "removes duplicated backtrace elements from nesting exception" do
38
38
  cause_bt = caller.unshift "some_other_line"
39
39
  cause = create_cause(StandardError, "msg", cause_bt)
@@ -44,7 +44,7 @@ describe Nestegg::NestingException do
44
44
  e.backtrace[0..1].should == ["#{__FILE__}:#{line}", "cause: StandardError: msg"]
45
45
  end
46
46
  end
47
-
47
+
48
48
  it "defaults cause to current raised exception ($!)" do
49
49
  expected_cause = StandardError.new
50
50
  raised_error = nil
@@ -59,5 +59,29 @@ describe Nestegg::NestingException do
59
59
  end
60
60
  raised_error.cause.should == expected_cause
61
61
  end
62
-
63
- end
62
+
63
+ it "uses passed message" do
64
+ begin
65
+ begin
66
+ raise StandardError, 'STD MSG'
67
+ rescue StandardError
68
+ raise TestNestingError, 'NESTED MESSAGE'
69
+ end
70
+ rescue TestNestingError => e
71
+ e.message.should == 'NESTED MESSAGE'
72
+ end
73
+ end
74
+
75
+ it "defaults message to cause's message" do
76
+ begin
77
+ begin
78
+ raise StandardError, 'STD MSG'
79
+ rescue StandardError
80
+ raise TestNestingError
81
+ end
82
+ rescue TestNestingError => e
83
+ e.message.should == 'STD MSG'
84
+ end
85
+ end
86
+
87
+ end
@@ -1,3 +1,10 @@
1
1
  require 'rubygems'
2
2
  require 'spec'
3
- require File.dirname(__FILE__) + '/../lib/nestegg'
3
+
4
+ #Replaced this `require` with `$LOAD_PATH.unshift`
5
+ #to ensure the file is used instead of the gem.
6
+ #lib/nestegg.rb was loading nestegg/version from the gem
7
+ #instead of lib/nestegg/version.rb
8
+ #require File.dirname(__FILE__) + '/../lib/nestegg'
9
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '../lib'))
10
+ require 'nestegg'
metadata CHANGED
@@ -1,20 +1,22 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: loganb-nestegg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - John D. Hume
8
+ - Logan Bowers
9
+ - Matt Scilipoti
8
10
  autorequire:
9
11
  bindir: bin
10
12
  cert_chain: []
11
13
 
12
- date: 2009-09-22 00:00:00 -07:00
14
+ date: 2009-10-08 00:00:00 -07:00
13
15
  default_executable:
14
16
  dependencies: []
15
17
 
16
18
  description: Module to add a 'cause' field to exceptions and automatically chains exceptions on re-raise
17
- email: duelin dot markers at gmail
19
+ email: logan@datacurrent.com
18
20
  executables: []
19
21
 
20
22
  extensions: []
@@ -22,6 +24,7 @@ extensions: []
22
24
  extra_rdoc_files:
23
25
  - README.txt
24
26
  files:
27
+ - .gitignore
25
28
  - History.txt
26
29
  - License.txt
27
30
  - Manifest.txt
@@ -31,14 +34,13 @@ files:
31
34
  - examples/nestegg_example.rb
32
35
  - lib/nestegg.rb
33
36
  - lib/nestegg/nesting_exception.rb
34
- - lib/nestegg/version.rb
35
- - nestegg.gemspec
36
37
  - spec/nestegg/nesting_exception_spec.rb
37
38
  - spec/spec.opts
38
39
  - spec/spec_helper.rb
39
- has_rdoc: false
40
- homepage: http://nestegg.rubyforge.org
41
- licenses:
40
+ has_rdoc: true
41
+ homepage: http://github.com/loganb/nestegg
42
+ licenses: []
43
+
42
44
  post_install_message:
43
45
  rdoc_options:
44
46
  - --charset=UTF-8
@@ -1,9 +0,0 @@
1
- module Nestegg #:nodoc:
2
- module VERSION #:nodoc:
3
- MAJOR = 0
4
- MINOR = 0
5
- TINY = 2
6
-
7
- STRING = [MAJOR, MINOR, TINY].join('.')
8
- end
9
- end
@@ -1,54 +0,0 @@
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.3"
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