rubyception 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/MIT-LICENSE +20 -0
- data/README.md +30 -0
- data/Rakefile +42 -0
- data/app/assets/javascripts/rubyception/app.coffee +4 -0
- data/app/assets/javascripts/rubyception/application.coffee +17 -0
- data/app/assets/javascripts/rubyception/application.js +15 -0
- data/app/assets/javascripts/rubyception/collections/backtrace_lines.coffee +4 -0
- data/app/assets/javascripts/rubyception/collections/entries.coffee +3 -0
- data/app/assets/javascripts/rubyception/collections/lines.coffee +3 -0
- data/app/assets/javascripts/rubyception/init.coffee +10 -0
- data/app/assets/javascripts/rubyception/lib/backbone.js +1431 -0
- data/app/assets/javascripts/rubyception/lib/inflections.js +659 -0
- data/app/assets/javascripts/rubyception/lib/jenny.coffee +262 -0
- data/app/assets/javascripts/rubyception/lib/milk.coffee +261 -0
- data/app/assets/javascripts/rubyception/lib/mousetrap.js +7 -0
- data/app/assets/javascripts/rubyception/lib/underscore-min.js +32 -0
- data/app/assets/javascripts/rubyception/models/backtrace_line.coffee +2 -0
- data/app/assets/javascripts/rubyception/models/entry.coffee +2 -0
- data/app/assets/javascripts/rubyception/models/line.coffee +2 -0
- data/app/assets/javascripts/rubyception/routers/log.coffee +45 -0
- data/app/assets/javascripts/rubyception/shBrushSql.js +66 -0
- data/app/assets/javascripts/rubyception/shCore.js +17 -0
- data/app/assets/javascripts/rubyception/template.js +1 -0
- data/app/assets/javascripts/rubyception/views/backtrace_lines/backtrace_line.coffee +8 -0
- data/app/assets/javascripts/rubyception/views/backtrace_lines/index.coffee +16 -0
- data/app/assets/javascripts/rubyception/views/entries/entry.coffee +49 -0
- data/app/assets/javascripts/rubyception/views/entries/index.coffee +79 -0
- data/app/assets/javascripts/rubyception/views/lines/index.coffee +5 -0
- data/app/assets/javascripts/rubyception/views/lines/line.coffee +10 -0
- data/app/assets/javascripts/rubyception/views/logs/show.coffee +8 -0
- data/app/assets/stylesheets/rubyception/application.css +13 -0
- data/app/assets/stylesheets/rubyception/application.sass +12 -0
- data/app/assets/stylesheets/rubyception/backtrace_lines.sass +66 -0
- data/app/assets/stylesheets/rubyception/default.sass +35 -0
- data/app/assets/stylesheets/rubyception/entries.sass +57 -0
- data/app/assets/stylesheets/rubyception/lines.sass +41 -0
- data/app/assets/stylesheets/rubyception/shCore.css +226 -0
- data/app/assets/stylesheets/rubyception/shThemeDefault.css +117 -0
- data/app/controllers/rubyception/application_controller.rb +4 -0
- data/app/controllers/rubyception/templating_controller.rb +22 -0
- data/app/helpers/rubyception/application_helper.rb +9 -0
- data/app/models/rubyception/entry.rb +108 -0
- data/app/models/rubyception/line.rb +55 -0
- data/app/views/layouts/rubyception/application.haml +15 -0
- data/app/views/rubyception/application/index.haml +0 -0
- data/app/views/rubyception/backtrace_lines/_backtrace_line.haml +5 -0
- data/app/views/rubyception/backtrace_lines/_index.haml +7 -0
- data/app/views/rubyception/entries/_entry.haml +12 -0
- data/app/views/rubyception/entries/_index.haml +1 -0
- data/app/views/rubyception/lines/_index.haml +3 -0
- data/app/views/rubyception/lines/_line.haml +2 -0
- data/app/views/rubyception/lines/action_controller/_exist_fragment.haml +0 -0
- data/app/views/rubyception/lines/action_controller/_expire_fragment.haml +0 -0
- data/app/views/rubyception/lines/action_controller/_expire_page.haml +0 -0
- data/app/views/rubyception/lines/action_controller/_halted_callback.haml +0 -0
- data/app/views/rubyception/lines/action_controller/_process_action.haml +0 -0
- data/app/views/rubyception/lines/action_controller/_read_fragment.haml +0 -0
- data/app/views/rubyception/lines/action_controller/_redirect_to.haml +0 -0
- data/app/views/rubyception/lines/action_controller/_send_data.haml +0 -0
- data/app/views/rubyception/lines/action_controller/_send_file.haml +0 -0
- data/app/views/rubyception/lines/action_controller/_start_processing.haml +0 -0
- data/app/views/rubyception/lines/action_controller/_write_fragment.haml +0 -0
- data/app/views/rubyception/lines/action_controller/_write_page.haml +0 -0
- data/app/views/rubyception/lines/action_mailer/_deliver.haml +0 -0
- data/app/views/rubyception/lines/action_mailer/_receive.haml +0 -0
- data/app/views/rubyception/lines/action_view/_render_partial.haml +3 -0
- data/app/views/rubyception/lines/action_view/_render_template.haml +6 -0
- data/app/views/rubyception/lines/active_record/_identity.haml +3 -0
- data/app/views/rubyception/lines/active_record/_sql.haml +4 -0
- data/app/views/rubyception/lines/active_resource/_request.haml +0 -0
- data/app/views/rubyception/lines/active_support/_cache_delete.haml +0 -0
- data/app/views/rubyception/lines/active_support/_cache_exist.haml +0 -0
- data/app/views/rubyception/lines/active_support/_cache_fetch_hit.haml +0 -0
- data/app/views/rubyception/lines/active_support/_cache_generate.haml +0 -0
- data/app/views/rubyception/lines/active_support/_cache_read.haml +0 -0
- data/app/views/rubyception/lines/active_support/_cache_write.haml +0 -0
- data/config/initializers/sass.rb +4 -0
- data/config/initializers/websocket_server.rb +23 -0
- data/config/routes.rb +3 -0
- data/config/templating.yml +39 -0
- data/db/development.sqlite3 +0 -0
- data/lib/rubyception.rb +6 -0
- data/lib/rubyception/catcher.rb +12 -0
- data/lib/rubyception/engine.rb +5 -0
- data/lib/rubyception/subscriber.rb +30 -0
- data/lib/rubyception/templating.rb +48 -0
- data/lib/rubyception/version.rb +3 -0
- data/lib/rubyception/websocket_server.rb +30 -0
- data/lib/tasks/rubyception_tasks.rake +4 -0
- data/lib/tasks/templates.rake +7 -0
- data/test/dummy/README.rdoc +261 -0
- data/test/dummy/Rakefile +7 -0
- data/test/dummy/app/assets/javascripts/application.js +15 -0
- data/test/dummy/app/assets/stylesheets/application.css +13 -0
- data/test/dummy/app/controllers/application_controller.rb +3 -0
- data/test/dummy/app/controllers/tasks_controller.rb +4 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/app/views/tasks/index.html.erb +1 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +59 -0
- data/test/dummy/config/boot.rb +10 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +67 -0
- data/test/dummy/config/environments/test.rb +37 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/inflections.rb +15 -0
- data/test/dummy/config/initializers/mime_types.rb +5 -0
- data/test/dummy/config/initializers/secret_token.rb +7 -0
- data/test/dummy/config/initializers/session_store.rb +8 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +5 -0
- data/test/dummy/config/routes.rb +5 -0
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/log/development.log +183 -0
- data/test/dummy/public/404.html +26 -0
- data/test/dummy/public/422.html +26 -0
- data/test/dummy/public/500.html +25 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/script/rails +6 -0
- data/test/dummy/tmp/cache/assets/C2A/A50/sprockets%2F502789294f7d708459013948aa30c91c +0 -0
- data/test/dummy/tmp/cache/assets/C76/720/sprockets%2F610e52016b025a1ce3828a39a7e93981 +0 -0
- data/test/dummy/tmp/cache/assets/C7E/740/sprockets%2F8703235e74ff13492a454a492b24b7c5 +0 -0
- data/test/dummy/tmp/cache/assets/C86/920/sprockets%2Fc4933e5c2861e44ab07485567259fa32 +0 -0
- data/test/dummy/tmp/cache/assets/C9C/F10/sprockets%2F33864d14794ad865eed8829535780ad9 +0 -0
- data/test/dummy/tmp/cache/assets/CA1/8B0/sprockets%2F2fb362180bfba307350968110ec6f454 +0 -0
- data/test/dummy/tmp/cache/assets/CAD/770/sprockets%2Fc5914c960063cf7cdcd50130a7637485 +0 -0
- data/test/dummy/tmp/cache/assets/CAD/DB0/sprockets%2Fe276db0373d02afa09f069436349328d +0 -0
- data/test/dummy/tmp/cache/assets/CAE/140/sprockets%2F6350953af3f774482a51481f8cd0a3c3 +0 -0
- data/test/dummy/tmp/cache/assets/CB0/010/sprockets%2F1c103104469484b76897daa3d04c6ee9 +0 -0
- data/test/dummy/tmp/cache/assets/CB2/E10/sprockets%2F7b063ac8c2e913114d098d89e60228e5 +0 -0
- data/test/dummy/tmp/cache/assets/CB5/EA0/sprockets%2Fe98d20291409af69a7316a86c45da651 +0 -0
- data/test/dummy/tmp/cache/assets/CB9/B80/sprockets%2F07c32ba22a6489f062e48df8830667d8 +0 -0
- data/test/dummy/tmp/cache/assets/CBE/630/sprockets%2F476aa283807fdd8203e98d3137686eb5 +0 -0
- data/test/dummy/tmp/cache/assets/CBE/A10/sprockets%2F7f66283cb01647a7c4cf954b62919c29 +0 -0
- data/test/dummy/tmp/cache/assets/CC8/DC0/sprockets%2F302790cf97013f80dc311cf2ad0a6342 +0 -0
- data/test/dummy/tmp/cache/assets/CD1/8E0/sprockets%2Fe898f78743c913b3855e1786cc58ec61 +0 -0
- data/test/dummy/tmp/cache/assets/CD2/510/sprockets%2F32995b414c804ddbb00f5504841f5e1b +0 -0
- data/test/dummy/tmp/cache/assets/CD6/EE0/sprockets%2F8666c05da70453c6e7cda433411192af +0 -0
- data/test/dummy/tmp/cache/assets/CD8/370/sprockets%2F357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/CE4/F70/sprockets%2F538e295f0a0d9311c8259bf029ec680f +0 -0
- data/test/dummy/tmp/cache/assets/CE5/3E0/sprockets%2F7b916f5404e1ee4a943e921d6523a97b +0 -0
- data/test/dummy/tmp/cache/assets/CE9/D20/sprockets%2F9dd235d6e21764622b79bf65cf15349a +0 -0
- data/test/dummy/tmp/cache/assets/CF2/2F0/sprockets%2F314b4a0885d2efea526a19f539987e96 +0 -0
- data/test/dummy/tmp/cache/assets/CFB/750/sprockets%2F42c8014c71d022dd4c60ed1e963b076a +0 -0
- data/test/dummy/tmp/cache/assets/D03/BA0/sprockets%2F7c98f37658deed89f88b13d429262a75 +0 -0
- data/test/dummy/tmp/cache/assets/D07/3B0/sprockets%2F2ca3210b7cff57c3299aea8507803f32 +0 -0
- data/test/dummy/tmp/cache/assets/D08/7E0/sprockets%2F47ed6467d629e22254ca2b0d13c863bb +0 -0
- data/test/dummy/tmp/cache/assets/D0F/970/sprockets%2F0461a7c825c4bb945e2f5daf00974f64 +0 -0
- data/test/dummy/tmp/cache/assets/D10/E40/sprockets%2Fa39042b3a568331554c57725fedfcf3e +0 -0
- data/test/dummy/tmp/cache/assets/D13/740/sprockets%2F98a98bb8bc60c8b170c451195e44e42d +0 -0
- data/test/dummy/tmp/cache/assets/D14/BE0/sprockets%2Faa69f1166262379365d818afcf4fa3b3 +0 -0
- data/test/dummy/tmp/cache/assets/D15/C40/sprockets%2F8fe3d124a7582df0a47c44743f3e3d85 +0 -0
- data/test/dummy/tmp/cache/assets/D1B/210/sprockets%2F567244d0d8f2733c6d1826ee82c76dce +0 -0
- data/test/dummy/tmp/cache/assets/D2C/BD0/sprockets%2F17c8f4a03e52cd0d6b85605b0abd7413 +0 -0
- data/test/dummy/tmp/cache/assets/D2D/BE0/sprockets%2Fcdcde17900d6ad0c72c14390808a35b3 +0 -0
- data/test/dummy/tmp/cache/assets/D30/800/sprockets%2F6ad46c52755a4a6c0b81250fc72ae17c +0 -0
- data/test/dummy/tmp/cache/assets/D32/A10/sprockets%2F13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/D34/E20/sprockets%2Fc81175b2bb38464d022abb2d9b18bf87 +0 -0
- data/test/dummy/tmp/cache/assets/D38/420/sprockets%2Fc893136e3c5e0cb051358b8c01fc6b9c +0 -0
- data/test/dummy/tmp/cache/assets/D3C/C50/sprockets%2F52be58b70628a1836b3cea8bd096ee22 +0 -0
- data/test/dummy/tmp/cache/assets/D3E/980/sprockets%2F5e82819b1fe416d230b10d76abd948df +0 -0
- data/test/dummy/tmp/cache/assets/D3F/A80/sprockets%2F5e2ee04b0c2b6417f9ab728692a738cd +0 -0
- data/test/dummy/tmp/cache/assets/D41/340/sprockets%2Ffdc1e8bf346373a650e6d082f522a59e +0 -0
- data/test/dummy/tmp/cache/assets/D41/920/sprockets%2F64c94c28c60bbb70d9a3b9e972ae3057 +0 -0
- data/test/dummy/tmp/cache/assets/D47/BB0/sprockets%2F40929a27da40e05aa0b4aa0173f1ebb1 +0 -0
- data/test/dummy/tmp/cache/assets/D49/740/sprockets%2Fbcb0e6511f88b9af6d70380c86a57b79 +0 -0
- data/test/dummy/tmp/cache/assets/D4E/1B0/sprockets%2Ff7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/D50/940/sprockets%2Ff601e768c1f96abd3d019e7f7564e3c9 +0 -0
- data/test/dummy/tmp/cache/assets/D53/460/sprockets%2F64e051e79ebdaa56bd989d67831f941d +0 -0
- data/test/dummy/tmp/cache/assets/D58/150/sprockets%2F70d598d088bce2f8078c80866be9cff0 +0 -0
- data/test/dummy/tmp/cache/assets/D5A/EA0/sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/D66/E40/sprockets%2F0cd4ea4f30e313f641b96be80a13cf98 +0 -0
- data/test/dummy/tmp/cache/assets/D69/5A0/sprockets%2F8a630d58f110eeeffad123986912bae1 +0 -0
- data/test/dummy/tmp/cache/assets/D69/E10/sprockets%2F3d4d98cb1ad46a0b7635b75993c2ac0d +0 -0
- data/test/dummy/tmp/cache/assets/D6A/920/sprockets%2F9f1c0c3ad8aae418e1004d5cf54f5479 +0 -0
- data/test/dummy/tmp/cache/assets/D6B/A70/sprockets%2Fff1bd1557a03e82f5c2c45d58b661a4f +0 -0
- data/test/dummy/tmp/cache/assets/D6F/6B0/sprockets%2F1e2a322de4879106937ede70ffa2da6e +0 -0
- data/test/dummy/tmp/cache/assets/D70/780/sprockets%2F6c6a33bccf82b144dbd7982f0854f8b0 +0 -0
- data/test/dummy/tmp/cache/assets/D73/C90/sprockets%2F9752db727fd681d97becb91a17ad302d +0 -0
- data/test/dummy/tmp/cache/assets/D74/A50/sprockets%2Fe50162da67fdab880a08590f618dfc8e +0 -0
- data/test/dummy/tmp/cache/assets/D75/270/sprockets%2Fef0b31d47f8f9acc69f0234019b737ee +0 -0
- data/test/dummy/tmp/cache/assets/D77/320/sprockets%2F0c96ad8de5e6a049f5df53415baa4697 +0 -0
- data/test/dummy/tmp/cache/assets/D7A/CF0/sprockets%2Fb7e1aa09c7c42e2b98895e16dbc839b6 +0 -0
- data/test/dummy/tmp/cache/assets/D7B/110/sprockets%2F55184d1c2bc87fc49369d69e10be7adf +0 -0
- data/test/dummy/tmp/cache/assets/D81/A40/sprockets%2Ff886784e31a152dc32fdf5cf782d6bd9 +0 -0
- data/test/dummy/tmp/cache/assets/D91/AE0/sprockets%2Fab00df33bbe0ef2939b4d43e042e4d77 +0 -0
- data/test/dummy/tmp/cache/assets/D9E/1A0/sprockets%2F69bf83cb71b257071ba6db37bdea78f1 +0 -0
- data/test/dummy/tmp/cache/assets/D9E/840/sprockets%2Fc8da1010ea3b0a24bd101a2dd319dc4c +0 -0
- data/test/dummy/tmp/cache/assets/DA0/880/sprockets%2F89c46cad03e38a94663bfaac1b8d95d0 +0 -0
- data/test/dummy/tmp/cache/assets/DA1/950/sprockets%2F1ea6768fec37a8ee2ad758d4152ae1d2 +0 -0
- data/test/dummy/tmp/cache/assets/DA1/D40/sprockets%2Ffd605d648ad0a46b3e3ef9cf089a51b6 +0 -0
- data/test/dummy/tmp/cache/assets/DA1/FB0/sprockets%2Fe8cba462fd2940b4be7bf2d294fd7209 +0 -0
- data/test/dummy/tmp/cache/assets/DA9/140/sprockets%2Fa9dc7b7a71d4a92925c654f09d17fefa +0 -0
- data/test/dummy/tmp/cache/assets/DAA/960/sprockets%2F486294de7d016fa0ec65f0f9efa2e19f +0 -0
- data/test/dummy/tmp/cache/assets/DAB/9E0/sprockets%2Fa425c97bf53c87ea907267ce66ad5deb +0 -0
- data/test/dummy/tmp/cache/assets/DB3/1D0/sprockets%2F095c6e852a938bbfb9fc98a9ea105ee8 +0 -0
- data/test/dummy/tmp/cache/assets/DC3/C60/sprockets%2F0c49e61f99da10cf7acc0cac7736b23a +0 -0
- data/test/dummy/tmp/cache/assets/DC7/E70/sprockets%2Fdae539d9ce457212fabb2abf298e112d +0 -0
- data/test/dummy/tmp/cache/assets/DC8/C90/sprockets%2F880a4acdf2b3dec03f783e63ed10e6e3 +0 -0
- data/test/dummy/tmp/cache/assets/DD0/DE0/sprockets%2Fdd9bcfaa02c63a17f16d84fb523fd886 +0 -0
- data/test/dummy/tmp/cache/assets/DD0/E10/sprockets%2F7ff09d9b55239e81c67ac0bd1cd60cfb +0 -0
- data/test/dummy/tmp/cache/assets/DD3/140/sprockets%2Fdcdc4960e9f9381cbaec40b2f26c8f53 +0 -0
- data/test/dummy/tmp/cache/assets/DD4/340/sprockets%2Ff2cff1054cf9ff3d947f1372db9b6aa2 +0 -0
- data/test/dummy/tmp/cache/assets/DD7/F90/sprockets%2F3cbb2ecff5ff45927078c4490a93bfeb +0 -0
- data/test/dummy/tmp/cache/assets/DDC/400/sprockets%2Fcffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/DE2/3D0/sprockets%2F503d37fdad31b11af5bd20b78ee3eaa0 +0 -0
- data/test/dummy/tmp/cache/assets/DF5/440/sprockets%2Fadaab579f5cf709a6c31b2fe40404ede +0 -0
- data/test/dummy/tmp/cache/assets/DFC/4A0/sprockets%2Fb2e7beb7a4bdf292c1b627bf0f84d9f0 +0 -0
- data/test/dummy/tmp/cache/assets/E02/C10/sprockets%2Fdd42eb4f61a99477f901cc31ddda7cfd +0 -0
- data/test/dummy/tmp/cache/assets/E04/610/sprockets%2Fd7d96ebe1affa231845c03c78ff6eaa7 +0 -0
- data/test/dummy/tmp/cache/assets/E04/890/sprockets%2F2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/E14/060/sprockets%2F7d7d19b9786dbc0f535478bcdcdc8fce +0 -0
- data/test/dummy/tmp/cache/assets/E27/F00/sprockets%2F8abb689fab00eaa7301adf5d198f4dce +0 -0
- data/test/dummy/tmp/cache/assets/E2B/870/sprockets%2F22736cce6575f0dd0fcedb11ece9cc8a +0 -0
- data/test/dummy/tmp/cache/assets/E31/FB0/sprockets%2Fa8bb4c8b0dc7cc0affd698f7e2a27d72 +0 -0
- data/test/dummy/tmp/cache/assets/E3B/E00/sprockets%2F4e3fffccff7a681b16a92b6caf8ef761 +0 -0
- data/test/dummy/tmp/cache/assets/E57/9C0/sprockets%2Fb3ca68a8872ea6d2cc2bcbfe01a7fde6 +0 -0
- data/test/dummy/tmp/cache/assets/E69/200/sprockets%2Ff2e92a9a60ccdd889dd57cd5bdfed0f2 +0 -0
- data/test/dummy/tmp/cache/assets/E6B/860/sprockets%2Ffde862d9eef7ace776b5e3ebc470bcb4 +0 -0
- data/test/dummy/tmp/cache/assets/F4A/1F0/sprockets%2Ffceff42fa3bdfb2eafbcad5a77ad38ee +0 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/rubyception_test.rb +7 -0
- data/test/test_helper.rb +15 -0
- metadata +495 -0
@@ -0,0 +1,30 @@
|
|
1
|
+
class Rubyception::Subscriber < ActiveSupport::LogSubscriber
|
2
|
+
INTERNAL_PARAMS = %w(controller action format _method only_path)
|
3
|
+
|
4
|
+
# ActionController
|
5
|
+
|
6
|
+
def start_processing(event)
|
7
|
+
Rubyception::WebsocketServer.start event
|
8
|
+
end
|
9
|
+
|
10
|
+
def process_action(event)
|
11
|
+
Rubyception::WebsocketServer.current_entry.finalize event
|
12
|
+
end
|
13
|
+
|
14
|
+
# http://edgeguides.rubyonrails.org/active_support_instrumentation.html#render_partial-
|
15
|
+
[
|
16
|
+
:render_template, # identifier (template name) , layout
|
17
|
+
:render_partial , # identifier
|
18
|
+
:sql , # sql (the query) , name (ie SELECT, DELETE ...)
|
19
|
+
:deliver , # mailer (Mailer class) , message_id , subject , to, from, bcc, cc, date, mail (message contents)
|
20
|
+
:redirect_to , # status (http status) , location
|
21
|
+
:halted_callback, # filter (method name where chain halted)
|
22
|
+
|
23
|
+
].each do |name|
|
24
|
+
class_eval <<-METHOD, __FILE__, __LINE__ + 1
|
25
|
+
def #{name}(event)
|
26
|
+
Rubyception::WebsocketServer.current_entry << event
|
27
|
+
end
|
28
|
+
METHOD
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# This compiles haml templates into a json object and writes it to
|
2
|
+
# the file app/javascripts/template.js. Its so we can render html
|
3
|
+
# via javascript.
|
4
|
+
|
5
|
+
class Rubyception::Templating
|
6
|
+
def self.r partial
|
7
|
+
t = Rubyception::TemplatingController.new
|
8
|
+
t.r partial
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.append_to_tree template, current
|
12
|
+
keys = current.split('/').collect{|k|"['#{k}']"}.join
|
13
|
+
partials = {}
|
14
|
+
template.each_index do |i|
|
15
|
+
partials[template[i]] = self.r("#{current}/#{template[i]}")
|
16
|
+
end
|
17
|
+
eval "@@templates#{keys} = partials"
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.process_tree template, key=nil, current=''
|
21
|
+
path = "#{current}/#{key}"
|
22
|
+
path = key.to_s if current == ''
|
23
|
+
kind = template.class.to_s
|
24
|
+
case kind
|
25
|
+
when 'Hash'
|
26
|
+
template.each do |k,v|
|
27
|
+
if v.nil?
|
28
|
+
self.append_to_tree [k], path
|
29
|
+
else
|
30
|
+
self.process_tree v, k, path
|
31
|
+
end
|
32
|
+
end
|
33
|
+
when 'Array'
|
34
|
+
self.append_to_tree template, path
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def self.compile
|
39
|
+
yml = File.join(File.dirname(__FILE__),'..','..','config','templating.yml')
|
40
|
+
file = File.open yml
|
41
|
+
templates = YAML::load file
|
42
|
+
@@templates = templates
|
43
|
+
self.process_tree templates
|
44
|
+
js = "Template = #{@@templates.to_json}"
|
45
|
+
path = File.join(File.dirname(__FILE__),'..','..','app','assets','javascripts','rubyception','template.js')
|
46
|
+
File.open(path,'w'){|f|f.write(js)}
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require 'em-websocket'
|
2
|
+
|
3
|
+
class Rubyception::WebsocketServer
|
4
|
+
cattr_accessor :sockets
|
5
|
+
cattr_accessor :current_entry
|
6
|
+
|
7
|
+
def self.start(event)
|
8
|
+
self.current_entry = Rubyception::Entry.new(event)
|
9
|
+
self.send_all self.current_entry.to_json
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.send_all(*args)
|
13
|
+
self.sockets.each do |socket|
|
14
|
+
socket.send(*args)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def initialize
|
19
|
+
Thread.new do
|
20
|
+
options = {
|
21
|
+
host: '0.0.0.0',
|
22
|
+
port: 3030 }
|
23
|
+
EventMachine::WebSocket.start(options) do |ws|
|
24
|
+
ws.onopen do
|
25
|
+
Rubyception::WebsocketServer.sockets << ws
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,261 @@
|
|
1
|
+
== Welcome to Rails
|
2
|
+
|
3
|
+
Rails is a web-application framework that includes everything needed to create
|
4
|
+
database-backed web applications according to the Model-View-Control pattern.
|
5
|
+
|
6
|
+
This pattern splits the view (also called the presentation) into "dumb"
|
7
|
+
templates that are primarily responsible for inserting pre-built data in between
|
8
|
+
HTML tags. The model contains the "smart" domain objects (such as Account,
|
9
|
+
Product, Person, Post) that holds all the business logic and knows how to
|
10
|
+
persist themselves to a database. The controller handles the incoming requests
|
11
|
+
(such as Save New Account, Update Product, Show Post) by manipulating the model
|
12
|
+
and directing data to the view.
|
13
|
+
|
14
|
+
In Rails, the model is handled by what's called an object-relational mapping
|
15
|
+
layer entitled Active Record. This layer allows you to present the data from
|
16
|
+
database rows as objects and embellish these data objects with business logic
|
17
|
+
methods. You can read more about Active Record in
|
18
|
+
link:files/vendor/rails/activerecord/README.html.
|
19
|
+
|
20
|
+
The controller and view are handled by the Action Pack, which handles both
|
21
|
+
layers by its two parts: Action View and Action Controller. These two layers
|
22
|
+
are bundled in a single package due to their heavy interdependence. This is
|
23
|
+
unlike the relationship between the Active Record and Action Pack that is much
|
24
|
+
more separate. Each of these packages can be used independently outside of
|
25
|
+
Rails. You can read more about Action Pack in
|
26
|
+
link:files/vendor/rails/actionpack/README.html.
|
27
|
+
|
28
|
+
|
29
|
+
== Getting Started
|
30
|
+
|
31
|
+
1. At the command prompt, create a new Rails application:
|
32
|
+
<tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
|
33
|
+
|
34
|
+
2. Change directory to <tt>myapp</tt> and start the web server:
|
35
|
+
<tt>cd myapp; rails server</tt> (run with --help for options)
|
36
|
+
|
37
|
+
3. Go to http://localhost:3000/ and you'll see:
|
38
|
+
"Welcome aboard: You're riding Ruby on Rails!"
|
39
|
+
|
40
|
+
4. Follow the guidelines to start developing your application. You can find
|
41
|
+
the following resources handy:
|
42
|
+
|
43
|
+
* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
|
44
|
+
* Ruby on Rails Tutorial Book: http://www.railstutorial.org/
|
45
|
+
|
46
|
+
|
47
|
+
== Debugging Rails
|
48
|
+
|
49
|
+
Sometimes your application goes wrong. Fortunately there are a lot of tools that
|
50
|
+
will help you debug it and get it back on the rails.
|
51
|
+
|
52
|
+
First area to check is the application log files. Have "tail -f" commands
|
53
|
+
running on the server.log and development.log. Rails will automatically display
|
54
|
+
debugging and runtime information to these files. Debugging info will also be
|
55
|
+
shown in the browser on requests from 127.0.0.1.
|
56
|
+
|
57
|
+
You can also log your own messages directly into the log file from your code
|
58
|
+
using the Ruby logger class from inside your controllers. Example:
|
59
|
+
|
60
|
+
class WeblogController < ActionController::Base
|
61
|
+
def destroy
|
62
|
+
@weblog = Weblog.find(params[:id])
|
63
|
+
@weblog.destroy
|
64
|
+
logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
The result will be a message in your log file along the lines of:
|
69
|
+
|
70
|
+
Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
|
71
|
+
|
72
|
+
More information on how to use the logger is at http://www.ruby-doc.org/core/
|
73
|
+
|
74
|
+
Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
|
75
|
+
several books available online as well:
|
76
|
+
|
77
|
+
* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
|
78
|
+
* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
|
79
|
+
|
80
|
+
These two books will bring you up to speed on the Ruby language and also on
|
81
|
+
programming in general.
|
82
|
+
|
83
|
+
|
84
|
+
== Debugger
|
85
|
+
|
86
|
+
Debugger support is available through the debugger command when you start your
|
87
|
+
Mongrel or WEBrick server with --debugger. This means that you can break out of
|
88
|
+
execution at any point in the code, investigate and change the model, and then,
|
89
|
+
resume execution! You need to install ruby-debug to run the server in debugging
|
90
|
+
mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
|
91
|
+
|
92
|
+
class WeblogController < ActionController::Base
|
93
|
+
def index
|
94
|
+
@posts = Post.all
|
95
|
+
debugger
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
So the controller will accept the action, run the first line, then present you
|
100
|
+
with a IRB prompt in the server window. Here you can do things like:
|
101
|
+
|
102
|
+
>> @posts.inspect
|
103
|
+
=> "[#<Post:0x14a6be8
|
104
|
+
@attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
|
105
|
+
#<Post:0x14a6620
|
106
|
+
@attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
|
107
|
+
>> @posts.first.title = "hello from a debugger"
|
108
|
+
=> "hello from a debugger"
|
109
|
+
|
110
|
+
...and even better, you can examine how your runtime objects actually work:
|
111
|
+
|
112
|
+
>> f = @posts.first
|
113
|
+
=> #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
|
114
|
+
>> f.
|
115
|
+
Display all 152 possibilities? (y or n)
|
116
|
+
|
117
|
+
Finally, when you're ready to resume execution, you can enter "cont".
|
118
|
+
|
119
|
+
|
120
|
+
== Console
|
121
|
+
|
122
|
+
The console is a Ruby shell, which allows you to interact with your
|
123
|
+
application's domain model. Here you'll have all parts of the application
|
124
|
+
configured, just like it is when the application is running. You can inspect
|
125
|
+
domain models, change values, and save to the database. Starting the script
|
126
|
+
without arguments will launch it in the development environment.
|
127
|
+
|
128
|
+
To start the console, run <tt>rails console</tt> from the application
|
129
|
+
directory.
|
130
|
+
|
131
|
+
Options:
|
132
|
+
|
133
|
+
* Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
|
134
|
+
made to the database.
|
135
|
+
* Passing an environment name as an argument will load the corresponding
|
136
|
+
environment. Example: <tt>rails console production</tt>.
|
137
|
+
|
138
|
+
To reload your controllers and models after launching the console run
|
139
|
+
<tt>reload!</tt>
|
140
|
+
|
141
|
+
More information about irb can be found at:
|
142
|
+
link:http://www.rubycentral.org/pickaxe/irb.html
|
143
|
+
|
144
|
+
|
145
|
+
== dbconsole
|
146
|
+
|
147
|
+
You can go to the command line of your database directly through <tt>rails
|
148
|
+
dbconsole</tt>. You would be connected to the database with the credentials
|
149
|
+
defined in database.yml. Starting the script without arguments will connect you
|
150
|
+
to the development database. Passing an argument will connect you to a different
|
151
|
+
database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
|
152
|
+
PostgreSQL and SQLite 3.
|
153
|
+
|
154
|
+
== Description of Contents
|
155
|
+
|
156
|
+
The default directory structure of a generated Ruby on Rails application:
|
157
|
+
|
158
|
+
|-- app
|
159
|
+
| |-- assets
|
160
|
+
| |-- images
|
161
|
+
| |-- javascripts
|
162
|
+
| `-- stylesheets
|
163
|
+
| |-- controllers
|
164
|
+
| |-- helpers
|
165
|
+
| |-- mailers
|
166
|
+
| |-- models
|
167
|
+
| `-- views
|
168
|
+
| `-- layouts
|
169
|
+
|-- config
|
170
|
+
| |-- environments
|
171
|
+
| |-- initializers
|
172
|
+
| `-- locales
|
173
|
+
|-- db
|
174
|
+
|-- doc
|
175
|
+
|-- lib
|
176
|
+
| `-- tasks
|
177
|
+
|-- log
|
178
|
+
|-- public
|
179
|
+
|-- script
|
180
|
+
|-- test
|
181
|
+
| |-- fixtures
|
182
|
+
| |-- functional
|
183
|
+
| |-- integration
|
184
|
+
| |-- performance
|
185
|
+
| `-- unit
|
186
|
+
|-- tmp
|
187
|
+
| |-- cache
|
188
|
+
| |-- pids
|
189
|
+
| |-- sessions
|
190
|
+
| `-- sockets
|
191
|
+
`-- vendor
|
192
|
+
|-- assets
|
193
|
+
`-- stylesheets
|
194
|
+
`-- plugins
|
195
|
+
|
196
|
+
app
|
197
|
+
Holds all the code that's specific to this particular application.
|
198
|
+
|
199
|
+
app/assets
|
200
|
+
Contains subdirectories for images, stylesheets, and JavaScript files.
|
201
|
+
|
202
|
+
app/controllers
|
203
|
+
Holds controllers that should be named like weblogs_controller.rb for
|
204
|
+
automated URL mapping. All controllers should descend from
|
205
|
+
ApplicationController which itself descends from ActionController::Base.
|
206
|
+
|
207
|
+
app/models
|
208
|
+
Holds models that should be named like post.rb. Models descend from
|
209
|
+
ActiveRecord::Base by default.
|
210
|
+
|
211
|
+
app/views
|
212
|
+
Holds the template files for the view that should be named like
|
213
|
+
weblogs/index.html.erb for the WeblogsController#index action. All views use
|
214
|
+
eRuby syntax by default.
|
215
|
+
|
216
|
+
app/views/layouts
|
217
|
+
Holds the template files for layouts to be used with views. This models the
|
218
|
+
common header/footer method of wrapping views. In your views, define a layout
|
219
|
+
using the <tt>layout :default</tt> and create a file named default.html.erb.
|
220
|
+
Inside default.html.erb, call <% yield %> to render the view using this
|
221
|
+
layout.
|
222
|
+
|
223
|
+
app/helpers
|
224
|
+
Holds view helpers that should be named like weblogs_helper.rb. These are
|
225
|
+
generated for you automatically when using generators for controllers.
|
226
|
+
Helpers can be used to wrap functionality for your views into methods.
|
227
|
+
|
228
|
+
config
|
229
|
+
Configuration files for the Rails environment, the routing map, the database,
|
230
|
+
and other dependencies.
|
231
|
+
|
232
|
+
db
|
233
|
+
Contains the database schema in schema.rb. db/migrate contains all the
|
234
|
+
sequence of Migrations for your schema.
|
235
|
+
|
236
|
+
doc
|
237
|
+
This directory is where your application documentation will be stored when
|
238
|
+
generated using <tt>rake doc:app</tt>
|
239
|
+
|
240
|
+
lib
|
241
|
+
Application specific libraries. Basically, any kind of custom code that
|
242
|
+
doesn't belong under controllers, models, or helpers. This directory is in
|
243
|
+
the load path.
|
244
|
+
|
245
|
+
public
|
246
|
+
The directory available for the web server. Also contains the dispatchers and the
|
247
|
+
default HTML files. This should be set as the DOCUMENT_ROOT of your web
|
248
|
+
server.
|
249
|
+
|
250
|
+
script
|
251
|
+
Helper scripts for automation and generation.
|
252
|
+
|
253
|
+
test
|
254
|
+
Unit and functional tests along with fixtures. When using the rails generate
|
255
|
+
command, template test files will be generated for you and placed in this
|
256
|
+
directory.
|
257
|
+
|
258
|
+
vendor
|
259
|
+
External libraries that the application depends on. Also includes the plugins
|
260
|
+
subdirectory. If the app has frozen rails, those gems also go here, under
|
261
|
+
vendor/rails/. This directory is in the load path.
|
data/test/dummy/Rakefile
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
3
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
4
|
+
|
5
|
+
require File.expand_path('../config/application', __FILE__)
|
6
|
+
|
7
|
+
Dummy::Application.load_tasks
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// the compiled file.
|
9
|
+
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require_tree .
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|