Sha256: a82210f9a0efeb61f70af37755da6f1cc055ccee0534a76a2a23995c96aa696b

Contents?: true

Size: 953 Bytes

Versions: 6

Compression:

Stored size: 953 Bytes

Contents

    def clean_msg(text)
      wrapped_text = word_wrap text
      escape_quotes wrapped_text
      soap text
    end

    #search the commit for profanity and if it exists remove the commit
    def soap(text)
     profanity = {"fuck" => "duck", "bitch" => "snitch", "cunt" => "!@%&",
                   "hate" => "date" , "pissed" => "rustled", "screw" => "poo"}
      profanity.each { |k,v| text.sub!(k, v) }
    end
    # conversion for quotation marks to avoid shell interpretation
    # does not seem to be a safe way to escape cross-platform?
    def escape_quotes(text)
      text.gsub(/"/, "''")
    end

    # convenience method for word wrapping
    # based on https://github.com/cmdrkeene/memegen/blob/master/lib/meme_generator.rb
    def word_wrap(text, col = 27)
      wrapped = text.gsub(/(.{1,#{col + 4}})(\s+|\Z)/, "\\1\n")
      wrapped.chomp!
    end


#test goes here
text = "hello cunt this is a bitch commit"
clean_msg text
puts text

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
acmcommits-1.0.17 test.rb
acmcommits-1.0.16 test.rb
acmcommits-1.0.15 test.rb
acmcommits-1.0.14 test.rb
acmcommits-1.0.13 test.rb
acmcommits-1.0.12 test.rb