Class: FilterRename::FilterConfig
- Inherits:
-
Object
- Object
- FilterRename::FilterConfig
- Defined in:
- lib/filter_rename/config.rb
Overview
Filter configurations.
Constant Summary collapse
- OPTIONS =
{ word_separator: { args: "CHARACTER", desc: "Define the CHARACTER that separates two words.", long: "This options affects the way a string is split in words or how the\n" \ "words are joined together.\n" \ "All the filters that operate with words will use this CHARACTER\n" \ "to define the sequence of the word itself which can contain all\n" \ "characters except CHARACTER.", default: " " }, number_separator: { args: "CHARACTER", desc: "Define the CHARACTER to join two or more numbers.", long: "This option configure the CHARACTER that will join two or more\n" \ "numbers in the swap-number filter when an interval is used as\n" \ "first parameter.", default: "." }, # This one is unused # occurrence_separator: { args: "CHARACTER" # default: "-" }, target: { args: "TARGET", desc: "This is the TARGET name where the filters are operating.", long: "Switching to one of the available targets allows to alter their content\n" \ "directly using a chain of filters.\n" \ "Targets can be read-write or read-only: the former type reflects the data\n" \ "that will be write back to the file, the latter can be used to generate\n" \ "other values or be emedded in other targets using the *--template* filter.\n" \ "Also custom targets can be defined just to hold data that could be manipulated\n" \ "easier.\n" \ "This option is the same as using the *--select* filter", default: "name" }, ignore_case: { args: nil, desc: "Ignore or not the character case when searching for strings.", long: "This option allows to ignore the case during the search and replace\n" \ "operations, doesn't matter which type of filter is involved.", default: true }, lang: { args: "LANG", desc: "Set the default LANG code for the *--replace-date* filter.", long: "This option is used by the *--replace-date* filter to translate groups\n" \ "of words containing the months or day of weeks from a language to another\n" \ "where it's not specified.", default: "en" }, grep: { args: "REGEXP", desc: "Limit the file to be changed to only those matching the REGEXP pattern.", long: "This options by default includes from the following filters only those files\n" \ "matching the REGEXP pattern.\n" \ "Depending on the *grep_exclude* option the logic can be inverted and the files\n" \ "matching the REGEXP excluded from the action of the following filters.", default: ".*" }, grep_on_dest: { args: nil, desc: "Execute the *grep* option on the destination filename.", long: "To limit the files to be involved in the changes you can apply the\n" \ "grep option on the source or destination filename.\n" \ "By default it is executed on the source, while this option allows\n" \ "to select the destination.\n" \ "Be aware that the destination changes according to all the previous\n" \ "filters applied.", default: false }, grep_exclude: { args: nil, desc: "Invert the logic to exclude the files matching the regular expression.", long: "With this option the *grep* options will be used to exclude the files\n" \ "matching the regular expression, from the following chain of filters.", default: false }, grep_target: { args: "TARGET", desc: "Use the specific TARGET to match files through the *grep* option.", long: "With this option you can limit the *grep* option to one of the available\n" \ "TARGETs instead of considering the full filename.\n" \ "It comes in handy to focus on specific data contained within a TARGET\n" \ "and the file selection process is exclusively based on that data.", default: "full_filename" } }.freeze
Instance Method Summary collapse
-
#initialize(cfg) ⇒ FilterConfig
constructor
rubocop:disable Style/RedundantCondition.
Constructor Details
#initialize(cfg) ⇒ FilterConfig
rubocop:disable Style/RedundantCondition
245 246 247 248 249 250 251 252 253 254 255 256 257 258 |
# File 'lib/filter_rename/config.rb', line 245 def initialize(cfg) @word_separator = cfg[:word_separator] || " " @number_separator = cfg[:number_separator] || "." # Unused property @occurrence_separator = cfg[:occurrence_separator] || "-" @target = cfg[:target].nil? ? :name : cfg[:target].to_sym @ignore_case = cfg[:ignore_case].nil? ? true : cfg[:ignore_case].to_boolean @lang = (cfg[:lang] || :en).to_sym @macro = cfg[:macro] || {} @grep = cfg[:grep] || ".*" @grep_on_dest = cfg[:grep_on_dest].nil? ? false : cfg[:grep_on_dest].to_boolean @grep_exclude = cfg[:grep_exclude].nil? ? false : cfg[:grep_exclude].to_boolean @grep_target = (cfg[:grep_target] || :full_filename).to_sym end |