Module: RubyInfo

Defined in:
lib/ruby_info.rb

Constant Summary collapse

VERSION =
'1.0.1'

Class Method Summary collapse

Class Method Details

.[](what) ⇒ Object



9
10
11
# File 'lib/ruby_info.rb', line 9

def [](what)
  send what
end

.allObject



17
18
19
# File 'lib/ruby_info.rb', line 17

def all
  Hash[ list.map{ |l| [l, self.public_send(l)] }]
end

.child_program_statusObject



47
48
49
# File 'lib/ruby_info.rb', line 47

def child_program_status
  $CHILD_STATUS
end

.current_callstackObject



123
124
125
# File 'lib/ruby_info.rb', line 123

def current_callstack
  caller
end

.current_fileObject

# # current info



99
100
101
# File 'lib/ruby_info.rb', line 99

def current_file #  __FILE__
  return $` if caller[0].rindex(/:\d+(:in `.*')?$/)
end

.current_file_directoryObject



107
108
109
110
111
112
113
# File 'lib/ruby_info.rb', line 107

def current_file_directory
  if current_file[0,1] == '(' && current_file[-1,1] == ')'
    current_file
  else
    File.dirname(current_file)
  end
end

.current_lineObject

__LINE__



115
116
117
# File 'lib/ruby_info.rb', line 115

def current_line # __LINE__
  return $1.to_i if caller[0].rindex( /:(\d+)(:in `.*')?$/ )
end

.current_methodObject

__method__ (except aliases)



119
120
121
# File 'lib/ruby_info.rb', line 119

def current_method # __method__ (except aliases)
  return $1.to_sym if caller(1)[0].rindex( /\`([^\']+)\'/ )
end

.debugObject



189
190
191
# File 'lib/ruby_info.rb', line 189

def debug
  $DEBUG
end

.debug_activated?Boolean

Returns:

  • (Boolean)


193
194
195
# File 'lib/ruby_info.rb', line 193

def debug_activated?
  !! $DEBUG
end

.encoding_aliasesObject



170
171
172
# File 'lib/ruby_info.rb', line 170

def encoding_aliases
  Encoding.aliases
end

.encodingsObject



166
167
168
# File 'lib/ruby_info.rb', line 166

def encodings
  Encoding.name_list
end

.envObject

# # system info



54
55
56
# File 'lib/ruby_info.rb', line 54

def env
  ::ENV
end

.external_encodingObject



158
159
160
# File 'lib/ruby_info.rb', line 158

def external_encoding
  Encoding.default_external
end

.gcObject



70
71
72
# File 'lib/ruby_info.rb', line 70

def gc
  GC.stat
end

.gets_separatorObject



142
143
144
# File 'lib/ruby_info.rb', line 142

def gets_separator
  $/
end

.global_constantsObject



208
209
210
# File 'lib/ruby_info.rb', line 208

def global_constants
  Object.constants
end

.global_variablesObject

# # ruby objects



204
205
206
# File 'lib/ruby_info.rb', line 204

def global_variables
  Object.send :global_variables
end

.hostnameObject

# # network info



92
93
94
# File 'lib/ruby_info.rb', line 92

def hostname
  Socket.gethostname
end

.internal_encodingObject



162
163
164
# File 'lib/ruby_info.rb', line 162

def internal_encoding
  Encoding.default_internal
end

.join_separatorObject



146
147
148
# File 'lib/ruby_info.rb', line 146

def join_separator
  $,
end

.last_exceptionObject



197
198
199
# File 'lib/ruby_info.rb', line 197

def last_exception
  $!
end

.last_inputObject



138
139
140
# File 'lib/ruby_info.rb', line 138

def last_input
  $_
end

.last_input_fileObject

# # input / string info



130
131
132
# File 'lib/ruby_info.rb', line 130

def last_input_file
  $FILENAME
end

.last_input_line_numberObject



134
135
136
# File 'lib/ruby_info.rb', line 134

def last_input_line_number
  $.
end

.listObject



13
14
15
# File 'lib/ruby_info.rb', line 13

def list
  singleton_methods.map(&:to_sym) - [:[], :list, :all]
end

.load_pathObject



66
67
68
# File 'lib/ruby_info.rb', line 66

def load_path
  $:
end

.loaded_programsObject



35
36
37
# File 'lib/ruby_info.rb', line 35

def loaded_programs
  $"
end

.osObject



58
59
60
# File 'lib/ruby_info.rb', line 58

def os
  RbConfig::CONFIG['host_os']
end


150
151
152
# File 'lib/ruby_info.rb', line 150

def print_separator
  $,
end

.process_idObject



62
63
64
# File 'lib/ruby_info.rb', line 62

def process_id
  $$
end

.program_argumentsObject



31
32
33
# File 'lib/ruby_info.rb', line 31

def program_arguments
  $*
end

.program_dataObject



39
40
41
# File 'lib/ruby_info.rb', line 39

def program_data
  defined?(::DATA) && DATA
end

.program_nameObject

# # program info



27
28
29
# File 'lib/ruby_info.rb', line 27

def program_name
  $0
end


251
252
253
# File 'lib/ruby_info.rb', line 251

def ruby_copyright
  defined?(::RUBY_COPYRIGHT) && ::RUBY_COPYRIGHT
end

.ruby_descriptionObject



231
232
233
# File 'lib/ruby_info.rb', line 231

def ruby_description
  ::RUBY_DESCRIPTION
end

.ruby_engineObject

also see the ruby_engine gem



239
240
241
# File 'lib/ruby_info.rb', line 239

def ruby_engine # also see the ruby_engine gem
  defined?(::RUBY_ENGINE) && ::RUBY_ENGINE
end

.ruby_patchlevelObject



227
228
229
# File 'lib/ruby_info.rb', line 227

def ruby_patchlevel
  ::RUBY_PATCHLEVEL
end

.ruby_platformObject



243
244
245
# File 'lib/ruby_info.rb', line 243

def ruby_platform
  ::RUBY_PLATFORM
end

.ruby_release_dateObject



235
236
237
# File 'lib/ruby_info.rb', line 235

def ruby_release_date
  ::RUBY_RELEASE_DATE
end

.ruby_revisionObject



247
248
249
# File 'lib/ruby_info.rb', line 247

def ruby_revision
  defined?(::RUBY_REVISION) && ::RUBY_REVISION
end

.ruby_versionObject

# # ruby info



223
224
225
# File 'lib/ruby_info.rb', line 223

def ruby_version # also see the ruby_version gem
  ::RUBY_VERSION
end

.script_linesObject



43
44
45
# File 'lib/ruby_info.rb', line 43

def script_lines
  defined?(::SCRIPT_LINES__) && SCRIPT_LINES__
end

.security_levelObject

# # misc



177
178
179
# File 'lib/ruby_info.rb', line 177

def security_level
  $SAFE
end

.signalsObject



216
217
218
# File 'lib/ruby_info.rb', line 216

def signals
  Signal.list
end

.split_separatorObject



154
155
156
# File 'lib/ruby_info.rb', line 154

def split_separator
  $;
end

.system_call_errorsObject



212
213
214
# File 'lib/ruby_info.rb', line 212

def system_call_errors
  Errno.constants
end

.user_homeObject



85
86
87
# File 'lib/ruby_info.rb', line 85

def user_home
  Dir.home
end

.user_loginObject

# # user info



77
78
79
# File 'lib/ruby_info.rb', line 77

def 
  Etc.getlogin
end

.user_nameObject



81
82
83
# File 'lib/ruby_info.rb', line 81

def user_name
  Etc.getpwnam().gecos.split(',')[0]
end

.verboseObject



181
182
183
# File 'lib/ruby_info.rb', line 181

def verbose
  $VERBOSE
end

.warnings_activated?Boolean

Returns:

  • (Boolean)


185
186
187
# File 'lib/ruby_info.rb', line 185

def warnings_activated?
  !! $VERBOSE
end

.working_directoryObject



103
104
105
# File 'lib/ruby_info.rb', line 103

def working_directory
  Dir.pwd
end