pebbles-suddenly_death 0.0.1
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 +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +54 -0
- data/Rakefile +1 -0
- data/lib/pebbles/suddenly_death.rb +54 -0
- data/lib/pebbles/suddenly_death/version.rb +5 -0
- data/pebbles-suddenly_death.gemspec +21 -0
- data/spec/lib/pebbles/suddenly_death_spec.rb +26 -0
- data/spec/spec_helper.rb +3 -0
- metadata +91 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 ainame
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# Pebbles::SuddenlyDeath
|
2
|
+
|
3
|
+
This module is a joke.
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'pebbles-suddenly_death'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install pebbles-suddenly_death
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
require 'pebbles/suddenly_death'
|
23
|
+
|
24
|
+
class Greeter
|
25
|
+
def hello
|
26
|
+
'hello world'
|
27
|
+
end
|
28
|
+
|
29
|
+
include Pebbles::SuddenlyDeath
|
30
|
+
end
|
31
|
+
|
32
|
+
greeter = Greeter.new
|
33
|
+
1000.times do |x|
|
34
|
+
begin
|
35
|
+
greeter.hello
|
36
|
+
rescue => e
|
37
|
+
puts x, e.message
|
38
|
+
break
|
39
|
+
end
|
40
|
+
end
|
41
|
+
#=> 74
|
42
|
+
#=> _人人人人人人_
|
43
|
+
#=>> 突然の死 <
|
44
|
+
#=> ̄Y^Y^Y^Y^Y ̄
|
45
|
+
|
46
|
+
```
|
47
|
+
|
48
|
+
## Contributing
|
49
|
+
|
50
|
+
1. Fork it
|
51
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
52
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
53
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
54
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
require "pebbles/suddenly_death/version"
|
3
|
+
|
4
|
+
module Pebbles
|
5
|
+
class SuddenlyDeathError < StandardError
|
6
|
+
def message
|
7
|
+
<<'EOS'
|
8
|
+
_人人人人人人_
|
9
|
+
> 突然の死 <
|
10
|
+
 ̄Y^Y^Y^Y^Y ̄
|
11
|
+
EOS
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
module SuddenlyDeath
|
16
|
+
def self.included(base)
|
17
|
+
base.class_eval do
|
18
|
+
defined_instance_methods =
|
19
|
+
base.public_instance_methods(true) - Object.public_instance_methods(true)
|
20
|
+
|
21
|
+
defined_instance_methods.each do |method|
|
22
|
+
method_with_death = (method.to_s + "_with_death").to_sym
|
23
|
+
method_without_death = (method.to_s + "_without_death").to_sym
|
24
|
+
|
25
|
+
define_method(method_with_death) do |*args|
|
26
|
+
__send__ method_without_death, *args
|
27
|
+
raise Pebbles::SuddenlyDeathError if rand(100) == 0
|
28
|
+
end
|
29
|
+
|
30
|
+
alias_method method_without_death, method
|
31
|
+
alias_method method, method_with_death
|
32
|
+
end
|
33
|
+
|
34
|
+
singleton_class = (class << base; self end)
|
35
|
+
defined_class_methods =
|
36
|
+
self.public_methods(true) - Object.public_methods(true)
|
37
|
+
|
38
|
+
defined_class_methods.each do |method|
|
39
|
+
method_with_death = (method.to_s + "_with_death").to_sym
|
40
|
+
method_without_death = (method.to_s + "_without_death").to_sym
|
41
|
+
singleton_class.class_eval do
|
42
|
+
define_method(method_with_death) do |*args|
|
43
|
+
__send__ method_without_death, *args
|
44
|
+
raise Pebbles::SuddenlyDeathError if rand(100) == 0
|
45
|
+
end
|
46
|
+
|
47
|
+
alias_method method_without_death, method
|
48
|
+
alias_method method, method_with_death
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'pebbles/suddenly_death/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "pebbles-suddenly_death"
|
8
|
+
gem.version = Pebbles::SuddenlyDeath::VERSION
|
9
|
+
gem.authors = ["ainame"]
|
10
|
+
gem.email = ["ainame954@facebook.com"]
|
11
|
+
gem.description = %q{This is joke gem. When this include into some class, that will suddenly raising error. }
|
12
|
+
gem.summary = %q{This provide suddenly raise error for your code.}
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.files = `git ls-files`.split($/)
|
16
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
17
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
18
|
+
gem.require_paths = ["lib"]
|
19
|
+
gem.add_development_dependency('rspec')
|
20
|
+
gem.add_development_dependency('pry')
|
21
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'pebbles/suddenly_death'
|
2
|
+
|
3
|
+
describe Pebbles::SuddenlyDeath do
|
4
|
+
before(:each) do
|
5
|
+
class Dummy
|
6
|
+
def instance_method_dummy
|
7
|
+
'instance_method'
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.class_method_dummy
|
11
|
+
'class_method'
|
12
|
+
end
|
13
|
+
include Pebbles::SuddenlyDeath
|
14
|
+
end
|
15
|
+
|
16
|
+
@subject = Dummy.new
|
17
|
+
end
|
18
|
+
|
19
|
+
context "included some class" do
|
20
|
+
it "should hook raising error on included module's methods execution" do
|
21
|
+
proc { 1000.times { @subject.instance_method_dummy } }.
|
22
|
+
should raise_error
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: pebbles-suddenly_death
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- ainame
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-01-29 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: pry
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: ! 'This is joke gem. When this include into some class, that will suddenly
|
47
|
+
raising error. '
|
48
|
+
email:
|
49
|
+
- ainame954@facebook.com
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- .gitignore
|
55
|
+
- Gemfile
|
56
|
+
- LICENSE.txt
|
57
|
+
- README.md
|
58
|
+
- Rakefile
|
59
|
+
- lib/pebbles/suddenly_death.rb
|
60
|
+
- lib/pebbles/suddenly_death/version.rb
|
61
|
+
- pebbles-suddenly_death.gemspec
|
62
|
+
- spec/lib/pebbles/suddenly_death_spec.rb
|
63
|
+
- spec/spec_helper.rb
|
64
|
+
homepage: ''
|
65
|
+
licenses: []
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options: []
|
68
|
+
require_paths:
|
69
|
+
- lib
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
71
|
+
none: false
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
none: false
|
78
|
+
requirements:
|
79
|
+
- - ! '>='
|
80
|
+
- !ruby/object:Gem::Version
|
81
|
+
version: '0'
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 1.8.24
|
85
|
+
signing_key:
|
86
|
+
specification_version: 3
|
87
|
+
summary: This provide suddenly raise error for your code.
|
88
|
+
test_files:
|
89
|
+
- spec/lib/pebbles/suddenly_death_spec.rb
|
90
|
+
- spec/spec_helper.rb
|
91
|
+
has_rdoc:
|