Module: Asciidoctor::Diagram::Platform
- Defined in:
- lib/asciidoctor-diagram/util/platform.rb
Class Method Summary collapse
- .file_separator ⇒ Object
- .host_os_file_separator ⇒ Object
- .host_os_path(path) ⇒ Object
- .host_os_path_separator ⇒ Object
- .native_path(path) ⇒ Object
- .os ⇒ Object
- .os_info ⇒ Object
- .os_variant ⇒ Object
- .path_separator ⇒ Object
Class Method Details
.file_separator ⇒ Object
16 17 18 |
# File 'lib/asciidoctor-diagram/util/platform.rb', line 16 def self.file_separator os_info[:file_sep] end |
.host_os_file_separator ⇒ Object
20 21 22 |
# File 'lib/asciidoctor-diagram/util/platform.rb', line 20 def self.host_os_file_separator os_info[:host_os_file_sep] end |
.host_os_path(path) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/asciidoctor-diagram/util/platform.rb', line 81 def self.host_os_path(path) # special case for cygwin, it requires path translation for java to work if os_variant == :cygwin cygpath = ::Asciidoctor::Diagram::Which.which('cygpath') if cygpath != nil ::Asciidoctor::Diagram::Cli.run(cygpath, '-w', path)[:out] else puts 'cygwin warning: cygpath not found' native_path(path) end else native_path(path) end end |
.host_os_path_separator ⇒ Object
28 29 30 |
# File 'lib/asciidoctor-diagram/util/platform.rb', line 28 def self.host_os_path_separator os_info[:host_os_path_sep] end |
.native_path(path) ⇒ Object
70 71 72 73 74 75 76 77 78 79 |
# File 'lib/asciidoctor-diagram/util/platform.rb', line 70 def self.native_path(path) return path if path.nil? sep = file_separator if sep != '/' path.to_s.gsub('/', sep) else path.to_s end end |
.os ⇒ Object
8 9 10 |
# File 'lib/asciidoctor-diagram/util/platform.rb', line 8 def self.os os_info[:os] end |
.os_info ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/asciidoctor-diagram/util/platform.rb', line 32 def self.os_info @os ||= ( host_os = RbConfig::CONFIG['host_os'] file_sep = '/' host_os_file_sep = nil variant = nil path_sep = ::File::PATH_SEPARATOR host_os_path_sep = nil case host_os when /(msys|mingw|mswin|bccwin|wince|emc)/i os = :windows variant = $1.downcase.to_sym file_sep = '\\' when /(cygwin)/i os = :windows variant = $1.downcase.to_sym host_os_file_sep = '\\' host_os_path_sep = ';' when /darwin|mac os/i os = :macosx when /linux/i os = :linux else os = :unix end { :os => os, :os_variant => variant || os, :file_sep => file_sep, :host_os_file_sep => host_os_file_sep || file_sep, :path_sep => path_sep, :host_os_path_sep => host_os_path_sep || path_sep } ) end |
.os_variant ⇒ Object
12 13 14 |
# File 'lib/asciidoctor-diagram/util/platform.rb', line 12 def self.os_variant os_info[:os_variant] end |
.path_separator ⇒ Object
24 25 26 |
# File 'lib/asciidoctor-diagram/util/platform.rb', line 24 def self.path_separator os_info[:path_sep] end |