Class: Buildkite::Builder::Commands::Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/buildkite/builder/commands/abstract.rb

Direct Known Subclasses

Preview, Run

Constant Summary collapse

PIPELINES_DIRECTORY =
'pipelines'
POSSIBLE_PIPELINE_PATHS =
[
  File.join('.buildkite', Pipeline::PIPELINE_DEFINITION_FILE),
  File.join('buildkite', Pipeline::PIPELINE_DEFINITION_FILE),
  File.join(Pipeline::PIPELINE_DEFINITION_FILE)
].freeze
POSSIBLE_PIPELINES_PATHS =
[
  File.join('.buildkite', PIPELINES_DIRECTORY),
  File.join('buildkite', PIPELINES_DIRECTORY),
  File.join(PIPELINES_DIRECTORY)
].freeze

Class Attribute Summary collapse

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeAbstract

Returns a new instance of Abstract.



31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/buildkite/builder/commands/abstract.rb', line 31

def initialize
  @options = {}

  parser = OptionParser.new do |opts|
    opts.banner = "Usage: buildkite-builder #{command_name} [OPTIONS] [PIPELINE]"

    opts.on('-h', '--help', 'Prints this help') do
      options[:help] = opts
    end

    parse_options(opts)
  end
  parser.parse!
end

Class Attribute Details

.descriptionObject

Returns the value of attribute description.



22
23
24
# File 'lib/buildkite/builder/commands/abstract.rb', line 22

def description
  @description
end

Instance Attribute Details

#optionsObject (readonly)

Returns the value of attribute options.



29
30
31
# File 'lib/buildkite/builder/commands/abstract.rb', line 29

def options
  @options
end

Class Method Details

.executeObject



24
25
26
# File 'lib/buildkite/builder/commands/abstract.rb', line 24

def execute
  new.execute
end

Instance Method Details

#executeObject



46
47
48
49
50
51
52
53
54
55
# File 'lib/buildkite/builder/commands/abstract.rb', line 46

def execute
  if options[:help]
    puts options[:help]
    return
  elsif !pipeline_path
    abort "Unable to find pipeline"
  end

  run
end