Sha256: cdbb29f8be153834dba663bf0cafc5211e7394f8b4fdd352e58abc69b1ba246c

Contents?: true

Size: 962 Bytes

Versions: 2

Compression:

Stored size: 962 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?
      `git remote get-url origin` =~ /^git@github\.com/
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bard-0.51.0 lib/bard/ci.rb
bard-0.50.5 lib/bard/ci.rb