Module: Fixnames::Filters

Included in:
Engine
Defined in:
lib/fixnames/filters.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) banners



16
17
18
19
20
# File 'lib/fixnames/filters.rb', line 16

def banners
  option.banner_types.each do |x|
    remove_bracket_ranges(x)
  end
end

- (Object) brackets



22
23
24
# File 'lib/fixnames/filters.rb', line 22

def brackets
  remove wrap_brackets('.+?')
end

- (Object) camelcase



47
48
49
50
# File 'lib/fixnames/filters.rb', line 47

def camelcase
  replace '([a-z])([A-Z])', '\1_\2'
  fixed.downcase!
end

- (Object) charstrip(chrlist)



70
71
72
73
74
75
76
77
# File 'lib/fixnames/filters.rb', line 70

def charstrip(chrlist)
  re = Regexp.escape( if option.charstrip_allow_brackets
                        remove_bracket_characters_from(chrlist)
                      else
                        chrlist
                      end )
  remove "[#{re}]"
end

- (Object) checksums



26
27
28
# File 'lib/fixnames/filters.rb', line 26

def checksums
  remove wrap_brackets('[0-9a-fA-F]{8}')
end

- (Object) expunge(re)



3
4
5
# File 'lib/fixnames/filters.rb', line 3

def expunge(re)
  replace re, option.mendstr
end

- (Object) fix_dashes



41
42
43
44
45
# File 'lib/fixnames/filters.rb', line 41

def fix_dashes
  fixed.squeeze! '-'
  remove  '^-' while fixed =~ /^-/
  remove  '-$' while fixed =~ /-$/
end

- (Object) fix_dots



34
35
36
37
38
39
# File 'lib/fixnames/filters.rb', line 34

def fix_dots
  last = fixed.rindex('.')
  translate '.', '_'
  replace '(.*)\.(.*\.)', '\1_\2'
  fixed[last] = '.' if last
end

- (Object) hack_and



7
8
9
# File 'lib/fixnames/filters.rb', line 7

def hack_and
  replace '&', '_and_'
end

- (Object) junkwords(wordlist)



52
53
54
55
56
57
58
# File 'lib/fixnames/filters.rb', line 52

def junkwords(wordlist)
  wordlist.each do |word|
    replace "[_-]#{word}[_-]", '_'
    remove  "[_-]#{word}$"
    remove     "^#{word}[_-]"
  end
end

- (Object) lowercase



30
31
32
# File 'lib/fixnames/filters.rb', line 30

def lowercase
  translate 'A-Z', 'a-z'
end

- (Object) semicolon



11
12
13
14
# File 'lib/fixnames/filters.rb', line 11

def semicolon
  translate ';', '-'
  fixed.squeeze! '-'
end

- (Object) whitespace(chrlist)



60
61
62
63
64
65
66
67
68
# File 'lib/fixnames/filters.rb', line 60

def whitespace(chrlist)
  replace "[#{Regexp.escape chrlist}]", '_'
  replace '[_-]\.', '.' while fixed =~ /[_-]\./
  replace '_-',     '-' while fixed =~ /_-/
  replace '-_',     '-' while fixed =~ /-_/
  remove  '^_'          while fixed =~ /^_/
  remove  '_$'          while fixed =~ /_$/
  fixed.squeeze! '_'
end