class Epuber::Compiler::FileTypes::AbstractFile
Attributes
@return [Epuber::Compiler::CompilationContext] non-nil value only during process() method
@return [String] relative destination path
@return [String] final absolute destination path calculated by FileResolver
@return [Symbol] group of this file (:text, :image, :font, …), see Epuber::Compiler::FileFinder::GROUP_EXTENSIONS
@return [Symbol] type of path, one of :spine, :manifest, :package
@return [String] final relative destination path from root of the package calculated by FileResolver
@return [Set<Symbol>] list of properties
Public Class Methods
@param [String] source_path @param [String] dest_path
@return nil
# File lib/epuber/compiler/file_types/abstract_file.rb, line 56 def self.file_copy!(source_path, dest_path) FileUtils.mkdir_p(File.dirname(dest_path)) FileUtils.cp(source_path, dest_path) end
@param [String | to_s] content anything, that can be converted to string and should be written to file @param [String] to_path destination path
@return nil
# File lib/epuber/compiler/file_types/abstract_file.rb, line 78 def self.write_to_file(content, to_path) return unless write_to_file?(content, to_path) write_to_file!(content, to_path) end
@param [String | to_s] content anything, that can be converted to string and should be written to file @param [String] to_path destination path
@return nil
# File lib/epuber/compiler/file_types/abstract_file.rb, line 89 def self.write_to_file!(content, to_path) FileUtils.mkdir_p(File.dirname(to_path)) File.open(to_path, 'w') do |file_handle| file_handle.write(content) end end
@param [String | to_s] content anything, that can be converted to string and should be written to file @param [String] to_path destination path
@return nil
# File lib/epuber/compiler/file_types/abstract_file.rb, line 67 def self.write_to_file?(content, to_path) return true unless File.exists?(to_path) File.read(to_path) != content.to_s end
Public Instance Methods
# File lib/epuber/compiler/file_types/abstract_file.rb, line 44 def ==(other) self.class == other.class && final_destination_path == other.final_destination_path end