Class: FilterRename::GlobalConfig
- Inherits:
-
Object
- Object
- FilterRename::GlobalConfig
- Defined in:
- lib/filter_rename/config.rb
Overview
Global configurations.
Constant Summary collapse
- OPTIONS =
{ date_format: { args: "FORMAT", desc: "Describes the date FORMAT for <mtime> and <ctime> targets.", long: "This is how the <mtime> and <ctime> targets will be formatted\n" \ "for each file read, unless the *essential_tags* option is on.\n" \ "The allowed placeholders are prefixed with a percentage % char\n" \ "and are the same used by the *date* command.\n" \ "Use the *date* man page to get more info.", default: "%Y-%m-%d" }, hash_type: { args: "ALGORITHM", desc: "Use one of the ALGORITHM among sha1, sha2, md5 to create the <hash> target.", long: "It preloads the <hash> target with one of the allowed value\n" \ "sha1, sha2, or md5.\n" \ "Just as reminder, md5 is the less safe but the quicker to be\n" \ "executed, sha2 is the slowest but the safest.", default: "md5" }, hash_on_tags: { args: nil, desc: "Enable or not the hash calculation for each file.", long: "Hash calculation can be expensive, that's why it is disabled\n" \ "by default and the <hash> target is not created.", default: false }, hash_if_exists: { args: nil, desc: "Prints the hash code in case the file exists.", long: "This option shows the hash of the two files when the *dry* or\n" \ "*apply* operation is running and a conflict is raised.\n" \ "Looking at the hash code would be easier to understand wheter or\n" \ "not the renaming failure is caused by two clones or two totally\n" \ "different files that the chain of filters accidentally transformed\n" \ "in the same filename.", default: true }, counter_length: { args: "NUMBER", desc: "The minimum length of the counter padded by zeros.", long: "This is the length of the counter in terms of total NUMBER of\n" \ "chars rendered.\n" \ "It means that, when the counter length is less than NUMBER, a certain\n" \ "number of '0' is prepended to the counter to cover the difference.", default: "3" }, counter_start: { args: "NUMBER", desc: "Start the <count> target from NUMBER+1.", long: "This is the way to set the internal counter, that affect the <count>\n" \ "target, to a specific position.\n" \ "Be aware that, for technical reasons, it will start from NUMBER+1,\n" \ "so to have 0 for the first element just set NUMBER to -1", default: "0" }, inline_targets: { args: nil, desc: "Print the targets' list inline or in a column.", long: "This option affects the way the target's list for each file is shown:\n" \ "a *short* list where the data is in the same line, one for RW targets\n" \ "and one for RO targets, or a *long* list where the data is in column.", default: true }, pdf_metadata: { args: nil, desc: "Create the targets from the PDF files metadata.", long: "This option enable the generation of targets from the metadata\n" \ "embedded in the PDF files.", default: true }, image_metadata: { args: nil, desc: "Create the targets from the image files metadata.", long: "This option enable the generation of targets from the metadata\n" \ "embedded in the supported image files.", default: true }, audio_metadata: { args: nil, desc: "Create the targets from the audio files metadata.", long: "This option enable the generation of targets from the metadata\n" \ "embedded in the supported audio files.", default: true }, mimemagic: { args: nil, desc: "Create the extra targets depending from the file's mimetype.", long: "Disabling it, disable all the extra targets' calculation\n" \ "based on the file's mimetype.", default: true }, essential_tags: { args: nil, desc: "Define whether or not to enable only essential targets.", long: "Setting it to true the basic targets only which involve\n" \ "the file name, path, and extension, will be calculated.\n" \ "This is useful to use less memory or to skip\n" \ "those data that can't be calculated in case of a file list\n" \ "is served by the pipeline.", default: false }, check_source: { args: nil, desc: "Define whether or not to enable the source files checking.", long: "Setting it to false the source files aren't checked out\n" \ "and a list of files not necessarily in the same machine\n" \ "could be provided using the pipeline as an input.\n" \ "Combined with essential_tags to true and mimemagic to false\n" \ "is useful to avoid errors in that last scenario.", default: true } }.freeze
Instance Method Summary collapse
-
#initialize(cfg) ⇒ GlobalConfig
constructor
rubocop:disable Style/RedundantCondition.
Constructor Details
#initialize(cfg) ⇒ GlobalConfig
rubocop:disable Style/RedundantCondition
152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 |
# File 'lib/filter_rename/config.rb', line 152 def initialize(cfg) @date_format = cfg[:date_format] || "%Y-%m-%d" @hash_type = cfg[:hash_type].nil? ? :md5 : cfg[:hash_type].to_sym = cfg[:hash_on_tags] || false @hash_if_exists = cfg[:hash_if_exists] || true @counter_length = cfg[:counter_length] || 3 @counter_start = cfg[:counter_start] || 0 @inline_targets = cfg[:inline_targets].nil? ? true : cfg[:inline_targets].to_boolean = cfg[:pdf_metadata].nil? ? true : cfg[:pdf_metadata].to_boolean = cfg[:image_metadata].nil? ? true : cfg[:image_metadata].to_boolean = cfg[:audio_metadata].nil? ? true : cfg[:audio_metadata].to_boolean @mimemagic = cfg[:mimemagic].nil? ? true : cfg[:mimemagic].to_boolean = cfg[:essential_tags].nil? ? false : cfg[:essential_tags].to_boolean @check_source = cfg[:check_source].nil? ? true : cfg[:check_source].to_boolean end |