Module: RSCM::PathConverter
- Included in:
- Subversion
- Defined in:
- lib/rscm/path_converter.rb
Class Method Summary collapse
- .ensure_trailing_slash(url) ⇒ Object
- .filepath_to_nativepath(path, escaped) ⇒ Object
- .filepath_to_nativeurl(path) ⇒ Object
- .nativepath_to_filepath(path) ⇒ Object
Class Method Details
.ensure_trailing_slash(url) ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/rscm/path_converter.rb', line 49 def ensure_trailing_slash(url) return nil if url.nil? if(url && url[-1..-1] != "/") "#{url}/" else url end end |
.filepath_to_nativepath(path, escaped) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/rscm/path_converter.rb', line 10 def filepath_to_nativepath(path, escaped) return nil if path.nil? path = File.(path) if(WIN32) escaped ? path.gsub(/\//, "\\\\\\\\") : path.gsub(/\//, "\\") elsif(CYGWIN) cygpath = `cygpath --windows #{path}`.chomp escaped ? cygpath.gsub(/\\/, "\\\\\\\\") : cygpath else path end end |
.filepath_to_nativeurl(path) ⇒ Object
24 25 26 27 28 29 30 31 32 |
# File 'lib/rscm/path_converter.rb', line 24 def filepath_to_nativeurl(path) return nil if path.nil? if(WINDOWS) urlpath = filepath_to_nativepath(path, false).gsub(/\\/, "/") "file:///#{urlpath}" else "file://#{File.(path)}" end end |
.nativepath_to_filepath(path) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rscm/path_converter.rb', line 35 def nativepath_to_filepath(path) return nil if path.nil? path = File.(path) if(WIN32) path.gsub(/\//, "\\") elsif(CYGWIN) path = path.gsub(/\\/, "/") `cygpath --unix #{path}`.chomp else path end end |