mankiq 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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 787007df90afd0b8a6800513e29fb13e56cf5726
4
+ data.tar.gz: 5318a3be94755203fbe98ccb4071ad33eefc3f77
5
+ SHA512:
6
+ metadata.gz: c7815b416ac8eb44203b9f0e4446c1d7859cae182d2f741190cd712edb59fbb1c6df70a09fddcbcd3416f1cfce76a3e296a4106b0cf4322379b402ef7602496c
7
+ data.tar.gz: d2acd7ef5aa3c4858813ccf0bcfb195d8341efa1b41674d19eabca7805b95d5d55d70a2d68253a1572289776d4923e4485c91451c7b1e6aceed5644cc8720966
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in mankiq.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 pokka
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,47 @@
1
+ # Mankiq
2
+
3
+ Add manual workers to sidekiq
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'mankiq'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ ## Usage
18
+
19
+ Configuration
20
+
21
+ rails
22
+
23
+ ```
24
+ Mankiq.config.workers_dir = Rails.root.join("app/workers/manual_workers/*.rb").to_s
25
+ ```
26
+
27
+ include module
28
+
29
+ ```
30
+ class YourManualWorker
31
+ include Sidekiq::Worker
32
+ include Mankiq::Worker
33
+
34
+ def perform
35
+ ...
36
+ end
37
+ end
38
+ ```
39
+
40
+ Then you can reach a `Manual` tab in sidekiq web interface
41
+
42
+ Original author: wkang
43
+
44
+ ## License
45
+
46
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
47
+
@@ -0,0 +1,16 @@
1
+ require "mankiq/version"
2
+
3
+ module Mankiq
4
+
5
+ class Configuration
6
+ attr_accessor :workers_dir
7
+ end
8
+
9
+ def self.config
10
+ @configuration ||= Configuration.new
11
+ end
12
+
13
+ end
14
+
15
+ require "mankiq/worker"
16
+ require "mankiq/web"
@@ -0,0 +1,3 @@
1
+ module Mankiq
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,33 @@
1
+ <header class="row">
2
+ <div class="col-sm-5">
3
+ <h3>Manual Jobs</h3>
4
+ </div>
5
+ </header>
6
+
7
+ <div class="container">
8
+ <div class="row">
9
+
10
+ <div class="col-md-12">
11
+ <table class="table table-striped table-bordered table-white table-sidetiq">
12
+ <thead>
13
+ <th style="width: 50%">Worker</th>
14
+ <th style="width: 25%">Queue</th>
15
+ <th style="width: 25%">Actions</th>
16
+ </thead>
17
+ <% @workers.each do |worker| %>
18
+ <tr>
19
+ <td><%= worker.name %></td>
20
+ <td><%= worker.get_sidekiq_options["queue"] %></td>
21
+ <td>
22
+ <form action="<%= "#{root_path}manual/#{worker.name}/trigger" %>" method="post">
23
+ <%= csrf_tag %>
24
+ <input class="btn btn-danger btn-small" type="submit" name="trigger" value="Trigger" data-confirm="Are you sure you want to trigger this job?" />
25
+ </form>
26
+ </td>
27
+ </tr>
28
+ <% end %>
29
+ </table>
30
+ </div>
31
+
32
+ </div>
33
+ </div>
@@ -0,0 +1,30 @@
1
+ require 'sidekiq/web'
2
+
3
+ module Mankiq
4
+ module Web
5
+ VIEWS_PATH = File.expand_path('../views', __FILE__)
6
+
7
+ def self.registered(app)
8
+ app.get "/manual" do
9
+ Dir[Mankiq.config.workers_dir].each {|file| require file }
10
+ @workers = Worker.workers.sort_by { |worker| worker.name }
11
+ erb File.read(File.join(VIEWS_PATH, 'manual_workers.html.erb')), locals: {view_path: VIEWS_PATH}
12
+ end
13
+
14
+ app.post "/manual/:name/trigger" do
15
+ halt 404 unless (name = params[:name])
16
+
17
+ worker = Worker.workers.detect do |worker|
18
+ worker.name == name
19
+ end
20
+
21
+ worker.perform_async if worker
22
+ redirect "#{root_path}/manual"
23
+ end
24
+ end
25
+
26
+ end
27
+ end
28
+
29
+ Sidekiq::Web.register(Mankiq::Web)
30
+ Sidekiq::Web.tabs["Manual"] = "manual"
@@ -0,0 +1,31 @@
1
+ module Mankiq
2
+
3
+ module SubclassTracking
4
+ def subclasses(deep = false)
5
+ @subclasses ||= []
6
+ end
7
+
8
+ def inherited(klass)
9
+ super
10
+ subclasses << klass
11
+ end
12
+ end
13
+
14
+ module Worker
15
+ extend SubclassTracking
16
+
17
+ def self.workers
18
+ subclasses(true).select do |klass|
19
+ klass.method_defined?(:perform)
20
+ end
21
+ end
22
+
23
+ def self.included(klass)
24
+ super
25
+
26
+ klass.extend(SubclassTracking)
27
+ subclasses << klass
28
+ end
29
+ end
30
+
31
+ end
@@ -0,0 +1,24 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'mankiq/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "mankiq"
8
+ spec.version = Mankiq::VERSION
9
+ spec.authors = ["pokka"]
10
+ spec.email = ["ifunafu@gmail.com"]
11
+
12
+ spec.summary = %q{Add manual workers to sidekiq}
13
+ spec.description = %q{Add manual workers to sidekiq}
14
+ spec.homepage = "https://github.com/pokka/mankiq"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.10"
23
+ spec.add_dependency "sidekiq", "~> 4.0.0"
24
+ end
metadata ADDED
@@ -0,0 +1,83 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: mankiq
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - pokka
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-03-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sidekiq
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 4.0.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 4.0.0
41
+ description: Add manual workers to sidekiq
42
+ email:
43
+ - ifunafu@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - LICENSE.txt
51
+ - README.md
52
+ - lib/mankiq.rb
53
+ - lib/mankiq/version.rb
54
+ - lib/mankiq/views/manual_workers.html.erb
55
+ - lib/mankiq/web.rb
56
+ - lib/mankiq/worker.rb
57
+ - mankiq.gemspec
58
+ homepage: https://github.com/pokka/mankiq
59
+ licenses:
60
+ - MIT
61
+ metadata: {}
62
+ post_install_message:
63
+ rdoc_options: []
64
+ require_paths:
65
+ - lib
66
+ required_ruby_version: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ required_rubygems_version: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ requirements: []
77
+ rubyforge_project:
78
+ rubygems_version: 2.4.5.1
79
+ signing_key:
80
+ specification_version: 4
81
+ summary: Add manual workers to sidekiq
82
+ test_files: []
83
+ has_rdoc: