Sha256: a70e63bd2cfc118be32cd218d99e13754bdfd97831f8859bf175076f092a479c

Contents?: true

Size: 1.59 KB

Versions: 1

Compression:

Stored size: 1.59 KB

Contents

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

module Evrone
  module CI
    class Router
      class Build

        include Router::Helper::Logger
        include Router::Helper::Config

        attr_reader :message, :output
        attr_accessor :matrix, :jobs_count, :commit_info

        def initialize(perform_build_message)
          @output  = ''
          @message = perform_build_message
        end

        def to_perform_job_message(travis, job_id)
          queue   = travis.to_queue
          job_message = Message::PerformJob.new(
            id:               message.id,
            name:             message.name,
            src:              message.src,
            sha:              message.sha,
            pull_request_id:  message.pull_request_id,
            deploy_key:       message.deploy_key,
            job_id:           job_id,
            before_script:    queue.to_before_script,
            script:           queue.to_script,
            matrix_keys:      travis.matrix_keys,
          )
          job_message
        end

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

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

        def create_build_log_message(data)
          tm = Time.now
          Message::BuildLog.new(
            build_id:  message.id,
            tm:        tm.to_i,
            tm_usec:   tm.usec,
            log:       data
          )
        end

      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
evrone-ci-router-0.2.0.pre0 lib/evrone/ci/router/build.rb