lib/travis/cli/logs.rb in travis-1.11.1 vs lib/travis/cli/logs.rb in travis-1.12.0
- old
+ new
@@ -1,15 +1,21 @@
+# frozen_string_literal: true
+
require 'travis/cli'
require 'travis/tools/safe_string'
require 'travis/tools/system'
module Travis
module CLI
class Logs < RepoCommand
attr_accessor :delete, :reason
- description "streams test logs"
- on('-d', '--delete [REASON]', 'remove logs') { |c, reason| c.delete, c.reason = true, reason }
+
+ description 'streams test logs'
+ on('-d', '--delete [REASON]', 'remove logs') do |c, reason|
+ c.delete = true
+ c.reason = reason
+ end
on('-f', '--force', 'do not ask user to confirm deleting the logs')
on('--[no-]stream', 'only print current logs, do not stream')
def setup
super
@@ -23,21 +29,23 @@
delete ? delete_log(job) : display_log(job)
end
def delete_log(job)
unless force?
- error "not deleting logs without --force" unless interactive?
- error "aborted" unless danger_zone? "Do you really want to delete the build log for #{color(job.inspect_info, :underline)}?"
+ error 'not deleting logs without --force' unless interactive?
+ error 'aborted' unless danger_zone? "Do you really want to delete the build log for #{color(job.inspect_info,
+ :underline)}?"
end
- warn "deleting log for #{color(job.inspect_info, [:bold, :info])}"
+ warn "deleting log for #{color(job.inspect_info, %i[bold info])}"
job.delete_log(reason || {})
end
def display_log(job)
- info "displaying logs for #{color(job.inspect_info, [:bold, :info])}"
+ info "displaying logs for #{color(job.inspect_info, %i[bold info])}"
return print_log(job.log.body) unless stream?
+
job.log.body { |part| print_log(part) }
ensure
print "\e[0m" if interactive?
end
@@ -45,21 +53,22 @@
print interactive? ? encoded(part) : clean(part)
end
private
- def job(number)
- number = last_build.number + number if number.start_with? '.'
- job = super(number) || build(number) || branch(number)
- job = job.jobs.first if job.respond_to? :jobs
- job
- end
+ def job(number)
+ number = last_build.number + number if number.start_with? '.'
+ job = super(number) || build(number) || branch(number)
+ job = job.jobs.first if job.respond_to? :jobs
+ job
+ end
- def check_websocket
- require 'websocket-native' if stream?
- rescue LoadError => e
- raise e if e.respond_to?(:path) and e.path != 'websocket-native'
- info "speed up log streaming by installing the websocket-native gem"
- end
+ def check_websocket
+ require 'websocket-native' if stream?
+ rescue LoadError => e
+ raise e if e.respond_to?(:path) && (e.path != 'websocket-native')
+
+ info 'speed up log streaming by installing the websocket-native gem'
+ end
end
end
-end
\ No newline at end of file
+end