Sha256: c39d661996fdc2cca30272539ffa934fa7b50b6feef1793719a37eac1e294f65

Contents?: true

Size: 1.14 KB

Versions: 23

Compression:

Stored size: 1.14 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
          @message        = perform_job_message
          @output         = Common::OutputBuffer.new(&method(:publish_job_log_message))
        end

        def add_to_output(str)
          output << str
          logger.debug str.strip if logger.level == 0
        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 release
          output.close
        end

        def publish_job_log_message(str)
          @output_counter += 1
          log = Message::JobLog.new(
            build_id: message.id,
            job_id:   message.job_id,
            tm:       output_counter,
            log:      str
          )
          JobLogsConsumer.publish log
          log
        end

      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
evrone-ci-worker-0.2.0.pre28 lib/evrone/ci/worker/job.rb
evrone-ci-worker-0.2.0.pre27 lib/evrone/ci/worker/job.rb
evrone-ci-worker-0.2.0.pre26 lib/evrone/ci/worker/job.rb
evrone-ci-worker-0.2.0.pre25 lib/evrone/ci/worker/job.rb
evrone-ci-worker-0.2.0.pre24 lib/evrone/ci/worker/job.rb
evrone-ci-worker-0.2.0.pre23 lib/evrone/ci/worker/job.rb
evrone-ci-worker-0.2.0.pre22 lib/evrone/ci/worker/job.rb
evrone-ci-worker-0.2.0.pre21 lib/evrone/ci/worker/job.rb
evrone-ci-worker-0.2.0.pre20 lib/evrone/ci/worker/job.rb
evrone-ci-worker-0.2.0.pre19 lib/evrone/ci/worker/job.rb
evrone-ci-worker-0.2.0.pre18 lib/evrone/ci/worker/job.rb
evrone-ci-worker-0.2.0.pre17 lib/evrone/ci/worker/job.rb
evrone-ci-worker-0.2.0.pre15 lib/evrone/ci/worker/job.rb
evrone-ci-worker-0.2.0.pre14 lib/evrone/ci/worker/job.rb
evrone-ci-worker-0.2.0.pre13 lib/evrone/ci/worker/job.rb
evrone-ci-worker-0.2.0.pre12 lib/evrone/ci/worker/job.rb
evrone-ci-worker-0.2.0.pre11 lib/evrone/ci/worker/job.rb
evrone-ci-worker-0.2.0.pre10 lib/evrone/ci/worker/job.rb
evrone-ci-worker-0.2.0.pre9 lib/evrone/ci/worker/job.rb
evrone-ci-worker-0.2.0.pre8 lib/evrone/ci/worker/job.rb