resque-notify 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 34b82aef365dd03c906437695c5fa793bd9fcf7f
4
+ data.tar.gz: d93ec005cf96c0801284e69c1d4fb01337c14471
5
+ SHA512:
6
+ metadata.gz: d03e32d98258a84ad9c63e651e0cf2719a048f744495a5a929ee2622e12238dba43ed3d8cd11bfd3f36358ae4b9ec12944edb6321cbb100987b27ce9cb5ba165
7
+ data.tar.gz: b01465d77f8b94261c7e3e854227596caf1faad4b4b6f18fb9f4776065300dca9de848bdf03cbf75daf5de63571530a1e9e4c7729f7d5cd88a690209cdda3074
data/.gitignore ADDED
@@ -0,0 +1,6 @@
1
+ pkg/*
2
+ *.gem
3
+ .bundle
4
+ coverage/*
5
+ .rvmrc
6
+ .project
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source "http://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in resque-pause.gemspec
4
+ gemspec
5
+
6
+ gem "rake"
7
+
8
+ group :test, :development do
9
+ platforms :mri_19, :mri_20 do
10
+ gem "debugger"
11
+ end
12
+
13
+ platforms :mri_21 do
14
+ gem "byebug"
15
+ end
16
+ end
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) Stephen Coley (stephen@coley.co)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
File without changes
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
@@ -0,0 +1,78 @@
1
+ (function(){
2
+ var failedCount = null;
3
+ var checkFailedInterval;
4
+
5
+ function getNotificationPrivileges(){
6
+ if (Notification.permission !== "granted")
7
+ Notification.requestPermission();
8
+ }
9
+
10
+ function checkFailedCount(){
11
+ var failedTd = $('td.queue.failed');
12
+ var newFailedCount = parseInt(failedTd.next().text());
13
+ if( failedCount === null ) {
14
+ failedCount = newFailedCount;
15
+ } else if ( newFailedCount > failedCount ) {
16
+ failedCount = newFailedCount;
17
+ //notifyFailed(newFailedCount, failedTd);
18
+ getFailed();
19
+ } else if ( newFailedCount < failedCount) {
20
+ failedCount = newFailedCount;
21
+ }
22
+ }
23
+
24
+ function notifyFailed(failedClassText, failedError) {
25
+ var failedLink = $('td.queue.failed').find('a').attr('href');
26
+ var notification = new Notification(failedClassText + ' Failed', {
27
+ icon: 'https://pbs.twimg.com/profile_images/456473652515463169/xXR95uqW_normal.png',
28
+ body: "Exception Raised: " + failedError
29
+ });
30
+ clearInterval(checkFailedInterval);
31
+ startInterval();
32
+
33
+ notification.onclick = function(){
34
+ window.open(failedLink);
35
+ }
36
+ }
37
+
38
+ function getFailed(){
39
+ $.ajax({
40
+ dataType: 'text',
41
+ type: 'get',
42
+ url: "http://mobi.mobi.dev/resque/failed.poll",
43
+ success: function(data) {
44
+ parseFailed($(data));
45
+ }
46
+ });
47
+ }
48
+
49
+ function parseFailed(failedData){
50
+ var failedLi = failedData.filter('.failed').find('li:first');
51
+ var failedClass = failedLi.find("dt:contains('Class')").next();
52
+ var failedClassText = failedClass.find('a code').text();
53
+ var failedError = failedLi.find("dd.error .backtrace").text();
54
+ notifyFailed(failedClassText, failedError);
55
+ }
56
+
57
+ function startInterval(){
58
+ checkFailedInterval = setInterval(checkFailedCount, 2000);
59
+ }
60
+
61
+ function startMonitoring(){
62
+ getNotificationPrivileges();
63
+ startInterval();
64
+ }
65
+
66
+ $(function(){
67
+ var pollLink = $('a[rel=poll]');
68
+ if( pollLink.length != 0) {
69
+ pollLink.click(function(){
70
+ startMonitoring();
71
+ });
72
+
73
+ var pollEvent = pollLink.data("events").click[3]
74
+ pollLink.data("events").click[3] = pollLink.data("events").click[4]
75
+ pollLink.data('events').click[4] = pollEvent;
76
+ }
77
+ });
78
+ })();
@@ -0,0 +1,45 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>Resque.</title>
6
+ <link href="<%=u 'reset.css' %>" media="screen" rel="stylesheet" type="text/css">
7
+ <link href="<%=u 'style.css' %>" media="screen" rel="stylesheet" type="text/css">
8
+ <script src="<%=u 'jquery-1.3.2.min.js' %>" type="text/javascript"></script>
9
+ <script src="<%=u 'jquery.relatize_date.js' %>" type="text/javascript"></script>
10
+ <script src="<%=u 'ranger.js' %>" type="text/javascript"></script>
11
+ <script src="<%=u '/notify/public/notify.js' %>" type="text/javascript"></script>
12
+ </head>
13
+ <body>
14
+ <div class="header">
15
+ <ul class='nav'>
16
+ <% tabs.each do |tab_name| %>
17
+ <%= tab tab_name %>
18
+ <% end %>
19
+ </ul>
20
+ <% if Resque.redis.namespace != :resque %>
21
+ <abbr class="namespace" title="Resque's Redis Namespace">
22
+ <%= Resque.redis.namespace %>
23
+ </abbr>
24
+ <% end %>
25
+ </div>
26
+
27
+ <% if @subtabs %>
28
+ <ul class='subnav'>
29
+ <% for subtab in @subtabs %>
30
+ <li <%= class_if_current "#{current_section}/#{subtab}" %>><a href="<%= current_section %>/<%= subtab %>"><span><%= subtab %></span></a></li>
31
+ <% end %>
32
+ </ul>
33
+ <% end %>
34
+
35
+ <div id="main">
36
+ <%= yield %>
37
+ </div>
38
+
39
+ <div id="footer">
40
+ <p>Powered by <a href="http://github.com/resque/resque">Resque</a> v<%=Resque::Version%></p>
41
+ <p>Connected to Redis namespace <%= Resque.redis.namespace %> on <%=Resque.redis_id%></p>
42
+ </div>
43
+
44
+ </body>
45
+ </html>
@@ -0,0 +1,51 @@
1
+ require 'resque'
2
+ require 'resque/server'
3
+
4
+ # Extends Resque Web Based UI.
5
+ # Structure has been borrowed from ResqueScheduler and ResquePause.
6
+ module ResqueNotify
7
+ module Server
8
+
9
+ def self.public_path(filename)
10
+ File.join(File.dirname(__FILE__), 'server', 'public', filename)
11
+ end
12
+
13
+ def self.included(base)
14
+
15
+ base.class_eval do
16
+
17
+ get /notify\/public\/([a-z]+\.[a-z]+)/ do
18
+ send_file ResqueNotify::Server.public_path(params[:captures].first)
19
+ end
20
+ end
21
+
22
+ end
23
+ end
24
+ end
25
+
26
+ Resque.extend ResqueNotify
27
+ Resque::Server.class_eval do
28
+ set :views, [settings.views, File.join(File.dirname(__FILE__), 'server', 'views')]
29
+
30
+ helpers do
31
+ def find_template(views, name, engine, &block)
32
+ views.each { |v| super(v, name, engine, &block) }
33
+ end
34
+ end
35
+
36
+
37
+ def show(page, layout = :'notify-layout')
38
+ response["Cache-Control"] = "max-age=0, private, must-revalidate"
39
+ begin
40
+ erb page.to_sym, {:layout => layout}, :resque => Resque
41
+ rescue Errno::ECONNREFUSED
42
+ erb :error, {:layout => false}, :error => "Can't connect to Redis! (#{Resque.redis_id})"
43
+ end
44
+ end
45
+
46
+ get "/failed.poll/?" do
47
+ show_for_polling('failed')
48
+ end
49
+
50
+ include ResqueNotify::Server
51
+ end
data/lib/version.rb ADDED
@@ -0,0 +1,7 @@
1
+ module Resque
2
+ module Plugins
3
+ module Notify
4
+ VERSION = "0.0.1"
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,19 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "resque-notify"
7
+ s.version = Resque::Plugins::Notify::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Stephen Coley"]
10
+ s.email = ["stephen@coley.co"]
11
+ s.homepage = "https://github.com/srcoley/resque-notify"
12
+ s.summary = %q{A Resque plugin that sends desktop notifications when a job fails}
13
+ s.description = %q{A Resque plugin that sends desktop notifications when a job fails}
14
+
15
+ s.files = `git ls-files`.split("\n")
16
+ s.require_paths = ["lib"]
17
+
18
+ s.add_dependency('resque', '>= 1.9.10')
19
+ end
metadata ADDED
@@ -0,0 +1,68 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: resque-notify
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Stephen Coley
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: resque
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - '>='
18
+ - !ruby/object:Gem::Version
19
+ version: 1.9.10
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - '>='
25
+ - !ruby/object:Gem::Version
26
+ version: 1.9.10
27
+ description: A Resque plugin that sends desktop notifications when a job fails
28
+ email:
29
+ - stephen@coley.co
30
+ executables: []
31
+ extensions: []
32
+ extra_rdoc_files: []
33
+ files:
34
+ - .gitignore
35
+ - Gemfile
36
+ - LICENSE
37
+ - README.md
38
+ - Rakefile
39
+ - lib/resque-notify/server.rb
40
+ - lib/resque-notify/server/public/notify.js
41
+ - lib/resque-notify/server/views/notify-layout.erb
42
+ - lib/version.rb
43
+ - resque-notify.gemspec
44
+ homepage: https://github.com/srcoley/resque-notify
45
+ licenses: []
46
+ metadata: {}
47
+ post_install_message:
48
+ rdoc_options: []
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - '>='
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubyforge_project:
63
+ rubygems_version: 2.0.14
64
+ signing_key:
65
+ specification_version: 4
66
+ summary: A Resque plugin that sends desktop notifications when a job fails
67
+ test_files: []
68
+ has_rdoc: