sidekiq-belt 0.3.3 → 0.3.5
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -0
- data/README.md +29 -0
- data/lib/sidekiq/belt/community/files.rb +2 -0
- data/lib/sidekiq/belt/community/top_label.rb +29 -0
- data/lib/sidekiq/belt/version.rb +1 -1
- data/lib/sidekiq/belt.rb +9 -1
- data/lib/sidekiq/web_action_helper.rb +23 -8
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22715eaf1b97cc17ccba000c8afe03226a8d6c53b330eaa09e7c145b37c3ec62
|
4
|
+
data.tar.gz: 539f10b1b8f408e046b908d9e88bddc092348f9c43177374f6ed716523190abf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4692c9cbf5354af3a7fd7ca42552d1da901a837dc4c59d433784127732e4edb3a4980b607875491e9f332a052aef5b714441883a77981e4cec427a09e72de0d5
|
7
|
+
data.tar.gz: d592e7f91d8364cbe6df0fa786f19edfbdcc4d05a6cc4632779134dafa1854e55d872fe8c3ba50c7d617e6a83d0c8da7bd7ab6500226d34c4210c14e31ce8ab8
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
## [Unreleased]
|
2
2
|
|
3
|
+
## [0.3.5] - 2024-09-27
|
4
|
+
|
5
|
+
- Fix replace_content to dynamic routes
|
6
|
+
|
7
|
+
## [0.3.4] - 2024-01-07
|
8
|
+
|
9
|
+
- Feature top label
|
10
|
+
|
11
|
+
## [0.3.3] - 2024-06-11
|
12
|
+
|
13
|
+
- Feature list to run jobs
|
14
|
+
|
3
15
|
## [0.3.2] - 2024-01-07
|
4
16
|
|
5
17
|
- Feature to sort periodic list by class name
|
data/README.md
CHANGED
@@ -116,6 +116,35 @@ Sidekiq::Belt.configure do |config|
|
|
116
116
|
end
|
117
117
|
```
|
118
118
|
|
119
|
+
### Add to your web sidekiq a top label by enviroment (sidekiq)
|
120
|
+
|
121
|
+
This feature adds a little line on top of Sidekiq web that shows a configurable message.
|
122
|
+
|
123
|
+

|
124
|
+

|
125
|
+
|
126
|
+
To enable this feature, pass the `top_label` option:
|
127
|
+
```ruby
|
128
|
+
Sidekiq::Belt.use!([:top_label])
|
129
|
+
```
|
130
|
+
|
131
|
+
```ruby
|
132
|
+
Sidekiq::Belt.configure do |config|
|
133
|
+
config.top_label = {
|
134
|
+
production: {
|
135
|
+
background_color: 'red',
|
136
|
+
text: 'Be carefull',
|
137
|
+
color: 'white'
|
138
|
+
},
|
139
|
+
development: {
|
140
|
+
background_color: 'green',
|
141
|
+
text: 'You are safe!',
|
142
|
+
color: 'white'
|
143
|
+
}
|
144
|
+
}
|
145
|
+
end
|
146
|
+
```
|
147
|
+
|
119
148
|
## Development
|
120
149
|
|
121
150
|
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require "sidekiq"
|
4
4
|
|
5
5
|
require_relative "run_job"
|
6
|
+
require_relative "top_label"
|
6
7
|
|
7
8
|
module Sidekiq
|
8
9
|
module Belt
|
@@ -10,6 +11,7 @@ module Sidekiq
|
|
10
11
|
module Files
|
11
12
|
def self.use!(options = [:all])
|
12
13
|
Sidekiq::Belt::Community::RunJob.use! if should_use?(:run_job, options)
|
14
|
+
Sidekiq::Belt::Community::TopLabel.use! if should_use?(:top_label, options)
|
13
15
|
|
14
16
|
true
|
15
17
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "sidekiq/web"
|
4
|
+
require "sidekiq/web/helpers"
|
5
|
+
|
6
|
+
module Sidekiq
|
7
|
+
module Belt
|
8
|
+
module Community
|
9
|
+
module TopLabel
|
10
|
+
def self.use!
|
11
|
+
Sidekiq::WebActionHelper.change_layout do |content|
|
12
|
+
top_label = (Sidekiq::Belt.config.top_label || {}).fetch(Sidekiq::Belt.env, {})
|
13
|
+
|
14
|
+
html = "<div class='container-fluid'
|
15
|
+
style='background: #{::Rack::Utils.escape_html(top_label.fetch(:background_color, "red"))};
|
16
|
+
text-align: center;
|
17
|
+
color: #{::Rack::Utils.escape_html(top_label.fetch(:color, "white"))};'>
|
18
|
+
#{::Rack::Utils.escape_html(top_label[:text].to_s)}
|
19
|
+
</div>"
|
20
|
+
unless top_label.empty?
|
21
|
+
content.gsub!('<div class="container-fluid">',
|
22
|
+
"#{html} <div class='container-fluid'>")
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/sidekiq/belt/version.rb
CHANGED
data/lib/sidekiq/belt.rb
CHANGED
@@ -25,7 +25,15 @@ module Sidekiq
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.config
|
28
|
-
@config ||= Struct.new(:run_jobs).new([])
|
28
|
+
@config ||= Struct.new(:run_jobs, :top_label).new([], {})
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.env
|
32
|
+
(Sidekiq.default_configuration[:environment] ||
|
33
|
+
ENV["APP_ENV"] ||
|
34
|
+
ENV["RAILS_ENV"] ||
|
35
|
+
ENV["RACK_ENV"] ||
|
36
|
+
"development").to_sym
|
29
37
|
end
|
30
38
|
end
|
31
39
|
end
|
@@ -6,21 +6,36 @@ require "sidekiq/web/action"
|
|
6
6
|
module Sidekiq
|
7
7
|
module WebActionHelper
|
8
8
|
def render(engine, content, options = {})
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
9
|
+
path_info = ::Rack::Utils.unescape(env["PATH_INFO"])
|
10
|
+
|
11
|
+
replace_views = Sidekiq::Config::DEFAULTS[:replace_views] || {}
|
12
|
+
|
13
|
+
replace_views.each do |key, content_blocks|
|
14
|
+
next if WebRoute.new("", key, true).match("", path_info).nil?
|
15
|
+
|
16
|
+
content_blocks.each do |content_block|
|
17
|
+
content_block.call(content)
|
18
|
+
end
|
13
19
|
end
|
14
20
|
|
15
|
-
|
21
|
+
super
|
22
|
+
end
|
16
23
|
|
17
|
-
|
24
|
+
def self.change_layout(&block)
|
25
|
+
Sidekiq::Config::DEFAULTS[:layout_changes] ||= []
|
26
|
+
Sidekiq::Config::DEFAULTS[:layout_changes] << block
|
27
|
+
end
|
28
|
+
|
29
|
+
def _render
|
30
|
+
content = super
|
31
|
+
|
32
|
+
layout_changes = Sidekiq::Config::DEFAULTS[:layout_changes] || []
|
18
33
|
|
19
|
-
|
34
|
+
layout_changes.each do |content_block|
|
20
35
|
content_block.call(content)
|
21
36
|
end
|
22
37
|
|
23
|
-
|
38
|
+
content
|
24
39
|
end
|
25
40
|
end
|
26
41
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sidekiq-belt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Danilo Jeremias da Silva
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sidekiq
|
@@ -43,6 +43,7 @@ files:
|
|
43
43
|
- lib/sidekiq/belt.rb
|
44
44
|
- lib/sidekiq/belt/community/files.rb
|
45
45
|
- lib/sidekiq/belt/community/run_job.rb
|
46
|
+
- lib/sidekiq/belt/community/top_label.rb
|
46
47
|
- lib/sidekiq/belt/community/views/run_jobs.erb
|
47
48
|
- lib/sidekiq/belt/ent/files.rb
|
48
49
|
- lib/sidekiq/belt/ent/periodic_pause.rb
|
@@ -76,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
77
|
- !ruby/object:Gem::Version
|
77
78
|
version: '0'
|
78
79
|
requirements: []
|
79
|
-
rubygems_version: 3.5.
|
80
|
+
rubygems_version: 3.5.16
|
80
81
|
signing_key:
|
81
82
|
specification_version: 4
|
82
83
|
summary: This Ruby gem enhances the capabilities of Sidekiq, Sidekiq Pro, and Sidekiq
|