Module: Wukong::Deploy::ConflictResolution

Included in:
Templater
Defined in:
lib/wukong-deploy/templater/conflict_resolution.rb

Instance Method Summary collapse

Instance Method Details

#always_replace!Object



27
28
29
# File 'lib/wukong-deploy/templater/conflict_resolution.rb', line 27

def always_replace!
  @always_replace = true
end

#always_replace?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/wukong-deploy/templater/conflict_resolution.rb', line 23

def always_replace?
  @always_replace || options[:force]
end

#handle_conflict(new_content, path) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/wukong-deploy/templater/conflict_resolution.rb', line 7

def handle_conflict(new_content, path)
  existing_content = File.read(path)
  case
  when new_content == existing_content
    message_same(path)
  when always_replace?
    message_replace(path)
    write_file(new_content, path)
  when never_replace?
    message_skip(path)
  else
    message_conflict(path)
    diff!(new_content, existing_content, path)
  end
end

#never_replace!Object



35
36
37
# File 'lib/wukong-deploy/templater/conflict_resolution.rb', line 35

def never_replace!
  @never_replace = true
end

#never_replace?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/wukong-deploy/templater/conflict_resolution.rb', line 31

def never_replace?
  @never_replace || options[:skip]
end