watcher 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +21 -0
- data/License.txt +27 -0
- data/Manifest.txt +25 -0
- data/PostInstall.txt +7 -0
- data/README.txt +105 -0
- data/Rakefile +4 -0
- data/TODO +23 -0
- data/config/hoe.rb +75 -0
- data/config/requirements.rb +15 -0
- data/lib/watcher/version.rb +9 -0
- data/lib/watcher.rb +596 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/script/txt2html +82 -0
- data/setup.rb +1585 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/test/test_helper.rb +2 -0
- data/test/test_watcher.rb +11 -0
- data/test/watcher-example.rb +50 -0
- data/website/index.html +141 -0
- data/website/index.txt +83 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.html.erb +48 -0
- data.tar.gz.sig +0 -0
- metadata +122 -0
- metadata.gz.sig +0 -0
data/History.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
== 1.1.0 2008-07-22
|
2
|
+
|
3
|
+
* 1 major enhancement:
|
4
|
+
* Initial public release (via RubyForge)
|
5
|
+
|
6
|
+
* 4 minor enhancements:
|
7
|
+
* Consolidated the verification stage and the action perform stage to a
|
8
|
+
single pair of methods, as opposed to two methods to verify, and two
|
9
|
+
similar methods to perform. This was to prevent changes from one section
|
10
|
+
from causing an hard-to-find bug in the other section.
|
11
|
+
* Added ability to track number of warnings and errors. Warnings are
|
12
|
+
Exceptions that are not re-raised. Errors are Exceptions that are
|
13
|
+
re-raised.
|
14
|
+
* Added ability to send log output to a specified email address.
|
15
|
+
* Cleaned up RDoc formatting, and improved readability.
|
16
|
+
|
17
|
+
== 1.0.0 2008-07-09
|
18
|
+
|
19
|
+
* 1 major enhancement:
|
20
|
+
* Initial private release
|
21
|
+
* Major functionality features working. No critical bugs, just TODO items.
|
data/License.txt
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
(Simplified BSD License)
|
2
|
+
|
3
|
+
Copyright (c) 2008 Karrick McDermott
|
4
|
+
All rights reserved.
|
5
|
+
|
6
|
+
Redistribution and use in source and binary forms, with or without
|
7
|
+
modification, are permitted provided that the following conditions
|
8
|
+
are met:
|
9
|
+
|
10
|
+
1. Redistributions of source code must retain the above copyright
|
11
|
+
notice, this list of conditions and the following disclaimer.
|
12
|
+
2. Redistributions in binary form must reproduce the above copyright
|
13
|
+
notice, this list of conditions and the following disclaimer in the
|
14
|
+
documentation and/or other materials provided with the distribution.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
18
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
19
|
+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
20
|
+
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
21
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
22
|
+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
23
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
24
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
25
|
+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
26
|
+
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
27
|
+
POSSIBILITY OF SUCH DAMAGE.
|
data/Manifest.txt
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
History.txt
|
2
|
+
License.txt
|
3
|
+
Manifest.txt
|
4
|
+
PostInstall.txt
|
5
|
+
README.txt
|
6
|
+
Rakefile
|
7
|
+
TODO
|
8
|
+
config/hoe.rb
|
9
|
+
config/requirements.rb
|
10
|
+
lib/watcher.rb
|
11
|
+
lib/watcher/version.rb
|
12
|
+
script/console
|
13
|
+
script/destroy
|
14
|
+
script/generate
|
15
|
+
script/txt2html
|
16
|
+
setup.rb
|
17
|
+
tasks/deployment.rake
|
18
|
+
tasks/environment.rake
|
19
|
+
tasks/website.rake
|
20
|
+
test/watcher-example.rb
|
21
|
+
website/index.html
|
22
|
+
website/index.txt
|
23
|
+
website/javascripts/rounded_corners_lite.inc.js
|
24
|
+
website/stylesheets/screen.css
|
25
|
+
website/template.html.erb
|
data/PostInstall.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,105 @@
|
|
1
|
+
= watcher
|
2
|
+
|
3
|
+
* http://watcher.rubyforge.org
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Watcher provides advanced integrated exception handling and logging
|
8
|
+
functionality to your Ruby programs.
|
9
|
+
|
10
|
+
This is useful both in the development stage of a program, and while
|
11
|
+
in production use, for instance on a server, as Watcher can be
|
12
|
+
directed to email generated log files to a specified user in the event
|
13
|
+
of errors or warnings.
|
14
|
+
|
15
|
+
By combining exception handling and detailed logging facilities,
|
16
|
+
Watcher greatly reduces code-bloat and potential program flow logic
|
17
|
+
flaws, as Watcher eliminates the necessity to write a tremendous
|
18
|
+
amount of boiler-plate code in the form of "begin, rescue, ensure,
|
19
|
+
end" blocks.
|
20
|
+
|
21
|
+
Watcher also provides a very flexible exception handling capability,
|
22
|
+
allowing a programmer to easily direct Watcher what actions to take in
|
23
|
+
the event of an exception. These failure actions may include any
|
24
|
+
combination of logging the failure, invoking a Proc object, retrying
|
25
|
+
the code, and allowing the exception to propagate up the call-stack by
|
26
|
+
re-raising the exception. Exceptions that are re-raised in a child
|
27
|
+
call-stack are caught by the parent call-stack, and are then dealt
|
28
|
+
with by the programmer determined rules of the parent call-stack. All
|
29
|
+
this happens while Watcher ensures the logs are properly maintained
|
30
|
+
for the various actions taken.
|
31
|
+
|
32
|
+
== FEATURES/PROBLEMS:
|
33
|
+
|
34
|
+
* Exception handling without the boiler-plate code.
|
35
|
+
* Multiple tiers of verbosity.
|
36
|
+
* Flexible logging capabilities, including to files, STDERR, email.
|
37
|
+
* Nested, and hierarchical log output for descriptive stack-frame level
|
38
|
+
understanding where an exception was thrown.
|
39
|
+
* Ability to change the time format of your logs by supplying an arbitrary
|
40
|
+
Proc to return the time in the format of your choice.
|
41
|
+
* Ability to customize the layout of the logs, by turning off hierarchical
|
42
|
+
view, or changing Strings used to indicate events.
|
43
|
+
* Email log files automatically, based on number of errors or warnings.
|
44
|
+
* Ability to invoke arbitrary sequence of events if exception is thrown,
|
45
|
+
including invocation of Proc objects.
|
46
|
+
|
47
|
+
== SYNOPSIS:
|
48
|
+
|
49
|
+
# create Watcher instance with slightly modified defaults
|
50
|
+
$watcher=Watcher.create(:output=>log_file, :verbosity=>:warn)
|
51
|
+
|
52
|
+
$watcher.info("starting #{File.basename($0)}") do
|
53
|
+
# Look for CONFIG_PATH. If not found, log warning then re-write it
|
54
|
+
fail_actions=[:log, lambda {write_config(config_path)}]
|
55
|
+
$watcher.info("searching for [#{config_path}].", fail_actions) do
|
56
|
+
if not File.exists?(config_path)
|
57
|
+
raise RuntimeError.new("WARNING: Missing [#{config_path}]. Creating a default config file. (You should probably verify it...)")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
# invoke utility, which uses $watcher as well
|
62
|
+
fsc=FileSystemChecker.new(:config_path=>config_path)
|
63
|
+
fsc.check_file_systems(:all=>all_flag, :remount=>remount_flag)
|
64
|
+
if email_flag and $watcher.errors > 0
|
65
|
+
$watcher.send_email(email,'FAIL: Required filesystems are not mounted')
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
== REQUIREMENTS:
|
70
|
+
|
71
|
+
* Passion for coding.
|
72
|
+
|
73
|
+
== INSTALL:
|
74
|
+
|
75
|
+
$ sudo gem install
|
76
|
+
|
77
|
+
== LICENSE:
|
78
|
+
|
79
|
+
(The Simplified BSD License)
|
80
|
+
|
81
|
+
Copyright (c) 2008 Karrick McDermott
|
82
|
+
All rights reserved.
|
83
|
+
|
84
|
+
Redistribution and use in source and binary forms, with or without
|
85
|
+
modification, are permitted provided that the following conditions
|
86
|
+
are met:
|
87
|
+
|
88
|
+
1. Redistributions of source code must retain the above copyright
|
89
|
+
notice, this list of conditions and the following disclaimer.
|
90
|
+
2. Redistributions in binary form must reproduce the above copyright
|
91
|
+
notice, this list of conditions and the following disclaimer in the
|
92
|
+
documentation and/or other materials provided with the distribution.
|
93
|
+
|
94
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
95
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
96
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
97
|
+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
98
|
+
COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
99
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
100
|
+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
101
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
102
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
103
|
+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
104
|
+
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
105
|
+
POSSIBILITY OF SUCH DAMAGE.
|
data/Rakefile
ADDED
data/TODO
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
CRITICAL
|
2
|
+
|
3
|
+
* none
|
4
|
+
|
5
|
+
MINOR
|
6
|
+
|
7
|
+
* Write unit tests. This goes without saying.
|
8
|
+
|
9
|
+
* Write some non-trivial example code. I have developed and ported several non-trivial utilities from Logger to Watcher, and am extremely happy with the results. Now let me get something ready to package with this gem.
|
10
|
+
|
11
|
+
* Consolidation/refactoring of warnings and errors. (Principle of least surprise should be applied.) The :log fail action would now imply a warning, while a :raise implies an error. (This is not immediately intuitive.)
|
12
|
+
|
13
|
+
* Trap signals to clean up properly.
|
14
|
+
|
15
|
+
* Log rotation.
|
16
|
+
|
17
|
+
LOW
|
18
|
+
|
19
|
+
* Figure out how to get ri documentation working.
|
20
|
+
|
21
|
+
* Provide a Watcher.destroy method which closes the Watcher instance and changes the @@watcher class attribute back to nil.
|
22
|
+
|
23
|
+
* Validate data when attributes accessors invoked, for instance @current_indent.
|
data/config/hoe.rb
ADDED
@@ -0,0 +1,75 @@
|
|
1
|
+
require 'watcher/version'
|
2
|
+
|
3
|
+
AUTHOR = 'Karrick McDermott' # can also be an array of Authors
|
4
|
+
EMAIL = "karrick@karrick.net"
|
5
|
+
DESCRIPTION = "Watcher provides advanced integrated exception handling and logging functionality to your Ruby programs."
|
6
|
+
GEM_NAME = 'watcher' # what ppl will type to install your gem
|
7
|
+
RUBYFORGE_PROJECT = 'watcher' # The unix name for your project
|
8
|
+
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
9
|
+
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
10
|
+
EXTRA_DEPENDENCIES = [
|
11
|
+
# ['activesupport', '>= 1.3.1']
|
12
|
+
] # An array of rubygem dependencies [name, version]
|
13
|
+
|
14
|
+
@config_file = "~/.rubyforge/user-config.yml"
|
15
|
+
@config = nil
|
16
|
+
RUBYFORGE_USERNAME = "unknown" # Don't change this. Modify your "~/.rubyforge/user-config.yml" file.
|
17
|
+
def rubyforge_username
|
18
|
+
unless @config
|
19
|
+
begin
|
20
|
+
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
21
|
+
rescue
|
22
|
+
puts <<-EOS
|
23
|
+
ERROR: No rubyforge config file found: #{@config_file}
|
24
|
+
Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
25
|
+
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
26
|
+
EOS
|
27
|
+
exit
|
28
|
+
end
|
29
|
+
end
|
30
|
+
RUBYFORGE_USERNAME.replace @config["username"]
|
31
|
+
end
|
32
|
+
|
33
|
+
|
34
|
+
REV = nil
|
35
|
+
# UNCOMMENT IF REQUIRED:
|
36
|
+
# REV = YAML.load(`svn info`)['Revision']
|
37
|
+
VERS = Watcher::VERSION::STRING + (REV ? ".#{REV}" : "")
|
38
|
+
RDOC_OPTS = ['--quiet', '--title', 'watcher documentation',
|
39
|
+
"--opname", "index.html",
|
40
|
+
"--line-numbers",
|
41
|
+
"--main", "README",
|
42
|
+
"--inline-source"]
|
43
|
+
|
44
|
+
class Hoe
|
45
|
+
def extra_deps
|
46
|
+
@extra_deps.reject! { |x| Array(x).first == 'hoe' }
|
47
|
+
@extra_deps
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
# Generate all the Rake tasks
|
52
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
53
|
+
$hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
54
|
+
p.developer(AUTHOR, EMAIL)
|
55
|
+
p.description = DESCRIPTION
|
56
|
+
p.summary = DESCRIPTION
|
57
|
+
p.url = HOMEPATH
|
58
|
+
p.remote_rdoc_dir = '' # Release to root (Watcher is my only project)
|
59
|
+
p.rsync_args << ' --exclude=statsvn/'
|
60
|
+
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
61
|
+
p.test_globs = ["test/**/test_*.rb"]
|
62
|
+
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
|
63
|
+
|
64
|
+
# == Optional
|
65
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
66
|
+
#p.extra_deps = EXTRA_DEPENDENCIES
|
67
|
+
|
68
|
+
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
69
|
+
end
|
70
|
+
|
71
|
+
CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
72
|
+
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
73
|
+
$hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
|
74
|
+
$hoe.rsync_args = '-av --delete --ignore-errors'
|
75
|
+
$hoe.spec.post_install_message = File.open(File.dirname(__FILE__) + "/../PostInstall.txt").read rescue ""
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
include FileUtils
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
%w[rake hoe newgem rubigen].each do |req_gem|
|
6
|
+
begin
|
7
|
+
require req_gem
|
8
|
+
rescue LoadError
|
9
|
+
puts "This Rakefile requires the '#{req_gem}' RubyGem."
|
10
|
+
puts "Installation: gem install #{req_gem} -y"
|
11
|
+
exit
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
|