shitceptions 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/shitceptions.rb +94 -0
- data/lib/shitceptions/emojis.rb +849 -0
- data/lib/shitceptions/error.rb +29 -0
- data/lib/shitceptions/version.rb +3 -0
- data/spec/lib/shitceptions_spec.rb +100 -0
- data/spec/spec_helper.rb +22 -0
- metadata +168 -0
@@ -0,0 +1,29 @@
|
|
1
|
+
module Shitceptions
|
2
|
+
# @author Seth Vargo <sethvargo@gmail.com>
|
3
|
+
class ShittyArgumentError < StandardError
|
4
|
+
def initialize(klass)
|
5
|
+
@klass
|
6
|
+
end
|
7
|
+
|
8
|
+
def to_s
|
9
|
+
"Expected klass to be of type Class, but was #{@klass.inspect}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# @author Seth Vargo <sethvargo@gmail.com>
|
14
|
+
class ShittyEmojiError < StandardError
|
15
|
+
def initialize(name)
|
16
|
+
@name
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_s
|
20
|
+
[
|
21
|
+
"Unknown emoji #{@name.inspect}. Did you mean one of:",
|
22
|
+
"",
|
23
|
+
Shitceptions::EMOJIS.keys.join("\n"),
|
24
|
+
"",
|
25
|
+
"?"
|
26
|
+
]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Shitceptions do
|
5
|
+
describe '.configure' do
|
6
|
+
it 'yields a configuration block' do
|
7
|
+
expect {
|
8
|
+
Shitceptions.configure do |c|
|
9
|
+
end
|
10
|
+
}.to_not raise_error
|
11
|
+
end
|
12
|
+
|
13
|
+
context 'block options' do
|
14
|
+
shared_examples 'a config_option' do |name, default_value|
|
15
|
+
boolean_method = "#{name}?".to_sym
|
16
|
+
setter_method = "#{name}=".to_sym
|
17
|
+
|
18
|
+
it "defaults to #{default_value}" do
|
19
|
+
expect(Shitceptions.send(boolean_method)).to eq(default_value)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'accepts user input' do
|
23
|
+
expect(Shitceptions).to respond_to(setter_method)
|
24
|
+
end
|
25
|
+
|
26
|
+
it 'sets the instance variable to false' do
|
27
|
+
Shitceptions.send(setter_method, false)
|
28
|
+
expect(Shitceptions.send(boolean_method)).to be_false
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'sets the instance variable to true' do
|
32
|
+
Shitceptions.send(setter_method, true)
|
33
|
+
expect(Shitceptions.send(boolean_method)).to be_true
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
describe '#enabled' do
|
38
|
+
it_behaves_like 'a config_option', :enabled, true
|
39
|
+
end
|
40
|
+
|
41
|
+
describe '#include_original_error' do
|
42
|
+
it_behaves_like 'a config_option', :include_original_error, false
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe '.shittify' do
|
48
|
+
it 'raises an exception if a class is not given' do
|
49
|
+
expect {
|
50
|
+
Shitceptions.shittify("String", nil)
|
51
|
+
}.to raise_error(Shitceptions::ShittyArgumentError)
|
52
|
+
end
|
53
|
+
|
54
|
+
context 'when #include_original_error is true' do
|
55
|
+
let(:klass) do
|
56
|
+
class MyClass < StandardError
|
57
|
+
def to_s
|
58
|
+
"This is the old exception"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
MyClass
|
63
|
+
end
|
64
|
+
|
65
|
+
before do
|
66
|
+
Shitceptions.include_original_error = true
|
67
|
+
Shitceptions.shittify(klass, :pile_of_poo)
|
68
|
+
end
|
69
|
+
|
70
|
+
it 'includes the original error' do
|
71
|
+
expect {
|
72
|
+
raise klass
|
73
|
+
}.to raise_error('💩 This is the old exception')
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
context 'when #include_original_error is false' do
|
78
|
+
let(:klass) do
|
79
|
+
class MyClass < StandardError
|
80
|
+
def to_s
|
81
|
+
"This is the old exception"
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
MyClass
|
86
|
+
end
|
87
|
+
|
88
|
+
before do
|
89
|
+
Shitceptions.include_original_error = false
|
90
|
+
Shitceptions.shittify(klass, :pile_of_poo)
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'includes the original error' do
|
94
|
+
expect {
|
95
|
+
raise klass
|
96
|
+
}.to raise_error('💩 ')
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spork'
|
2
|
+
|
3
|
+
Spork.prefork do
|
4
|
+
require 'rspec/core'
|
5
|
+
|
6
|
+
RSpec.configure do |config|
|
7
|
+
# Disable .should syntax
|
8
|
+
config.expect_with :rspec do |c|
|
9
|
+
c.syntax = :expect
|
10
|
+
end
|
11
|
+
|
12
|
+
# Run tags focus: true
|
13
|
+
config.filter_run focus: true
|
14
|
+
|
15
|
+
# Run all when no filters
|
16
|
+
config.run_all_when_everything_filtered = true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
Spork.each_run do
|
21
|
+
require 'shitceptions'
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,168 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: shitceptions
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Seth Vargo
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-05-19 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: fuubar
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.1'
|
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: '1.1'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: guard
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ~>
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '1.8'
|
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: '1.8'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: guard-rspec
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ~>
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '3.0'
|
54
|
+
type: :development
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.0'
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: guard-spork
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ~>
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: 1.5exi
|
70
|
+
type: :development
|
71
|
+
prerelease: false
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: 1.5exi
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rake
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ~>
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '10.0'
|
86
|
+
type: :development
|
87
|
+
prerelease: false
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: '10.0'
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: spork
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0.9'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '0.9'
|
110
|
+
- !ruby/object:Gem::Dependency
|
111
|
+
name: rspec
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
113
|
+
none: false
|
114
|
+
requirements:
|
115
|
+
- - ~>
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '2.13'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ~>
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '2.13'
|
126
|
+
description: Shitceptions - a gem for making exceptions more fun!
|
127
|
+
email:
|
128
|
+
- sethvargo@gmail.com
|
129
|
+
executables: []
|
130
|
+
extensions: []
|
131
|
+
extra_rdoc_files: []
|
132
|
+
files:
|
133
|
+
- lib/shitceptions/emojis.rb
|
134
|
+
- lib/shitceptions/error.rb
|
135
|
+
- lib/shitceptions/version.rb
|
136
|
+
- lib/shitceptions.rb
|
137
|
+
- spec/lib/shitceptions_spec.rb
|
138
|
+
- spec/spec_helper.rb
|
139
|
+
homepage: https://github.com/sethvargo/shitceptions
|
140
|
+
licenses:
|
141
|
+
- Apache 2.0
|
142
|
+
post_install_message:
|
143
|
+
rdoc_options: []
|
144
|
+
require_paths:
|
145
|
+
- lib
|
146
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
147
|
+
none: false
|
148
|
+
requirements:
|
149
|
+
- - ! '>='
|
150
|
+
- !ruby/object:Gem::Version
|
151
|
+
version: '0'
|
152
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
153
|
+
none: false
|
154
|
+
requirements:
|
155
|
+
- - ! '>='
|
156
|
+
- !ruby/object:Gem::Version
|
157
|
+
version: '0'
|
158
|
+
requirements: []
|
159
|
+
rubyforge_project:
|
160
|
+
rubygems_version: 1.8.23
|
161
|
+
signing_key:
|
162
|
+
specification_version: 3
|
163
|
+
summary: Have you ever wanted a poop emoji for "LoadError", or a fist for "ArgumentError"?
|
164
|
+
Well now you can. Simply install shitceptions and life is a dream!
|
165
|
+
test_files:
|
166
|
+
- spec/lib/shitceptions_spec.rb
|
167
|
+
- spec/spec_helper.rb
|
168
|
+
has_rdoc:
|