derailed-mole 1.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +17 -0
- data/Manifest.txt +137 -0
- data/README.txt +216 -0
- data/Rakefile +46 -0
- data/bin/molify +64 -0
- data/config/database.yml +21 -0
- data/config/test_database.yml +69 -0
- data/lib/mole.rb +260 -0
- data/lib/mole/db/migrate.rb +90 -0
- data/lib/mole/e_mole.rb +75 -0
- data/lib/mole/e_mole_helper.rb +2 -0
- data/lib/mole/logger.rb +134 -0
- data/lib/mole/models/mole_feature.rb +58 -0
- data/lib/mole/models/mole_log.rb +31 -0
- data/lib/mole/module.rb +292 -0
- data/lib/mole/moler.rb +71 -0
- data/lib/mole/utils/frameworks.rb +53 -0
- data/lib/mole/version.rb +15 -0
- data/mole.gemspec +37 -0
- data/samples/merbapp/README +14 -0
- data/samples/merbapp/Rakefile +124 -0
- data/samples/merbapp/app/controllers/application.rb +3 -0
- data/samples/merbapp/app/controllers/exceptions.rb +13 -0
- data/samples/merbapp/app/controllers/moled.rb +25 -0
- data/samples/merbapp/app/helpers/global_helper.rb +5 -0
- data/samples/merbapp/app/mailers/views/layout/application.html.erb +1 -0
- data/samples/merbapp/app/mailers/views/layout/application.text.erb +1 -0
- data/samples/merbapp/app/parts/views/layout/application.html.erb +1 -0
- data/samples/merbapp/app/views/exceptions/internal_server_error.html.erb +216 -0
- data/samples/merbapp/app/views/exceptions/not_acceptable.html.erb +38 -0
- data/samples/merbapp/app/views/exceptions/not_found.html.erb +40 -0
- data/samples/merbapp/app/views/layout/application.html.erb +11 -0
- data/samples/merbapp/app/views/moled/index.html.erb +5 -0
- data/samples/merbapp/app/views/moled/result.html.erb +5 -0
- data/samples/merbapp/config/boot.rb +11 -0
- data/samples/merbapp/config/dependencies.rb +41 -0
- data/samples/merbapp/config/environments/development.rb +1 -0
- data/samples/merbapp/config/environments/production.rb +1 -0
- data/samples/merbapp/config/environments/test.rb +1 -0
- data/samples/merbapp/config/merb.yml +82 -0
- data/samples/merbapp/config/merb_init.rb +26 -0
- data/samples/merbapp/config/mole_config.rb +33 -0
- data/samples/merbapp/config/router.rb +38 -0
- data/samples/merbapp/config/upload.conf +0 -0
- data/samples/merbapp/public/images/merb.jpg +0 -0
- data/samples/merbapp/public/merb.fcgi +6 -0
- data/samples/merbapp/public/stylesheets/master.css +119 -0
- data/samples/merbapp/script/destroy +32 -0
- data/samples/merbapp/script/generate +32 -0
- data/samples/merbapp/script/stop_merb +13 -0
- data/samples/merbapp/spec/spec_helper.rb +15 -0
- data/samples/merbapp/test/test_helper.rb +14 -0
- data/samples/railsapp/README +14 -0
- data/samples/railsapp/Rakefile +10 -0
- data/samples/railsapp/app/controllers/application.rb +13 -0
- data/samples/railsapp/app/controllers/moled_controller.rb +24 -0
- data/samples/railsapp/app/helpers/application_helper.rb +3 -0
- data/samples/railsapp/app/views/moled/index.html.erb +5 -0
- data/samples/railsapp/app/views/moled/result.html.erb +5 -0
- data/samples/railsapp/config/boot.rb +109 -0
- data/samples/railsapp/config/database.yml +13 -0
- data/samples/railsapp/config/environment.rb +59 -0
- data/samples/railsapp/config/environments/development.rb +18 -0
- data/samples/railsapp/config/environments/production.rb +20 -0
- data/samples/railsapp/config/environments/test.rb +22 -0
- data/samples/railsapp/config/initializers/inflections.rb +10 -0
- data/samples/railsapp/config/initializers/mime_types.rb +5 -0
- data/samples/railsapp/config/initializers/mole.rb +10 -0
- data/samples/railsapp/config/moles/mole_config.rb +44 -0
- data/samples/railsapp/config/routes.rb +35 -0
- data/samples/railsapp/doc/README_FOR_APP +2 -0
- data/samples/railsapp/public/.htaccess +40 -0
- data/samples/railsapp/public/404.html +30 -0
- data/samples/railsapp/public/422.html +30 -0
- data/samples/railsapp/public/500.html +30 -0
- data/samples/railsapp/public/dispatch.cgi +10 -0
- data/samples/railsapp/public/dispatch.fcgi +24 -0
- data/samples/railsapp/public/dispatch.rb +10 -0
- data/samples/railsapp/public/favicon.ico +0 -0
- data/samples/railsapp/public/images/rails.png +0 -0
- data/samples/railsapp/public/javascripts/application.js +2 -0
- data/samples/railsapp/public/javascripts/controls.js +963 -0
- data/samples/railsapp/public/javascripts/dragdrop.js +972 -0
- data/samples/railsapp/public/javascripts/effects.js +1120 -0
- data/samples/railsapp/public/javascripts/prototype.js +4225 -0
- data/samples/railsapp/public/robots.txt +5 -0
- data/samples/railsapp/script/about +3 -0
- data/samples/railsapp/script/console +3 -0
- data/samples/railsapp/script/destroy +3 -0
- data/samples/railsapp/script/generate +3 -0
- data/samples/railsapp/script/performance/benchmarker +3 -0
- data/samples/railsapp/script/performance/profiler +3 -0
- data/samples/railsapp/script/performance/request +3 -0
- data/samples/railsapp/script/plugin +3 -0
- data/samples/railsapp/script/process/inspector +3 -0
- data/samples/railsapp/script/process/reaper +3 -0
- data/samples/railsapp/script/process/spawner +3 -0
- data/samples/railsapp/script/runner +3 -0
- data/samples/railsapp/script/server +3 -0
- data/samples/railsapp/test/test_helper.rb +38 -0
- data/samples/rubyapp/README +22 -0
- data/samples/rubyapp/bin/ruby_app +35 -0
- data/samples/rubyapp/config/mole_conf.rb +31 -0
- data/samples/rubyapp/lib/fred.rb +22 -0
- data/spec/config/auto_mole_config.rb +26 -0
- data/spec/config/mole_config.rb +0 -0
- data/spec/config/moles/fred_config.rb +0 -0
- data/spec/data/blee.rb +64 -0
- data/spec/db/migrate_spec.rb +19 -0
- data/spec/emole_spec.rb +43 -0
- data/spec/logger_spec.rb +56 -0
- data/spec/models/mole_feature_spec.rb +48 -0
- data/spec/models/mole_log_spec.rb +62 -0
- data/spec/module_spec.rb +229 -0
- data/spec/mole_spec.rb +135 -0
- data/spec/moler_spec.rb +77 -0
- data/spec/spec_helper.rb +76 -0
- data/spec/utils/framework_spec.rb +99 -0
- data/tasks/ann.rake +76 -0
- data/tasks/annotations.rake +22 -0
- data/tasks/doc.rake +48 -0
- data/tasks/gem.rake +110 -0
- data/tasks/manifest.rake +49 -0
- data/tasks/mole.rake +115 -0
- data/tasks/post_load.rake +26 -0
- data/tasks/rubyforge.rake +57 -0
- data/tasks/setup.rb +227 -0
- data/tasks/spec.rake +54 -0
- data/tasks/svn.rake +44 -0
- data/tasks/test.rake +38 -0
- data/templates/mole/e_mole/exception_alerts.rhtml +14 -0
- data/templates/mole/e_mole/feature_alerts.rhtml +11 -0
- data/templates/mole/e_mole/perf_alerts.rhtml +12 -0
- metadata +206 -0
data/History.txt
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
== 1.0.0 / 2008-02-04
|
2
|
+
|
3
|
+
* 1 Initial drop
|
4
|
+
* Converted from rails plugin into gem
|
5
|
+
* Retrofited to work with pure ruby, merb and rails env
|
6
|
+
|
7
|
+
== 1.0.1 / 2008-02-04
|
8
|
+
|
9
|
+
* 1 Documentation enhancements
|
10
|
+
|
11
|
+
== 1.0.2 / 2008-02-04
|
12
|
+
|
13
|
+
* 1 Added Snitch support
|
14
|
+
|
15
|
+
== 1.0.3 / 2008-02-05
|
16
|
+
|
17
|
+
* 1 Bug Fixes
|
data/Manifest.txt
ADDED
@@ -0,0 +1,137 @@
|
|
1
|
+
History.txt
|
2
|
+
Manifest.txt
|
3
|
+
README.txt
|
4
|
+
Rakefile
|
5
|
+
bin/molify
|
6
|
+
config/database.yml
|
7
|
+
config/test_database.yml
|
8
|
+
lib/mole.rb
|
9
|
+
lib/mole/db/migrate.rb
|
10
|
+
lib/mole/e_mole.rb
|
11
|
+
lib/mole/e_mole_helper.rb
|
12
|
+
lib/mole/logger.rb
|
13
|
+
lib/mole/models/mole_feature.rb
|
14
|
+
lib/mole/models/mole_log.rb
|
15
|
+
lib/mole/module.rb
|
16
|
+
lib/mole/moler.rb
|
17
|
+
lib/mole/utils/frameworks.rb
|
18
|
+
lib/mole/version.rb
|
19
|
+
samples/merbapp/README
|
20
|
+
samples/merbapp/Rakefile
|
21
|
+
samples/merbapp/app/controllers/application.rb
|
22
|
+
samples/merbapp/app/controllers/exceptions.rb
|
23
|
+
samples/merbapp/app/controllers/moled.rb
|
24
|
+
samples/merbapp/app/helpers/global_helper.rb
|
25
|
+
samples/merbapp/app/mailers/views/layout/application.html.erb
|
26
|
+
samples/merbapp/app/mailers/views/layout/application.text.erb
|
27
|
+
samples/merbapp/app/parts/views/layout/application.html.erb
|
28
|
+
samples/merbapp/app/views/exceptions/internal_server_error.html.erb
|
29
|
+
samples/merbapp/app/views/exceptions/not_acceptable.html.erb
|
30
|
+
samples/merbapp/app/views/exceptions/not_found.html.erb
|
31
|
+
samples/merbapp/app/views/layout/application.html.erb
|
32
|
+
samples/merbapp/app/views/moled/index.html.erb
|
33
|
+
samples/merbapp/app/views/moled/result.html.erb
|
34
|
+
samples/merbapp/config/boot.rb
|
35
|
+
samples/merbapp/config/dependencies.rb
|
36
|
+
samples/merbapp/config/environments/development.rb
|
37
|
+
samples/merbapp/config/environments/production.rb
|
38
|
+
samples/merbapp/config/environments/test.rb
|
39
|
+
samples/merbapp/config/merb.yml
|
40
|
+
samples/merbapp/config/merb_init.rb
|
41
|
+
samples/merbapp/config/mole_config.rb
|
42
|
+
samples/merbapp/config/router.rb
|
43
|
+
samples/merbapp/config/upload.conf
|
44
|
+
samples/merbapp/log/merb.4000.pid
|
45
|
+
samples/merbapp/public/images/merb.jpg
|
46
|
+
samples/merbapp/public/merb.fcgi
|
47
|
+
samples/merbapp/public/stylesheets/master.css
|
48
|
+
samples/merbapp/script/destroy
|
49
|
+
samples/merbapp/script/generate
|
50
|
+
samples/merbapp/script/stop_merb
|
51
|
+
samples/merbapp/spec/spec_helper.rb
|
52
|
+
samples/merbapp/test/test_helper.rb
|
53
|
+
samples/railsapp/README
|
54
|
+
samples/railsapp/Rakefile
|
55
|
+
samples/railsapp/app/controllers/application.rb
|
56
|
+
samples/railsapp/app/controllers/moled_controller.rb
|
57
|
+
samples/railsapp/app/helpers/application_helper.rb
|
58
|
+
samples/railsapp/app/views/moled/index.html.erb
|
59
|
+
samples/railsapp/app/views/moled/result.html.erb
|
60
|
+
samples/railsapp/config/boot.rb
|
61
|
+
samples/railsapp/config/database.yml
|
62
|
+
samples/railsapp/config/environment.rb
|
63
|
+
samples/railsapp/config/environments/development.rb
|
64
|
+
samples/railsapp/config/environments/production.rb
|
65
|
+
samples/railsapp/config/environments/test.rb
|
66
|
+
samples/railsapp/config/initializers/inflections.rb
|
67
|
+
samples/railsapp/config/initializers/mime_types.rb
|
68
|
+
samples/railsapp/config/initializers/mole.rb
|
69
|
+
samples/railsapp/config/moles/mole_config.rb
|
70
|
+
samples/railsapp/config/routes.rb
|
71
|
+
samples/railsapp/doc/README_FOR_APP
|
72
|
+
samples/railsapp/log/development.log
|
73
|
+
samples/railsapp/log/production.log
|
74
|
+
samples/railsapp/log/server.log
|
75
|
+
samples/railsapp/log/test.log
|
76
|
+
samples/railsapp/public/.htaccess
|
77
|
+
samples/railsapp/public/404.html
|
78
|
+
samples/railsapp/public/422.html
|
79
|
+
samples/railsapp/public/500.html
|
80
|
+
samples/railsapp/public/dispatch.cgi
|
81
|
+
samples/railsapp/public/dispatch.fcgi
|
82
|
+
samples/railsapp/public/dispatch.rb
|
83
|
+
samples/railsapp/public/favicon.ico
|
84
|
+
samples/railsapp/public/images/rails.png
|
85
|
+
samples/railsapp/public/javascripts/application.js
|
86
|
+
samples/railsapp/public/javascripts/controls.js
|
87
|
+
samples/railsapp/public/javascripts/dragdrop.js
|
88
|
+
samples/railsapp/public/javascripts/effects.js
|
89
|
+
samples/railsapp/public/javascripts/prototype.js
|
90
|
+
samples/railsapp/public/robots.txt
|
91
|
+
samples/railsapp/script/about
|
92
|
+
samples/railsapp/script/console
|
93
|
+
samples/railsapp/script/destroy
|
94
|
+
samples/railsapp/script/generate
|
95
|
+
samples/railsapp/script/performance/benchmarker
|
96
|
+
samples/railsapp/script/performance/profiler
|
97
|
+
samples/railsapp/script/performance/request
|
98
|
+
samples/railsapp/script/plugin
|
99
|
+
samples/railsapp/script/process/inspector
|
100
|
+
samples/railsapp/script/process/reaper
|
101
|
+
samples/railsapp/script/process/spawner
|
102
|
+
samples/railsapp/script/runner
|
103
|
+
samples/railsapp/script/server
|
104
|
+
samples/railsapp/test/test_helper.rb
|
105
|
+
samples/rubyapp/README
|
106
|
+
samples/rubyapp/bin/ruby_app
|
107
|
+
samples/rubyapp/config/mole_conf.rb
|
108
|
+
samples/rubyapp/lib/fred.rb
|
109
|
+
spec/config/auto_mole_config.rb
|
110
|
+
spec/config/mole_config.rb
|
111
|
+
spec/config/moles/fred_config.rb
|
112
|
+
spec/data/blee.rb
|
113
|
+
spec/db/migrate_spec.rb
|
114
|
+
spec/emole_spec.rb
|
115
|
+
spec/logger_spec.rb
|
116
|
+
spec/models/mole_feature_spec.rb
|
117
|
+
spec/models/mole_log_spec.rb
|
118
|
+
spec/module_spec.rb
|
119
|
+
spec/mole_spec.rb
|
120
|
+
spec/moler_spec.rb
|
121
|
+
spec/spec_helper.rb
|
122
|
+
spec/utils/framework_spec.rb
|
123
|
+
tasks/ann.rake
|
124
|
+
tasks/annotations.rake
|
125
|
+
tasks/doc.rake
|
126
|
+
tasks/gem.rake
|
127
|
+
tasks/manifest.rake
|
128
|
+
tasks/mole.rake
|
129
|
+
tasks/post_load.rake
|
130
|
+
tasks/rubyforge.rake
|
131
|
+
tasks/setup.rb
|
132
|
+
tasks/spec.rake
|
133
|
+
tasks/svn.rake
|
134
|
+
tasks/test.rake
|
135
|
+
templates/mole/e_mole/exception_alerts.rhtml
|
136
|
+
templates/mole/e_mole/feature_alerts.rhtml
|
137
|
+
templates/mole/e_mole/perf_alerts.rhtml
|
data/README.txt
ADDED
@@ -0,0 +1,216 @@
|
|
1
|
+
The MOle
|
2
|
+
by Fernand Galiana
|
3
|
+
liquidrail.com
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
The MOle allows you to track user's interactions with your ruby application and closely monitors
|
8
|
+
how your customers are using your application. This is a must cheaper way than to hire a monitoring
|
9
|
+
service and produces much more detailed information on your application behavior and usage. To boot
|
10
|
+
your managers will love you !
|
11
|
+
|
12
|
+
Whether you are releasing a new application or improving on an old one, it is always a good thing
|
13
|
+
to know if anyone is using your application and if they are, how they are using it.
|
14
|
+
What features are your users most fond of and which features find their way into the abyss?
|
15
|
+
Using the MOle you'll be able to rapidly assess whether or not your application is a hit and if
|
16
|
+
your coolest features are thought as such by your users. You will be able to elegantly record user
|
17
|
+
interactions and leverage these findings for the next iteration of your application.
|
18
|
+
|
19
|
+
The MOle was initialy released as a Rails plugin, but we found the behavior usefull in other types
|
20
|
+
of projects such as Merb or straight up ruby applications, and decided to re-release it as a gem
|
21
|
+
instead.
|
22
|
+
|
23
|
+
== PROJECT INFORMATION
|
24
|
+
|
25
|
+
* Developer: Fernand Galiana [liquidrail.com]
|
26
|
+
* Forum: http://groups.google.com/group/mole-plugin
|
27
|
+
* Home: mole.rubyforge.org
|
28
|
+
* Svn: svn://rubyforge.org/var/svn/mole/mole/trunk
|
29
|
+
* Git: git://github.com/derailed/mole.git
|
30
|
+
* Snitch Svn: svn://rubyforge.org/var/svn/mole/snitch/trunk
|
31
|
+
* Examples: svn://rubyforge.org/var/svn/mole/samples
|
32
|
+
|
33
|
+
== FEATURES:
|
34
|
+
|
35
|
+
The MOle allows you to easily
|
36
|
+
|
37
|
+
* Trap method calls within your ruby application. You can use the MOle with either a straight ruby
|
38
|
+
application, Rails or Merb. The MOle allows you to inject aspects across various method calls.
|
39
|
+
You are in full control on how and where to trap the calls and the arguments you want to record.
|
40
|
+
'Moled' methods are not limited to controller's actions, you can also mole any third party or library methods.
|
41
|
+
|
42
|
+
* Single configuration file. You won't have to sprinkle MOle code all over your application.
|
43
|
+
The MOle instructions reside in a single file easy to manage and maintain.
|
44
|
+
|
45
|
+
* Trap and surface uncaught exceptions in one easy call. The MOle will watch your execution stack
|
46
|
+
and alert you when an unexpected exception is encountered
|
47
|
+
|
48
|
+
* Trap and surface performance bottle neck in your ruby application in one easy call. You can
|
49
|
+
specify a performance threshold within the MOle configuration file. Any methods taking longer
|
50
|
+
than the specified threshold will trip an alert.
|
51
|
+
|
52
|
+
* You can record users interaction by either using the MOle is a transient or persistent mode.
|
53
|
+
In the persistent mode, users interactions will be recorded in your database. In the transient
|
54
|
+
case, MOle events will be recorded in your application logs.
|
55
|
+
|
56
|
+
== INSTALL:
|
57
|
+
|
58
|
+
* sudo gem install mole
|
59
|
+
|
60
|
+
== SYNOPSIS:
|
61
|
+
|
62
|
+
* The MOle can operate in 2 different modes: transient or persistent. The transient mode will
|
63
|
+
simply record MOle interactions within your log file. If you opt to use the
|
64
|
+
persistent mode (recommanded!) which will allow to leverage the Snitch Application
|
65
|
+
and also draw out MOle usage reports from you database, you will need to install the 2 MOle tables in your database.
|
66
|
+
This is achived via the 'molify' command. In order to 'MOle' an application using the persistent
|
67
|
+
mode, you will need to issue the following commands:
|
68
|
+
|
69
|
+
> cd my_non_moled_application
|
70
|
+
> molify --up --config config/database.yml --env test
|
71
|
+
|
72
|
+
This command will update your test database and create the MOle tables required when
|
73
|
+
the MOle is in a persistent mode. Namely, these tables are mole_features and mole_logs.
|
74
|
+
|
75
|
+
You can use molify --help to see usage information.
|
76
|
+
|
77
|
+
* Mole initialization. This must be specified during your application initialization code.
|
78
|
+
In a rails app, this can be set in you application controller class or environment.rb. In
|
79
|
+
a Merb app, this can be set in your merb_init.rb file.
|
80
|
+
|
81
|
+
require 'mole'
|
82
|
+
Mole.initialize( :moleable => true,
|
83
|
+
:application => "Smf",
|
84
|
+
:emole_from => "MoleBeatch@liquidrail.com",
|
85
|
+
:emole_recipients => ['fernand@liquidrail.com'],
|
86
|
+
:mode => :persistent,
|
87
|
+
:log_file => $stdout,
|
88
|
+
:log_level => :debug,
|
89
|
+
:perf_threshold => 2,
|
90
|
+
:mole_config => File.join( File.dirname(__FILE__), %w[mole.rb] ) )
|
91
|
+
# Load the MOle configuration file(s)
|
92
|
+
::Mole.load_configuration
|
93
|
+
|
94
|
+
NOTE: The mole_config can either be a single ruby file or a directory containing multiple MOle
|
95
|
+
configuration files. Thanks to Ian Schreuder for the suggestion !
|
96
|
+
|
97
|
+
NOTE: For rails applications you can either put the MOle initialization code in a custom initializer
|
98
|
+
ie config/initializers/mole.rb or in your environment file (config/environments/production.rb).
|
99
|
+
You will need to make the load_configuration call in your application controller(application.rb) as follows:
|
100
|
+
|
101
|
+
::Mole.load_mole_configuration rescue nil
|
102
|
+
|
103
|
+
In dev env, the MOle will reload the configuration so you can tweak your app on the fly. In production
|
104
|
+
env the MOle configuration will be loaded once.
|
105
|
+
|
106
|
+
* Now you'll need to create a mole.rb specification file to specify the various aspects you'll want
|
107
|
+
to inject. This file is specified in the initialize call via the :mole_config tag.
|
108
|
+
|
109
|
+
To trap a feature before or after it occurs you can use the mole_before/mole_after
|
110
|
+
interceptors. The following will mole the "Posts" class after the "show" method is called.
|
111
|
+
The context argument hands you an execution context. In a rails/merb environment
|
112
|
+
this will be your controller object. You can handle this interaction any way
|
113
|
+
you want. The MOle provides a convenience class to record this interaction via
|
114
|
+
the database or the MOle logger in the guise of Mole::Moler. But you can also log it to
|
115
|
+
any media you'll find suitable. In a rails/merb context, you'll be able to extract session/params information
|
116
|
+
as in this case.
|
117
|
+
|
118
|
+
Posts.mole_after( :feature => :show ) { |context, feature, ret, block, *args|
|
119
|
+
# Records the interaction to the database
|
120
|
+
Mole::Moler.mole_it( context, feature,
|
121
|
+
context.session[:user_id], # Retrieves which user performed this action
|
122
|
+
:post_id=> context.params[:post_id], # Records request parameter post id
|
123
|
+
:url => context.instance_variable_get( "@url" ) ) # Retrieves controller state
|
124
|
+
end
|
125
|
+
}
|
126
|
+
|
127
|
+
To record performance issues, you will need to provide a collection of
|
128
|
+
methods that must be watched on a given class. In the case of rails or merb you can easily fetch the list
|
129
|
+
of actions from the controller api and pass it to the MOle. The MOle provides convenience
|
130
|
+
classes to log the perf issues to your database and send out alerts when a perf condition is met.
|
131
|
+
Upon invocation, you will be handed a calling context, that comprises the feature (method) being
|
132
|
+
called, the actual time it took to complete the call and any args/block that was passed into
|
133
|
+
the feature that causes the performance threshold to be triggered. Setting the :email option
|
134
|
+
to true will also send out an email alert.
|
135
|
+
|
136
|
+
Posts.mole_perf( :features => merb_actions ) do |context, feature, elapsed_time, ret, block, *args|
|
137
|
+
user = context.instance_variable_get( "@user" )
|
138
|
+
key = context.params[:key], "N/A"
|
139
|
+
request = context.request.nil? ? "N/A" : context.request.remote_ip,
|
140
|
+
Mole::Moler.perf_it( context, user.id,
|
141
|
+
:controller => context.class.name,
|
142
|
+
:feature => feature,
|
143
|
+
:key => key,
|
144
|
+
:request => request,
|
145
|
+
:user => user.user_name,
|
146
|
+
:elapsed_time => "%3.3f" % elapsed_time,
|
147
|
+
:email => true )
|
148
|
+
end
|
149
|
+
|
150
|
+
The unchecked exception trap works very similarly to the mole_perf trap. It will pass in
|
151
|
+
the context of the method that triggered the exception.
|
152
|
+
|
153
|
+
Posts.mole_unchecked( :features => merb_actions ) do |context, action, boom, block, *args|
|
154
|
+
sub = context.instance_variable_get("@sub")
|
155
|
+
user_id = "N/A"
|
156
|
+
user_id = sub.user.id if sub and sub.user
|
157
|
+
Mole::Moler.check_it( context, user_id,
|
158
|
+
:controller => context.class.name,
|
159
|
+
:action => action,
|
160
|
+
:boom => boom,
|
161
|
+
:email => true )
|
162
|
+
end
|
163
|
+
|
164
|
+
== Snitch
|
165
|
+
|
166
|
+
To view MOle interaction simply, we've created the "Snitch" a rails console application that
|
167
|
+
allows you to see the results of your MOled application. The Snitch is a Rails 2.0 application.
|
168
|
+
It is available at http://mole.rubyforge.org/svn/snitch/trunk/.
|
169
|
+
|
170
|
+
In order to start using the Snitch you will have to perform the following steps:
|
171
|
+
|
172
|
+
* Download the Snitch
|
173
|
+
svn co http://mole.rubyforge.org/svn/snitch/trunk/
|
174
|
+
|
175
|
+
* The Snitch needs to access your user table to provide user related log information. So
|
176
|
+
you will need to run the following rake task and provide your users table description.
|
177
|
+
|
178
|
+
> rake setup
|
179
|
+
|
180
|
+
* Edit the Snitch database.yml to point to your application database.
|
181
|
+
|
182
|
+
* Out of the box the Snitch will monitor and application named "Default". You will want
|
183
|
+
to match the application name that you've used in the Mole.initialize call. So you
|
184
|
+
should now be able to specify the following commands:
|
185
|
+
|
186
|
+
> script/server
|
187
|
+
|
188
|
+
Then in your browser
|
189
|
+
|
190
|
+
http://localhost:3000?app_name=my_moled_application_name
|
191
|
+
|
192
|
+
* NOTE: You will keep enhancing the Snitch to provide capistrano deployment scripts,
|
193
|
+
auto application name detection and many other enhancements...
|
194
|
+
|
195
|
+
== LICENSE:
|
196
|
+
|
197
|
+
MIT Copyright (c) 2008
|
198
|
+
|
199
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
200
|
+
a copy of this software and associated documentation files (the
|
201
|
+
'Software'), to deal in the Software without restriction, including
|
202
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
203
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
204
|
+
permit persons to whom the Software is furnished to do so, subject to
|
205
|
+
the following conditions:
|
206
|
+
|
207
|
+
The above copyright notice and this permission notice shall be
|
208
|
+
included in all copies or substantial portions of the Software.
|
209
|
+
|
210
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
211
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
212
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
213
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
214
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
215
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
216
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,46 @@
|
|
1
|
+
# Look in the tasks/setup.rb file for the various options that can be
|
2
|
+
# configured in this Rakefile. The .rake files in the tasks directory
|
3
|
+
# are where the options are used.
|
4
|
+
|
5
|
+
load 'tasks/setup.rb'
|
6
|
+
|
7
|
+
ensure_in_path 'lib'
|
8
|
+
require 'mole'
|
9
|
+
require 'mole/version'
|
10
|
+
|
11
|
+
task :default => 'spec:run'
|
12
|
+
|
13
|
+
PROJ.name = 'mole'
|
14
|
+
PROJ.authors = 'Fernand Galiana'
|
15
|
+
PROJ.email = 'fernand@liquidrail.com'
|
16
|
+
PROJ.url = 'http://mole.rubyforge.org'
|
17
|
+
PROJ.rubyforge_name = 'mole'
|
18
|
+
PROJ.description = "A flexible way to track user's interactions within your ruby web applications"
|
19
|
+
PROJ.spec_opts << '--color'
|
20
|
+
PROJ.rcov_dir = ENV['CC_BUILD_ARTIFACTS'] ? "#{ENV['CC_BUILD_ARTIFACTS']}/test_coverage" : 'coverage'
|
21
|
+
PROJ.rdoc_dir = ENV['CC_BUILD_ARTIFACTS'] ? "#{ENV['CC_BUILD_ARTIFACTS']}/api_docs" : 'docs'
|
22
|
+
PROJ.ruby_opts = %w[-W0]
|
23
|
+
PROJ.version = ::Mole::Version.version
|
24
|
+
PROJ.svn = 'mole'
|
25
|
+
PROJ.rcov_threshold = 90.0
|
26
|
+
PROJ.executables = ['molify']
|
27
|
+
|
28
|
+
PROJ.exclude << %w[.DS_Store$ .swo$ .swp$]
|
29
|
+
PROJ.tests = FileList['test/**/test_*.rb']
|
30
|
+
PROJ.annotation_tags << 'BOZO'
|
31
|
+
|
32
|
+
desc "Clean up artifact directories"
|
33
|
+
task :clean do
|
34
|
+
rcov_artifacts = File.join( File.dirname( __FILE__ ), "coverage" )
|
35
|
+
FileUtils.rm_rf rcov_artifacts if File.exists? rcov_artifacts
|
36
|
+
rdoc_artifacts = File.join( File.dirname( __FILE__ ), "docs" )
|
37
|
+
FileUtils.rm_rf rdoc_artifacts if File.exists? rdoc_artifacts
|
38
|
+
gem_artifacts = File.join( File.dirname( __FILE__ ), "pkg" )
|
39
|
+
FileUtils.rm_rf gem_artifacts if File.exists? gem_artifacts
|
40
|
+
end
|
41
|
+
|
42
|
+
task 'gem:package' => 'manifest:assert'
|
43
|
+
|
44
|
+
|
45
|
+
depend_on "logging" , "= 0.9.0"
|
46
|
+
depend_on "activerecord", "= 2.0.2"
|
data/bin/molify
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'optparse'
|
3
|
+
|
4
|
+
require File.expand_path(
|
5
|
+
File.join(File.dirname(__FILE__), '..', 'lib', 'mole') )
|
6
|
+
|
7
|
+
require 'mole/db/migrate'
|
8
|
+
|
9
|
+
module Mole
|
10
|
+
class Molify
|
11
|
+
# Performs db migration when the MOle is to be used in a persistent mode.
|
12
|
+
def initialize( argv=ARGV )
|
13
|
+
option_parser = default_option_parser
|
14
|
+
option_parser.parse!(argv)
|
15
|
+
puts options.inspect
|
16
|
+
::Mole::Db::Migrate.new( options ).apply
|
17
|
+
end
|
18
|
+
|
19
|
+
# access the options
|
20
|
+
def options #:nodoc:
|
21
|
+
if not @options then
|
22
|
+
@options = OpenStruct.new
|
23
|
+
# Unless specified attempt to lookup config/database.yml
|
24
|
+
@options.configuration = File.join( Dir.pwd, %w[config database.yml] )
|
25
|
+
# Unless specified assumes test env
|
26
|
+
@options.environment = "test"
|
27
|
+
# Unless specficied migrates up
|
28
|
+
@options.direction = :up
|
29
|
+
end
|
30
|
+
return @options
|
31
|
+
end
|
32
|
+
|
33
|
+
def default_option_parser #:nodoc:
|
34
|
+
OptionParser.new do |op|
|
35
|
+
op.separator ""
|
36
|
+
op.separator "Molify options"
|
37
|
+
|
38
|
+
op.on( "-c", "--config FILE", "The location of the database configuration file." ) do |db|
|
39
|
+
options.configuration = db
|
40
|
+
end
|
41
|
+
|
42
|
+
op.on("-e", "--env ENV", "The environment to run in." ) do |env|
|
43
|
+
options.environment = env
|
44
|
+
end
|
45
|
+
|
46
|
+
op.on("-u", "--up", "Install MOle related tables") do |dir|
|
47
|
+
options.direction= :up
|
48
|
+
end
|
49
|
+
|
50
|
+
op.on("-d", "--down", "Uninstall MOle related tables") do |dir|
|
51
|
+
options.direction= :down
|
52
|
+
end
|
53
|
+
|
54
|
+
op.separator ""
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
Mole::Molify.new(ARGV)
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
|