Module: Muwu::Helper::SanitizerHelper

Defined in:
lib/muwu/helper/sanitizer_helper.rb

Class Method Summary collapse

Class Method Details

.sanitize_destination_file_basename(basename) ⇒ Object



12
13
14
# File 'lib/muwu/helper/sanitizer_helper.rb', line 12

def sanitize_destination_file_basename(basename)
  File.basename(basename.to_s).gsub(/\W/,'_').gsub(/_{2,}/,'_')
end

.sanitize_metadata(metadata) ⇒ Object



37
38
39
40
41
42
43
44
45
# File 'lib/muwu/helper/sanitizer_helper.rb', line 37

def ()
   = {}
  .each_pair do |k,v|
    key_safe = CGI::escape_html(k.to_s)
    value_safe = CGI::escape_html(v.to_s)
    [key_safe] = value_safe
  end
  
end

.sanitize_text_item_basename(basename) ⇒ Object



17
18
19
# File 'lib/muwu/helper/sanitizer_helper.rb', line 17

def sanitize_text_item_basename(basename)
  basename.to_s.gsub(RegexpLib.path_two_or_more_dots,'_')
end

.sanitize_text_item_path(path) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/muwu/helper/sanitizer_helper.rb', line 22

def sanitize_text_item_path(path)
  case path
  when Array
    return path.map { |p| sanitize_text_item_path_segment(p) }
  when Integer, String
    return sanitize_text_item_path_segment(path)
  end
end

.sanitize_text_item_path_segment(path) ⇒ Object



32
33
34
# File 'lib/muwu/helper/sanitizer_helper.rb', line 32

def sanitize_text_item_path_segment(path)
  path.to_s.downcase.gsub(/\s/,'_').gsub(/\W/,'').gsub(/_{2,}/,'_')
end