Module: Asciidoctor::Diagram::Platform

Defined in:
lib/asciidoctor-diagram/util/platform.rb

Class Method Summary collapse

Class Method Details

.native_path(path) ⇒ Object



45
46
47
48
49
50
51
52
53
54
# File 'lib/asciidoctor-diagram/util/platform.rb', line 45

def self.native_path(path)
  return path if path.nil?

  path_sep = path_separator
  if path_sep != '/'
    path.to_s.gsub('/', path_sep)
  else
    path.to_s
  end
end

.osObject



6
7
8
# File 'lib/asciidoctor-diagram/util/platform.rb', line 6

def self.os
  os_info[:os]
end

.os_infoObject



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/asciidoctor-diagram/util/platform.rb', line 18

def self.os_info
  @os ||= (
  host_os = RbConfig::CONFIG['host_os']

  path_sep = '/'
  variant = nil
  case host_os
    when /(mswin|bccwin|wince|emc)/i
      os = :windows
      variant = $1.downcase.to_sym
      path_sep = '\\'
    when /(msys|mingw|cygwin)/i
      os = :windows
      variant = $1.downcase.to_sym
    when /darwin|mac os/i
      os = :macosx
    when /linux/i
      os = :linux
    else
      os = :unix
  end
  {
      :os => os, :os_variant => variant || os, :path_sep => path_sep
  }
  )
end

.os_variantObject



10
11
12
# File 'lib/asciidoctor-diagram/util/platform.rb', line 10

def self.os_variant
  os_info[:os_variant]
end

.path_separatorObject



14
15
16
# File 'lib/asciidoctor-diagram/util/platform.rb', line 14

def self.path_separator
  os_info[:path_sep]
end