Sha256: ad404248ca3a2f02126fc445720a6fa33e9dc188519e22bde32d6bc34aab4b4f

Contents?: true

Size: 961 Bytes

Versions: 12

Compression:

Stored size: 961 Bytes

Contents

require "forwardable"

class Bard::CLI < Thor
  class CI
    def initialize project_name, branch, local: false
      @project_name = project_name
      @branch = branch
      @local = !!local
    end

    attr_reader :project_name, :branch, :runner

    def sha
      @sha ||= `git rev-parse #{branch}`.chomp
    end

    def runner
      @runner ||= choose_runner_class.new(project_name, branch, sha)
    end

    extend Forwardable
    delegate [:run, :exists?, :console, :last_response, :status] => :runner

    private

    def choose_runner_class
      if local?
        require_relative "./ci/local"
        Local
      else
        if github_actions?
          require_relative "./ci/github_actions"
          GithubActions
        else
          require_relative "./ci/jenkins"
          Jenkins
        end
      end
    end

    def local?
      @local
    end

    def github_actions?
      File.exist?(".github/workflows/ci.yml")
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
bard-0.59.2 lib/bard/ci.rb
bard-0.59.1 lib/bard/ci.rb
bard-0.59.0 lib/bard/ci.rb
bard-0.58.0 lib/bard/ci.rb
bard-0.57.0 lib/bard/ci.rb
bard-0.56.0 lib/bard/ci.rb
bard-0.55.0 lib/bard/ci.rb
bard-0.54.0 lib/bard/ci.rb
bard-0.53.0 lib/bard/ci.rb
bard-0.52.2 lib/bard/ci.rb
bard-0.52.1 lib/bard/ci.rb
bard-0.52.0 lib/bard/ci.rb