public
Description: A stand-alone Merb eXception tracker inspired by logged_exception
Clone URL: git://github.com/fightinjoe/mex.git
Added support for using Mex as a gem inline with a current merb app
Aaron Wheeler (author)
Fri Apr 18 06:08:41 -0700 2008
commit  b6f18ccc46d17c51c5e189fbf00718b44367d293
tree    99e743a021f646f08c1e174adc456a941c641e4c
parent  e046f668dd92740ca9b451bd90a27fdb1c3da42f
0
...
1
2
3
4
 
5
6
7
8
9
10
 
 
 
 
 
11
12
13
...
1
2
3
 
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
0
@@ -1,13 +1,18 @@
0
 MeX - Merb eXception tracking
0
 ==============
0
 
0
-Version 0.1.0
0
+Version 0.2.0
0
 
0
 ==============
0
 
0
 MeX is a flat Merb app that provides a web service for logging exceptions
0
 raised by other web apps.
0
 
0
+MeX can be run in two different ways: as a stand alone web service or as
0
+a Merb plugin.
0
+
0
+== Running MeX as a stand-alone web service
0
+
0
 Start from the command line with:
0
 
0
   merb -p 4911
...
1
2
3
 
4
5
6
7
8
9
10
11
12
 
13
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
16
17
...
1
2
3
4
5
6
7
8
9
10
 
11
 
12
13
 
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
0
@@ -1,17 +1,36 @@
0
 # make sure we're running inside Merb
0
 if defined?(Merb::Plugins)
0
 
0
+
0
   # Merb gives you a Merb::Plugins.config hash...feel free to put your stuff in your piece of it
0
   Merb::Plugins.config[:mex] = {
0
     :chickens => false
0
   }
0
   
0
   Merb::BootLoader.before_app_loads do
0
- # require code that must be loaded before the application
0
   end
0
-
0
+
0
   Merb::BootLoader.after_app_loads do
0
- # code that can be required after the application loads
0
+ require 'mex/application'
0
+ Language::English::Inflect.plural_word('mex','mexes')
0
+ Merb::Router.prepend do |r|
0
+ r.match('/mex').to(:controller => 'mexes', :action => 'index')
0
+
0
+ r.match('/mex/query.js').
0
+ to(:controller => 'mexes', :action => 'query', :format => 'js').
0
+ name(:query_js)
0
+
0
+ r.match('/mex/query.rss').
0
+ to(:controller => 'mexes', :action => 'query', :format => 'xml').
0
+ name(:query_rss)
0
+
0
+
0
+ r.match('/mex/delete_all.js').
0
+ to(:controller => 'mexes', :action => 'delete_all', :format => 'js').
0
+ name(:delete_all)
0
+
0
+ r.resources :mexes
0
+ end
0
   end
0
   
0
   Merb::Plugins.add_rakefiles "mex/merbtasks"
...
5
6
7
8
 
 
 
 
9
10
11
...
102
103
104
105
 
106
107
108
...
163
164
165
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
167
168
...
5
6
7
 
8
9
10
11
12
13
14
...
105
106
107
 
108
109
110
111
...
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
0
@@ -5,7 +5,10 @@ class Mexes < Merb::Controller
0
   # before :require_basic_authentication
0
 
0
   def _template_location(action, type = nil, controller = controller_name)
0
- controller == "layout" ? "layout.#{action}.#{type}" : "#{action}.#{type}"
0
+ undo = Merb.load_paths[:view].first.gsub(%r{[^/]+}, '..')
0
+ prefix = File.dirname(__FILE__)
0
+ file = controller == "layout" ? "layout.#{action}.#{type}" : "#{action}.#{type}"
0
+ File.join( '.', undo, prefix, 'views', file )
0
   end
0
 
0
   def index
0
@@ -102,7 +105,7 @@ class Mexes < Merb::Controller
0
 
0
 end
0
 
0
-class Exceptions < Merb::Controller; end
0
+# class Exceptions < Merb::Controller; end
0
 
0
 module Merb
0
   module MexesHelper
0
@@ -163,6 +166,54 @@ module Merb
0
   end
0
 end
0
 
0
+# This is a temporary fix until DataMapper 0.9 is released
0
+# with support for custom types
0
+module DataMapperExt
0
+ def self.included(base)
0
+ base.send :extend, ClassMethods
0
+ end
0
+
0
+ module ClassMethods
0
+ private
0
+
0
+ # Provides a way for storing objects as YAML in the database.
0
+ # Not ideal, as this can be polymorphically abused, but a good
0
+ # start towards typecasting
0
+ #
0
+ # ==== Example
0
+ # require 'datamapper_ext'
0
+ # MyClass < DataMapper::Base
0
+ # include DataMapperExt
0
+ # ...
0
+ # yaml_attribute :my_hash, :my_array
0
+ # ...
0
+ #
0
+ def yaml_attribute( *attributes )
0
+ for attribute in attributes
0
+ instance_variable = "@#{ attribute }"
0
+ cache_variable = "#{ instance_variable }_cache"
0
+ getter = attribute.to_s
0
+ setter = "#{ getter }="
0
+
0
+ class_eval <<-EOS
0
+ def #{ getter }
0
+ #{ cache_variable } ||= #{ instance_variable } && YAML.load( #{ instance_variable } )
0
+ end
0
+
0
+ def #{ setter }( hash )
0
+ if hash.is_a?( Hash ) || hash.is_a?( Array )
0
+ #{ cache_variable } = hash
0
+ hash = hash.to_yaml
0
+ end
0
+ #{ instance_variable } = hash
0
+ end
0
+ EOS
0
+ end
0
+ end
0
+ end
0
+
0
+end
0
+
0
 class Mex < DataMapper::Base
0
   include DataMapperExt
0
   set_table_name('mexes')
...
6
7
8
9
10
 
 
11
12
13
 
14
15
16
 
17
18
19
...
6
7
8
 
 
9
10
11
12
 
13
14
15
 
16
17
18
19
0
@@ -6,14 +6,14 @@
0
   <%# javascript_include_tag 'prototype','effects' %>
0
   <!-- <script type="text/javascript" charset="utf-8" src="/javascripts/jquery.js"></script> -->
0
   <script type="text/javascript">
0
-<%= IO.read(File.join(Merb.root, 'views/jquery.js')) %>
0
-<%= IO.read(File.join(Merb.root, 'views/form.js')) %>
0
+<%= IO.read(File.join(File.dirname(__FILE__), 'jquery.js')) %>
0
+<%= IO.read(File.join(File.dirname(__FILE__), 'form.js')) %>
0
   </script>
0
   <script type="text/javascript">
0
-<%= IO.read(File.join(Merb.root, 'views/mex.js')) %>
0
+<%= IO.read(File.join(File.dirname(__FILE__), 'mex.js')) %>
0
   </script>
0
   <style type="text/css">
0
-<%= IO.read(File.join(Merb.root, 'views/style.css')) %>
0
+<%= IO.read(File.join(File.dirname(__FILE__), 'style.css')) %>
0
   </style>
0
 </head>
0
 <body>

Comments

    No one has commented yet.