Class: GemBootstrap::FileConflictManager Private

Inherits:
Object
  • Object
show all
Defined in:
lib/gem-bootstrap/file_conflict_manager.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary collapse

PROMPT =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

'Overwrite %<path>s? (enter "h" for help) [ynaqdh]: '

Instance Method Summary collapse

Constructor Details

#initialize(io:) ⇒ FileConflictManager

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of FileConflictManager.



11
12
13
14
# File 'lib/gem-bootstrap/file_conflict_manager.rb', line 11

def initialize(io:)
  @io = io
  @overwrite_all = false
end

Instance Method Details

#overwrite_all?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


17
18
19
# File 'lib/gem-bootstrap/file_conflict_manager.rb', line 17

def overwrite_all?
  @overwrite_all
end

#should_overwrite?(file_path, old_contents, new_contents) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns true if the file should be overwritten

Returns:

  • (Boolean)

    Returns true if the file should be overwritten



22
23
24
25
26
27
28
# File 'lib/gem-bootstrap/file_conflict_manager.rb', line 22

def should_overwrite?(file_path, old_contents, new_contents)
  if @overwrite_all
    true
  else
    ask(file_path, old_contents, new_contents)
  end
end