Sha256: c82db2e2c70435cc26ac3fc8cee1483f2d6d3aba2d641f56a6c6e788a6fc2fd0

Contents?: true

Size: 1.03 KB

Versions: 2

Compression:

Stored size: 1.03 KB

Contents

require 'evrone/ci/message'
require 'evrone/ci/common'

module Evrone
  module CI
    module Worker
      class Job

        include Helper::Logger

        attr_reader :output, :message, :output_counter

        def initialize(perform_job_message)
          @output_counter = 0
          @output         = ""
          @message        = perform_job_message
        end

        def add_to_output(str)
          output << str
          logger.debug str.strip if logger.level == 0
          JobLogsConsumer.publish create_job_log_message(str)
        end

        def add_command_to_output(cmd)
          add_to_output "$ #{cmd}\n"
        end

        def add_trace_to_output(log)
          add_to_output log.split(/\n/).map{|i| " ===> #{i}\n" }.join
        end

        def create_job_log_message(data)
          @output_counter += 1
          Message::JobLog.new(
            build_id: message.id,
            job_id:   message.job_id,
            tm:       @output_counter,
            log:      data
          )
        end

      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
evrone-ci-worker-0.2.0.pre4 lib/evrone/ci/worker/job.rb
evrone-ci-worker-0.2.0.pre3 lib/evrone/ci/worker/job.rb