hammertime 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.2
1
+ 0.0.3
@@ -0,0 +1,11 @@
1
+ # IN A WORLD... where ruby-debug and IRB is not in the load
2
+ # path... one man will raise an exception.
3
+ require 'rubygems'
4
+ require '../lib/hammertime'
5
+
6
+ # Clear out load path. Now LoadError will be raised when
7
+ # Hammertime tries to load IRB or the debugger.
8
+ $:.clear
9
+
10
+ include Hammertime
11
+ raise "Holy smokes!"
@@ -1,54 +1,44 @@
1
1
  # Generated by jeweler
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
5
 
6
6
  Gem::Specification.new do |s|
7
- s.name = %q{hammertime}
8
- s.version = "0.0.2"
7
+ s.name = "hammertime"
8
+ s.version = "0.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Avdi Grimm"]
12
- s.date = %q{2010-01-20}
13
- s.description = %q{When this library is required, it replaces the default Ruby exception-raising
14
- behavior. When an error is raised, the developer is presented with a menu
15
- enabling them to ignore the error, view a stack trace, debug the error using IRB
16
- or ruby-debug, and more.
17
- }
18
- s.email = %q{avdi@avdi.org}
12
+ s.date = "2012-01-30"
13
+ s.description = "When this library is required, it replaces the default Ruby exception-raising\nbehavior. When an error is raised, the developer is presented with a menu\nenabling them to ignore the error, view a stack trace, debug the error using IRB\nor ruby-debug, and more.\n"
14
+ s.email = "avdi@avdi.org"
19
15
  s.extra_rdoc_files = [
20
16
  "LICENSE",
21
- "README.rdoc"
17
+ "README.rdoc"
22
18
  ]
23
19
  s.files = [
24
20
  ".document",
25
- ".gitignore",
26
- "LICENSE",
27
- "README.rdoc",
28
- "Rakefile",
29
- "VERSION",
30
- "example.rb",
31
- "hammertime.gemspec",
32
- "lib/hammertime.rb",
33
- "spec/hammertime_spec.rb",
34
- "spec/spec.opts",
35
- "spec/spec_helper.rb"
36
- ]
37
- s.homepage = %q{http://github.com/avdi/hammertime}
38
- s.rdoc_options = ["--charset=UTF-8"]
39
- s.require_paths = ["lib"]
40
- s.rubygems_version = %q{1.3.5}
41
- s.summary = %q{Exception debugging console for Ruby}
42
- s.test_files = [
21
+ "LICENSE",
22
+ "README.rdoc",
23
+ "Rakefile",
24
+ "VERSION",
25
+ "example.rb",
26
+ "examples/loaderror.rb",
27
+ "hammertime.gemspec",
28
+ "lib/hammertime.rb",
43
29
  "spec/hammertime_spec.rb",
44
- "spec/spec_helper.rb"
30
+ "spec/spec.opts",
31
+ "spec/spec_helper.rb"
45
32
  ]
33
+ s.homepage = "http://github.com/avdi/hammertime"
34
+ s.require_paths = ["lib"]
35
+ s.rubygems_version = "1.8.10"
36
+ s.summary = "Exception debugging console for Ruby"
46
37
 
47
38
  if s.respond_to? :specification_version then
48
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
49
39
  s.specification_version = 3
50
40
 
51
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
41
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
52
42
  s.add_runtime_dependency(%q<ruby-debug>, ["~> 0.10"])
53
43
  s.add_runtime_dependency(%q<highline>, ["~> 1.5"])
54
44
  s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
@@ -1,3 +1,4 @@
1
+ require 'thread'
1
2
  require 'highline'
2
3
 
3
4
  module Hammertime
@@ -28,12 +29,15 @@ module Hammertime
28
29
 
29
30
  def hammertime_raise(*args)
30
31
  backtrace = caller(2)
31
- Thread.exclusive do
32
- error, backtrace =
32
+ fallback = lambda do
33
+ hammertime_original_raise(*args)
34
+ end
35
+ exclusive_and_non_reentrant(fallback) do
36
+ error, backtrace =
33
37
  case args.size
34
38
  when 0 then [($!.nil? ? RuntimeError.new : $!), backtrace]
35
- when 1 then
36
- if args[0].is_a?(String)
39
+ when 1 then
40
+ if args[0].is_a?(String)
37
41
  [RuntimeError.exception(args[0]), backtrace]
38
42
  else
39
43
  [args[0].exception, backtrace]
@@ -52,7 +56,7 @@ module Hammertime
52
56
  else
53
57
  ::Hammertime.stopped = true
54
58
  end
55
-
59
+
56
60
  c = ::Hammertime.hammertime_console
57
61
  c.say "\n"
58
62
  c.say "=== Stop! Hammertime. ==="
@@ -118,6 +122,14 @@ module Hammertime
118
122
 
119
123
  private
120
124
 
125
+ # No lazy initialization where threads are concerned. We still use
126
+ # ||= on the off chance that this file gets loaded twice in 1.8.
127
+ @mutex ||= Mutex.new
128
+
129
+ def self.mutex
130
+ @mutex
131
+ end
132
+
121
133
  def self.hammertime_console
122
134
  @console ||= HighLine.new($stdin, $stderr)
123
135
  end
@@ -128,6 +140,17 @@ module Hammertime
128
140
  return true if ::Hammertime.ignored_lines.include?(backtrace.first)
129
141
  return false
130
142
  end
143
+
144
+ def exclusive_and_non_reentrant(fallback, &block)
145
+ lock_acquired = ::Hammertime.mutex.try_lock
146
+ if lock_acquired
147
+ yield
148
+ ::Hammertime.mutex.unlock
149
+ else
150
+ fallback.call
151
+ end
152
+ end
153
+
131
154
  end
132
155
 
133
156
  unless ::Object < Hammertime
metadata CHANGED
@@ -1,7 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hammertime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ hash: 25
5
+ prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 3
10
+ version: 0.0.3
5
11
  platform: ruby
6
12
  authors:
7
13
  - Avdi Grimm
@@ -9,39 +15,54 @@ autorequire:
9
15
  bindir: bin
10
16
  cert_chain: []
11
17
 
12
- date: 2010-01-20 00:00:00 -05:00
13
- default_executable:
18
+ date: 2012-01-30 00:00:00 Z
14
19
  dependencies:
15
20
  - !ruby/object:Gem::Dependency
16
21
  name: ruby-debug
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
24
+ none: false
20
25
  requirements:
21
26
  - - ~>
22
27
  - !ruby/object:Gem::Version
28
+ hash: 31
29
+ segments:
30
+ - 0
31
+ - 10
23
32
  version: "0.10"
24
- version:
33
+ type: :runtime
34
+ version_requirements: *id001
25
35
  - !ruby/object:Gem::Dependency
26
36
  name: highline
27
- type: :runtime
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
30
40
  requirements:
31
41
  - - ~>
32
42
  - !ruby/object:Gem::Version
43
+ hash: 5
44
+ segments:
45
+ - 1
46
+ - 5
33
47
  version: "1.5"
34
- version:
48
+ type: :runtime
49
+ version_requirements: *id002
35
50
  - !ruby/object:Gem::Dependency
36
51
  name: rspec
37
- type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
52
+ prerelease: false
53
+ requirement: &id003 !ruby/object:Gem::Requirement
54
+ none: false
40
55
  requirements:
41
56
  - - ">="
42
57
  - !ruby/object:Gem::Version
58
+ hash: 13
59
+ segments:
60
+ - 1
61
+ - 2
62
+ - 9
43
63
  version: 1.2.9
44
- version:
64
+ type: :development
65
+ version_requirements: *id003
45
66
  description: |
46
67
  When this library is required, it replaces the default Ruby exception-raising
47
68
  behavior. When an error is raised, the developer is presented with a menu
@@ -58,45 +79,49 @@ extra_rdoc_files:
58
79
  - README.rdoc
59
80
  files:
60
81
  - .document
61
- - .gitignore
62
82
  - LICENSE
63
83
  - README.rdoc
64
84
  - Rakefile
65
85
  - VERSION
66
86
  - example.rb
87
+ - examples/loaderror.rb
67
88
  - hammertime.gemspec
68
89
  - lib/hammertime.rb
69
90
  - spec/hammertime_spec.rb
70
91
  - spec/spec.opts
71
92
  - spec/spec_helper.rb
72
- has_rdoc: true
73
93
  homepage: http://github.com/avdi/hammertime
74
94
  licenses: []
75
95
 
76
96
  post_install_message:
77
- rdoc_options:
78
- - --charset=UTF-8
97
+ rdoc_options: []
98
+
79
99
  require_paths:
80
100
  - lib
81
101
  required_ruby_version: !ruby/object:Gem::Requirement
102
+ none: false
82
103
  requirements:
83
104
  - - ">="
84
105
  - !ruby/object:Gem::Version
106
+ hash: 3
107
+ segments:
108
+ - 0
85
109
  version: "0"
86
- version:
87
110
  required_rubygems_version: !ruby/object:Gem::Requirement
111
+ none: false
88
112
  requirements:
89
113
  - - ">="
90
114
  - !ruby/object:Gem::Version
115
+ hash: 3
116
+ segments:
117
+ - 0
91
118
  version: "0"
92
- version:
93
119
  requirements: []
94
120
 
95
121
  rubyforge_project:
96
- rubygems_version: 1.3.5
122
+ rubygems_version: 1.8.10
97
123
  signing_key:
98
124
  specification_version: 3
99
125
  summary: Exception debugging console for Ruby
100
- test_files:
101
- - spec/hammertime_spec.rb
102
- - spec/spec_helper.rb
126
+ test_files: []
127
+
data/.gitignore DELETED
@@ -1,22 +0,0 @@
1
- ## MAC OS
2
- .DS_Store
3
-
4
- ## TEXTMATE
5
- *.tmproj
6
- tmtags
7
-
8
- ## EMACS
9
- *~
10
- \#*
11
- .\#*
12
-
13
- ## VIM
14
- *.swp
15
-
16
- ## PROJECT::GENERAL
17
- coverage
18
- rdoc
19
- pkg
20
-
21
- ## PROJECT::SPECIFIC
22
-