Sha256: e480cd3d62d310f1804f874efa8d47029272c4ba95eaef5f3d62c09fc92d37f7

Contents?: true

Size: 819 Bytes

Versions: 10

Compression:

Stored size: 819 Bytes

Contents

require "open3"

module Bard
  class CI
    class Local < Struct.new(:project_name, :branch, :sha)
      def run
        start

        start_time = Time.new.to_i
        while building?
          elapsed_time = Time.new.to_i - start_time
          yield elapsed_time, nil
          sleep(2)
        end

        @stdin.close
        @console = @stdout_and_stderr.read
        @stdout_and_stderr.close

        success?
      end

      def exists?
        true
      end

      def console
        @console
      end

      private

      def start
        @stdin, @stdout_and_stderr, @wait_thread = Open3.popen2e("CLEAN=true bin/rake ci")
      end

      def building?
        ![nil, false].include?(@wait_thread.status)
      end

      def success?
        @wait_thread.value.success?
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
bard-1.1.2 lib/bard/ci/local.rb
bard-1.1.1 lib/bard/ci/local.rb
bard-1.1.0 lib/bard/ci/local.rb
bard-1.0.8 lib/bard/ci/local.rb
bard-1.0.7 lib/bard/ci/local.rb
bard-1.0.6 lib/bard/ci/local.rb
bard-1.0.5 lib/bard/ci/local.rb
bard-1.0.4 lib/bard/ci/local.rb
bard-1.0.3 lib/bard/ci/local.rb
bard-1.0.2 lib/bard/ci/local.rb