module Fixnames::Filters
Public Instance Methods
and_to_dash()
click to toggle source
# File lib/fixnames/filters.rb, line 11 def and_to_dash replace '[-_ ]+and[-_ ]+', '-' end
brackets()
click to toggle source
# File lib/fixnames/filters.rb, line 26 def brackets bop = option.bracket_characters_open.dup bcl = option.bracket_characters_close.dup while bop.length > 0 op = "%03o" % bop.slice!(0,1).bytes.first cl = "%03o" % bcl.slice!(0,1).bytes.first replace "\\#{op}(.+?)\\#{cl}", '-\\1-' end end
camelcase()
click to toggle source
# File lib/fixnames/filters.rb, line 66 def camelcase replace '([a-z])([A-Z])', '\1_\2' fixed.downcase! end
charstrip(chrlist)
click to toggle source
# File lib/fixnames/filters.rb, line 93 def charstrip(chrlist) re = Regexp.escape( if option.charstrip_allow_brackets remove_bracket_characters_from(chrlist) else chrlist end ) remove "[#{re}]" end
checksums()
click to toggle source
# File lib/fixnames/filters.rb, line 36 def checksums remove wrap_brackets('[0-9a-fA-F]{8}') end
expunge(re)
click to toggle source
# File lib/fixnames/filters.rb, line 3 def expunge(re) replace re, option.mendstr end
fix_dashes()
click to toggle source
# File lib/fixnames/filters.rb, line 51 def fix_dashes fixed.squeeze! '-' replace_all '--', '-' remove_all '^-' remove_all '-$' replace_all '-\.', '.' replace_all '\.-', '.' end
fix_dots()
click to toggle source
# File lib/fixnames/filters.rb, line 44 def fix_dots last = fixed.rindex('.') translate '.', '_' replace '(.*)\.(.*\.)', '\1_\2' fixed[last] = '.' if last end
fix_numsep()
click to toggle source
# File lib/fixnames/filters.rb, line 62 def fix_numsep replace '^(\d+)_', '\1-' end
hack_and()
click to toggle source
# File lib/fixnames/filters.rb, line 7 def hack_and replace '&', '_and_' end
junkwords(wordlist)
click to toggle source
# File lib/fixnames/filters.rb, line 71 def junkwords(wordlist) wordlist.each do |word| replace "[_-]#{word}[_-]", '_' remove "[_-]#{word}$" remove "^#{word}[_-]" end end
lowercase()
click to toggle source
# File lib/fixnames/filters.rb, line 40 def lowercase translate 'A-Z', 'a-z' end
semicolon()
click to toggle source
# File lib/fixnames/filters.rb, line 15 def semicolon translate ';', '-' fixed.squeeze! '-' end
whitespace(chrlist)
click to toggle source
# File lib/fixnames/filters.rb, line 79 def whitespace(chrlist) replace "[#{Regexp.escape chrlist}]", '_' remove_all '^_' remove_all '_$' replace_all '_-', '-' replace_all '-_', '-' replace_all '_\.', '.' replace_all '\._', '.' fixed.squeeze! '_' end