Class: Danger::Runner

Inherits:
CLAide::Command
  • Object
show all
Defined in:
lib/danger/commands/runner.rb

Direct Known Subclasses

Init, Local, Systems

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Runner

Returns a new instance of Runner.



28
29
30
31
32
33
34
35
36
37
# File 'lib/danger/commands/runner.rb', line 28

def initialize(argv)
  dangerfile = argv.option("dangerfile", "Dangerfile")
  @dangerfile_path = dangerfile if File.exist? dangerfile
  @base = argv.option("base")
  @head = argv.option("head")
  @danger_id = argv.option("danger_id", "danger")
  @cork = Cork::Board.new(silent: argv.option("silent", false),
                          verbose: argv.option("verbose", false))
  super
end

Instance Attribute Details

#corkObject

Returns the value of attribute cork.



20
21
22
# File 'lib/danger/commands/runner.rb', line 20

def cork
  @cork
end

Class Method Details

.optionsObject



46
47
48
49
50
51
52
53
# File 'lib/danger/commands/runner.rb', line 46

def self.options
  [
    ["--base=[master|dev|stable]", "A branch/tag/commit to use as the base of the diff"],
    ["--head=[master|dev|stable]", "A branch/tag/commit to use as the head"],
    ["--dangerfile=<path/to/dangerfile>", "The location of your Dangerfile"],
    ["--danger_id=<id>", "The identifier of this Danger instance"]
  ].concat(super)
end

Instance Method Details

#runObject



55
56
57
58
59
60
# File 'lib/danger/commands/runner.rb', line 55

def run
  Executor.new(ENV).run(base: @base,
                   head: @head,
                   dangerfile_path: @dangerfile_path,
                   danger_id: @danger_id)
end

#validate!Object



39
40
41
42
43
44
# File 'lib/danger/commands/runner.rb', line 39

def validate!
  super
  if self.class == Runner && !@dangerfile_path
    help! "Could not find a Dangerfile."
  end
end