Module: GitCommitNotifier::EscapeHelper
- Included in:
- DiffToHtml, ResultProcessor
- Defined in:
- lib/git_commit_notifier/escape_helper.rb
Overview
Provides content escaping helpers.
Instance Method Summary collapse
- #decode_escaped_filename(filename) ⇒ Object
-
#escape_content(s) ⇒ String
Escapes expanded content using CGI.escapeHTML and #expand_tabs.
-
#expand_tabs(s, tabWidth) ⇒ String
Expand tabs into spaces.
Instance Method Details
#decode_escaped_filename(filename) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/git_commit_notifier/escape_helper.rb', line 27 def decode_escaped_filename( filename ) filename.gsub( /\\\d\d\d\\\d\d\d/ ) { |match| mb_char_code = match.split( '\\' )[ 1, 2 ] mb_char_code.map! { |x| x.oct } mb_char_code.pack( 'C*' ).force_encoding( 'UTF-8') } end |
#escape_content(s) ⇒ String
Escapes expanded content using CGI.escapeHTML and #expand_tabs.
23 24 25 |
# File 'lib/git_commit_notifier/escape_helper.rb', line 23 def escape_content(s) CGI.escapeHTML((s, 4)).gsub(" ", " ") end |
#expand_tabs(s, tabWidth) ⇒ String
Expand tabs into spaces.
10 11 12 13 14 15 16 17 |
# File 'lib/git_commit_notifier/escape_helper.rb', line 10 def (s, tabWidth) delta = 0 s.gsub(/\t/) do |m| add = tabWidth - (delta + $~.offset(0)[0]) % tabWidth delta += add - 1 " " * add end end |