class Pandocomatic::Command
Command
is a base class of all actions pandocomatic executes while converting a file or a directory of files.
@!attribute errors
@return [Error[]] list of errors created while preparing and running a command
@!attribute index
@return [Number] the index of this Command in the list with all commands to run when running pandocomatic.
Attributes
Public Class Methods
Create a new Command
# File lib/pandocomatic/command/command.rb, line 46 def initialize @errors = [] @@total += 1 @index = @@total end
Reset all Commands
@param configuration [Configuration] the configuration used to convert
# File lib/pandocomatic/command/command.rb, line 55 def self.reset(configuration) @@src_root = configuration.src_root @@dry_run = configuration.dry_run? @@quiet = configuration.quiet? @@modified_only = configuration.modified_only? @@total = 0 end
Public Instance Methods
Is this Command
converting a directory?
@return [Boolean] false
# File lib/pandocomatic/command/command.rb, line 148 def directory? false end
Does this Command
not actually execute?
@return [Boolean]
# File lib/pandocomatic/command/command.rb, line 73 def dry_run? @@dry_run end
Is the source file newer than the destination file?
@param src [String] the source file @param dst [String] the destination file
@return [Boolean] True if src has been modified after dst has been last
# File lib/pandocomatic/command/command.rb, line 186 def file_modified?(src, dst) !File.exist? dst or File.mtime(src) > File.mtime(dst) end
Convert this Command’s index to a string representation
@return [String]
# File lib/pandocomatic/command/command.rb, line 114 def index_to_s (@@total - @index + 1).to_s.rjust(@@total.to_s.size) end
Make this Command
run quietly
# File lib/pandocomatic/command/command.rb, line 107 def make_quiet @@quiet = true end
Is this Command
only executed on modified files?
@return [Boolean]
# File lib/pandocomatic/command/command.rb, line 87 def modified_only? @@modified_only end
Does this Command
convert a file multiple times?
@return [Boolean] false
# File lib/pandocomatic/command/command.rb, line 155 def multiple? false end
Is this Command
executed silently?
@return [Boolean]
# File lib/pandocomatic/command/command.rb, line 80 def quiet? @@quiet end
Actually run this Command
# File lib/pandocomatic/command/command.rb, line 128 def run; end
Will this Command
be skipped, thus not executed?
@return [Boolean] false
# File lib/pandocomatic/command/command.rb, line 162 def skip? false end
Get the root directory of this Command’s conversion process
@return [String]
# File lib/pandocomatic/command/command.rb, line 66 def src_root @@src_root end
Create a String representation of this Command
@return [String]
# File lib/pandocomatic/command/command.rb, line 141 def to_s 'command' end
Decrement the total number of conversion commands by 1
# File lib/pandocomatic/command/command.rb, line 167 def uncount @@total -= 1 end