Sha256: 40d1d9ec15cf286fc04c2d0c843ab7f7e1921e3494a8e6368f1289663be9bd5e
Contents?: true
Size: 1.24 KB
Versions: 17
Compression:
Stored size: 1.24 KB
Contents
# frozen_string_literal: true module Buildkite module Pipelines class Command BIN_PATH = 'buildkite-agent' def self.pipeline!(*args) abort unless pipeline(*args) end def self.pipeline(subcommand, *args) new(:pipeline, subcommand, *args).run end def self.artifact!(*args) abort unless artifact(*args) end def self.artifact(subcommand, *args) new(:artifact, subcommand, *args).run end def initialize(command, subcommand, *args) @command = command.to_s @subcommand = subcommand.to_s @options = extract_options(args) @args = transform_args(args) end def run system(*to_a) end private def to_a command = [BIN_PATH, @command, @subcommand] command.concat(@options.to_a.flatten) command.concat(@args) end def extract_options(args) return {} unless args.first.is_a?(Hash) args.shift.tap do |options| options.transform_keys! do |key| "--#{key.to_s.tr('_', '-')}" end options.transform_values!(&:to_s) end end def transform_args(args) args.map!(&:to_s) end end end end
Version data entries
17 entries across 17 versions & 1 rubygems