rakeleak 0.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.
Files changed (82) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.md +40 -0
  3. data/Rakefile +40 -0
  4. data/app/assets/javascripts/rakeleak/application.js +17 -0
  5. data/app/assets/javascripts/rakeleak/tasks.js +53 -0
  6. data/app/assets/stylesheets/rakeleak/application.css +13 -0
  7. data/app/assets/stylesheets/rakeleak/tasks.css +124 -0
  8. data/app/controllers/rakeleak/application_controller.rb +4 -0
  9. data/app/controllers/rakeleak/tasks_controller.rb +26 -0
  10. data/app/views/layouts/rakeleak/application.html.erb +16 -0
  11. data/app/views/rakeleak/tasks/_task.html.erb +7 -0
  12. data/app/views/rakeleak/tasks/index.html.erb +15 -0
  13. data/config/routes.rb +5 -0
  14. data/lib/rakeleak/engine.rb +13 -0
  15. data/lib/rakeleak/version.rb +3 -0
  16. data/lib/rakeleak.rb +12 -0
  17. data/test/dummy/README.rdoc +261 -0
  18. data/test/dummy/Rakefile +7 -0
  19. data/test/dummy/app/assets/javascripts/application.js +15 -0
  20. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  21. data/test/dummy/app/controllers/application_controller.rb +3 -0
  22. data/test/dummy/app/helpers/application_helper.rb +2 -0
  23. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  24. data/test/dummy/config/application.rb +59 -0
  25. data/test/dummy/config/boot.rb +10 -0
  26. data/test/dummy/config/database.yml +25 -0
  27. data/test/dummy/config/environment.rb +5 -0
  28. data/test/dummy/config/environments/development.rb +37 -0
  29. data/test/dummy/config/environments/production.rb +67 -0
  30. data/test/dummy/config/environments/test.rb +37 -0
  31. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  32. data/test/dummy/config/initializers/inflections.rb +15 -0
  33. data/test/dummy/config/initializers/mime_types.rb +5 -0
  34. data/test/dummy/config/initializers/secret_token.rb +7 -0
  35. data/test/dummy/config/initializers/session_store.rb +8 -0
  36. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  37. data/test/dummy/config/locales/en.yml +5 -0
  38. data/test/dummy/config/routes.rb +4 -0
  39. data/test/dummy/config.ru +4 -0
  40. data/test/dummy/lib/tasks/error.rake +6 -0
  41. data/test/dummy/lib/tasks/simple.rake +6 -0
  42. data/test/dummy/lib/tasks/timerror.rake +8 -0
  43. data/test/dummy/lib/tasks/wait_3_sec.rake +6 -0
  44. data/test/dummy/log/development.log +113332 -0
  45. data/test/dummy/log/test.log +7528 -0
  46. data/test/dummy/public/404.html +26 -0
  47. data/test/dummy/public/422.html +26 -0
  48. data/test/dummy/public/500.html +25 -0
  49. data/test/dummy/public/favicon.ico +0 -0
  50. data/test/dummy/script/rails +6 -0
  51. data/test/dummy/tmp/cache/assets/C5E/440/sprockets%2Fba31529ca20206e11215433ee169332b +0 -0
  52. data/test/dummy/tmp/cache/assets/C9B/4A0/sprockets%2F798d65ca17a72755d92723797da97d24 +0 -0
  53. data/test/dummy/tmp/cache/assets/CB9/3A0/sprockets%2F16a64c486f8333fe04529e91e5a6635b +0 -0
  54. data/test/dummy/tmp/cache/assets/CE8/240/sprockets%2F777dce4d696645611f0ae85347dc00b7 +0 -0
  55. data/test/dummy/tmp/cache/assets/CEE/A10/sprockets%2F5f66bc32b0a17ed0847c99b4747989c0 +0 -0
  56. data/test/dummy/tmp/cache/assets/CEF/D60/sprockets%2F8ce62194b0c88c58b75f30703867fbc7 +0 -0
  57. data/test/dummy/tmp/cache/assets/D02/6E0/sprockets%2F5db2ebf4409582ca15d8da402374e431 +0 -0
  58. data/test/dummy/tmp/cache/assets/D0D/370/sprockets%2Feda0592655569205d3738f32c4bdadf0 +0 -0
  59. data/test/dummy/tmp/cache/assets/D27/240/sprockets%2Fd28e9af8999b4f679b650105a606b9bf +0 -0
  60. data/test/dummy/tmp/cache/assets/D7B/DD0/sprockets%2F6f2905cdb5eed396c60140fbe94c9e66 +0 -0
  61. data/test/dummy/tmp/cache/assets/D8B/7C0/sprockets%2F5ef63b3be3860b7a1d2f1edbd1b08025 +0 -0
  62. data/test/dummy/tmp/cache/assets/D91/470/sprockets%2F80012ff0ade705b8eed3f36fa5ed5121 +0 -0
  63. data/test/dummy/tmp/cache/assets/D9C/D90/sprockets%2F383b39d58a0ed61af597d1ebdd2e01e5 +0 -0
  64. data/test/dummy/tmp/cache/assets/D9E/9F0/sprockets%2F3f8503a3d9bfee0922e881e8a32fccb2 +0 -0
  65. data/test/dummy/tmp/cache/assets/DB1/A30/sprockets%2F2cfcbef803fb9c40270c8846f6f983ef +0 -0
  66. data/test/dummy/tmp/cache/assets/DC5/D40/sprockets%2F7cf78f2e7bf164a14df03fcd0d0bd900 +0 -0
  67. data/test/dummy/tmp/cache/assets/DC8/880/sprockets%2F2ecbee3d3fdfbc150f65064a19ed9225 +0 -0
  68. data/test/dummy/tmp/cache/assets/DC9/730/sprockets%2F09cb8bd8fb2b5a925a9ef047cac34a53 +0 -0
  69. data/test/dummy/tmp/cache/assets/DD4/990/sprockets%2F2f127f8c0ebf8d16939a0efc14fe09ec +0 -0
  70. data/test/dummy/tmp/cache/assets/DDB/EA0/sprockets%2F2395acf962c33e59dc8655cafeab8e3d +0 -0
  71. data/test/dummy/tmp/cache/assets/DEA/BE0/sprockets%2F352f037cde13c0e2e244d1dcaa5fde6c +0 -0
  72. data/test/dummy/tmp/cache/assets/DEB/510/sprockets%2F99aed1df3af79a258def18d7db49993c +0 -0
  73. data/test/dummy/tmp/cache/assets/E29/770/sprockets%2F3f8c60e8d26acb84da06d9aaac3cc7e5 +0 -0
  74. data/test/dummy/tmp/cache/assets/E5A/A10/sprockets%2Ff9ffe2fc2fc392bab3c1361efae80ad6 +0 -0
  75. data/test/functional/rakeleak/tasks_controller_test.rb +48 -0
  76. data/test/integration/navigation_test.rb +10 -0
  77. data/test/rakeleak_test.rb +23 -0
  78. data/test/routing/rakeleak_routing_test.rb +18 -0
  79. data/test/test_helper.rb +15 -0
  80. data/vendor/assets/javascripts/rakeleak/jquery.fastLiveFilter.js +57 -0
  81. data/vendor/assets/javascripts/rakeleak/jquery.highlight.js +108 -0
  82. metadata +254 -0
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,48 @@
1
+ require 'test_helper'
2
+
3
+ module Rakeleak
4
+ class TasksControllerTest < ActionController::TestCase
5
+ include Rake::DSL
6
+
7
+ setup do
8
+ @routes = Engine.routes
9
+ end
10
+
11
+ test 'should get index' do
12
+ get :index
13
+ assert_response :success
14
+ assert_not_nil assigns(:tasks)
15
+ assert_template :index
16
+ end
17
+
18
+ test 'run task' do
19
+ name = 'simple'
20
+ done = false
21
+ Rake::Task.tasks << task(name) {|_| done = true }
22
+
23
+ post :run, id: name, format: :json
24
+ assert_response :success
25
+ assert_equal true, done
26
+ end
27
+
28
+ test 'return forbidden status if task failed' do
29
+ name = 'error'
30
+ Rake::Task.tasks << task(name) {|_| raise 'boom!' }
31
+
32
+ post :run, id: name, format: :json
33
+ assert_response :forbidden
34
+ end
35
+
36
+ test 'return error description if task failed' do
37
+ name = 'error'
38
+ message = 'boom!'
39
+ Rake::Task.tasks << task(name) {|_| raise message }
40
+
41
+ post :run, id: name, format: :json
42
+ json = JSON.parse(response.body)
43
+ assert_not_nil json['error']
44
+ assert_equal message, json['error']['msg']
45
+ assert_not_nil json['error']['stacktrace']
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,10 @@
1
+ require 'test_helper'
2
+
3
+ class NavigationTest < ActionDispatch::IntegrationTest
4
+ fixtures :all
5
+
6
+ # test "the truth" do
7
+ # assert true
8
+ # end
9
+ end
10
+
@@ -0,0 +1,23 @@
1
+ require 'test_helper'
2
+
3
+ class RakeleakTest < ActiveSupport::TestCase
4
+ include Rake::DSL
5
+
6
+ test 'loading available rake tasks' do
7
+ Rails.application.load_tasks
8
+ assert_equal Rake::Task.tasks.size, Rakeleak.tasks.size
9
+ end
10
+
11
+ test 'running existing task' do
12
+ name = 'simple'
13
+ Rake::Task.tasks << task(name) {|_| 'eval this string and stop' }
14
+ assert_nothing_raised { Rakeleak.run(name) }
15
+ end
16
+
17
+ test 'running existing task throwing exception' do
18
+ name = 'exception'
19
+ message = 'simple exception'
20
+ Rake::Task.tasks << task(name) {|_| raise message }
21
+ assert_raise(RuntimeError) { Rakeleak.run(name) }
22
+ end
23
+ end
@@ -0,0 +1,18 @@
1
+ require 'test_helper'
2
+
3
+ module Rakeleak
4
+ class RakeleakRoutingTest < ActionController::TestCase
5
+ setup do
6
+ @routes = Engine.routes
7
+ end
8
+
9
+ test '/tasks routes to tasks#index' do
10
+ assert_routing '/tasks', { controller: 'rakeleak/tasks', action: 'index' }
11
+ end
12
+
13
+ test '/tasks/:task/run routes to tasks#run' do
14
+ assert_routing({ path: '/tasks/about/run', method: :post },
15
+ { controller: 'rakeleak/tasks', action: 'run', id: 'about' })
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,15 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
+ require "rails/test_help"
6
+
7
+ Rails.backtrace_cleaner.remove_silencers!
8
+
9
+ # Load support files
10
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
11
+
12
+ # Load fixtures from the engine
13
+ if ActiveSupport::TestCase.method_defined?(:fixture_path=)
14
+ ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
15
+ end
@@ -0,0 +1,57 @@
1
+ /**
2
+ * fastLiveFilter jQuery plugin 1.0.3
3
+ *
4
+ * Copyright (c) 2011, Anthony Bush
5
+ * License: <http://www.opensource.org/licenses/bsd-license.php>
6
+ * Project Website: http://anthonybush.com/projects/jquery_fast_live_filter/
7
+ **/
8
+
9
+ jQuery.fn.fastLiveFilter = function(list, options) {
10
+ // Options: input, list, timeout, callback
11
+ options = options || {};
12
+ list = jQuery(list);
13
+ var input = this;
14
+ var timeout = options.timeout || 0;
15
+ var callback = options.callback || function() {};
16
+
17
+ var keyTimeout;
18
+
19
+ // NOTE: because we cache lis & len here, users would need to re-init the plugin
20
+ // if they modify the list in the DOM later. This doesn't give us that much speed
21
+ // boost, so perhaps it's not worth putting it here.
22
+ var lis = list.children();
23
+ var len = lis.length;
24
+ var oldDisplay = len > 0 ? lis[0].style.display : "block";
25
+ callback(len); // do a one-time callback on initialization to make sure everything's in sync
26
+
27
+ input.change(function() {
28
+ // var startTime = new Date().getTime();
29
+ var filter = input.val().toLowerCase();
30
+ var li;
31
+ var numShown = 0;
32
+ for (var i = 0; i < len; i++) {
33
+ li = lis[i];
34
+ if ((li.textContent || li.innerText || "").toLowerCase().indexOf(filter) >= 0) {
35
+ if (li.style.display == "none") {
36
+ li.style.display = oldDisplay;
37
+ }
38
+ numShown++;
39
+ } else {
40
+ if (li.style.display != "none") {
41
+ li.style.display = "none";
42
+ }
43
+ }
44
+ }
45
+ callback(numShown);
46
+ // var endTime = new Date().getTime();
47
+ // console.log('Search for ' + filter + ' took: ' + (endTime - startTime) + ' (' + numShown + ' results)');
48
+ return false;
49
+ }).keydown(function() {
50
+ // TODO: one point of improvement could be in here: currently the change event is
51
+ // invoked even if a change does not occur (e.g. by pressing a modifier key or
52
+ // something)
53
+ clearTimeout(keyTimeout);
54
+ keyTimeout = setTimeout(function() { input.change(); }, timeout);
55
+ });
56
+ return this; // maintain jQuery chainability
57
+ }
@@ -0,0 +1,108 @@
1
+ /*
2
+ * jQuery Highlight plugin
3
+ *
4
+ * Based on highlight v3 by Johann Burkard
5
+ * http://johannburkard.de/blog/programming/javascript/highlight-javascript-text-higlighting-jquery-plugin.html
6
+ *
7
+ * Code a little bit refactored and cleaned (in my humble opinion).
8
+ * Most important changes:
9
+ * - has an option to highlight only entire words (wordsOnly - false by default),
10
+ * - has an option to be case sensitive (caseSensitive - false by default)
11
+ * - highlight element tag and class names can be specified in options
12
+ *
13
+ * Usage:
14
+ * // wrap every occurrance of text 'lorem' in content
15
+ * // with <span class='highlight'> (default options)
16
+ * $('#content').highlight('lorem');
17
+ *
18
+ * // search for and highlight more terms at once
19
+ * // so you can save some time on traversing DOM
20
+ * $('#content').highlight(['lorem', 'ipsum']);
21
+ * $('#content').highlight('lorem ipsum');
22
+ *
23
+ * // search only for entire word 'lorem'
24
+ * $('#content').highlight('lorem', { wordsOnly: true });
25
+ *
26
+ * // don't ignore case during search of term 'lorem'
27
+ * $('#content').highlight('lorem', { caseSensitive: true });
28
+ *
29
+ * // wrap every occurrance of term 'ipsum' in content
30
+ * // with <em class='important'>
31
+ * $('#content').highlight('ipsum', { element: 'em', className: 'important' });
32
+ *
33
+ * // remove default highlight
34
+ * $('#content').unhighlight();
35
+ *
36
+ * // remove custom highlight
37
+ * $('#content').unhighlight({ element: 'em', className: 'important' });
38
+ *
39
+ *
40
+ * Copyright (c) 2009 Bartek Szopka
41
+ *
42
+ * Licensed under MIT license.
43
+ *
44
+ */
45
+
46
+ jQuery.extend({
47
+ highlight: function (node, re, nodeName, className) {
48
+ if (node.nodeType === 3) {
49
+ var match = node.data.match(re);
50
+ if (match) {
51
+ var highlight = document.createElement(nodeName || 'span');
52
+ highlight.className = className || 'highlight';
53
+ var wordNode = node.splitText(match.index);
54
+ wordNode.splitText(match[0].length);
55
+ var wordClone = wordNode.cloneNode(true);
56
+ highlight.appendChild(wordClone);
57
+ wordNode.parentNode.replaceChild(highlight, wordNode);
58
+ return 1; //skip added node in parent
59
+ }
60
+ } else if ((node.nodeType === 1 && node.childNodes) && // only element nodes that have children
61
+ !/(script|style)/i.test(node.tagName) && // ignore script and style nodes
62
+ !(node.tagName === nodeName.toUpperCase() && node.className === className)) { // skip if already highlighted
63
+ for (var i = 0; i < node.childNodes.length; i++) {
64
+ i += jQuery.highlight(node.childNodes[i], re, nodeName, className);
65
+ }
66
+ }
67
+ return 0;
68
+ }
69
+ });
70
+
71
+ jQuery.fn.unhighlight = function (options) {
72
+ var settings = { className: 'highlight', element: 'span' };
73
+ jQuery.extend(settings, options);
74
+
75
+ return this.find(settings.element + "." + settings.className).each(function () {
76
+ var parent = this.parentNode;
77
+ parent.replaceChild(this.firstChild, this);
78
+ parent.normalize();
79
+ }).end();
80
+ };
81
+
82
+ jQuery.fn.highlight = function (words, options) {
83
+ var settings = { className: 'highlight', element: 'span', caseSensitive: false, wordsOnly: false };
84
+ jQuery.extend(settings, options);
85
+
86
+ if (words.constructor === String) {
87
+ words = [words];
88
+ }
89
+ words = jQuery.grep(words, function(word, i){
90
+ return word != '';
91
+ });
92
+ words = jQuery.map(words, function(word, i) {
93
+ return word.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, "\\$&");
94
+ });
95
+ if (words.length == 0) { return this; };
96
+
97
+ var flag = settings.caseSensitive ? "" : "i";
98
+ var pattern = "(" + words.join("|") + ")";
99
+ if (settings.wordsOnly) {
100
+ pattern = "\\b" + pattern + "\\b";
101
+ }
102
+ var re = new RegExp(pattern, flag);
103
+
104
+ return this.each(function () {
105
+ jQuery.highlight(this, re, settings.element, settings.className);
106
+ });
107
+ };
108
+