Module: JekyllAdmin::FileHelper

Included in:
Server
Defined in:
lib/jekyll-admin/file_helper.rb

Instance Method Summary collapse

Instance Method Details

#delete_file(path) ⇒ Object

Delete the file at the given path



29
30
31
32
33
# File 'lib/jekyll-admin/file_helper.rb', line 29

def delete_file(path)
  Jekyll.logger.debug "DELETING:", path
  FileUtils.rm_f sanitized_path(path)
  conditionally_process_site
end

#delete_file_without_process(path) ⇒ Object



35
36
37
38
# File 'lib/jekyll-admin/file_helper.rb', line 35

def delete_file_without_process(path)
  Jekyll.logger.debug "DELETING:", path
  FileUtils.rm_f sanitized_path(path)
end

#requested_fileObject

The file the user requested in the URL



6
7
8
# File 'lib/jekyll-admin/file_helper.rb', line 6

def requested_file
  find_by_path(path)
end

#write_file(path, content) ⇒ Object

Write a file to disk with the given content



18
19
20
21
22
23
24
25
26
# File 'lib/jekyll-admin/file_helper.rb', line 18

def write_file(path, content)
  Jekyll.logger.debug "WRITING:", path
  path = sanitized_path(path)
  FileUtils.mkdir_p File.dirname(path)
  File.open(path, "wb") do |file|
    file.write(content)
  end
  conditionally_process_site
end

#written_fileObject

The file ultimately written to disk This may be the requested file, or in the case of a rename will be read from the new path that was actually written to disk



13
14
15
# File 'lib/jekyll-admin/file_helper.rb', line 13

def written_file
  find_by_path(write_path)
end