Class: Danger::DryRun

Inherits:
Runner
  • Object
show all
Defined in:
lib/danger/commands/dry_run.rb

Instance Attribute Summary

Attributes inherited from Runner

#cork

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ DryRun

Returns a new instance of DryRun.



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/danger/commands/dry_run.rb', line 15

def initialize(argv)
  show_help = true if argv.arguments == ["-h"]

  # Currently CLAide doesn't support short option like -h https://github.com/CocoaPods/CLAide/pull/60
  # when user pass in -h, mimic the behavior of passing in --help.
  argv = CLAide::ARGV.new ["--help"] if show_help

  super

  if argv.flag?("pry", false)
    @dangerfile_path = PrySetup.new(cork).setup_pry(@dangerfile_path)
  end
end

Class Method Details

.optionsObject



9
10
11
12
13
# File 'lib/danger/commands/dry_run.rb', line 9

def self.options
  [
    ["--pry", "Drop into a Pry shell after evaluating the Dangerfile."]
  ]
end

Instance Method Details

#runObject



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/danger/commands/dry_run.rb', line 36

def run
  ENV["DANGER_USE_LOCAL_ONLY_GIT"] = "YES"
  ENV["DANGER_LOCAL_HEAD"] = @head if @head
  ENV["DANGER_LOCAL_BASE"] = @base if @base

  env = EnvironmentManager.new(ENV, cork)
  dm = Dangerfile.new(env, cork)

  exit 1 if dm.run(
    Danger::EnvironmentManager.danger_base_branch,
    Danger::EnvironmentManager.danger_head_branch,
    @dangerfile_path,
    nil,
    nil,
    nil
  )
end

#validate!Object



29
30
31
32
33
34
# File 'lib/danger/commands/dry_run.rb', line 29

def validate!
  super
  unless @dangerfile_path
    help! "Could not find a Dangerfile."
  end
end