Class: Danger::Init

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

Instance Method Summary collapse

Methods inherited from Runner

options, #post_results

Constructor Details

#initialize(argv) ⇒ Init

Returns a new instance of Init.



6
7
8
9
# File 'lib/danger/commands/init.rb', line 6

def initialize(argv)
  @dangerfile_path = "Dangerfile" if File.exist? "Dangerfile"
  super
end

Instance Method Details

#runObject



17
18
19
20
21
22
23
# File 'lib/danger/commands/init.rb', line 17

def run
  dir = Danger.gem_path

  content = File.read(File.join(dir, "lib", "assets", "DangerfileTemplate"))
  File.write("Dangerfile", content)
  puts "Successfully created 'Dangerfile'"
end

#validate!Object



11
12
13
14
15
# File 'lib/danger/commands/init.rb', line 11

def validate!
  if @dangerfile_path
    help! "Found an existing Dangerfile."
  end
end