Module: Git::Approvals::Utils
- Included in:
- Approval
- Defined in:
- lib/git/approvals/utils.rb
Class Method Summary collapse
-
.filenamify(string) ⇒ Object
Converts a string into a string that can be used as a filename.
- .transform_filename(str, options = {}) ⇒ Object
Class Method Details
.filenamify(string) ⇒ Object
Converts a string into a string that can be used as a filename.
7 8 9 10 11 12 13 |
# File 'lib/git/approvals/utils.rb', line 7 def filenamify( string ) string .gsub( /([a-z])([A-Z])/, '\1_\2' ) .gsub( /\W+/, '_' ) .gsub( /^_|_$/, '' ) .downcase end |
.transform_filename(str, options = {}) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/git/approvals/utils.rb', line 18 def transform_filename( str, ={} ) if opt = .delete( :format ) str.chomp! File.extname( str ) str << '.' << opt.to_s end if opt = .delete( :filename ) base = File.basename( str, File.extname( str ) ) str.sub! /#{base}(?!\/)/, opt end str end |