Module: RubyInfo
- Defined in:
- lib/ruby_info.rb
Constant Summary collapse
- VERSION =
'1.0.1'
Class Method Summary collapse
- .[](what) ⇒ Object
- .all ⇒ Object
- .child_program_status ⇒ Object
- .current_callstack ⇒ Object
-
.current_file ⇒ Object
# # current info.
- .current_file_directory ⇒ Object
-
.current_line ⇒ Object
__LINE__.
-
.current_method ⇒ Object
__method__ (except aliases).
- .debug ⇒ Object
- .debug_activated? ⇒ Boolean
- .encoding_aliases ⇒ Object
- .encodings ⇒ Object
-
.env ⇒ Object
# # system info.
- .external_encoding ⇒ Object
- .gc ⇒ Object
- .gets_separator ⇒ Object
- .global_constants ⇒ Object
-
.global_variables ⇒ Object
# # ruby objects.
-
.hostname ⇒ Object
# # network info.
- .internal_encoding ⇒ Object
- .join_separator ⇒ Object
- .last_exception ⇒ Object
- .last_input ⇒ Object
-
.last_input_file ⇒ Object
# # input / string info.
- .last_input_line_number ⇒ Object
- .list ⇒ Object
- .load_path ⇒ Object
- .loaded_programs ⇒ Object
- .os ⇒ Object
- .print_separator ⇒ Object
- .process_id ⇒ Object
- .program_arguments ⇒ Object
- .program_data ⇒ Object
-
.program_name ⇒ Object
# # program info.
- .ruby_copyright ⇒ Object
- .ruby_description ⇒ Object
-
.ruby_engine ⇒ Object
also see the ruby_engine gem.
- .ruby_patchlevel ⇒ Object
- .ruby_platform ⇒ Object
- .ruby_release_date ⇒ Object
- .ruby_revision ⇒ Object
-
.ruby_version ⇒ Object
# # ruby info.
- .script_lines ⇒ Object
-
.security_level ⇒ Object
# # misc.
- .signals ⇒ Object
- .split_separator ⇒ Object
- .system_call_errors ⇒ Object
- .user_home ⇒ Object
-
.user_login ⇒ Object
# # user info.
- .user_name ⇒ Object
- .verbose ⇒ Object
- .warnings_activated? ⇒ Boolean
- .working_directory ⇒ Object
Class Method Details
.[](what) ⇒ Object
9 10 11 |
# File 'lib/ruby_info.rb', line 9 def [](what) send what end |
.all ⇒ Object
17 18 19 |
# File 'lib/ruby_info.rb', line 17 def all Hash[ list.map{ |l| [l, self.public_send(l)] }] end |
.child_program_status ⇒ Object
47 48 49 |
# File 'lib/ruby_info.rb', line 47 def child_program_status $CHILD_STATUS end |
.current_callstack ⇒ Object
123 124 125 |
# File 'lib/ruby_info.rb', line 123 def current_callstack caller end |
.current_file ⇒ Object
# # 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_directory ⇒ Object
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_line ⇒ Object
__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_method ⇒ Object
__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 |
.debug ⇒ Object
189 190 191 |
# File 'lib/ruby_info.rb', line 189 def debug $DEBUG end |
.debug_activated? ⇒ Boolean
193 194 195 |
# File 'lib/ruby_info.rb', line 193 def debug_activated? !! $DEBUG end |
.encoding_aliases ⇒ Object
170 171 172 |
# File 'lib/ruby_info.rb', line 170 def encoding_aliases Encoding.aliases end |
.encodings ⇒ Object
166 167 168 |
# File 'lib/ruby_info.rb', line 166 def encodings Encoding.name_list end |
.env ⇒ Object
# # system info
54 55 56 |
# File 'lib/ruby_info.rb', line 54 def env ::ENV end |
.external_encoding ⇒ Object
158 159 160 |
# File 'lib/ruby_info.rb', line 158 def external_encoding Encoding.default_external end |
.gc ⇒ Object
70 71 72 |
# File 'lib/ruby_info.rb', line 70 def gc GC.stat end |
.gets_separator ⇒ Object
142 143 144 |
# File 'lib/ruby_info.rb', line 142 def gets_separator $/ end |
.global_constants ⇒ Object
208 209 210 |
# File 'lib/ruby_info.rb', line 208 def global_constants Object.constants end |
.global_variables ⇒ Object
# # ruby objects
204 205 206 |
# File 'lib/ruby_info.rb', line 204 def global_variables Object.send :global_variables end |
.hostname ⇒ Object
# # network info
92 93 94 |
# File 'lib/ruby_info.rb', line 92 def hostname Socket.gethostname end |
.internal_encoding ⇒ Object
162 163 164 |
# File 'lib/ruby_info.rb', line 162 def internal_encoding Encoding.default_internal end |
.join_separator ⇒ Object
146 147 148 |
# File 'lib/ruby_info.rb', line 146 def join_separator $, end |
.last_exception ⇒ Object
197 198 199 |
# File 'lib/ruby_info.rb', line 197 def last_exception $! end |
.last_input ⇒ Object
138 139 140 |
# File 'lib/ruby_info.rb', line 138 def last_input $_ end |
.last_input_file ⇒ Object
# # input / string info
130 131 132 |
# File 'lib/ruby_info.rb', line 130 def last_input_file $FILENAME end |
.last_input_line_number ⇒ Object
134 135 136 |
# File 'lib/ruby_info.rb', line 134 def last_input_line_number $. end |
.list ⇒ Object
13 14 15 |
# File 'lib/ruby_info.rb', line 13 def list singleton_methods.map(&:to_sym) - [:[], :list, :all] end |
.load_path ⇒ Object
66 67 68 |
# File 'lib/ruby_info.rb', line 66 def load_path $: end |
.loaded_programs ⇒ Object
35 36 37 |
# File 'lib/ruby_info.rb', line 35 def loaded_programs $" end |
.os ⇒ Object
58 59 60 |
# File 'lib/ruby_info.rb', line 58 def os RbConfig::CONFIG['host_os'] end |
.print_separator ⇒ Object
150 151 152 |
# File 'lib/ruby_info.rb', line 150 def print_separator $, end |
.process_id ⇒ Object
62 63 64 |
# File 'lib/ruby_info.rb', line 62 def process_id $$ end |
.program_arguments ⇒ Object
31 32 33 |
# File 'lib/ruby_info.rb', line 31 def program_arguments $* end |
.program_data ⇒ Object
39 40 41 |
# File 'lib/ruby_info.rb', line 39 def program_data defined?(::DATA) && DATA end |
.program_name ⇒ Object
# # program info
27 28 29 |
# File 'lib/ruby_info.rb', line 27 def program_name $0 end |
.ruby_copyright ⇒ Object
251 252 253 |
# File 'lib/ruby_info.rb', line 251 def ruby_copyright defined?(::RUBY_COPYRIGHT) && ::RUBY_COPYRIGHT end |
.ruby_description ⇒ Object
231 232 233 |
# File 'lib/ruby_info.rb', line 231 def ruby_description ::RUBY_DESCRIPTION end |
.ruby_engine ⇒ Object
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_patchlevel ⇒ Object
227 228 229 |
# File 'lib/ruby_info.rb', line 227 def ruby_patchlevel ::RUBY_PATCHLEVEL end |
.ruby_platform ⇒ Object
243 244 245 |
# File 'lib/ruby_info.rb', line 243 def ruby_platform ::RUBY_PLATFORM end |
.ruby_release_date ⇒ Object
235 236 237 |
# File 'lib/ruby_info.rb', line 235 def ruby_release_date ::RUBY_RELEASE_DATE end |
.ruby_revision ⇒ Object
247 248 249 |
# File 'lib/ruby_info.rb', line 247 def ruby_revision defined?(::RUBY_REVISION) && ::RUBY_REVISION end |
.ruby_version ⇒ Object
# # 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_lines ⇒ Object
43 44 45 |
# File 'lib/ruby_info.rb', line 43 def script_lines defined?(::SCRIPT_LINES__) && SCRIPT_LINES__ end |
.security_level ⇒ Object
# # misc
177 178 179 |
# File 'lib/ruby_info.rb', line 177 def security_level $SAFE end |
.signals ⇒ Object
216 217 218 |
# File 'lib/ruby_info.rb', line 216 def signals Signal.list end |
.split_separator ⇒ Object
154 155 156 |
# File 'lib/ruby_info.rb', line 154 def split_separator $; end |
.system_call_errors ⇒ Object
212 213 214 |
# File 'lib/ruby_info.rb', line 212 def system_call_errors Errno.constants end |
.user_home ⇒ Object
85 86 87 |
# File 'lib/ruby_info.rb', line 85 def user_home Dir.home end |
.user_login ⇒ Object
# # user info
77 78 79 |
# File 'lib/ruby_info.rb', line 77 def user_login Etc.getlogin end |
.user_name ⇒ Object
81 82 83 |
# File 'lib/ruby_info.rb', line 81 def user_name Etc.getpwnam(user_login).gecos.split(',')[0] end |
.verbose ⇒ Object
181 182 183 |
# File 'lib/ruby_info.rb', line 181 def verbose $VERBOSE end |
.warnings_activated? ⇒ Boolean
185 186 187 |
# File 'lib/ruby_info.rb', line 185 def warnings_activated? !! $VERBOSE end |
.working_directory ⇒ Object
103 104 105 |
# File 'lib/ruby_info.rb', line 103 def working_directory Dir.pwd end |