Module: RubyInfo
- Defined in:
- lib/ruby_info.rb,
lib/ruby_info/version.rb
Constant Summary collapse
- VERSION =
"1.0.0"
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
8 9 10 |
# File 'lib/ruby_info.rb', line 8 def [](what) send what end |
.all ⇒ Object
16 17 18 |
# File 'lib/ruby_info.rb', line 16 def all Hash[ list.map{ |l| [l, self.public_send(l)] }] end |
.child_program_status ⇒ Object
46 47 48 |
# File 'lib/ruby_info.rb', line 46 def child_program_status $CHILD_STATUS end |
.current_callstack ⇒ Object
122 123 124 |
# File 'lib/ruby_info.rb', line 122 def current_callstack caller end |
.current_file ⇒ Object
# # 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_directory ⇒ Object
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_line ⇒ Object
__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_method ⇒ Object
__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 |
.debug ⇒ Object
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_aliases ⇒ Object
169 170 171 |
# File 'lib/ruby_info.rb', line 169 def encoding_aliases Encoding.aliases end |
.encodings ⇒ Object
165 166 167 |
# File 'lib/ruby_info.rb', line 165 def encodings Encoding.name_list end |
.env ⇒ Object
# # system info
53 54 55 |
# File 'lib/ruby_info.rb', line 53 def env ::ENV end |
.external_encoding ⇒ Object
157 158 159 |
# File 'lib/ruby_info.rb', line 157 def external_encoding Encoding.default_external end |
.gc ⇒ Object
69 70 71 |
# File 'lib/ruby_info.rb', line 69 def gc GC.stat end |
.gets_separator ⇒ Object
141 142 143 |
# File 'lib/ruby_info.rb', line 141 def gets_separator $/ end |
.global_constants ⇒ Object
207 208 209 |
# File 'lib/ruby_info.rb', line 207 def global_constants Object.constants end |
.global_variables ⇒ Object
# # ruby objects
203 204 205 |
# File 'lib/ruby_info.rb', line 203 def global_variables Object.send :global_variables end |
.hostname ⇒ Object
# # network info
91 92 93 |
# File 'lib/ruby_info.rb', line 91 def hostname Socket.gethostname end |
.internal_encoding ⇒ Object
161 162 163 |
# File 'lib/ruby_info.rb', line 161 def internal_encoding Encoding.default_internal end |
.join_separator ⇒ Object
145 146 147 |
# File 'lib/ruby_info.rb', line 145 def join_separator $, end |
.last_exception ⇒ Object
196 197 198 |
# File 'lib/ruby_info.rb', line 196 def last_exception $! end |
.last_input ⇒ Object
137 138 139 |
# File 'lib/ruby_info.rb', line 137 def last_input $_ end |
.last_input_file ⇒ Object
# # input / string info
129 130 131 |
# File 'lib/ruby_info.rb', line 129 def last_input_file $FILENAME end |
.last_input_line_number ⇒ Object
133 134 135 |
# File 'lib/ruby_info.rb', line 133 def last_input_line_number $. end |
.list ⇒ Object
12 13 14 |
# File 'lib/ruby_info.rb', line 12 def list singleton_methods.map(&:to_sym) - [:[], :list, :all] end |
.load_path ⇒ Object
65 66 67 |
# File 'lib/ruby_info.rb', line 65 def load_path $: end |
.loaded_programs ⇒ Object
34 35 36 |
# File 'lib/ruby_info.rb', line 34 def loaded_programs $" end |
.os ⇒ Object
57 58 59 |
# File 'lib/ruby_info.rb', line 57 def os RbConfig::CONFIG['host_os'] end |
.print_separator ⇒ Object
149 150 151 |
# File 'lib/ruby_info.rb', line 149 def print_separator $, end |
.process_id ⇒ Object
61 62 63 |
# File 'lib/ruby_info.rb', line 61 def process_id $$ end |
.program_arguments ⇒ Object
30 31 32 |
# File 'lib/ruby_info.rb', line 30 def program_arguments $* end |
.program_data ⇒ Object
38 39 40 |
# File 'lib/ruby_info.rb', line 38 def program_data defined?(::DATA) && DATA end |
.program_name ⇒ Object
# # program info
26 27 28 |
# File 'lib/ruby_info.rb', line 26 def program_name $0 end |
.ruby_copyright ⇒ Object
250 251 252 |
# File 'lib/ruby_info.rb', line 250 def ruby_copyright defined?(::RUBY_COPYRIGHT) && ::RUBY_COPYRIGHT end |
.ruby_description ⇒ Object
230 231 232 |
# File 'lib/ruby_info.rb', line 230 def ruby_description ::RUBY_DESCRIPTION end |
.ruby_engine ⇒ Object
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_patchlevel ⇒ Object
226 227 228 |
# File 'lib/ruby_info.rb', line 226 def ruby_patchlevel ::RUBY_PATCHLEVEL end |
.ruby_platform ⇒ Object
242 243 244 |
# File 'lib/ruby_info.rb', line 242 def ruby_platform ::RUBY_PLATFORM end |
.ruby_release_date ⇒ Object
234 235 236 |
# File 'lib/ruby_info.rb', line 234 def ruby_release_date ::RUBY_RELEASE_DATE end |
.ruby_revision ⇒ Object
246 247 248 |
# File 'lib/ruby_info.rb', line 246 def ruby_revision defined?(::RUBY_REVISION) && ::RUBY_REVISION end |
.ruby_version ⇒ Object
# # 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_lines ⇒ Object
42 43 44 |
# File 'lib/ruby_info.rb', line 42 def script_lines defined?(::SCRIPT_LINES__) && SCRIPT_LINES__ end |
.security_level ⇒ Object
# # misc
176 177 178 |
# File 'lib/ruby_info.rb', line 176 def security_level $SAFE end |
.signals ⇒ Object
215 216 217 |
# File 'lib/ruby_info.rb', line 215 def signals Signal.list end |
.split_separator ⇒ Object
153 154 155 |
# File 'lib/ruby_info.rb', line 153 def split_separator $; end |
.system_call_errors ⇒ Object
211 212 213 |
# File 'lib/ruby_info.rb', line 211 def system_call_errors Errno.constants end |
.user_home ⇒ Object
84 85 86 |
# File 'lib/ruby_info.rb', line 84 def user_home Dir.home end |
.user_login ⇒ Object
# # user info
76 77 78 |
# File 'lib/ruby_info.rb', line 76 def user_login Etc.getlogin end |
.user_name ⇒ Object
80 81 82 |
# File 'lib/ruby_info.rb', line 80 def user_name Etc.getpwnam(user_login).gecos.split(',')[0] end |
.verbose ⇒ Object
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_directory ⇒ Object
102 103 104 |
# File 'lib/ruby_info.rb', line 102 def working_directory Dir.pwd end |