tmtms-noexception 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/Gemfile +6 -0
- data/LICENSE +21 -0
- data/README.md +67 -0
- data/Rakefile +2 -0
- data/lib/noexception.rb +46 -0
- data/noexception.gemspec +24 -0
- metadata +79 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: e15469eadc61738c479f211f4979921103b8eca3
|
4
|
+
data.tar.gz: bb8518a7e68720c435aeac9b61610f7f00394503
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 54c96159c3aba904146f18a51dbfa459e85a47324a1f13d8586101c47b388b8471609d5bf98d4549311f8bb64ac1f11be779b61e97b780a7cf799ec9ec3ff5f4
|
7
|
+
data.tar.gz: 167ac9c7cfd0f4e896a968058d83dd3f120e23e54124de6533e692bcf99c91b3247cdf157acf22d8e7083483100222597c5ba8891752b2c5b0440eb060adeb20
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2017 TOMITA Masahiro
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
# Noexception
|
2
|
+
|
3
|
+
## Installation
|
4
|
+
|
5
|
+
Add this line to your application's Gemfile:
|
6
|
+
|
7
|
+
```ruby
|
8
|
+
gem 'tmtms-noexception'
|
9
|
+
```
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install noexception
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
```ruby
|
22
|
+
require 'noexception'
|
23
|
+
|
24
|
+
class Foo
|
25
|
+
def abc
|
26
|
+
raise 'abc error'
|
27
|
+
end
|
28
|
+
|
29
|
+
def xyz
|
30
|
+
raise 'xyz error'
|
31
|
+
end
|
32
|
+
|
33
|
+
def bar
|
34
|
+
123
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
Foo.include NoException::No
|
39
|
+
|
40
|
+
foo = Foo.new
|
41
|
+
p foo.abc #=> nil
|
42
|
+
p $error #=> #<RuntimeError: abc error>
|
43
|
+
p foo.xyz #=> nil
|
44
|
+
p $error #=> #<RuntimeError: xyz error>
|
45
|
+
p foo.bar #=> 123
|
46
|
+
```
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
Foo.include NoException::No(:abc)
|
50
|
+
|
51
|
+
foo = Foo.new
|
52
|
+
p foo.abc #=> nil
|
53
|
+
p $error #=> #<RuntimeError: abc error>
|
54
|
+
p foo.xyz #=> raise 'xyz error'
|
55
|
+
```
|
56
|
+
|
57
|
+
```ruby
|
58
|
+
Foo.include NoException::Go
|
59
|
+
|
60
|
+
foo = Foo.new
|
61
|
+
p foo.abc #=> [nil, #<RuntimeError: abc error>]
|
62
|
+
p foo.bar #=> [123, nil]
|
63
|
+
```
|
64
|
+
|
65
|
+
## Contributing
|
66
|
+
|
67
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/tmtm/noexception.
|
data/Rakefile
ADDED
data/lib/noexception.rb
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
module NoException
|
2
|
+
def self.No(*methods)
|
3
|
+
Module.new do
|
4
|
+
define_singleton_method(:included) do |klass|
|
5
|
+
methods = klass.instance_methods(false) if methods.empty?
|
6
|
+
mod = Module.new do
|
7
|
+
methods.each do |m|
|
8
|
+
define_method m do |*args|
|
9
|
+
begin
|
10
|
+
return super(*args)
|
11
|
+
rescue StandardError => e
|
12
|
+
$error = e
|
13
|
+
return nil
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
klass.prepend mod
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
No = self.No()
|
24
|
+
|
25
|
+
def self.Go(*methods)
|
26
|
+
Module.new do
|
27
|
+
define_singleton_method(:included) do |klass|
|
28
|
+
methods = klass.instance_methods(false) if methods.empty?
|
29
|
+
mod = Module.new do
|
30
|
+
methods.each do |m|
|
31
|
+
define_method m do |*args|
|
32
|
+
begin
|
33
|
+
return super(*args), nil
|
34
|
+
rescue StandardError => e
|
35
|
+
return nil, e
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
klass.prepend mod
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
Go = Go()
|
46
|
+
end
|
data/noexception.gemspec
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |spec|
|
5
|
+
spec.name = "tmtms-noexception"
|
6
|
+
spec.version = '0.0.1'
|
7
|
+
spec.licenses = ['MIT']
|
8
|
+
spec.authors = ["TOMITA Masahiro"]
|
9
|
+
spec.email = ["tommy@tmtm.org"]
|
10
|
+
|
11
|
+
spec.summary = 'NoException'
|
12
|
+
spec.description = 'NoException'
|
13
|
+
spec.homepage = 'https://github.com/tmtm/noexception'
|
14
|
+
|
15
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
|
+
f.match(%r{^(test|spec|features)/})
|
17
|
+
end
|
18
|
+
spec.bindir = "exe"
|
19
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
+
spec.require_paths = ["lib"]
|
21
|
+
|
22
|
+
spec.add_development_dependency "bundler", "~> 1.15"
|
23
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
24
|
+
end
|
metadata
ADDED
@@ -0,0 +1,79 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: tmtms-noexception
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- TOMITA Masahiro
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2017-09-26 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.15'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.15'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
description: NoException
|
42
|
+
email:
|
43
|
+
- tommy@tmtm.org
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- ".gitignore"
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE
|
51
|
+
- README.md
|
52
|
+
- Rakefile
|
53
|
+
- lib/noexception.rb
|
54
|
+
- noexception.gemspec
|
55
|
+
homepage: https://github.com/tmtm/noexception
|
56
|
+
licenses:
|
57
|
+
- MIT
|
58
|
+
metadata: {}
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
requirements:
|
65
|
+
- - ">="
|
66
|
+
- !ruby/object:Gem::Version
|
67
|
+
version: '0'
|
68
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: '0'
|
73
|
+
requirements: []
|
74
|
+
rubyforge_project:
|
75
|
+
rubygems_version: 2.6.11
|
76
|
+
signing_key:
|
77
|
+
specification_version: 4
|
78
|
+
summary: NoException
|
79
|
+
test_files: []
|