sysexits 1.0.2 → 1.1.0
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.tar.gz.sig +0 -0
- data/.gemtest +0 -0
- data/ChangeLog +67 -0
- data/History.rdoc +20 -0
- data/Manifest.txt +8 -0
- data/{README.md → README.rdoc} +43 -26
- data/Rakefile +19 -47
- data/lib/sysexits.rb +103 -70
- metadata +101 -53
- metadata.gz.sig +0 -0
- data/History.md +0 -15
data.tar.gz.sig
CHANGED
Binary file
|
data/.gemtest
ADDED
File without changes
|
data/ChangeLog
ADDED
@@ -0,0 +1,67 @@
|
|
1
|
+
2010-12-22 Michael Granger <ged@FaerieMUD.org>
|
2
|
+
|
3
|
+
* .hgtags:
|
4
|
+
Added tag v1.0.2 for changeset d0f0419db01c
|
5
|
+
[f4502cd6a855] [tip]
|
6
|
+
|
7
|
+
* .hgsigs:
|
8
|
+
Added signature for changeset 2baa1e0251b7
|
9
|
+
[d0f0419db01c] [v1.0.2]
|
10
|
+
|
11
|
+
* README.md:
|
12
|
+
Point to the Bitbucket page for project stuff.
|
13
|
+
[2baa1e0251b7]
|
14
|
+
|
15
|
+
* History.md, Manifest.txt, README.md, Rakefile, lib/sysexits.rb,
|
16
|
+
spec/sysexits_spec.rb:
|
17
|
+
Converted to Hoe, RSpec 2, bumped version to 1.0.2.
|
18
|
+
[bbab3d3bc005]
|
19
|
+
|
20
|
+
2010-10-14 Michael Granger <ged@FaerieMUD.org>
|
21
|
+
|
22
|
+
* .hgtags:
|
23
|
+
Added tag 1.0.1 for changeset 8285d2794be9
|
24
|
+
[a3d2ca996996]
|
25
|
+
|
26
|
+
* .hgsigs:
|
27
|
+
Added signature for changeset abfbf4b067bd
|
28
|
+
[8285d2794be9] [1.0.1]
|
29
|
+
|
30
|
+
* Rakefile, lib/sysexits.rb, project.yml:
|
31
|
+
Fixes for 1.9.2, build system update, version bump.
|
32
|
+
[abfbf4b067bd]
|
33
|
+
|
34
|
+
* .hgignore, README.md, Rakefile, project.yml:
|
35
|
+
Fixing documentation errors
|
36
|
+
[409f895dfe75]
|
37
|
+
|
38
|
+
2010-06-19 Michael Granger <ged@FaerieMUD.org>
|
39
|
+
|
40
|
+
* .hgtags:
|
41
|
+
Added tag 1.0.0 for changeset ff90a4c80dce
|
42
|
+
[2a3d27bf17a0]
|
43
|
+
|
44
|
+
* .hgsigs:
|
45
|
+
Added signature for changeset d43f3935008a
|
46
|
+
[ff90a4c80dce] [1.0.0]
|
47
|
+
|
48
|
+
* README.markdown, README.md, Rakefile, lib/sysexits.rb, project.yml:
|
49
|
+
Updated build system, prep for release.
|
50
|
+
[d43f3935008a]
|
51
|
+
|
52
|
+
2010-06-18 Michael Granger <ged@FaerieMUD.org>
|
53
|
+
|
54
|
+
* README.markdown:
|
55
|
+
Wow, Kernel.include? Really? Good thing it's Friday.
|
56
|
+
[5b05aabe75b9]
|
57
|
+
|
58
|
+
* .hgignore, README, README.markdown, Rakefile, lib/sysexits.rb,
|
59
|
+
spec/sysexits_spec.rb:
|
60
|
+
Cleanup, switched README and class docs, docs corrections, no-
|
61
|
+
monkeypatch test.
|
62
|
+
[975a57604d30]
|
63
|
+
|
64
|
+
* .hgignore, LICENSE, README, Rakefile, lib/sysexits.rb, project.yml,
|
65
|
+
spec/sysexits_spec.rb:
|
66
|
+
Initial checkin
|
67
|
+
[917705a6837d]
|
data/History.rdoc
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
== v1.1.0 [2012-09-18] Michael Granger <ged@FaerieMUD.org>
|
2
|
+
|
3
|
+
Updated docs, added Sysexits::exit!, removed YARD cruft (ick!).
|
4
|
+
|
5
|
+
|
6
|
+
== v1.0.2 [2010-12-22] Michael Granger <ged@FaerieMUD.org>
|
7
|
+
|
8
|
+
Converted to RSpec 2, Hoe.
|
9
|
+
|
10
|
+
|
11
|
+
== v1.0.1 [2010-10-14] Michael Granger <ged@FaerieMUD.org>
|
12
|
+
|
13
|
+
Fixes for Ruby 1.9.2.
|
14
|
+
|
15
|
+
|
16
|
+
== v1.0.0 [2010-06-19] Michael Granger <ged@FaerieMUD.org>
|
17
|
+
|
18
|
+
Initial release.
|
19
|
+
|
20
|
+
|
data/Manifest.txt
ADDED
data/{README.md → README.rdoc}
RENAMED
@@ -1,48 +1,53 @@
|
|
1
|
-
|
1
|
+
= sysexits
|
2
2
|
|
3
|
-
|
3
|
+
project:: https://bitbucket.org/ged/sysexits
|
4
|
+
github:: https://github.com/ged/sysexits
|
5
|
+
docs:: http://deveiate.org/code/sysexits
|
4
6
|
|
5
|
-
## Description
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
== Description
|
9
|
+
|
10
|
+
Have you ever wanted to call <code>exit()</code> with an error condition, but
|
11
|
+
weren't sure what exit status to use? No? Maybe it's just me, then.
|
9
12
|
|
10
13
|
Anyway, I was reading manpages late one evening before retiring to bed in my
|
11
|
-
palatial estate in rural Oregon, and I stumbled across
|
12
|
-
chagrin, I couldn't find a
|
13
|
-
|
14
|
-
one!
|
14
|
+
palatial estate in rural Oregon, and I stumbled across
|
15
|
+
<code>sysexits(3)</code>. Much to my chagrin, I couldn't find a +sysexits+ for
|
16
|
+
Ruby! Well, for the other 2 people that actually care about
|
17
|
+
<code>style(9)</code> as it applies to Ruby code, now there is one!
|
15
18
|
|
16
|
-
Sysexits is a
|
17
|
-
the standard (BSDish) exit codes, used as arguments to
|
19
|
+
Sysexits is a *completely* *awesome* collection of human-readable constants for
|
20
|
+
the standard (BSDish) exit codes, used as arguments to +exit+ to
|
18
21
|
indicate a specific error condition to the parent process.
|
19
22
|
|
20
23
|
It's so fantastically fabulous that you'll want to fork it right away to avoid
|
21
24
|
being thought of as that guy that's still using Webrick for his blog. I mean,
|
22
|
-
|
25
|
+
<code>exit(1)</code> is so passé! This is like the 14-point font of Systems
|
26
|
+
Programming.
|
23
27
|
|
24
28
|
Like the C header file from which this was derived (I mean forked, naturally),
|
25
|
-
error numbers begin at
|
26
|
-
old
|
27
|
-
other programs may already return.
|
29
|
+
error numbers begin at <code>Sysexits::EX__BASE</code> (which is way more cool
|
30
|
+
than plain old +64+) to reduce the possibility of clashing with other exit
|
31
|
+
statuses that other programs may already return.
|
28
32
|
|
29
33
|
The codes are available in two forms: as constants which can be imported into
|
30
|
-
your own namespace via
|
31
|
-
Hash keyed by Symbols derived from the
|
34
|
+
your own namespace via <code>include Sysexits</code>, or as
|
35
|
+
<code>Sysexits::STATUS_CODES</code>, a Hash keyed by Symbols derived from the
|
36
|
+
constant names.
|
32
37
|
|
33
38
|
Allow me to demonstrate. First, the old way:
|
34
39
|
|
35
|
-
exit( 69 )
|
40
|
+
exit( 69 )
|
36
41
|
|
37
42
|
Whaaa...? Is that a euphemism? What's going on? See how unattractive and...
|
38
43
|
well, 1970 that is? We're not changing vaccuum tubes here, people, we're
|
39
|
-
|
44
|
+
<em>building a totally-awesome future in the Cloud™!</em>
|
40
45
|
|
41
46
|
include Sysexits
|
42
47
|
exit EX_UNAVAILABLE
|
43
48
|
|
44
|
-
Okay, at least this is readable to people who have used fork()
|
45
|
-
twice, but you could do so much better!
|
49
|
+
Okay, at least this is readable to people who have used <code>fork()</code>
|
50
|
+
more than twice, but you could do so much better!
|
46
51
|
|
47
52
|
include Sysexits
|
48
53
|
exit :unavailable
|
@@ -50,12 +55,24 @@ twice, but you could do so much better!
|
|
50
55
|
Holy Toledo! It's like we're writing Ruby, but our own made-up dialect in
|
51
56
|
which variable++ is possible! Well, okay, it's not quite that cool. But it
|
52
57
|
does look more Rubyish. And no monkeys were patched in the filming of this
|
53
|
-
episode! All the simpletons still exiting with icky
|
58
|
+
episode! All the simpletons still exiting with icky _numbers_ can still
|
54
59
|
continue blithely along, none the wiser.
|
55
60
|
|
56
|
-
|
61
|
+
== Caveats
|
62
|
+
|
63
|
+
At some point, Apple started including their own +sysexits+ library in
|
64
|
+
+vendor_ruby+, so to load the gem version on a MacOS X 10.7+ box, you need to
|
65
|
+
do:
|
66
|
+
|
67
|
+
gem 'sysexits'
|
68
|
+
require 'sysexits'
|
69
|
+
|
70
|
+
It's a bit ugly, but there isn't a whole lot I can do about it. Sorry.
|
71
|
+
|
72
|
+
|
73
|
+
== Contributing
|
57
74
|
|
58
|
-
You can clone the source with Mercurial, submit bug reports, suggestions,
|
75
|
+
You can clone the source with Mercurial, submit bug reports, suggestions,
|
59
76
|
etc., via the project page:
|
60
77
|
|
61
78
|
https://bitbucket.org/ged/sysexits
|
@@ -78,9 +95,9 @@ You can read more super-exited pointless marketing at:
|
|
78
95
|
Or maybe not.
|
79
96
|
|
80
97
|
|
81
|
-
|
98
|
+
== License
|
82
99
|
|
83
|
-
Copyright (c) 2010, Michael Granger
|
100
|
+
Copyright (c) 2010-2012, Michael Granger
|
84
101
|
All rights reserved.
|
85
102
|
|
86
103
|
Redistribution and use in source and binary forms, with or without
|
data/Rakefile
CHANGED
@@ -3,28 +3,31 @@
|
|
3
3
|
|
4
4
|
require 'hoe'
|
5
5
|
|
6
|
+
Hoe.plugin :deveiate
|
6
7
|
Hoe.plugin :mercurial
|
7
|
-
Hoe.plugin :yard
|
8
8
|
Hoe.plugin :signing
|
9
9
|
|
10
10
|
Hoe.plugins.delete :rubyforge
|
11
11
|
|
12
12
|
hoespec = Hoe.spec 'sysexits' do
|
13
|
-
self.readme_file = 'README.
|
13
|
+
self.readme_file = 'README.rdoc'
|
14
|
+
self.history_file = 'History.rdoc'
|
15
|
+
self.extra_rdoc_files = FileList[ '*.rdoc' ]
|
16
|
+
self.spec_extras[:rdoc_options] = ['-f', 'fivefish', '-t', 'Sysexits']
|
14
17
|
|
15
18
|
self.developer 'Michael Granger', 'ged@FaerieMUD.org'
|
16
19
|
|
17
|
-
self.
|
18
|
-
|
20
|
+
self.dependency 'rspec', '~> 2.11', :developer
|
21
|
+
self.dependency 'simplecov', '~> 0.6', :developer
|
19
22
|
|
20
23
|
self.spec_extras[:licenses] = ["BSD"]
|
21
24
|
self.spec_extras[:post_install_message] = %{
|
22
25
|
Get ready to be amazed. I'll bet you can't wait to Exit Like
|
23
26
|
a Pro®!
|
24
|
-
|
27
|
+
|
25
28
|
Well, if you want, you can do it right from the command-line! Check
|
26
29
|
this out:
|
27
|
-
|
30
|
+
|
28
31
|
ruby -rubygems -e \\
|
29
32
|
'require "sysexits"; include Sysexits; exit :software_error' \\
|
30
33
|
|| echo $?
|
@@ -34,54 +37,23 @@ hoespec = Hoe.spec 'sysexits' do
|
|
34
37
|
|
35
38
|
}.gsub( /^\t+/m, '' )
|
36
39
|
|
37
|
-
self.spec_extras[:signing_key] = '/Volumes/Keys/ged-private_gem_key.pem'
|
38
|
-
|
39
40
|
self.require_ruby_version( '>=1.8.7' )
|
40
41
|
self.hg_sign_tags = true if self.respond_to?( :hg_sign_tags )
|
41
|
-
|
42
|
-
self.yard_opts = [ '--use-cache', '--protected', '--verbose' ]
|
43
42
|
self.rdoc_locations << "deveiate:/usr/local/www/public/code/#{remote_rdoc_dir}"
|
44
43
|
end
|
45
44
|
|
46
45
|
ENV['VERSION'] ||= hoespec.spec.version.to_s
|
47
46
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
rev = get_numeric_rev()
|
55
|
-
trace "Current rev is: %p" % [ rev ]
|
56
|
-
hoespec.spec.version.version << "pre#{rev}"
|
57
|
-
Rake::Task[:gem].clear
|
58
|
-
|
59
|
-
Gem::PackageTask.new( hoespec.spec ) do |pkg|
|
60
|
-
pkg.need_zip = true
|
61
|
-
pkg.need_tar = true
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
### Make the ChangeLog update if the repo has changed since it was last built
|
66
|
-
file '.hg/branch'
|
67
|
-
file 'ChangeLog' => '.hg/branch' do |task|
|
68
|
-
$stderr.puts "Updating the changelog..."
|
69
|
-
content = make_changelog()
|
70
|
-
File.open( task.name, 'w', 0644 ) do |fh|
|
71
|
-
fh.print( content )
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
# Rebuild the ChangeLog immediately before release
|
76
|
-
task :prerelease => 'ChangeLog'
|
77
|
-
|
78
|
-
rescue NameError => err
|
79
|
-
task :no_hg_helpers do
|
80
|
-
fail "Couldn't define the :pre task: %s: %s" % [ err.class.name, err.message ]
|
81
|
-
end
|
82
|
-
|
83
|
-
task :pre => :no_hg_helpers
|
84
|
-
task 'ChangeLog' => :no_hg_helpers
|
47
|
+
# Run the tests before checking in
|
48
|
+
task 'hg:precheckin' => [ :check_history, :check_manifest, :spec ]
|
49
|
+
|
50
|
+
# Rebuild the ChangeLog immediately before release
|
51
|
+
task :prerelease => 'ChangeLog'
|
52
|
+
CLOBBER.include( 'ChangeLog' )
|
85
53
|
|
54
|
+
desc "Build a coverage report"
|
55
|
+
task :coverage do
|
56
|
+
ENV["COVERAGE"] = 'yes'
|
57
|
+
Rake::Task[:spec].invoke
|
86
58
|
end
|
87
59
|
|
data/lib/sysexits.rb
CHANGED
@@ -1,30 +1,48 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
3
|
# = sysexits
|
4
|
-
#
|
4
|
+
#
|
5
5
|
# Exit status codes for system programs.
|
6
|
-
#
|
7
|
-
#
|
8
|
-
#
|
9
|
-
#
|
10
|
-
#
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
14
|
-
#
|
15
|
-
#
|
6
|
+
#
|
7
|
+
# == Usage
|
8
|
+
#
|
9
|
+
# To support running on a Mac running OS X 10.7 or later, you'll
|
10
|
+
# need to force the gem first in the load path to avoid Apple's
|
11
|
+
# own helpfully vendored 'sysexits' library:
|
12
|
+
#
|
13
|
+
# gem 'sysexits'
|
14
|
+
# require 'sysexits'
|
15
|
+
#
|
16
|
+
# You can look up the appropriate code yourself, and exit using
|
17
|
+
# the regular exit method, of course:
|
18
|
+
#
|
19
|
+
# status_code = Sysexits.exit_status( :success )
|
20
|
+
# exit( status_code )
|
21
|
+
#
|
22
|
+
# Or, just use Sysexits::exit with the code name:
|
23
|
+
#
|
24
|
+
# Sysexits.exit( :usage )
|
25
|
+
#
|
26
|
+
# Or, mix the enhanced ::exit into your namespace:
|
27
|
+
#
|
28
|
+
# include Sysexits
|
29
|
+
# exit( :unavailable )
|
30
|
+
#
|
31
|
+
# It also supports #exit! in all the same ways as above.
|
32
|
+
#
|
33
|
+
#
|
16
34
|
# == License
|
17
|
-
#
|
35
|
+
#
|
18
36
|
# This file was derived almost entirely from the BSD sysexits.h, which
|
19
37
|
# is distributed under the following license:
|
20
38
|
#
|
21
39
|
# Copyright (c) 1987, 1993
|
22
40
|
# The Regents of the University of California. All rights reserved.
|
23
|
-
#
|
41
|
+
#
|
24
42
|
# Redistribution and use in source and binary forms, with or without
|
25
43
|
# modification, are permitted provided that the following conditions
|
26
44
|
# are met:
|
27
|
-
#
|
45
|
+
#
|
28
46
|
# 1. Redistributions of source code must retain the above copyright
|
29
47
|
# notice, this list of conditions and the following disclaimer.
|
30
48
|
# 2. Redistributions in binary form must reproduce the above copyright
|
@@ -37,7 +55,7 @@
|
|
37
55
|
# 4. Neither the name of the University nor the names of its contributors
|
38
56
|
# may be used to endorse or promote products derived from this software
|
39
57
|
# without specific prior written permission.
|
40
|
-
#
|
58
|
+
#
|
41
59
|
# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
|
42
60
|
# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
43
61
|
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
@@ -53,91 +71,96 @@
|
|
53
71
|
module Sysexits
|
54
72
|
|
55
73
|
# The library version
|
56
|
-
VERSION = '1.0
|
74
|
+
VERSION = '1.1.0'
|
57
75
|
|
58
76
|
# The library's revision id
|
59
|
-
REVISION = %q$Revision:
|
77
|
+
REVISION = %q$Revision: 003b25c84462 $
|
60
78
|
|
61
79
|
|
62
|
-
#
|
80
|
+
#
|
63
81
|
# The constants
|
64
|
-
#
|
82
|
+
#
|
65
83
|
|
66
|
-
# Successful termination
|
84
|
+
# <b>:ok,</b> <b>:success</b> - Successful termination
|
67
85
|
EX_OK = 0
|
68
86
|
|
69
|
-
|
70
|
-
# The base value for sysexit codes
|
87
|
+
# <b>:_base</b> - The base value for sysexit codes
|
71
88
|
EX__BASE = 64
|
72
89
|
|
73
|
-
# The command was used incorrectly, e.g., with the wrong
|
74
|
-
# arguments, a bad flag, a bad syntax in a parameter, or whatever.
|
90
|
+
# <b>:usage</b> - The command was used incorrectly, e.g., with the wrong
|
91
|
+
# number of arguments, a bad flag, a bad syntax in a parameter, or whatever.
|
75
92
|
EX_USAGE = 64
|
76
93
|
|
77
|
-
# The input data was incorrect in
|
78
|
-
# for user data, not system files.
|
94
|
+
# <b>:dataerr,</b> <b>:data_error</b> - The input data was incorrect in
|
95
|
+
# some way. This should only be used for user data, not system files.
|
79
96
|
EX_DATAERR = 65
|
80
97
|
|
81
|
-
# An input file (not a system
|
82
|
-
#
|
83
|
-
# it cared to catch it).
|
98
|
+
# <b>:noinput,</b> <b>:input_missing</b> - An input file (not a system
|
99
|
+
# file) did not exist or was not readable. This could also include errors
|
100
|
+
# like "No message" to a mailer (if it cared to catch it).
|
84
101
|
EX_NOINPUT = 66
|
85
102
|
|
86
|
-
# The user specified did not exist.
|
87
|
-
# addresses or remote logins.
|
103
|
+
# <b>:nouser,</b> <b>:no_such_user</b> - The user specified did not exist.
|
104
|
+
# This might be used for mail addresses or remote logins.
|
88
105
|
EX_NOUSER = 67
|
89
106
|
|
90
|
-
# The host specified did not exist.
|
91
|
-
# or network requests.
|
107
|
+
# <b>:nohost,</b> <b>:no_such_host</b> - The host specified did not exist.
|
108
|
+
# This is used in mail addresses or network requests.
|
92
109
|
EX_NOHOST = 68
|
93
110
|
|
94
|
-
#
|
95
|
-
#
|
96
|
-
#
|
97
|
-
# why.
|
111
|
+
# <b>:unavailable,</b> <b>:service_unavailable</b> - A service is
|
112
|
+
# unavailable. This can occur if a support program or file does not exist.
|
113
|
+
# This can also be used as a catchall message when something you wanted to
|
114
|
+
# do doesn't work, but you don't know why.
|
98
115
|
EX_UNAVAILABLE = 69
|
99
116
|
|
100
|
-
# An internal software error has
|
101
|
-
# to non-operating system related
|
117
|
+
# <b>:software,</b> <b>:software_error</b> - An internal software error has
|
118
|
+
# been detected. This should be limited to non-operating system related
|
119
|
+
# errors.
|
102
120
|
EX_SOFTWARE = 70
|
103
121
|
|
104
|
-
# An operating system error
|
105
|
-
# be used for such things as
|
106
|
-
# the like. It includes things
|
107
|
-
# does not exist in the passwd file.
|
122
|
+
# <b>:oserr,</b> <b>:operating_system_error</b> - An operating system error
|
123
|
+
# has been detected. This is intended to be used for such things as
|
124
|
+
# "cannot fork", "cannot create pipe", or the like. It includes things
|
125
|
+
# like getuid returning a user that does not exist in the passwd file.
|
108
126
|
EX_OSERR = 71
|
109
127
|
|
110
|
-
# Some system file
|
111
|
-
# exist, cannot be opened, or
|
112
|
-
# error).
|
128
|
+
# <b>:osfile,</b> <b>:operating_system_file_error</b> - Some system file
|
129
|
+
# (e.g., /etc/passwd, /etc/utmp, etc.) does not exist, cannot be opened, or
|
130
|
+
# has some sort of error (e.g., syntax error).
|
113
131
|
EX_OSFILE = 72
|
114
132
|
|
115
|
-
# A (user specified) output
|
133
|
+
# <b>:cantcreat,</b> <b>:cant_create_output</b> - A (user specified) output
|
134
|
+
# file cannot be created.
|
116
135
|
EX_CANTCREAT = 73
|
117
136
|
|
118
|
-
# An error occurred while doing I/O on a file.
|
137
|
+
# <b>:ioerr</b> - An error occurred while doing I/O on a file.
|
119
138
|
EX_IOERR = 74
|
120
139
|
|
121
|
-
#
|
122
|
-
#
|
123
|
-
#
|
140
|
+
# <b>:tempfail,</b> <b>:temporary_failure,</b> <b>:try_again</b> - Temporary
|
141
|
+
# failure, indicating something that is not really a serious error. In
|
142
|
+
# sendmail, this means that a mailer (e.g.) could not create a connection,
|
143
|
+
# and the request should be reattempted later.
|
124
144
|
EX_TEMPFAIL = 75
|
125
145
|
|
126
|
-
# The remote system returned
|
127
|
-
# a protocol exchange.
|
146
|
+
# <b>:protocol,</b> <b>:protocol_error</b> - The remote system returned
|
147
|
+
# something that was "not possible" during a protocol exchange.
|
128
148
|
EX_PROTOCOL = 76
|
129
149
|
|
130
|
-
# You did not have sufficient
|
131
|
-
# This is not intended for file
|
132
|
-
# NOINPUT or CANTCREAT, but rather
|
150
|
+
# <b>:noperm,</b> <b>:permission_denied</b> - You did not have sufficient
|
151
|
+
# permission to perform the operation. This is not intended for file
|
152
|
+
# system problems, which should use NOINPUT or CANTCREAT, but rather
|
153
|
+
# for higher level permissions.
|
133
154
|
EX_NOPERM = 77
|
134
155
|
|
135
|
-
# There was an error in a
|
156
|
+
# <b>:config,</b> <b>:config_error</b> - There was an error in a
|
157
|
+
# user-specified configuration value.
|
136
158
|
EX_CONFIG = 78
|
137
159
|
|
138
160
|
|
139
|
-
# The maximum listed value. Automatically determined
|
140
|
-
# and I'll forget to update this if I ever add
|
161
|
+
# <b>:_max</b> - The maximum listed value. Automatically determined
|
162
|
+
# because, well, we can and I'll forget to update this if I ever add
|
163
|
+
# any codes.
|
141
164
|
EX__MAX = constants.
|
142
165
|
select {|name| name =~ /^EX_/ }.
|
143
166
|
collect {|name| self.const_get(name) }.max
|
@@ -203,20 +226,30 @@ module Sysexits
|
|
203
226
|
module_function
|
204
227
|
###############
|
205
228
|
|
206
|
-
###
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
end
|
229
|
+
### Turn +status+ into a numeric exit status and return it.
|
230
|
+
def exit_status( status )
|
231
|
+
case status
|
232
|
+
when Symbol, String
|
233
|
+
return STATUS_CODES[ status.to_sym ] || status
|
234
|
+
else
|
235
|
+
return status
|
236
|
+
end
|
237
|
+
end
|
238
|
+
|
217
239
|
|
240
|
+
### Exit with the exit +status+, which can be either one of the
|
241
|
+
### keys of STATUS_CODES or a number.
|
242
|
+
def exit( status=EX_OK )
|
243
|
+
status = exit_status( status )
|
218
244
|
::Kernel.exit( status )
|
219
245
|
end
|
220
246
|
|
247
|
+
|
248
|
+
### Exit with the given +status+ without running exit handlers.
|
249
|
+
def exit!( status=EX_OK )
|
250
|
+
status = exit_status( status )
|
251
|
+
::Kernel.exit!( status )
|
252
|
+
end
|
253
|
+
|
221
254
|
end # module Sysexits
|
222
255
|
|
metadata
CHANGED
@@ -2,12 +2,12 @@
|
|
2
2
|
name: sysexits
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
hash: 19
|
5
|
-
prerelease:
|
5
|
+
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
|
+
- 1
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 1.0.2
|
10
|
+
version: 1.1.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Michael Granger
|
@@ -35,87 +35,132 @@ cert_chain:
|
|
35
35
|
cmlhXe46pZNJgWKbxZah85jIjx95hR8vOI+NAM5iH9kOqK13DrxacTKPhqj5PjwF
|
36
36
|
-----END CERTIFICATE-----
|
37
37
|
|
38
|
-
date:
|
39
|
-
default_executable:
|
38
|
+
date: 2012-09-18 00:00:00 Z
|
40
39
|
dependencies:
|
41
40
|
- !ruby/object:Gem::Dependency
|
42
|
-
name: hoe-
|
41
|
+
name: hoe-mercurial
|
43
42
|
prerelease: false
|
44
43
|
requirement: &id001 !ruby/object:Gem::Requirement
|
45
44
|
none: false
|
46
45
|
requirements:
|
47
|
-
- -
|
46
|
+
- - ~>
|
48
47
|
- !ruby/object:Gem::Version
|
49
|
-
hash:
|
48
|
+
hash: 7
|
50
49
|
segments:
|
51
|
-
- 0
|
52
50
|
- 1
|
53
|
-
-
|
54
|
-
|
51
|
+
- 4
|
52
|
+
- 0
|
53
|
+
version: 1.4.0
|
55
54
|
type: :development
|
56
55
|
version_requirements: *id001
|
57
56
|
- !ruby/object:Gem::Dependency
|
58
|
-
name:
|
57
|
+
name: hoe-highline
|
59
58
|
prerelease: false
|
60
59
|
requirement: &id002 !ruby/object:Gem::Requirement
|
61
60
|
none: false
|
62
61
|
requirements:
|
63
62
|
- - ~>
|
64
63
|
- !ruby/object:Gem::Version
|
65
|
-
hash:
|
64
|
+
hash: 29
|
66
65
|
segments:
|
67
|
-
- 2
|
68
|
-
- 1
|
69
66
|
- 0
|
70
|
-
|
67
|
+
- 0
|
68
|
+
- 1
|
69
|
+
version: 0.0.1
|
71
70
|
type: :development
|
72
71
|
version_requirements: *id002
|
73
72
|
- !ruby/object:Gem::Dependency
|
74
|
-
name:
|
73
|
+
name: rdoc
|
75
74
|
prerelease: false
|
76
75
|
requirement: &id003 !ruby/object:Gem::Requirement
|
77
76
|
none: false
|
78
77
|
requirements:
|
79
|
-
- -
|
78
|
+
- - ~>
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
hash: 19
|
81
|
+
segments:
|
82
|
+
- 3
|
83
|
+
- 10
|
84
|
+
version: "3.10"
|
85
|
+
type: :development
|
86
|
+
version_requirements: *id003
|
87
|
+
- !ruby/object:Gem::Dependency
|
88
|
+
name: rspec
|
89
|
+
prerelease: false
|
90
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
92
|
+
requirements:
|
93
|
+
- - ~>
|
80
94
|
- !ruby/object:Gem::Version
|
81
|
-
hash:
|
95
|
+
hash: 21
|
82
96
|
segments:
|
83
97
|
- 2
|
84
|
-
-
|
98
|
+
- 11
|
99
|
+
version: "2.11"
|
100
|
+
type: :development
|
101
|
+
version_requirements: *id004
|
102
|
+
- !ruby/object:Gem::Dependency
|
103
|
+
name: simplecov
|
104
|
+
prerelease: false
|
105
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ~>
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
hash: 7
|
111
|
+
segments:
|
85
112
|
- 0
|
86
|
-
|
113
|
+
- 6
|
114
|
+
version: "0.6"
|
87
115
|
type: :development
|
88
|
-
version_requirements: *
|
89
|
-
|
90
|
-
|
116
|
+
version_requirements: *id005
|
117
|
+
- !ruby/object:Gem::Dependency
|
118
|
+
name: hoe
|
119
|
+
prerelease: false
|
120
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ~>
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
hash: 7
|
126
|
+
segments:
|
127
|
+
- 3
|
128
|
+
- 0
|
129
|
+
version: "3.0"
|
130
|
+
type: :development
|
131
|
+
version_requirements: *id006
|
132
|
+
description: "Have you ever wanted to call <code>exit()</code> with an error condition, but\n\
|
133
|
+
weren't sure what exit status to use? No? Maybe it's just me, then.\n\n\
|
91
134
|
Anyway, I was reading manpages late one evening before retiring to bed in my\n\
|
92
|
-
palatial estate in rural Oregon, and I stumbled across
|
93
|
-
chagrin, I couldn't find a
|
94
|
-
|
95
|
-
one!\n\n\
|
96
|
-
Sysexits is a
|
97
|
-
the standard (BSDish) exit codes, used as arguments to
|
135
|
+
palatial estate in rural Oregon, and I stumbled across\n\
|
136
|
+
<code>sysexits(3)</code>. Much to my chagrin, I couldn't find a +sysexits+ for\n\
|
137
|
+
Ruby! Well, for the other 2 people that actually care about\n\
|
138
|
+
<code>style(9)</code> as it applies to Ruby code, now there is one!\n\n\
|
139
|
+
Sysexits is a *completely* *awesome* collection of human-readable constants for\n\
|
140
|
+
the standard (BSDish) exit codes, used as arguments to +exit+ to\n\
|
98
141
|
indicate a specific error condition to the parent process.\n\n\
|
99
142
|
It's so fantastically fabulous that you'll want to fork it right away to avoid\n\
|
100
143
|
being thought of as that guy that's still using Webrick for his blog. I mean,\n\
|
101
|
-
|
144
|
+
<code>exit(1)</code> is so pass\xC3\xA9! This is like the 14-point font of Systems\n\
|
145
|
+
Programming.\n\n\
|
102
146
|
Like the C header file from which this was derived (I mean forked, naturally),\n\
|
103
|
-
error numbers begin at
|
104
|
-
old
|
105
|
-
other programs may already return.\n\n\
|
147
|
+
error numbers begin at <code>Sysexits::EX__BASE</code> (which is way more cool\n\
|
148
|
+
than plain old +64+) to reduce the possibility of clashing with other exit\n\
|
149
|
+
statuses that other programs may already return.\n\n\
|
106
150
|
The codes are available in two forms: as constants which can be imported into\n\
|
107
|
-
your own namespace via
|
108
|
-
Hash keyed by Symbols derived from the
|
109
|
-
|
151
|
+
your own namespace via <code>include Sysexits</code>, or as\n\
|
152
|
+
<code>Sysexits::STATUS_CODES</code>, a Hash keyed by Symbols derived from the\n\
|
153
|
+
constant names.\n\n\
|
154
|
+
Allow me to demonstrate. First, the old way:\n\n exit( 69 )\n\n\
|
110
155
|
Whaaa...? Is that a euphemism? What's going on? See how unattractive and...\n\
|
111
156
|
well, 1970 that is? We're not changing vaccuum tubes here, people, we're\n\
|
112
|
-
|
113
|
-
Okay, at least this is readable to people who have used fork()
|
114
|
-
twice, but you could do so much better!\n\n include Sysexits\n exit :unavailable\n\n\
|
157
|
+
<em>building a totally-awesome future in the Cloud\xE2\x84\xA2!</em>\n\n include Sysexits\n exit EX_UNAVAILABLE\n\n\
|
158
|
+
Okay, at least this is readable to people who have used <code>fork()</code>\n\
|
159
|
+
more than twice, but you could do so much better!\n\n include Sysexits\n exit :unavailable\n\n\
|
115
160
|
Holy Toledo! It's like we're writing Ruby, but our own made-up dialect in\n\
|
116
161
|
which variable++ is possible! Well, okay, it's not quite that cool. But it\n\
|
117
162
|
does look more Rubyish. And no monkeys were patched in the filming of this\n\
|
118
|
-
episode! All the simpletons still exiting with icky
|
163
|
+
episode! All the simpletons still exiting with icky _numbers_ can still\n\
|
119
164
|
continue blithely along, none the wiser."
|
120
165
|
email:
|
121
166
|
- ged@FaerieMUD.org
|
@@ -124,16 +169,20 @@ executables: []
|
|
124
169
|
extensions: []
|
125
170
|
|
126
171
|
extra_rdoc_files:
|
127
|
-
- History.
|
172
|
+
- History.rdoc
|
173
|
+
- Manifest.txt
|
174
|
+
- README.rdoc
|
128
175
|
files:
|
176
|
+
- ChangeLog
|
177
|
+
- History.rdoc
|
129
178
|
- LICENSE
|
130
|
-
-
|
179
|
+
- Manifest.txt
|
180
|
+
- README.rdoc
|
131
181
|
- Rakefile
|
132
182
|
- lib/sysexits.rb
|
133
183
|
- spec/sysexits_spec.rb
|
134
|
-
-
|
135
|
-
|
136
|
-
homepage: http://deveiate.org/sysexits.html
|
184
|
+
- .gemtest
|
185
|
+
homepage: https://bitbucket.org/ged/sysexits
|
137
186
|
licenses:
|
138
187
|
- BSD
|
139
188
|
post_install_message: "\n\
|
@@ -144,11 +193,10 @@ post_install_message: "\n\
|
|
144
193
|
I know, I know: so awesome right? Okay, I'll let you bask in the\n\
|
145
194
|
warn glow of superior systems-programming now.\n\n"
|
146
195
|
rdoc_options:
|
147
|
-
-
|
148
|
-
-
|
149
|
-
-
|
150
|
-
-
|
151
|
-
- Sysexits Documentation
|
196
|
+
- -f
|
197
|
+
- fivefish
|
198
|
+
- -t
|
199
|
+
- Sysexits
|
152
200
|
require_paths:
|
153
201
|
- lib
|
154
202
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -174,9 +222,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
174
222
|
requirements: []
|
175
223
|
|
176
224
|
rubyforge_project: sysexits
|
177
|
-
rubygems_version: 1.
|
225
|
+
rubygems_version: 1.8.24
|
178
226
|
signing_key:
|
179
227
|
specification_version: 3
|
180
|
-
summary: Have you ever wanted to call exit() with an error condition, but weren't sure what exit status to use? No? Maybe it's just me, then
|
228
|
+
summary: Have you ever wanted to call <code>exit()</code> with an error condition, but weren't sure what exit status to use? No? Maybe it's just me, then
|
181
229
|
test_files: []
|
182
230
|
|
metadata.gz.sig
CHANGED
Binary file
|
data/History.md
DELETED
@@ -1,15 +0,0 @@
|
|
1
|
-
## 1.0.2 [2010-12-22] Michael Granger <ged@FaerieMUD.org>
|
2
|
-
|
3
|
-
Converted to RSpec 2, Hoe.
|
4
|
-
|
5
|
-
|
6
|
-
## 1.0.1 [2010-10-14] Michael Granger <ged@FaerieMUD.org>
|
7
|
-
|
8
|
-
Fixes for Ruby 1.9.2.
|
9
|
-
|
10
|
-
|
11
|
-
## 1.0.0 [2010-06-19] Michael Granger <ged@FaerieMUD.org>
|
12
|
-
|
13
|
-
Initial release.
|
14
|
-
|
15
|
-
|