Sha256: 4e7681717e33e51f83dd93a03de000d5730f86024ec6120391c0743492b16163

Contents?: true

Size: 855 Bytes

Versions: 15

Compression:

Stored size: 855 Bytes

Contents

require "open3"

class Bard::CLI < Thor
  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

      attr_accessor :last_response

      private

      def start
        @stdin, @stdout_and_stderr, @wait_thread = Open3.popen2e("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

15 entries across 15 versions & 1 rubygems

Version Path
bard-0.52.2 lib/bard/ci/local.rb
bard-0.52.1 lib/bard/ci/local.rb
bard-0.52.0 lib/bard/ci/local.rb
bard-0.51.2 lib/bard/ci/local.rb
bard-0.51.1 lib/bard/ci/local.rb
bard-0.51.0 lib/bard/ci/local.rb
bard-0.50.5 lib/bard/ci/local.rb
bard-0.50.4 lib/bard/ci/local.rb
bard-0.50.3 lib/bard/ci/local.rb
bard-0.50.2 lib/bard/ci/local.rb
bard-0.50.1 lib/bard/ci/local.rb
bard-0.50.0 lib/bard/ci/local.rb
bard-0.49.0 lib/bard/ci/local.rb
bard-0.48.1 lib/bard/ci/local.rb
bard-0.48.0 lib/bard/ci/local.rb