angry_raise 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 +123 -0
- data/.travis.yml +12 -0
- data/Gemfile +3 -0
- data/LICENSE.txt +21 -0
- data/README.md +66 -0
- data/Rakefile +7 -0
- data/angry_raise.gemspec +25 -0
- data/lib/angry_raise.rb +103 -0
- data/lib/angry_raise/version.rb +3 -0
- metadata +109 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 4e66f5ac0d105ff5028ada3698fe34925c7faaa2
|
4
|
+
data.tar.gz: dcd29f3aadf24a843327e41a84979e9360be3707
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: bfec971c74e10770338a342d5a008a0a4f62fa57ab7e3727ccf08d5aa33fb3a344c77d3e726a648302aa1f2747335988f3c67c25f294a1ec582b5357a25f001a
|
7
|
+
data.tar.gz: a1b7aff15945ce8e8eb62e4501d72378b7852318b14ac496b04feed889a7e4fd90626c2f224d4f55bb649f305132908b3e897e3813693d279e8db6ee36efe0af
|
data/.gitignore
ADDED
@@ -0,0 +1,123 @@
|
|
1
|
+
|
2
|
+
# Created by https://www.gitignore.io/api/ruby,emacs
|
3
|
+
|
4
|
+
### Emacs ###
|
5
|
+
# -*- mode: gitignore; -*-
|
6
|
+
*~
|
7
|
+
\#*\#
|
8
|
+
/.emacs.desktop
|
9
|
+
/.emacs.desktop.lock
|
10
|
+
*.elc
|
11
|
+
auto-save-list
|
12
|
+
tramp
|
13
|
+
.\#*
|
14
|
+
|
15
|
+
# Org-mode
|
16
|
+
.org-id-locations
|
17
|
+
*_archive
|
18
|
+
|
19
|
+
# flymake-mode
|
20
|
+
*_flymake.*
|
21
|
+
|
22
|
+
# eshell files
|
23
|
+
/eshell/history
|
24
|
+
/eshell/lastdir
|
25
|
+
|
26
|
+
# elpa packages
|
27
|
+
/elpa/
|
28
|
+
|
29
|
+
# reftex files
|
30
|
+
*.rel
|
31
|
+
|
32
|
+
# AUCTeX auto folder
|
33
|
+
/auto/
|
34
|
+
|
35
|
+
# cask packages
|
36
|
+
.cask/
|
37
|
+
dist/
|
38
|
+
|
39
|
+
# Flycheck
|
40
|
+
flycheck_*.el
|
41
|
+
|
42
|
+
# server auth directory
|
43
|
+
/server/
|
44
|
+
|
45
|
+
# projectiles files
|
46
|
+
.projectile
|
47
|
+
projectile-bookmarks.eld
|
48
|
+
|
49
|
+
# directory configuration
|
50
|
+
.dir-locals.el
|
51
|
+
|
52
|
+
# saveplace
|
53
|
+
places
|
54
|
+
|
55
|
+
# url cache
|
56
|
+
url/cache/
|
57
|
+
|
58
|
+
# cedet
|
59
|
+
ede-projects.el
|
60
|
+
|
61
|
+
# smex
|
62
|
+
smex-items
|
63
|
+
|
64
|
+
# company-statistics
|
65
|
+
company-statistics-cache.el
|
66
|
+
|
67
|
+
# anaconda-mode
|
68
|
+
anaconda-mode/
|
69
|
+
|
70
|
+
### Ruby ###
|
71
|
+
*.gem
|
72
|
+
*.rbc
|
73
|
+
/.config
|
74
|
+
/coverage/
|
75
|
+
/InstalledFiles
|
76
|
+
/pkg/
|
77
|
+
/spec/reports/
|
78
|
+
/spec/examples.txt
|
79
|
+
/test/tmp/
|
80
|
+
/test/version_tmp/
|
81
|
+
/tmp/
|
82
|
+
|
83
|
+
# Used by dotenv library to load environment variables.
|
84
|
+
# .env
|
85
|
+
|
86
|
+
## Specific to RubyMotion:
|
87
|
+
.dat*
|
88
|
+
.repl_history
|
89
|
+
build/
|
90
|
+
*.bridgesupport
|
91
|
+
build-iPhoneOS/
|
92
|
+
build-iPhoneSimulator/
|
93
|
+
|
94
|
+
## Specific to RubyMotion (use of CocoaPods):
|
95
|
+
#
|
96
|
+
# We recommend against adding the Pods directory to your .gitignore. However
|
97
|
+
# you should judge for yourself, the pros and cons are mentioned at:
|
98
|
+
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
99
|
+
#
|
100
|
+
# vendor/Pods/
|
101
|
+
|
102
|
+
## Documentation cache and generated files:
|
103
|
+
/.yardoc/
|
104
|
+
/_yardoc/
|
105
|
+
/doc/
|
106
|
+
/rdoc/
|
107
|
+
|
108
|
+
## Environment normalization:
|
109
|
+
/.bundle/
|
110
|
+
/vendor/bundle
|
111
|
+
/lib/bundler/man/
|
112
|
+
|
113
|
+
# for a library or gem, you might want to ignore these files since the code is
|
114
|
+
# intended to run in multiple environments; otherwise, check them in:
|
115
|
+
Gemfile.lock
|
116
|
+
# .ruby-version
|
117
|
+
# .ruby-gemset
|
118
|
+
|
119
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
120
|
+
.rvmrc
|
121
|
+
|
122
|
+
|
123
|
+
# End of https://www.gitignore.io/api/ruby,emacs
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Skye Shaw
|
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
|
13
|
+
all 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
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
# AngryRaise
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/sshaw/angry_raise.svg?branch=master)](https://travis-ci.org/sshaw/angry_raise)
|
4
|
+
|
5
|
+
`raise` exceptions, with emotion and intensity
|
6
|
+
|
7
|
+
## Usage
|
8
|
+
|
9
|
+
```rb
|
10
|
+
require "angry_raise"
|
11
|
+
|
12
|
+
raise! "an error occured" # "RuntimeError: an error occured!"
|
13
|
+
raise! SomeError, "an error occured" # "SomeError: an error occured!"
|
14
|
+
raise! SomeError.new("an error occured") # "SomeError: an error occured!"
|
15
|
+
|
16
|
+
raise!! "an error occured" # "RuntimeError: An error occured!!"
|
17
|
+
raise!! SomeError, "an error occured" # "SomeError: An error occured!!"
|
18
|
+
raise!! SomeError.new("an error occured") # "SomeError: An error occured!!"
|
19
|
+
|
20
|
+
raise!!! "an error occured" # "RuntimeError: An Error Occured!!!"
|
21
|
+
raise!!! SomeError, "an error occured" # "SomeError: An Error Occured!!!"
|
22
|
+
raise!!! SomeError.new("an error occured") # "SomeError: An Error Occured!!!"
|
23
|
+
|
24
|
+
raise!!!! "an error occured" # "RuntimeError: AN ERROR OCCURED!!!!"
|
25
|
+
raise!!!! SomeError, "an error occured" # "SomeError: AN ERROR OCCURED!!!!"
|
26
|
+
raise!!!! SomeError.new("an error occured") # "SomeError: AN ERROR OCCURED!!!!"
|
27
|
+
```
|
28
|
+
|
29
|
+
Feel free to [capture the mood of each caller](https://www.youtube.com/watch?v=unz1CGoFVMU):
|
30
|
+
|
31
|
+
```rb
|
32
|
+
raise!!!!!!!!!!!!!! "an error occured" # RuntimeError: AN ERROR OCCURED!!!!!!!!!!!!!!
|
33
|
+
```
|
34
|
+
|
35
|
+
You can add a backtrace too, because sometimes, it's appropriate:
|
36
|
+
|
37
|
+
```rb
|
38
|
+
raise!!! SomeError, "an error occured", %w[frame1 frame2 frame3]
|
39
|
+
```
|
40
|
+
|
41
|
+
## Internationalization
|
42
|
+
|
43
|
+
```rb
|
44
|
+
I18n.locale = :es
|
45
|
+
raise!!! "tenemos una problema aqui" # ¡¡¡Tenemos Una Problema Aqui!!!
|
46
|
+
```
|
47
|
+
|
48
|
+
Currently only supports Spanish. Is there any other language *to* support?
|
49
|
+
|
50
|
+
## Can I Use This in Production?
|
51
|
+
|
52
|
+
Should one ever use monkey patched code in production‽‽‽
|
53
|
+
|
54
|
+
This library changes the behavior or `String#!`, `Exception#!` and `Exception::!` to
|
55
|
+
the **the exact opposite of their default implementations!** So, I'd say NO!!!!
|
56
|
+
|
57
|
+
## Author
|
58
|
+
|
59
|
+
Skye Shaw [skye.shaw =AT= gmail]
|
60
|
+
|
61
|
+
## See Also
|
62
|
+
|
63
|
+
* [Acme::Crap](https://metacpan.org/pod/Acme::Crap) - The Perl module that served as inspiration
|
64
|
+
* [Table flipper](https://github.com/iridakos/table_flipper) - Prepends the table flipper on Exception messages
|
65
|
+
* [class2](https://github.com/sshaw/class2) - DSL for creating class hierarchies
|
66
|
+
* [YYMMDD](https://github.com/sshaw/yymmdd) - Tiny DSL for idiomatic date parsing and formatting
|
data/Rakefile
ADDED
data/angry_raise.gemspec
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "angry_raise/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "angry_raise"
|
7
|
+
spec.version = AngryRaise::VERSION
|
8
|
+
spec.authors = ["Skye Shaw"]
|
9
|
+
spec.email = ["skye.shaw@gmail.com"]
|
10
|
+
spec.summary = "raise exceptions, with emotion and intensity"
|
11
|
+
spec.homepage = "https://github.com/sshaw/angry_raise"
|
12
|
+
spec.license = "MIT"
|
13
|
+
|
14
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
15
|
+
f.match(%r{^(test|spec|features)/})
|
16
|
+
end
|
17
|
+
spec.bindir = "bin"
|
18
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
|
21
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
22
|
+
spec.add_development_dependency "i18n"
|
23
|
+
spec.add_development_dependency "minitest", "~> 5.0"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
end
|
data/lib/angry_raise.rb
ADDED
@@ -0,0 +1,103 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
class String
|
5
|
+
def !
|
6
|
+
AngryRaise::String.new(self)
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class Exception
|
11
|
+
attr_reader :__level
|
12
|
+
|
13
|
+
def !
|
14
|
+
@__level ||= 0
|
15
|
+
@__level += 1
|
16
|
+
self
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.!
|
20
|
+
AngryRaise::Exception.new(self)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
module Kernel
|
25
|
+
def raise!(*argz)
|
26
|
+
if argz.size > 1
|
27
|
+
s = AngryRaise::String.new(argz[1].to_s)
|
28
|
+
argz[0].__level.times { !s } if argz[0].is_a?(Exception)
|
29
|
+
argz[1] = s.to_s
|
30
|
+
elsif argz[0].is_a?(Exception)
|
31
|
+
s = AngryRaise::String.new(argz[0].message)
|
32
|
+
argz[0].__level.times { !s } if argz[0].__level
|
33
|
+
argz[0].message.replace(s.to_s)
|
34
|
+
else argz[0]
|
35
|
+
argz[0] = argz[0].is_a?(AngryRaise::String) ? !argz[0] : AngryRaise::String.new(argz[0])
|
36
|
+
end
|
37
|
+
|
38
|
+
raise(*argz)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
module AngryRaise
|
43
|
+
class Exception < ::Exception
|
44
|
+
attr_reader :__level
|
45
|
+
|
46
|
+
def initialize(target)
|
47
|
+
@target = target
|
48
|
+
@__level = 1
|
49
|
+
end
|
50
|
+
|
51
|
+
def !
|
52
|
+
@__level += 1
|
53
|
+
self
|
54
|
+
end
|
55
|
+
|
56
|
+
def exception(s)
|
57
|
+
@target.exception(s)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class String
|
62
|
+
def initialize(str)
|
63
|
+
@str = str.to_s
|
64
|
+
@level = 1
|
65
|
+
end
|
66
|
+
|
67
|
+
def !
|
68
|
+
@level += 1
|
69
|
+
self
|
70
|
+
end
|
71
|
+
|
72
|
+
def to_s
|
73
|
+
rageify.dup
|
74
|
+
end
|
75
|
+
|
76
|
+
alias to_str to_s
|
77
|
+
|
78
|
+
def inspect
|
79
|
+
rageify.inspect
|
80
|
+
end
|
81
|
+
|
82
|
+
private
|
83
|
+
|
84
|
+
def rageify
|
85
|
+
return @str if @str.strip.empty?
|
86
|
+
|
87
|
+
s = case @level
|
88
|
+
when 1
|
89
|
+
@str + "!"
|
90
|
+
when 2
|
91
|
+
@str.capitalize << "!!"
|
92
|
+
when 3
|
93
|
+
@str.split(/(\s+)/).map(&:capitalize).join("") << "!!!"
|
94
|
+
else
|
95
|
+
@str.upcase << "!" * @level
|
96
|
+
end
|
97
|
+
|
98
|
+
# Should ENV be used too?
|
99
|
+
s.prepend("¡" * @level) if defined?(I18n) && I18n.locale =~ /\Aes(?:_|\b)/
|
100
|
+
s
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
metadata
ADDED
@@ -0,0 +1,109 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: angry_raise
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Skye Shaw
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-02-25 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.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: i18n
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: minitest
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '5.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '5.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rake
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '10.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '10.0'
|
69
|
+
description:
|
70
|
+
email:
|
71
|
+
- skye.shaw@gmail.com
|
72
|
+
executables: []
|
73
|
+
extensions: []
|
74
|
+
extra_rdoc_files: []
|
75
|
+
files:
|
76
|
+
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
78
|
+
- Gemfile
|
79
|
+
- LICENSE.txt
|
80
|
+
- README.md
|
81
|
+
- Rakefile
|
82
|
+
- angry_raise.gemspec
|
83
|
+
- lib/angry_raise.rb
|
84
|
+
- lib/angry_raise/version.rb
|
85
|
+
homepage: https://github.com/sshaw/angry_raise
|
86
|
+
licenses:
|
87
|
+
- MIT
|
88
|
+
metadata: {}
|
89
|
+
post_install_message:
|
90
|
+
rdoc_options: []
|
91
|
+
require_paths:
|
92
|
+
- lib
|
93
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
98
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
|
+
requirements:
|
100
|
+
- - ">="
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
requirements: []
|
104
|
+
rubyforge_project:
|
105
|
+
rubygems_version: 2.6.14
|
106
|
+
signing_key:
|
107
|
+
specification_version: 4
|
108
|
+
summary: raise exceptions, with emotion and intensity
|
109
|
+
test_files: []
|