Sha256: 27094fe8e6b56c9fa74e39035700ed68a4a5103eeb641dd9afebc428c14580a4

Contents?: true

Size: 952 Bytes

Versions: 10

Compression:

Stored size: 952 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] => :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

10 entries across 10 versions & 1 rubygems

Version Path
bard-0.51.2 lib/bard/ci.rb
bard-0.51.1 lib/bard/ci.rb
bard-0.50.4 lib/bard/ci.rb
bard-0.50.3 lib/bard/ci.rb
bard-0.50.2 lib/bard/ci.rb
bard-0.50.1 lib/bard/ci.rb
bard-0.50.0 lib/bard/ci.rb
bard-0.49.0 lib/bard/ci.rb
bard-0.48.1 lib/bard/ci.rb
bard-0.48.0 lib/bard/ci.rb