Class: Semaph::Shells::Pipeline::JobLogGrepCommand
- Inherits:
-
Object
- Object
- Semaph::Shells::Pipeline::JobLogGrepCommand
- Defined in:
- lib/semaph/shells/pipeline/job_log_grep_command.rb
Instance Attribute Summary collapse
-
#help ⇒ Object
readonly
Returns the value of attribute help.
-
#job_collection ⇒ Object
readonly
Returns the value of attribute job_collection.
-
#usage ⇒ Object
readonly
Returns the value of attribute usage.
Instance Method Summary collapse
- #execute(expression) ⇒ Object
-
#initialize(job_collection, scope) ⇒ JobLogGrepCommand
constructor
A new instance of JobLogGrepCommand.
Constructor Details
#initialize(job_collection, scope) ⇒ JobLogGrepCommand
Returns a new instance of JobLogGrepCommand.
7 8 9 10 11 12 |
# File 'lib/semaph/shells/pipeline/job_log_grep_command.rb', line 7 def initialize(job_collection, scope) @job_collection = job_collection @scope = scope @usage = "<expression>" @help = "retrieve logs for #{scope} jobs and grep for text" end |
Instance Attribute Details
#help ⇒ Object (readonly)
Returns the value of attribute help.
5 6 7 |
# File 'lib/semaph/shells/pipeline/job_log_grep_command.rb', line 5 def help @help end |
#job_collection ⇒ Object (readonly)
Returns the value of attribute job_collection.
5 6 7 |
# File 'lib/semaph/shells/pipeline/job_log_grep_command.rb', line 5 def job_collection @job_collection end |
#usage ⇒ Object (readonly)
Returns the value of attribute usage.
5 6 7 |
# File 'lib/semaph/shells/pipeline/job_log_grep_command.rb', line 5 def usage @usage end |
Instance Method Details
#execute(expression) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/semaph/shells/pipeline/job_log_grep_command.rb', line 14 def execute(expression) base = "tmp/logs/pipeline/#{job_collection.pipeline.id}" @job_collection.send(@scope).each do |job| unless job.finished? puts "skipping incomplete job #{job.id}" next end job.write_log(base) end system("ag #{expression} #{base} | less") end |