Class: ShellSanitizer
- Inherits:
-
Object
- Object
- ShellSanitizer
- Defined in:
- lib/luigi/ShellSanitizer.rb
Constant Summary collapse
- REPLACE_HASH =
{ ?“ => '"', ?” => '"', ?‘ => "'", ?’ => "'", ?„ => '"', ?» => ">>", ?« => "<<", ?ä => "ae", ?ö => "oe", ?ü => "ue", ?Ä => "Ae", ?Ö => "Oe", ?Ü => "Ue", ?ß => "ss", ?ï => "i", ?ë => "e", ?æ => "ae", ?Æ => "AE", ?œ => "oe", ?Œ => "OE", ?€ => "EUR", ?¥ => "YEN", ?½ => "1/2", ?¼ => "1/4", ?¾ => "3/4", ?© => "(c)", ?™ => "(TM)", ?® => "(r)", ?♥ => "<3", ?☺ => ":)" }
Class Method Summary collapse
- .clean_path(path) ⇒ Object
-
.deumlautify(string) ⇒ Object
TODO somebody find me a gem that works and I’ll replace this.
- .process(string) ⇒ Object
Class Method Details
.clean_path(path) ⇒ Object
33 34 35 36 37 38 39 40 |
# File 'lib/luigi/ShellSanitizer.rb', line 33 def self.clean_path(path) path = path.strip() path = deumlautify path path.sub!(/^\./,'') # removes hidden_file_dot '.' from the begging path.gsub!(/\//,'_') path.gsub!(/\//,'_') return path end |
.deumlautify(string) ⇒ Object
TODO somebody find me a gem that works and I’ll replace this
26 27 28 29 30 31 |
# File 'lib/luigi/ShellSanitizer.rb', line 26 def self.deumlautify(string) string = string.dup REPLACE_HASH.each{|k,v| string = string.force_encoding("UTF-8").gsub k, v } string.each_char.to_a.keep_if {|c| c.ascii_only?} return string end |
.process(string) ⇒ Object
19 20 21 22 23 |
# File 'lib/luigi/ShellSanitizer.rb', line 19 def self.process(string) string = deumlautify string #string = Ascii.process string return string end |