Class: RubySpriter::Utils::PathHelper
- Inherits:
-
Object
- Object
- RubySpriter::Utils::PathHelper
- Defined in:
- lib/ruby_spriter/utils/path_helper.rb
Overview
Cross-platform path handling utilities
Class Method Summary collapse
-
.normalize_for_python(path) ⇒ String
Normalize path for Python scripts (GIMP).
-
.quote_arg(arg) ⇒ String
Quote a command argument for shell execution.
-
.quote_path(path) ⇒ String
Quote a file path for shell execution.
-
.to_native(path) ⇒ String
Convert path to native format.
Class Method Details
.normalize_for_python(path) ⇒ String
Normalize path for Python scripts (GIMP)
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ruby_spriter/utils/path_helper.rb', line 35 def normalize_for_python(path) abs_path = File.absolute_path(path) if Platform.windows? # Use forward slashes for Python raw strings abs_path.gsub('\\', '/') else abs_path end end |
.quote_arg(arg) ⇒ String
Quote a command argument for shell execution
23 24 25 26 27 28 29 30 |
# File 'lib/ruby_spriter/utils/path_helper.rb', line 23 def quote_arg(arg) if Platform.windows? "\"#{arg}\"" else # Need 4 backslashes because gsub interprets backslashes in replacement string "'#{arg.gsub("'", "\\\\'")}'" end end |
.quote_path(path) ⇒ String
Quote a file path for shell execution
11 12 13 14 15 16 17 18 |
# File 'lib/ruby_spriter/utils/path_helper.rb', line 11 def quote_path(path) if Platform.windows? "\"#{path}\"" else # Need 4 backslashes because gsub interprets backslashes in replacement string "'#{path.gsub("'", "\\\\'")}'" end end |