Class: Thor::Actions::CreateFile

Inherits:
Object
  • Object
show all
Defined in:
lib/thor-ssh/actions/create_file.rb

Direct Known Subclasses

DownloadFile

Instance Method Summary collapse

Instance Method Details

#identical?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/thor-ssh/actions/create_file.rb', line 9

def identical?
  exists? && @base.destination_files.binread(destination) == render
end

#invoke!Object



13
14
15
16
17
18
19
20
# File 'lib/thor-ssh/actions/create_file.rb', line 13

def invoke!
  invoke_with_conflict_check do
    @base.destination_files.mkdir_p(File.dirname(destination))
    @base.destination_files.binwrite(destination, render)
    # @base.destination_files.open(destination, 'wb') { |f| f.write render }
  end
  given_destination
end