Module: System

Extended by:
System
Included in:
System
Defined in:
lib/more/facets/rbsystem.rb

Overview

System

The System module provides Platform and Ruby system information. The module should also be able to stand in for rbconfig. It is intended for use as a service module although it can be mixed-in too.

Note: This library is still being worked on a good bit.

Instance Method Summary collapse

Instance Method Details

#argvObject Also known as: options



60
# File 'lib/more/facets/rbsystem.rb', line 60

def argv; $* ; end

#child_statusObject Also known as: exit_status



71
# File 'lib/more/facets/rbsystem.rb', line 71

def child_status; $? ; end

#codingObject



84
# File 'lib/more/facets/rbsystem.rb', line 84

def coding; $-K ; end

#coding=(x) ⇒ Object



85
# File 'lib/more/facets/rbsystem.rb', line 85

def coding=(x); $-K=x ; end

#current_platformObject

platform —————————————————–



193
194
195
196
197
# File 'lib/more/facets/rbsystem.rb', line 193

def current_platform
  arch = Config::CONFIG['arch']
  #cpu, os = arch.split '-', 2
  return match_platform(arch)
end

#dataObject

Miscellaneous ———————————————



139
# File 'lib/more/facets/rbsystem.rb', line 139

def data; DATA ; end

#debugObject



77
# File 'lib/more/facets/rbsystem.rb', line 77

def debug; $DEBUG; end

#default_inputObject Also known as: defin, argf



105
# File 'lib/more/facets/rbsystem.rb', line 105

def default_input ; $< ; end

#default_outputObject Also known as: defout



109
# File 'lib/more/facets/rbsystem.rb', line 109

def default_output ; $> ; end

#default_output=(x) ⇒ Object Also known as: defout=



110
# File 'lib/more/facets/rbsystem.rb', line 110

def default_output=(x); $defout=x ; end

#envObject



92
# File 'lib/more/facets/rbsystem.rb', line 92

def env; ENV ; end

#environmentObject



91
# File 'lib/more/facets/rbsystem.rb', line 91

def environment; ENV ; end

#error_infoObject



74
# File 'lib/more/facets/rbsystem.rb', line 74

def error_info; $! ; end

#error_positionObject



75
# File 'lib/more/facets/rbsystem.rb', line 75

def error_position; $@ ; end

#extentionsObject



165
166
167
# File 'lib/more/facets/rbsystem.rb', line 165

def extentions
  [ 'rb', DLEXT ]
end

#input_field_separatorObject Also known as: fs



129
# File 'lib/more/facets/rbsystem.rb', line 129

def input_field_separator ; $/ ; end

#input_field_separator=(x) ⇒ Object Also known as: fs=



130
# File 'lib/more/facets/rbsystem.rb', line 130

def input_field_separator=(x) ; $/=x ; end

#input_line_numberObject Also known as: input_lineno



134
# File 'lib/more/facets/rbsystem.rb', line 134

def input_line_number ; $. ; end

#input_record_separatorObject Also known as: rs



124
# File 'lib/more/facets/rbsystem.rb', line 124

def input_record_separator ; $/ ; end

#input_record_separator=(x) ⇒ Object Also known as: rs=



125
# File 'lib/more/facets/rbsystem.rb', line 125

def input_record_separator=(x) ; $/=x ; end

#line_end_processingObject



87
# File 'lib/more/facets/rbsystem.rb', line 87

def line_end_processing; $-l ; end

#load_pathObject

load path —————————————————-



186
# File 'lib/more/facets/rbsystem.rb', line 186

def load_path; $: ; end

#loaded_featuresObject Also known as: required



188
# File 'lib/more/facets/rbsystem.rb', line 188

def loaded_features; $" ; end

#match_platform(arch) ⇒ Object



201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# File 'lib/more/facets/rbsystem.rb', line 201

def match_platform(arch)
  cpu, os = arch.split '-', 2
  cpu, os = nil, cpu if os.nil? # java

  cpu = case cpu
        when /i\d86/ then 'x86'
        else cpu
        end

  os  = case os
        when /cygwin/ then            [ 'cygwin',  nil ]
        when /darwin(\d+)?/ then      [ 'darwin',  $1  ]
        when /freebsd(\d+)/ then      [ 'freebsd', $1  ]
        when /^java$/ then            [ 'java',    nil ]
        when /^java([\d.]*)/ then     [ 'java',    $1  ]
        when /linux/ then             [ 'linux',   $1  ]
        when /mingw32/ then           [ 'mingw32', nil ]
        when /mswin32/ then           [ 'mswin32', nil ]
        when /openbsd(\d+\.\d+)/ then [ 'openbsd', $1  ]
        when /solaris(\d+\.\d+)/ then [ 'solaris', $1  ]
        else                          [ 'unknown', nil ]
        end

  [cpu, os].flatten.compact.join("-")
end

#output_field_separatorObject Also known as: ofs



119
# File 'lib/more/facets/rbsystem.rb', line 119

def output_field_separator ; $-F ; end

#output_field_separator=(x) ⇒ Object Also known as: ofs=



120
# File 'lib/more/facets/rbsystem.rb', line 120

def output_field_separator=(x) ; $-F=x ; end

#output_record_separatorObject Also known as: ors



114
# File 'lib/more/facets/rbsystem.rb', line 114

def output_record_separator ; $\ ; end

#output_record_separator=(x) ⇒ Object Also known as: ors=



115
# File 'lib/more/facets/rbsystem.rb', line 115

def output_record_separator=(x) ; $\=x ; end

#platformObject



153
154
155
# File 'lib/more/facets/rbsystem.rb', line 153

def platform
  RUBY_PLATFORM
end

#process_idObject Also known as: pid

these won’t work here def file; __FILE__ ; end def filepath; File.expand_path(__FILE__) ; end def lineno; __LINE__ ; end



68
# File 'lib/more/facets/rbsystem.rb', line 68

def process_id; $$ ; end

#program_loopObject



89
# File 'lib/more/facets/rbsystem.rb', line 89

def program_loop; $-p ; end

#program_nameObject

Execution Environment ————————————-



57
# File 'lib/more/facets/rbsystem.rb', line 57

def program_name; $0 ; end

#program_name=(x) ⇒ Object



58
# File 'lib/more/facets/rbsystem.rb', line 58

def program_name=(x); $0=x ; end

#releaseObject



161
162
163
# File 'lib/more/facets/rbsystem.rb', line 161

def release
  RUBY_RELEASE_DATE
end

#rubylibdirObject



169
170
171
# File 'lib/more/facets/rbsystem.rb', line 169

def rubylibdir
  File.join( libdir, 'ruby'  )
end

#rubypathObject



149
150
151
# File 'lib/more/facets/rbsystem.rb', line 149

def rubypath
  File.join( bindir, ruby_install_name )
end

#safeObject



79
# File 'lib/more/facets/rbsystem.rb', line 79

def safe; $SAFE; end

#stderrObject



102
# File 'lib/more/facets/rbsystem.rb', line 102

def stderr ; $stderr ; end

#stderr=(x) ⇒ Object



103
# File 'lib/more/facets/rbsystem.rb', line 103

def stderr=(x); $stderr=x ; end

#stdinObject

Input/Ouput Variables ————————————-



96
# File 'lib/more/facets/rbsystem.rb', line 96

def stdin; $stdin ; end

#stdin=(x) ⇒ Object



97
# File 'lib/more/facets/rbsystem.rb', line 97

def stdin=(x); $stdin=x ; end

#stdoutObject



99
# File 'lib/more/facets/rbsystem.rb', line 99

def stdout ; $stdout ; end

#stdout=(x) ⇒ Object



100
# File 'lib/more/facets/rbsystem.rb', line 100

def stdout=(x); $stdout=x ; end

#verboseObject



81
# File 'lib/more/facets/rbsystem.rb', line 81

def verbose; $VERBOSE; end

#verbose=(x) ⇒ Object



82
# File 'lib/more/facets/rbsystem.rb', line 82

def verbose=(x); $VERBOSE=x; end

#versionObject



157
158
159
# File 'lib/more/facets/rbsystem.rb', line 157

def version
  RUBY_VERSION
end