diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 749ae53..42c9d2d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,13 +15,14 @@ jobs: matrix: ruby: - '3.2.2' + - '3.3.6' steps: - - uses: actions/checkout@v4 - - name: Set up Ruby - uses: ruby/setup-ruby@v1 - with: - ruby-version: ${{ matrix.ruby }} - bundler-cache: true - - name: Run the default task - run: bundle exec rake + - uses: actions/checkout@v4 + - name: Set up Ruby + uses: ruby/setup-ruby@v1 + with: + ruby-version: ${{ matrix.ruby }} + bundler-cache: true + - name: Run the default task + run: bundle exec rake diff --git a/.rubocop.yml b/.rubocop.yml index 3ab92c1..2dab139 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -3,7 +3,7 @@ require: - rubocop-rspec AllCops: - TargetRubyVersion: 2.6 + TargetRubyVersion: 3 NewCops: enable Style/StringLiterals: diff --git a/CHANGELOG.md b/CHANGELOG.md index 94332b9..5fe794f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,10 @@ ## [Unreleased] +## [2.0.0] - 2024-09-27 +- Support for Sidekiq v8 + +## [1.0.0] - 2024-11-19 +- Force run batch callback + ## [0.3.6] - 2024-09-27 - Added force kill to instances diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md index 82874ea..da9ce21 100644 --- a/CODE_OF_CONDUCT.md +++ b/CODE_OF_CONDUCT.md @@ -2,83 +2,131 @@ ## Our Pledge -We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation. +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. -We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community. +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. ## Our Standards -Examples of behavior that contributes to a positive environment for our community include: +Examples of behavior that contributes to a positive environment for our +community include: * Demonstrating empathy and kindness toward other people * Being respectful of differing opinions, viewpoints, and experiences * Giving and gracefully accepting constructive feedback -* Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience -* Focusing on what is best not just for us as individuals, but for the overall community +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community Examples of unacceptable behavior include: -* The use of sexualized language or imagery, and sexual attention or - advances of any kind +* The use of sexualized language or imagery, and sexual attention or advances of + any kind * Trolling, insulting or derogatory comments, and personal or political attacks * Public or private harassment -* Publishing others' private information, such as a physical or email - address, without their explicit permission +* Publishing others' private information, such as a physical or email address, + without their explicit permission * Other conduct which could reasonably be considered inappropriate in a professional setting ## Enforcement Responsibilities -Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful. +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. -Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate. +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. ## Scope -This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official email address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. ## Enforcement -Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at daniloj.dasilva@gmail.com. All complaints will be reviewed and investigated promptly and fairly. +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported to the community leaders responsible for enforcement at +daniloj.dasilva@gmail.com. +All complaints will be reviewed and investigated promptly and fairly. -All community leaders are obligated to respect the privacy and security of the reporter of any incident. +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. ## Enforcement Guidelines -Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct: +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: ### 1. Correction -**Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community. +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. -**Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested. +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. ### 2. Warning -**Community Impact**: A violation through a single incident or series of actions. +**Community Impact**: A violation through a single incident or series of +actions. -**Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban. +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. ### 3. Temporary Ban -**Community Impact**: A serious violation of community standards, including sustained inappropriate behavior. +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. -**Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban. +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. ### 4. Permanent Ban -**Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals. +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. -**Consequence**: A permanent ban from any sort of public interaction within the community. +**Consequence**: A permanent ban from any sort of public interaction within the +community. ## Attribution -This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0, -available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html. +This Code of Conduct is adapted from the [Contributor Covenant][homepage], +version 2.1, available at +[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1]. -Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity). - -[homepage]: https://www.contributor-covenant.org +Community Impact Guidelines were inspired by +[Mozilla's code of conduct enforcement ladder][Mozilla CoC]. For answers to common questions about this code of conduct, see the FAQ at -https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations. +[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at +[https://www.contributor-covenant.org/translations][translations]. + +[homepage]: https://www.contributor-covenant.org +[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html +[Mozilla CoC]: https://github.com/mozilla/diversity +[FAQ]: https://www.contributor-covenant.org/faq +[translations]: https://www.contributor-covenant.org/translations diff --git a/Gemfile.lock b/Gemfile.lock index 920e0a7..535803e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,64 +1,64 @@ PATH remote: . specs: - sidekiq-belt (1.0.0) - sidekiq (> 7.1.4) + sidekiq-belt (2.0.0) + sidekiq (>= 7.3.8) GEM remote: https://rubygems.org/ specs: ast (2.4.2) + base64 (0.2.0) byebug (11.1.3) - concurrent-ruby (1.3.4) - connection_pool (2.4.1) + connection_pool (2.5.0) diff-lcs (1.5.1) docile (1.4.1) - json (2.7.2) + json (2.9.0) language_server-protocol (3.17.0.3) - logger (1.6.1) + logger (1.6.5) parallel (1.26.3) - parser (3.3.5.0) + parser (3.3.6.0) ast (~> 2.4.1) racc racc (1.8.1) - rack (3.1.7) + rack (3.1.9) rainbow (3.1.1) rake (13.2.1) - redis-client (0.22.2) + redis-client (0.23.2) connection_pool - regexp_parser (2.9.2) + regexp_parser (2.9.3) rspec (3.13.0) rspec-core (~> 3.13.0) rspec-expectations (~> 3.13.0) rspec-mocks (~> 3.13.0) - rspec-core (3.13.1) + rspec-core (3.13.2) rspec-support (~> 3.13.0) rspec-expectations (3.13.3) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-mocks (3.13.1) + rspec-mocks (3.13.2) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.13.0) - rspec-support (3.13.1) - rubocop (1.66.1) + rspec-support (3.13.2) + rubocop (1.69.2) json (~> 2.3) language_server-protocol (>= 3.17.0) parallel (~> 1.10) parser (>= 3.3.0.2) rainbow (>= 2.2.2, < 4.0) - regexp_parser (>= 2.4, < 3.0) - rubocop-ast (>= 1.32.2, < 2.0) + regexp_parser (>= 2.9.3, < 3.0) + rubocop-ast (>= 1.36.2, < 2.0) ruby-progressbar (~> 1.7) - unicode-display_width (>= 2.4.0, < 3.0) - rubocop-ast (1.32.3) + unicode-display_width (>= 2.4.0, < 4.0) + rubocop-ast (1.37.0) parser (>= 3.3.1.0) rubocop-rake (0.6.0) rubocop (~> 1.0) - rubocop-rspec (3.0.5) + rubocop-rspec (3.3.0) rubocop (~> 1.61) ruby-progressbar (1.13.0) - sidekiq (7.3.2) - concurrent-ruby (< 2) + sidekiq (7.3.8) + base64 connection_pool (>= 2.3.0) logger rack (>= 2.2.4) @@ -69,9 +69,12 @@ GEM simplecov_json_formatter (~> 0.1) simplecov-html (0.13.1) simplecov_json_formatter (0.1.4) - unicode-display_width (2.6.0) + unicode-display_width (3.1.2) + unicode-emoji (~> 4.0, >= 4.0.4) + unicode-emoji (4.0.4) PLATFORMS + ruby x86_64-linux DEPENDENCIES @@ -85,4 +88,4 @@ DEPENDENCIES simplecov BUNDLED WITH - 2.4.20 + 2.5.23 diff --git a/LICENSE b/LICENSE index 36df9ed..339c616 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2023 Danilo Jeremias da Silva +Copyright (c) 2024 Danilo Jeremias da Silva Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/bin/setup b/bin/setup old mode 100755 new mode 100644 diff --git a/lib/sidekiq/belt.rb b/lib/sidekiq/belt.rb index 1885c69..9ccecf5 100644 --- a/lib/sidekiq/belt.rb +++ b/lib/sidekiq/belt.rb @@ -3,6 +3,7 @@ require "sidekiq" require_relative "belt/version" +require "sidekiq/web" require_relative "web_action_helper" require_relative "web_router_helper" diff --git a/lib/sidekiq/belt/community/force_kill.rb b/lib/sidekiq/belt/community/force_kill.rb index 1566cb2..cc02f48 100644 --- a/lib/sidekiq/belt/community/force_kill.rb +++ b/lib/sidekiq/belt/community/force_kill.rb @@ -25,7 +25,7 @@ def self.registered(app) end app.get("/force_kill/:identity/kill") do - process = Sidekiq::ProcessSet[params["identity"]] + process = Sidekiq::ProcessSet[route_params(:identity)] if process process.stop! @@ -38,7 +38,10 @@ def self.registered(app) end def self.use! - Sidekiq::Web.register(Sidekiq::Belt::Community::ForceKill::SidekiqForceKill) + Sidekiq::Web.configure do |cfg| + cfg.register(Sidekiq::Belt::Community::ForceKill::SidekiqForceKill, name: "force_kill", tab: nil, + index: nil) + end Sidekiq::Process.prepend(Sidekiq::Belt::Community::ForceKill) end end diff --git a/lib/sidekiq/belt/community/run_job.rb b/lib/sidekiq/belt/community/run_job.rb index 0874b8a..1165cee 100644 --- a/lib/sidekiq/belt/community/run_job.rb +++ b/lib/sidekiq/belt/community/run_job.rb @@ -29,8 +29,6 @@ def self.run_job(job_id) module SidekiqRunJob def self.registered(app) - app.tabs["Run Jobs"] = "run_jobs" - app.get("/run_jobs") do @jobs = Sidekiq::Belt::Community::RunJob.list_grouped_jobs @@ -38,7 +36,7 @@ def self.registered(app) end app.post("/run_jobs/:rjid/run") do - Sidekiq::Belt::Community::RunJob.run_job(params[:rjid].to_i) + Sidekiq::Belt::Community::RunJob.run_job(route_params(:rjid).to_i) return redirect "#{root_path}run_jobs" end @@ -46,7 +44,10 @@ def self.registered(app) end def self.use! - Sidekiq::Web.register(Sidekiq::Belt::Community::RunJob::SidekiqRunJob) + Sidekiq::Web.configure do |cfg| + cfg.register(Sidekiq::Belt::Community::RunJob::SidekiqRunJob, name: "run_jobs", tab: "Run Jobs", + index: "run_jobs") + end end end end diff --git a/lib/sidekiq/belt/community/top_label.rb b/lib/sidekiq/belt/community/top_label.rb index 53cf771..eb1a1fb 100644 --- a/lib/sidekiq/belt/community/top_label.rb +++ b/lib/sidekiq/belt/community/top_label.rb @@ -6,23 +6,62 @@ module Sidekiq module Belt module Community - module TopLabel + class TopLabel def self.use! Sidekiq::WebActionHelper.change_layout do |content| - top_label = (Sidekiq::Belt.config.top_label || {}).fetch(Sidekiq::Belt.env, {}) - - html = "
-  #{::Rack::Utils.escape_html(top_label[:text].to_s)}  -
" - unless top_label.empty? - content.gsub!('
', - "#{html}
") - end + Sidekiq::Belt::Community::TopLabel.new(content).apply end end + + attr_reader :content, :top_label + + def initialize(content) + @content = content + @top_label = fetch_top_label + end + + def apply + inject_styles_and_label unless top_label.empty? + + content + end + + def fetch_top_label + (Sidekiq::Belt.config.top_label || {}).fetch(Sidekiq::Belt.env, {}) + end + + def inject_styles_and_label + content.gsub!("", "") + content.sub!(/]*>/, "\\0#{top_label_div}") + end + + def nonce_id + content[/nonce="([^"]*)"/, 1].to_s + end + + def top_label_div + text = ::Rack::Utils.escape_html(top_label[:text].to_s) + "
 #{text} 
" + end + + def styles + <<~CSS + header:first-of-type, .navbar-default { + margin-top: 20px; + } + + .top_label { + background: #{::Rack::Utils.escape_html(top_label.fetch(:background_color, "red"))} !important; + z-index: 99999; + text-align: center; + color: #{::Rack::Utils.escape_html(top_label.fetch(:color, "white"))}; + position: fixed; + width: 100%; + top: 0; + right: 0; + } + CSS + end end end end diff --git a/lib/sidekiq/belt/ent/periodic_pause.rb b/lib/sidekiq/belt/ent/periodic_pause.rb index dae9a27..80ae40d 100644 --- a/lib/sidekiq/belt/ent/periodic_pause.rb +++ b/lib/sidekiq/belt/ent/periodic_pause.rb @@ -62,13 +62,13 @@ def self.registered(app) end app.post("/loops/:lid/pause") do - Sidekiq::Periodic::Loop.new(params[:lid]).pause! + Sidekiq::Periodic::Loop.new(route_params(:lid)).pause! return redirect "#{root_path}loops" end app.post("/loops/:lid/unpause") do - Sidekiq::Periodic::Loop.new(params[:lid]).unpause! + Sidekiq::Periodic::Loop.new(route_params(:lid)).unpause! return redirect "#{root_path}loops" end @@ -87,7 +87,11 @@ def self.use! require("sidekiq-ent/periodic/manager") require("sidekiq-ent/periodic/static_loop") - Sidekiq::Web.register(Sidekiq::Belt::Ent::PeriodicPause::SidekiqLoopsPeriodicPause) + Sidekiq::Web.configure do |cfg| + cfg.register(Sidekiq::Belt::Ent::PeriodicPause::SidekiqLoopsPeriodicPause, name: "periodic_pause", + tab: nil, index: nil) + end + Sidekiq::Periodic::Loop.prepend(Sidekiq::Belt::Ent::PeriodicPause) Sidekiq::Periodic::StaticLoop.prepend(Sidekiq::Belt::Ent::PeriodicPause) Sidekiq::Periodic::Manager.prepend(Sidekiq::Belt::Ent::PeriodicPause::PauseServer) diff --git a/lib/sidekiq/belt/ent/periodic_run.rb b/lib/sidekiq/belt/ent/periodic_run.rb index 4623357..dede508 100644 --- a/lib/sidekiq/belt/ent/periodic_run.rb +++ b/lib/sidekiq/belt/ent/periodic_run.rb @@ -66,7 +66,7 @@ def self.registered(app) end app.post("/loops/:lid/run") do - Sidekiq::Periodic::Loop.new(params[:lid]).run + Sidekiq::Periodic::Loop.new(route_params(:lid)).run return redirect "#{root_path}loops" end @@ -78,7 +78,10 @@ def self.use! require("sidekiq-ent/periodic") require("sidekiq-ent/periodic/static_loop") - Sidekiq::Web.register(Sidekiq::Belt::Ent::PeriodicRun::SidekiqLoopsPeriodicRun) + Sidekiq::Web.configure do |cfg| + cfg.register(Sidekiq::Belt::Ent::PeriodicRun::SidekiqLoopsPeriodicRun, name: "periodic_run", tab: nil, + index: nil) + end Sidekiq::Periodic::Loop.prepend(Sidekiq::Belt::Ent::PeriodicRun) Sidekiq::Periodic::StaticLoop.prepend(Sidekiq::Belt::Ent::PeriodicRun) end diff --git a/lib/sidekiq/belt/pro/failed_batch_remove.rb b/lib/sidekiq/belt/pro/failed_batch_remove.rb index c396663..bb82dad 100644 --- a/lib/sidekiq/belt/pro/failed_batch_remove.rb +++ b/lib/sidekiq/belt/pro/failed_batch_remove.rb @@ -26,7 +26,7 @@ def self.registered(app) end app.post("/batches/:bid/remove") do - Sidekiq::Batch::Status.new(params[:bid]).delete + Sidekiq::Batch::Status.new(route_params(:bid)).delete return redirect "#{root_path}batches" end @@ -36,7 +36,10 @@ def self.registered(app) def self.use! require("sidekiq/web") - Sidekiq::Web.register(Sidekiq::Belt::Pro::FailedBatchRemove::SidekiqFailedBatchRemove) + Sidekiq::Web.configure do |cfg| + cfg.register(Sidekiq::Belt::Pro::FailedBatchRemove::SidekiqFailedBatchRemove, name: "remove_batch", + tab: nil, index: nil) + end end end end diff --git a/lib/sidekiq/belt/pro/force_batch_callback.rb b/lib/sidekiq/belt/pro/force_batch_callback.rb index a56a97d..c86ce8e 100644 --- a/lib/sidekiq/belt/pro/force_batch_callback.rb +++ b/lib/sidekiq/belt/pro/force_batch_callback.rb @@ -37,7 +37,7 @@ def self.registered(app) end app.post("/batches/:bid/force_callback/:action") do - Sidekiq::Batch::Callback.perform_inline(params[:action], params[:bid]) + Sidekiq::Batch::Callback.perform_inline(route_params(:action), route_params(:bid)) return redirect "#{root_path}batches" end @@ -47,7 +47,10 @@ def self.registered(app) def self.use! require("sidekiq/web") - Sidekiq::Web.register(Sidekiq::Belt::Pro::ForceBatchCallback::SidekiqForceBatchCallback) + Sidekiq::Web.configure do |cfg| + cfg.register(Sidekiq::Belt::Pro::ForceBatchCallback::SidekiqForceBatchCallback, name: "force_batch", + tab: nil, index: nil) + end end end end diff --git a/lib/sidekiq/belt/version.rb b/lib/sidekiq/belt/version.rb index a90ec1f..f24fd61 100644 --- a/lib/sidekiq/belt/version.rb +++ b/lib/sidekiq/belt/version.rb @@ -2,6 +2,6 @@ module Sidekiq module Belt - VERSION = "1.0.0" + VERSION = "2.0.0" end end diff --git a/lib/sidekiq/web_action_helper.rb b/lib/sidekiq/web_action_helper.rb index 08c8f15..da6950f 100644 --- a/lib/sidekiq/web_action_helper.rb +++ b/lib/sidekiq/web_action_helper.rb @@ -10,7 +10,11 @@ def initialize(content) replace_views = Sidekiq::Config::DEFAULTS[:replace_views] || {} replace_views.each do |key, content_blocks| - next if WebRoute.new("", key, true).match("", self.class.path_info).nil? + if Sidekiq::VERSION.to_i >= 8 + next if Sidekiq::Web::Application.match(self.class.full_env).nil? + elsif WebRoute.new("", key, true).match("", self.class.full_env["PATH_INFO"]).nil? + next + end content_blocks.each do |content_block| content_block.call(content) @@ -21,12 +25,12 @@ def initialize(content) end class << self - attr_accessor :path_info + attr_accessor :full_env end end def erb(content, options = {}) - ERB.path_info = ::Rack::Utils.unescape(env["PATH_INFO"]) + ERB.full_env = env super end @@ -49,5 +53,9 @@ def _render end end - Sidekiq::WebAction.prepend(Sidekiq::WebActionHelper) + if defined?(Sidekiq::Web::Action) + Sidekiq::Web::Action.prepend(Sidekiq::WebActionHelper) + else + Sidekiq::WebAction.prepend(Sidekiq::WebActionHelper) + end end diff --git a/lib/sidekiq/web_router_helper.rb b/lib/sidekiq/web_router_helper.rb index 3a7113f..9342687 100644 --- a/lib/sidekiq/web_router_helper.rb +++ b/lib/sidekiq/web_router_helper.rb @@ -13,5 +13,9 @@ def replace_content(path, &block) end end - Sidekiq::WebRouter.prepend(Sidekiq::WebRouterHelper) + if defined?(Sidekiq::Web::Router) + Sidekiq::Web::Router.prepend(Sidekiq::WebRouterHelper) + else + Sidekiq::WebRouter.prepend(Sidekiq::WebRouterHelper) + end end diff --git a/sidekiq-belt.gemspec b/sidekiq-belt.gemspec index a926e5a..756f99f 100644 --- a/sidekiq-belt.gemspec +++ b/sidekiq-belt.gemspec @@ -15,23 +15,25 @@ Gem::Specification.new do |spec| spec.homepage = "https://github.com/dannnylo/sidekiq-belt" spec.license = "MIT" - spec.required_ruby_version = ">= 2.6.0" + spec.required_ruby_version = ">= 3.0.0" spec.metadata["homepage_uri"] = spec.homepage spec.metadata["source_code_uri"] = spec.homepage + spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md" # Specify which files should be added to the gem when it is released. # The `git ls-files -z` loads the files in the RubyGem that have been added into git. - spec.files = Dir.chdir(__dir__) do - `git ls-files -z`.split("\x0").reject do |f| - (File.expand_path(f) == __FILE__) || - f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci appveyor Gemfile]) + gemspec = File.basename(__FILE__) + spec.files = IO.popen(%w[git ls-files -z], chdir: __dir__, err: IO::NULL) do |ls| + ls.readlines("\x0", chomp: true).reject do |f| + (f == gemspec) || + f.start_with?(*%w[bin/ test/ spec/ features/ .git .circleci .github appveyor Gemfile]) end end spec.bindir = "exe" spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) } spec.require_paths = ["lib"] - spec.add_dependency "sidekiq", "> 7.1.4" + spec.add_dependency "sidekiq", ">= 7.3.8" spec.metadata["rubygems_mfa_required"] = "true" end diff --git a/spec/sidekiq/belt/community/run_job_spec.rb b/spec/sidekiq/belt/community/run_job_spec.rb index acff747..3467341 100644 --- a/spec/sidekiq/belt/community/run_job_spec.rb +++ b/spec/sidekiq/belt/community/run_job_spec.rb @@ -10,7 +10,8 @@ described_class.use! - expect(Sidekiq::Web).to have_received(:register).with(described_class::SidekiqRunJob) + expect(Sidekiq::Web).to have_received(:register).with(described_class::SidekiqRunJob, + { index: "run_jobs", name: "run_jobs", tab: "Run Jobs" }) end it "registers the tab 'Run Jobs' with the path 'run_jobs'" do diff --git a/spec/sidekiq/belt/ent/periodic_pause_spec.rb b/spec/sidekiq/belt/ent/periodic_pause_spec.rb index 33f2af8..bcb9345 100644 --- a/spec/sidekiq/belt/ent/periodic_pause_spec.rb +++ b/spec/sidekiq/belt/ent/periodic_pause_spec.rb @@ -98,7 +98,8 @@ def initialize(lid, klass, options) expect(described_class).to have_received(:require).with("sidekiq-ent/periodic/manager").once expect(described_class).to have_received(:require).with("sidekiq-ent/periodic/static_loop").once - expect(Sidekiq::Web).to have_received(:register).with(described_class::SidekiqLoopsPeriodicPause) + expect(Sidekiq::Web).to have_received(:register).with(described_class::SidekiqLoopsPeriodicPause, + { index: nil, name: "periodic_pause", tab: nil }) expect(Sidekiq::Periodic::Loop).to have_received(:prepend).with(described_class) expect(Sidekiq::Periodic::StaticLoop).to have_received(:prepend).with(described_class) expect(Sidekiq::Periodic::Manager).to have_received(:prepend).with(described_class::PauseServer) diff --git a/spec/sidekiq/belt/ent/periodic_run_spec.rb b/spec/sidekiq/belt/ent/periodic_run_spec.rb index 7a180c2..6e6e622 100644 --- a/spec/sidekiq/belt/ent/periodic_run_spec.rb +++ b/spec/sidekiq/belt/ent/periodic_run_spec.rb @@ -56,7 +56,8 @@ def initialize(lid, klass, options) expect(described_class).to have_received(:require).with("sidekiq-ent/periodic").once expect(described_class).to have_received(:require).with("sidekiq-ent/periodic/static_loop").once - expect(Sidekiq::Web).to have_received(:register).with(described_class::SidekiqLoopsPeriodicRun) + expect(Sidekiq::Web).to have_received(:register).with(described_class::SidekiqLoopsPeriodicRun, + { index: nil, name: "periodic_run", tab: nil }) expect(Sidekiq::Periodic::Loop).to have_received(:prepend).with(described_class) expect(Sidekiq::Periodic::StaticLoop).to have_received(:prepend).with(described_class) end diff --git a/spec/sidekiq/web_action_helper_spec.rb b/spec/sidekiq/web_action_helper_spec.rb index 0aa84ed..ec364bb 100644 --- a/spec/sidekiq/web_action_helper_spec.rb +++ b/spec/sidekiq/web_action_helper_spec.rb @@ -30,7 +30,7 @@ def render(_engine, content, _options = {}) end it "replaces the page content with the block content" do - dummy_web_action::ERB.path_info = "/" + dummy_web_action::ERB.full_env = { "PATH_INFO" => "/" } expect(dummy_web_action::ERB.new("Sidekiq default").result).to eq("Sidekiq replaced twice") end end @@ -41,7 +41,7 @@ def render(_engine, content, _options = {}) end it "replaces the page content with the block content" do - dummy_web_action::ERB.path_info = "/" + dummy_web_action::ERB.full_env = { "PATH_INFO" => "/" } expect(dummy_web_action::ERB.new("Sidekiq default").result).to eq("Sidekiq default") end end