Module: SidekiqWebWorkers

Defined in:
lib/sidekiq-web-workers.rb,
lib/sidekiq-web-workers/web.rb,
lib/sidekiq-web-workers/version.rb,
lib/sidekiq-web-workers/job_runner.rb

Defined Under Namespace

Modules: Web Classes: JobRunner

Constant Summary collapse

VERSION =
"1.3.2"

Class Method Summary collapse

Class Method Details

.config_pathObject



34
35
36
# File 'lib/sidekiq-web-workers.rb', line 34

def self.config_path
  @config_root&.join("config", "sidekiq_web_jobs.yml")
end

.config_root=(path = Rails.root) ⇒ Object



15
16
17
18
# File 'lib/sidekiq-web-workers.rb', line 15

def self.config_root=(path = Rails.root)
  @config_root = path if path.is_a? Pathname
  @config_root = Pathname.new(path)
end

.jobsObject



11
12
13
# File 'lib/sidekiq-web-workers.rb', line 11

def self.jobs
  @jobs ||= load_jobs.uniq
end

.load_jobsObject



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/sidekiq-web-workers.rb', line 20

def self.load_jobs
  if config_path.present?
    YAML.load_file(config_path)
  else
    []
  end
rescue Errno::ENOENT
  Sidekiq.logger.warn("YAML configuration file couldn't be found")
  []
rescue Psych::SyntaxError
  Sidekiq.logger.warn("YAML configuration file contains invalid syntax")
  []
end

.search_jobs(search_text) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/sidekiq-web-workers.rb', line 38

def self.search_jobs(search_text)
  job_names = SidekiqWebWorkers.jobs
  return job_names unless search_text.present?

  job_names.map{ |job_name| JobPresenter.new(job_name) }
    .delete_if(&:empty?)
    .find_all { |job| job.include?(search_text) }
end