abort_if 0.1.0 → 0.1.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.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/abort_if.rb +6 -5
- data/lib/abort_if/exit.rb +24 -0
- data/lib/abort_if/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9382641ec11c37ac30b41e19e894327898bd87cb
|
4
|
+
data.tar.gz: 6b2c23d5e9e3ff6898ec5515c51f7039be43132f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da1482e773e97e38268b7d8544f9f5ab60f426ca872e04c93463ea339c282207ab23e46777fa64c4effc9786d3921e3288ed08b70a719f71437e6c2713eda3a4
|
7
|
+
data.tar.gz: 86e36eb1ea400665994d6ab25cbb2dea44263fd6cb83286034c6e44b03c62123ab439de1a87264f0e6c2dacf7426a487a37d7fdc9b4db99b934924dcfabcb305
|
data/README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# AbortIf
|
2
2
|
|
3
|
-
[](https://badge.fury.io/rb/abort_if) [](https://travis-ci.org/mooreryan/abort_if) [](https://coveralls.io/github/mooreryan/abort_if?branch=master)
|
4
4
|
|
5
5
|
Simple error logging and assertions for Ruby.
|
6
6
|
|
@@ -22,7 +22,7 @@ Or install it yourself as:
|
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
25
|
-
See [documentation](http://www.rubydoc.info/gems/
|
25
|
+
See [documentation](http://www.rubydoc.info/gems/abort_if) for complete
|
26
26
|
usage.
|
27
27
|
|
28
28
|
### Example ###
|
data/lib/abort_if.rb
CHANGED
@@ -19,6 +19,7 @@
|
|
19
19
|
require "abort_if/version"
|
20
20
|
require "abort_if/error"
|
21
21
|
require "abort_if/argument_error"
|
22
|
+
require "abort_if/exit"
|
22
23
|
require "assert/assert"
|
23
24
|
require "logger"
|
24
25
|
|
@@ -44,7 +45,7 @@ module AbortIf
|
|
44
45
|
# @param msg [String] the message written by the
|
45
46
|
# error logger
|
46
47
|
#
|
47
|
-
# @raise [
|
48
|
+
# @raise [AbortIf::Exit] if test is truthy
|
48
49
|
#
|
49
50
|
# @return [nil] if test is false or nil
|
50
51
|
#
|
@@ -53,7 +54,7 @@ module AbortIf
|
|
53
54
|
def abort_if test, msg="Fatal error"
|
54
55
|
if test
|
55
56
|
logger.fatal msg
|
56
|
-
|
57
|
+
raise Exit
|
57
58
|
end
|
58
59
|
end
|
59
60
|
|
@@ -62,7 +63,7 @@ module AbortIf
|
|
62
63
|
#
|
63
64
|
# @param fname [String] name of a file
|
64
65
|
#
|
65
|
-
# @raise [
|
66
|
+
# @raise [AbortIf::Exit] if file exists
|
66
67
|
#
|
67
68
|
# @return [nil] if file does not exist
|
68
69
|
def abort_if_file_exists fname
|
@@ -86,7 +87,7 @@ module AbortIf
|
|
86
87
|
#
|
87
88
|
# @param (see #abort_if)
|
88
89
|
#
|
89
|
-
# @raise [
|
90
|
+
# @raise [AbortIf::Exit] if test is false or nil
|
90
91
|
#
|
91
92
|
# @return [nil] if test is truthy
|
92
93
|
def abort_unless test, msg="Fatal error"
|
@@ -98,7 +99,7 @@ module AbortIf
|
|
98
99
|
#
|
99
100
|
# @param (see #abort_if_file_exists)
|
100
101
|
#
|
101
|
-
# @raise [
|
102
|
+
# @raise [AbortIf::Exit] if file does not exist
|
102
103
|
#
|
103
104
|
# @return [nil] if file exists
|
104
105
|
def abort_unless_file_exists fname
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Copyright 2016 Ryan Moore
|
2
|
+
# Contact: moorer@udel.edu
|
3
|
+
#
|
4
|
+
# This file is part of AbortIf.
|
5
|
+
#
|
6
|
+
# AbortIf is free software: you can redistribute it and/or modify
|
7
|
+
# it under the terms of the GNU General Public License as published by
|
8
|
+
# the Free Software Foundation, either version 3 of the License, or
|
9
|
+
# (at your option) any later version.
|
10
|
+
#
|
11
|
+
# AbortIf is distributed in the hope that it will be useful,
|
12
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
14
|
+
# GNU General Public License for more details.
|
15
|
+
#
|
16
|
+
# You should have received a copy of the GNU General Public License
|
17
|
+
# along with AbortIf. If not, see <http://www.gnu.org/licenses/>.
|
18
|
+
|
19
|
+
module AbortIf
|
20
|
+
# Raised instead of standard SystemExit so you can catch SystemExit
|
21
|
+
# raised by AbortIf module
|
22
|
+
class Exit < Object::SystemExit
|
23
|
+
end
|
24
|
+
end
|
data/lib/abort_if/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: abort_if
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ryan Moore
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -123,6 +123,7 @@ files:
|
|
123
123
|
- lib/abort_if.rb
|
124
124
|
- lib/abort_if/argument_error.rb
|
125
125
|
- lib/abort_if/error.rb
|
126
|
+
- lib/abort_if/exit.rb
|
126
127
|
- lib/abort_if/version.rb
|
127
128
|
- lib/assert/assert.rb
|
128
129
|
homepage: https://github.com/mooreryan/abort_if
|