Module: RubyInfo

Defined in:
lib/ruby_info.rb,
lib/ruby_info/version.rb

Constant Summary collapse

VERSION =
"1.0.0"

Class Method Summary collapse

Class Method Details

.[](what) ⇒ Object



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

def [](what)
  send what
end

.allObject



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

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

.child_program_statusObject



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

def child_program_status
  $CHILD_STATUS
end

.current_callstackObject



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

def current_callstack
  caller
end

.current_fileObject

# # current info



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

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

.current_file_directoryObject



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

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__



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

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

.current_methodObject

__method__ (except aliases)



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

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

.debugObject



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

def debug
  $DEBUG
end

.debug_activated?Boolean



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

def debug_activated?
  !! $DEBUG
end

.encoding_aliasesObject



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

def encoding_aliases
  Encoding.aliases
end

.encodingsObject



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

def encodings
  Encoding.name_list
end

.envObject

# # system info



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

def env
  ::ENV
end

.external_encodingObject



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

def external_encoding
  Encoding.default_external
end

.gcObject



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

def gc
  GC.stat
end

.gets_separatorObject



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

def gets_separator
  $/
end

.global_constantsObject



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

def global_constants
  Object.constants
end

.global_variablesObject

# # ruby objects



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

def global_variables
  Object.send :global_variables
end

.hostnameObject

# # network info



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

def hostname
  Socket.gethostname
end

.internal_encodingObject



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

def internal_encoding
  Encoding.default_internal
end

.join_separatorObject



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

def join_separator
  $,
end

.last_exceptionObject



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

def last_exception
  $!
end

.last_inputObject



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

def last_input
  $_
end

.last_input_fileObject

# # input / string info



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

def last_input_file
  $FILENAME
end

.last_input_line_numberObject



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

def last_input_line_number
  $.
end

.listObject



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

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

.load_pathObject



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

def load_path
  $:
end

.loaded_programsObject



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

def loaded_programs
  $"
end

.osObject



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

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


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

def print_separator
  $,
end

.process_idObject



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

def process_id
  $$
end

.program_argumentsObject



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

def program_arguments
  $*
end

.program_dataObject



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

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

.program_nameObject

# # program info



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

def program_name
  $0
end


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

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

.ruby_descriptionObject



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

def ruby_description
  ::RUBY_DESCRIPTION
end

.ruby_engineObject

also see the ruby_engine gem



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

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

.ruby_patchlevelObject



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

def ruby_patchlevel
  ::RUBY_PATCHLEVEL
end

.ruby_platformObject



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

def ruby_platform
  ::RUBY_PLATFORM
end

.ruby_release_dateObject



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

def ruby_release_date
  ::RUBY_RELEASE_DATE
end

.ruby_revisionObject



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

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

.ruby_versionObject

# # ruby info



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

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

.script_linesObject



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

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

.security_levelObject

# # misc



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

def security_level
  $SAFE
end

.signalsObject



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

def signals
  Signal.list
end

.split_separatorObject



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

def split_separator
  $;
end

.system_call_errorsObject



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

def system_call_errors
  Errno.constants
end

.user_homeObject



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

def user_home
  Dir.home
end

.user_loginObject

# # user info



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

def 
  Etc.getlogin
end

.user_nameObject



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

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

.verboseObject



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

def verbose
  $VERBOSE
end

.warnings_activated?Boolean



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

def warnings_activated?
  !! $VERBOSE
end

.working_directoryObject



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

def working_directory
  Dir.pwd
end