chuck-norris 0.0.1 → 0.1.0

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/.gitignore CHANGED
@@ -19,3 +19,6 @@ rdoc
19
19
  pkg
20
20
 
21
21
  ## PROJECT::SPECIFIC
22
+
23
+ ## Rubinius
24
+ *.rbc
data/Rakefile CHANGED
@@ -6,7 +6,7 @@ begin
6
6
  Jeweler::Tasks.new do |gem|
7
7
  gem.name = "chuck-norris"
8
8
  gem.summary = %Q{Chuck Norris}
9
- gem.description = %Q{When Chuck Norris throws exceptions, its across the room}
9
+ gem.description = %Q{When Chuck Norris throws exceptions, it's across the room}
10
10
  gem.email = "pahanix@gmail.com"
11
11
  gem.homepage = "http://github.com/pahanix/chuck-norris"
12
12
  gem.authors = ["Pavel Gorbokon (pahanix)"]
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.1
1
+ 0.1.0
data/chuck-norris.gemspec CHANGED
@@ -5,12 +5,12 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{chuck-norris}
8
- s.version = "0.0.1"
8
+ s.version = "0.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Pavel Gorbokon (pahanix)"]
12
- s.date = %q{2010-09-24}
13
- s.description = %q{When Chuck Norris throws exceptions, its across the room}
12
+ s.date = %q{2010-09-25}
13
+ s.description = %q{When Chuck Norris throws exceptions, it's across the room}
14
14
  s.email = %q{pahanix@gmail.com}
15
15
  s.extra_rdoc_files = [
16
16
  "LICENSE",
data/lib/chuck-norris.rb CHANGED
@@ -1,6 +1,39 @@
1
- class Object
2
- def raise(*args)
3
- $stdout.puts("Chuck Norris has thrown #{args.first} and killed your app.") unless $!.to_s == 'exit'
4
- exit 0
1
+ class Object
2
+ def raise_with_chuck_norris(*args)
3
+ exception = args.first
4
+ # Only Rubinius catches SystemExit at the end. Ignore it
5
+ unless exception.is_a?(SystemExit)
6
+ $stdout.puts("Chuck Norris has thrown #{args.first} and has given quarter to your app")
7
+ say "Boom"
8
+ end
9
+
10
+ raise_without_chuck_norris(*args)
5
11
  end
6
- end
12
+
13
+ alias raise_without_chuck_norris raise
14
+ alias raise raise_with_chuck_norris
15
+
16
+ private
17
+
18
+ def chuck_norris_pays_last_respects
19
+ $stdout.puts("Chuck Norris pays last respects to your app...")
20
+ say "Rest in Peace"
21
+ end
22
+
23
+ def say(text)
24
+ `say #{text} &` if RUBY_PLATFORM =~ /darwin/
25
+ end
26
+ end
27
+
28
+ # LITTLE HACK to put Chuck Norris last respects at the end of application lifetime.
29
+ # Kernel runs exit procs in reverse mode and at this point we can already have
30
+ # other exit procs. For example from Shoulda or UnitTest (I'm not sure which exactly).
31
+
32
+ # This hack works on MRI 1.8/1.9 and REE (actually it's a bug!)
33
+ # and does not work on JRuby/Rubinius (well done!)
34
+
35
+ # But anyway, we can postone creation of last respects on MRI 1.8/1.9 and REE.
36
+
37
+ Kernel.at_exit {
38
+ Kernel.at_exit { chuck_norris_pays_last_respects }
39
+ }
@@ -1,7 +1,18 @@
1
1
  require 'helper'
2
2
 
3
3
  class TestChuckNorris < Test::Unit::TestCase
4
- should "throw exception and kill the app" do
5
- raise StandardError
4
+ should "throw exception and say boom" do
5
+ begin
6
+ raise StandardError
7
+ rescue
8
+ end
6
9
  end
10
+
11
+ should "throw String exception and say boom" do
12
+ begin
13
+ raise "String"
14
+ rescue
15
+ end
16
+ end
17
+
7
18
  end
metadata CHANGED
@@ -1,13 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chuck-norris
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
5
4
  prerelease: false
6
5
  segments:
7
6
  - 0
8
- - 0
9
7
  - 1
10
- version: 0.0.1
8
+ - 0
9
+ version: 0.1.0
11
10
  platform: ruby
12
11
  authors:
13
12
  - Pavel Gorbokon (pahanix)
@@ -15,7 +14,7 @@ autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
16
 
18
- date: 2010-09-24 00:00:00 +03:00
17
+ date: 2010-09-25 00:00:00 +03:00
19
18
  default_executable:
20
19
  dependencies:
21
20
  - !ruby/object:Gem::Dependency
@@ -26,13 +25,12 @@ dependencies:
26
25
  requirements:
27
26
  - - ">="
28
27
  - !ruby/object:Gem::Version
29
- hash: 3
30
28
  segments:
31
29
  - 0
32
30
  version: "0"
33
31
  type: :development
34
32
  version_requirements: *id001
35
- description: "When Chuck Norris throws exceptions, it\xE2\x80\x99s across the room"
33
+ description: When Chuck Norris throws exceptions, it's across the room
36
34
  email: pahanix@gmail.com
37
35
  executables: []
38
36
 
@@ -66,7 +64,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
66
64
  requirements:
67
65
  - - ">="
68
66
  - !ruby/object:Gem::Version
69
- hash: 3
70
67
  segments:
71
68
  - 0
72
69
  version: "0"
@@ -75,7 +72,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
72
  requirements:
76
73
  - - ">="
77
74
  - !ruby/object:Gem::Version
78
- hash: 3
79
75
  segments:
80
76
  - 0
81
77
  version: "0"