Class: Newshound::JobReporter
- Inherits:
-
Object
- Object
- Newshound::JobReporter
- Defined in:
- lib/newshound/job_reporter.rb
Instance Attribute Summary collapse
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#job_source ⇒ Object
readonly
Returns the value of attribute job_source.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
- #banner_data ⇒ Object
- #generate_report ⇒ Object (also: #report)
-
#initialize(job_source: nil, configuration: nil, logger: nil) ⇒ JobReporter
constructor
A new instance of JobReporter.
Constructor Details
#initialize(job_source: nil, configuration: nil, logger: nil) ⇒ JobReporter
Returns a new instance of JobReporter.
7 8 9 10 11 |
# File 'lib/newshound/job_reporter.rb', line 7 def initialize(job_source: nil, configuration: nil, logger: nil) @configuration = configuration || Newshound.configuration @job_source = resolve_job_source(job_source) @logger = logger || (defined?(Rails) ? Rails.logger : Logger.new($stdout)) end |
Instance Attribute Details
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
5 6 7 |
# File 'lib/newshound/job_reporter.rb', line 5 def configuration @configuration end |
#job_source ⇒ Object (readonly)
Returns the value of attribute job_source.
5 6 7 |
# File 'lib/newshound/job_reporter.rb', line 5 def job_source @job_source end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
5 6 7 |
# File 'lib/newshound/job_reporter.rb', line 5 def logger @logger end |
Instance Method Details
#banner_data ⇒ Object
30 31 32 33 34 |
# File 'lib/newshound/job_reporter.rb', line 30 def return {queue_stats: {}} unless job_source job_source. end |
#generate_report ⇒ Object Also known as: report
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/newshound/job_reporter.rb', line 13 def generate_report return no_jobs_block unless job_source [ { type: "section", text: { type: "mrkdwn", text: "*📊 Job Queue Status*" } }, job_counts_section, queue_health_section ].compact end |