sidekiq_status 1.0.2 → 1.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/.rvmrc CHANGED
@@ -1 +1 @@
1
- rvm use 1.9.3-p374-perf@sidekiq_status --create
1
+ rvm use 1.9.3-p392-perf@sidekiq_status --create
data/.travis.yml CHANGED
@@ -4,5 +4,14 @@ rvm:
4
4
  - 1.9.3
5
5
  # - jruby-19mode # JRuby in 1.9 mode
6
6
  # - rbx-19mode
7
- # uncomment this line if your project needs to run something other than `rake`:
8
- # script: bundle exec rspec spec
7
+ env:
8
+ global:
9
+ - SHOW_SIDEKIQ=true
10
+ matrix:
11
+ - SIDEKIQ_VERSION="~>2.4.0"
12
+ - SIDEKIQ_VERSION="~>2.5.4"
13
+ - SIDEKIQ_VERSION="~>2.6.5"
14
+ - SIDEKIQ_VERSION="~>2.7.5"
15
+ - SIDEKIQ_VERSION="~>2.8.0"
16
+ - SIDEKIQ_VERSION="~>2.9.0"
17
+ script: bundle exec rake
data/Gemfile CHANGED
@@ -2,3 +2,6 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in sidekiq_status.gemspec
4
4
  gemspec
5
+
6
+ gem 'sidekiq', ENV['SIDEKIQ_VERSION'] if ENV['SIDEKIQ_VERSION']
7
+
data/README.md CHANGED
@@ -146,6 +146,11 @@ and clean status containers.
146
146
 
147
147
  ## Changelog
148
148
 
149
+ ### 1.0.3
150
+
151
+ * Include SidekiqStatus::Web app into Sidekiq::Web app unobtrusively (Peter Fern)
152
+ * sidekiq 2.8.0 and 2.9.0 support
153
+
149
154
  ### 1.0.2
150
155
 
151
156
  * sidekiq 2.7.0 support
@@ -1,5 +1,5 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
  module SidekiqStatus
3
3
  # SidekiqStatus version
4
- VERSION = "1.0.2"
4
+ VERSION = "1.0.3"
5
5
  end
@@ -1,75 +1,67 @@
1
1
  module SidekiqStatus
2
2
  # Hook into *Sidekiq::Web* Sinatra app which adds a new "/statuses" page
3
3
  module Web
4
- # A ruby module hook to treat the included code as if it was defined inside Sidekiq::Web.
5
- # Thus it extends Sidekiq::Web Sinatra application
6
- #
7
- # @param [Sidekiq::Web] target
8
- def self.extend_object(target)
9
- target.class_eval do
4
+ # Location of SidekiqStatus::Web view templates
5
+ VIEW_PATH = File.expand_path('../../../web/views', __FILE__)
6
+
7
+ # @param [Sidekiq::Web] app
8
+ def self.registered(app)
9
+ app.helpers do
10
10
  # Calls the given block for every possible template file in views,
11
11
  # named name.ext, where ext is registered on engine.
12
12
  def find_template(views, name, engine, &block)
13
- super(File.expand_path('../../../web/views', __FILE__), name, engine, &block)
13
+ super(VIEW_PATH, name, engine, &block)
14
14
  super
15
15
  end
16
+ end
16
17
 
17
- case tabs
18
- when Hash
19
- # Sidekiq >= 2.5.0
20
- tabs['Statuses'] = 'statuses'
21
- when Array
22
- # Sidekiq < 2.5.0
23
- tabs << 'Statuses'
24
- else
25
- raise ScriptError, 'unexpected Sidekiq::Web.tabs format'
26
- end
27
-
28
-
29
- get '/statuses' do
30
- @count = (params[:count] || 25).to_i
31
-
32
- @current_page = (params[:page] || 1).to_i
33
- @current_page = 1 unless @current_page > 0
18
+ app.get '/statuses' do
19
+ @count = (params[:count] || 25).to_i
34
20
 
35
- @total_size = SidekiqStatus::Container.size
21
+ @current_page = (params[:page] || 1).to_i
22
+ @current_page = 1 unless @current_page > 0
36
23
 
37
- pageidx = @current_page - 1
38
- @statuses = SidekiqStatus::Container.statuses(pageidx * @count, (pageidx + 1) * @count)
24
+ @total_size = SidekiqStatus::Container.size
39
25
 
40
- slim :statuses
41
- end
26
+ pageidx = @current_page - 1
27
+ @statuses = SidekiqStatus::Container.statuses(pageidx * @count, (pageidx + 1) * @count)
42
28
 
43
- get '/statuses/:jid' do
44
- @status = SidekiqStatus::Container.load(params[:jid])
45
- slim :status
46
- end
47
-
48
- get '/statuses/:jid/kill' do
49
- SidekiqStatus::Container.load(params[:jid]).request_kill
50
- redirect to(:statuses)
51
- end
29
+ render(:slim, :statuses)
30
+ end
52
31
 
53
- get '/statuses/delete/all' do
54
- SidekiqStatus::Container.delete
55
- redirect to(:statuses)
56
- end
32
+ app.get '/statuses/:jid' do
33
+ @status = SidekiqStatus::Container.load(params[:jid])
34
+ render(:slim, :status)
35
+ end
57
36
 
58
- get '/statuses/delete/complete' do
59
- SidekiqStatus::Container.delete('complete')
60
- redirect to(:statuses)
61
- end
37
+ app.get '/statuses/:jid/kill' do
38
+ SidekiqStatus::Container.load(params[:jid]).request_kill
39
+ redirect to(:statuses)
40
+ end
62
41
 
63
- get '/statuses/delete/finished' do
64
- SidekiqStatus::Container.delete(SidekiqStatus::Container::FINISHED_STATUS_NAMES)
65
- redirect to(:statuses)
66
- end
42
+ app.get '/statuses/delete/all' do
43
+ SidekiqStatus::Container.delete
44
+ redirect to(:statuses)
45
+ end
67
46
 
47
+ app.get '/statuses/delete/complete' do
48
+ SidekiqStatus::Container.delete('complete')
49
+ redirect to(:statuses)
50
+ end
68
51
 
52
+ app.get '/statuses/delete/finished' do
53
+ SidekiqStatus::Container.delete(SidekiqStatus::Container::FINISHED_STATUS_NAMES)
54
+ redirect to(:statuses)
69
55
  end
70
56
  end
71
57
  end
72
58
  end
73
59
 
74
- require 'sidekiq/web'
75
- Sidekiq::Web.extend(SidekiqStatus::Web)
60
+ require 'sidekiq/web' unless defined?(Sidekiq::Web)
61
+ Sidekiq::Web.register(SidekiqStatus::Web)
62
+ if Sidekiq::Web.tabs.is_a?(Array)
63
+ # For sidekiq < 2.5
64
+ Sidekiq::Web.tabs << "statuses"
65
+ else
66
+ Sidekiq::Web.tabs["Statuses"] = "statuses"
67
+ end
@@ -15,7 +15,7 @@ Gem::Specification.new do |gem|
15
15
  gem.require_paths = ["lib"]
16
16
  gem.version = SidekiqStatus::VERSION
17
17
 
18
- gem.add_runtime_dependency("sidekiq", ">= 2.6", "<= 2.8")
18
+ gem.add_runtime_dependency("sidekiq", ">= 2.4", "<= 2.9")
19
19
 
20
20
  gem.add_development_dependency("activesupport")
21
21
  gem.add_development_dependency("rspec")
@@ -9,7 +9,8 @@ describe SidekiqStatus::Worker do
9
9
  command,
10
10
  :chdir => DUMMY_APP_ROOT,
11
11
  :err => :out,
12
- :out => log_to
12
+ :out => log_to,
13
+ :pgroup => true
13
14
  )
14
15
  end
15
16
 
@@ -19,14 +20,8 @@ describe SidekiqStatus::Worker do
19
20
  begin
20
21
  yield(pid)
21
22
  ensure
22
- Process.kill('USR1', pid)
23
- Process.wait(pid, Process::WNOHANG)
24
- end
25
- end
26
-
27
- def wait(&block)
28
- Timeout.timeout(15) do
29
- sleep(0.5) while !block.call
23
+ Process.kill('TERM', -Process.getpgid(pid))
24
+ Process.wait(pid)
30
25
  end
31
26
  end
32
27
 
@@ -70,4 +65,4 @@ describe SidekiqStatus::Worker do
70
65
  end
71
66
  end
72
67
  end
73
- end
68
+ end
data/spec/spec_helper.rb CHANGED
@@ -30,4 +30,10 @@ RSpec.configure do |c|
30
30
  example.call
31
31
  end
32
32
  end
33
+
34
+ def wait(&block)
35
+ Timeout.timeout(15) do
36
+ sleep(0.5) while !block.call
37
+ end
38
+ end
33
39
  end
data/spec/worker_spec.rb CHANGED
@@ -120,7 +120,6 @@ describe Sidekiq::Worker do
120
120
  jid = SomeWorker.perform_async(*args)
121
121
  container = SidekiqStatus::Container.load(jid)
122
122
 
123
- ready = false
124
123
  lets_stop = false
125
124
 
126
125
  worker.extend(Module.new do
@@ -128,17 +127,13 @@ describe Sidekiq::Worker do
128
127
  self.total=(200)
129
128
  self.at(50, "25% done")
130
129
  self.payload = 'some payload'
131
- ready = true
132
- sleep(0.01) unless lets_stop
130
+ wait{ lets_stop }
133
131
  end
134
132
  end)
135
133
 
136
134
  worker_thread = Thread.new{ worker.perform(jid) }
137
135
  checker_thread = Thread.new do
138
- sleep(0.01) unless ready
139
-
140
- container.reload
141
- container.status.should == 'working'
136
+ wait{ container.reload.working? }
142
137
  container.at.should == 50
143
138
  container.total.should == 200
144
139
  container.message.should == '25% done'
@@ -147,13 +142,13 @@ describe Sidekiq::Worker do
147
142
  lets_stop = true
148
143
  end
149
144
 
150
- worker_thread.join(10)
151
- checker_thread.join(10)
145
+ worker_thread.join(15)
146
+ checker_thread.join(15)
147
+
148
+ wait{ container.reload.complete? }
152
149
 
153
- container.reload
154
- container.status.should == 'complete'
155
150
  container.payload.should == 'some payload'
156
151
  container.message.should be_nil
157
152
  end
158
153
  end
159
- end
154
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sidekiq_status
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-05 00:00:00.000000000 Z
12
+ date: 2013-04-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sidekiq
@@ -18,10 +18,10 @@ dependencies:
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: '2.6'
21
+ version: '2.4'
22
22
  - - <=
23
23
  - !ruby/object:Gem::Version
24
- version: '2.8'
24
+ version: '2.9'
25
25
  type: :runtime
26
26
  prerelease: false
27
27
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,10 +29,10 @@ dependencies:
29
29
  requirements:
30
30
  - - ! '>='
31
31
  - !ruby/object:Gem::Version
32
- version: '2.6'
32
+ version: '2.4'
33
33
  - - <=
34
34
  - !ruby/object:Gem::Version
35
- version: '2.8'
35
+ version: '2.9'
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: activesupport
38
38
  requirement: !ruby/object:Gem::Requirement