Module: RbConfig

Defined in:
lib/standard/facets/rbconfig.rb

Overview

An extended rendition of the Ruby's standard RbConfig module.

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.datadir(package_name) ⇒ Object

Return the path to the data directory associated with the given library/package name. Normally this is just

"#{Config::CONFIG['datadir']}/#{name}"

but may be modified by tools like RubyGems to handle versioned data directories.


32
33
34
# File 'lib/standard/facets/rbconfig.rb', line 32

def self.datadir(package_name)
  File.join(CONFIG['datadir'], package_name)
end

.host_osObject


38
39
40
# File 'lib/standard/facets/rbconfig.rb', line 38

def self.host_os
  CONFIG['host_os']
end

.inspectObject


5
6
7
# File 'lib/standard/facets/rbconfig.rb', line 5

def self.inspect
  CONFIG.inspect
end

.method_missing(s, *a, &b) ⇒ Object

Methodized lookup of config.


10
11
12
13
14
15
16
17
18
19
# File 'lib/standard/facets/rbconfig.rb', line 10

def self.method_missing(s,*a,&b)
  s = s.to_s
  if CONFIG.key?(s)
    CONFIG[s]
  elsif CONFIG.key?(s.upcase)
    CONFIG[s.upcase]
  else
    super(s,*a,&b)
  end
end

Instance Method Details

#bsd?Boolean

Returns:

  • (Boolean)

50
51
52
# File 'lib/standard/facets/rbconfig.rb', line 50

def bsd?
  host_os =~ /bsd/
end

#linux?Boolean

Returns:

  • (Boolean)

42
43
44
# File 'lib/standard/facets/rbconfig.rb', line 42

def linux?
  host_os =~ /linux|cygwin/
end

#mac?Boolean

Returns:

  • (Boolean)

46
47
48
# File 'lib/standard/facets/rbconfig.rb', line 46

def mac?
  host_os =~ /mac|darwin/
end

#posix?Boolean

Returns:

  • (Boolean)

68
69
70
71
72
73
74
75
# File 'lib/standard/facets/rbconfig.rb', line 68

def posix?
  linux? or mac? or bsd? or solaris? or begin 
    fork do end
    true
  rescue NotImplementedError, NoMethodError
    false
  end
end

#solaris?Boolean

Returns:

  • (Boolean)

58
59
60
# File 'lib/standard/facets/rbconfig.rb', line 58

def solaris?
  host_os =~ /solaris|sunos/
end

#symbian?Boolean

TODO: who knows what symbian returns?

Returns:

  • (Boolean)

63
64
65
# File 'lib/standard/facets/rbconfig.rb', line 63

def symbian?
  host_os =~ /symbian/
end

#windows?Boolean

Returns:

  • (Boolean)

54
55
56
# File 'lib/standard/facets/rbconfig.rb', line 54

def windows?
  host_os =~ /mswin|mingw/
end