Class: Epuber::Compiler::FileTypes::SourceFile

Inherits:
AbstractFile
  • Object
show all
Defined in:
lib/epuber/compiler/file_types/source_file.rb

Instance Attribute Summary collapse

Attributes inherited from AbstractFile

#destination_path, #final_destination_path, #group, #path_type, #pkg_destination_path, #properties

Instance Method Summary collapse

Methods inherited from AbstractFile

#==, file_copy, file_copy!, file_copy?, write_to_file, write_to_file!, write_to_file?

Constructor Details

#initialize(source_path) ⇒ SourceFile

Returns a new instance of SourceFile.

Parameters:

  • source_path (String)

    relative path from project root to source file



25
26
27
# File 'lib/epuber/compiler/file_types/source_file.rb', line 25

def initialize(source_path)
  @source_path = source_path
end

Instance Attribute Details

#abs_source_pathString

Returns absolute source path.

Returns:

  • (String)

    absolute source path



17
18
19
# File 'lib/epuber/compiler/file_types/source_file.rb', line 17

def abs_source_path
  @abs_source_path
end

#file_requestEpuber::Book::FileRequest



21
22
23
# File 'lib/epuber/compiler/file_types/source_file.rb', line 21

def file_request
  @file_request
end

#source_pathString (readonly)

Returns relative source path.

Returns:

  • (String)

    relative source path



13
14
15
# File 'lib/epuber/compiler/file_types/source_file.rb', line 13

def source_path
  @source_path
end

Instance Method Details

#default_file_copyObject



29
30
31
32
33
34
# File 'lib/epuber/compiler/file_types/source_file.rb', line 29

def default_file_copy
  if self.class.file_copy?(abs_source_path, final_destination_path)
    UI.print_processing_debug_info("Copying to #{pkg_destination_path}")
    self.class.file_copy!(abs_source_path, final_destination_path)
  end
end

#write_compiled(content) ⇒ Object



36
37
38
39
40
41
# File 'lib/epuber/compiler/file_types/source_file.rb', line 36

def write_compiled(content)
  if self.class.write_to_file?(content, final_destination_path)
    UI.print_processing_debug_info("Writing compiled version to #{pkg_destination_path}")
    self.class.write_to_file!(content, final_destination_path)
  end
end

#write_processed(content) ⇒ Object



43
44
45
46
47
48
# File 'lib/epuber/compiler/file_types/source_file.rb', line 43

def write_processed(content)
  if self.class.write_to_file?(content, final_destination_path)
    UI.print_processing_debug_info("Writing processed version to #{pkg_destination_path}")
    self.class.write_to_file!(content, final_destination_path)
  end
end