ruby_info 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f0a180ae154076161ee14aac39e9f74c26f93b15
4
+ data.tar.gz: 3d3159b564dc88be1d26067ef4f338fed8a9b6a2
5
+ SHA512:
6
+ metadata.gz: 3ea72adbf6a0961da75585508b597c91ae075571b95d024baf74f45df18b08282dde6aee6c0acc2f0d339237b3cd54e5b5d9055d146d4a00fa730d9650c78445
7
+ data.tar.gz: 5b0d6865a5e2bc0c75590ee5580290a8c014a3231f2c180aa98eb6036d335d260e8f77db0963d1a355cf7c03074811721c58227ae937432c28e413463b14de5a
data/.gitignore ADDED
@@ -0,0 +1,2 @@
1
+ Gemfile.lock
2
+ pkg
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour --format documentation
data/ChangeLog.rdoc ADDED
@@ -0,0 +1,16 @@
1
+ === 1.0.0 / 2014-01-15
2
+
3
+ * New method: all (Output all available information)
4
+ * Rename platform to ruby_platform
5
+ * Rename environment to env
6
+ * Add hostname (Socket.gethostname)
7
+ * Add signals and system_call_errors (Signal.list and Errno.constants)
8
+ * Add script_lines (SCRIPT_LINES__)
9
+ * Add encodings and encoding_aliases (Encoding.name_list and Encoding.aliases)
10
+ * Add gc (GC.stat)
11
+ * Add user_home (Dir.home)
12
+ * Add ruby_revision and ruby_copyright (RUBY_REVISION and RUBY_COPYRIGHT)
13
+ * Add verbose and debug ($VERBOSE and $DEBUG)
14
+ * Fix program_arguments
15
+ * Moved from zucker 13.1 gem into its own gem
16
+
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ platform :rbx do
6
+ gem 'rubysl-date'
7
+ gem 'rubysl-singleton'
8
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,37 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ ruby_info (1.0.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.2.5)
10
+ json (1.8.1)
11
+ rake (10.1.1)
12
+ rdoc (3.12.2)
13
+ json (~> 1.4)
14
+ rspec (2.14.1)
15
+ rspec-core (~> 2.14.0)
16
+ rspec-expectations (~> 2.14.0)
17
+ rspec-mocks (~> 2.14.0)
18
+ rspec-core (2.14.7)
19
+ rspec-expectations (2.14.4)
20
+ diff-lcs (>= 1.1.3, < 2.0)
21
+ rspec-mocks (2.14.4)
22
+ rubygems-tasks (0.2.4)
23
+ rubysl-date (2.0.6)
24
+ rubysl-singleton (2.0.0)
25
+
26
+ PLATFORMS
27
+ ruby
28
+
29
+ DEPENDENCIES
30
+ bundler (~> 1.0)
31
+ rake (~> 10.1)
32
+ rdoc (~> 3.0)
33
+ rspec (~> 2.4)
34
+ ruby_info!
35
+ rubygems-tasks (~> 0.2)
36
+ rubysl-date
37
+ rubysl-singleton
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2014 Jan Lelis
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.rdoc ADDED
@@ -0,0 +1,26 @@
1
+ = RubyInfo
2
+
3
+ Provides a +RubyInfo+ class that simplifies accessing global information. Run <tt>RubyInfo.list</tt> to get started. You can also run <tt>RubyInfo.all</tt> to get a hash of all available information (may be a lot).
4
+
5
+ == Setup
6
+
7
+ On your command-line:
8
+
9
+ $ gem install ruby_info
10
+
11
+ In Ruby:
12
+
13
+ require 'ruby_info'
14
+
15
+ == Usage
16
+
17
+ Call methods on the +RubyInfo+ class. See source for more documentation.
18
+
19
+ == Also See
20
+
21
+ https://github.com/janlelis/ruby_engine
22
+ https://github.com/janlelis/ruby_version
23
+
24
+ == J-_-L
25
+
26
+ Copyright (c) 2010-2014 Jan Lelis. MIT License. Originated from the zucker gem.
data/Rakefile ADDED
@@ -0,0 +1,36 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+
5
+ begin
6
+ require 'bundler'
7
+ rescue LoadError => e
8
+ warn e.message
9
+ warn "Run `gem install bundler` to install Bundler."
10
+ exit -1
11
+ end
12
+
13
+ begin
14
+ Bundler.setup(:development)
15
+ rescue Bundler::BundlerError => e
16
+ warn e.message
17
+ warn "Run `bundle install` to install missing gems."
18
+ exit e.status_code
19
+ end
20
+
21
+ require 'rake'
22
+
23
+ require 'rubygems/tasks'
24
+ Gem::Tasks.new
25
+
26
+ require 'rdoc/task'
27
+ RDoc::Task.new do |rdoc|
28
+ rdoc.title = "ruby_version"
29
+ end
30
+ task :doc => :rdoc
31
+
32
+ require 'rspec/core/rake_task'
33
+ RSpec::Core::RakeTask.new
34
+
35
+ task :test => :spec
36
+ task :default => :spec
@@ -0,0 +1,3 @@
1
+ module RubyInfo
2
+ VERSION = "1.0.0"
3
+ end
data/lib/ruby_info.rb ADDED
@@ -0,0 +1,254 @@
1
+ require 'rbconfig'
2
+ require 'etc'
3
+ require 'socket'
4
+
5
+
6
+ module RubyInfo
7
+ class << self
8
+ def [](what)
9
+ send what
10
+ end
11
+
12
+ def list
13
+ singleton_methods.map(&:to_sym) - [:[], :list, :all]
14
+ end
15
+
16
+ def all
17
+ Hash[ list.map{ |l| [l, self.public_send(l)] }]
18
+ end
19
+ end
20
+
21
+ module_function
22
+
23
+ # # #
24
+ # program info
25
+
26
+ def program_name
27
+ $0
28
+ end
29
+
30
+ def program_arguments
31
+ $*
32
+ end
33
+
34
+ def loaded_programs
35
+ $"
36
+ end
37
+
38
+ def program_data
39
+ defined?(::DATA) && DATA
40
+ end
41
+
42
+ def script_lines
43
+ defined?(::SCRIPT_LINES__) && SCRIPT_LINES__
44
+ end
45
+
46
+ def child_program_status
47
+ $CHILD_STATUS
48
+ end
49
+
50
+ # # #
51
+ # system info
52
+
53
+ def env
54
+ ::ENV
55
+ end
56
+
57
+ def os
58
+ RbConfig::CONFIG['host_os']
59
+ end
60
+
61
+ def process_id
62
+ $$
63
+ end
64
+
65
+ def load_path
66
+ $:
67
+ end
68
+
69
+ def gc
70
+ GC.stat
71
+ end
72
+
73
+ # # #
74
+ # user info
75
+
76
+ def user_login
77
+ Etc.getlogin
78
+ end
79
+
80
+ def user_name
81
+ Etc.getpwnam(user_login).gecos.split(',')[0]
82
+ end
83
+
84
+ def user_home
85
+ Dir.home
86
+ end
87
+
88
+ # # #
89
+ # network info
90
+
91
+ def hostname
92
+ Socket.gethostname
93
+ end
94
+
95
+ # # #
96
+ # current info
97
+
98
+ def current_file # __FILE__
99
+ return $` if caller[0].rindex(/:\d+(:in `.*')?$/)
100
+ end
101
+
102
+ def working_directory
103
+ Dir.pwd
104
+ end
105
+
106
+ def current_file_directory
107
+ if current_file[0,1] == '(' && current_file[-1,1] == ')'
108
+ current_file
109
+ else
110
+ File.dirname(current_file)
111
+ end
112
+ end
113
+
114
+ def current_line # __LINE__
115
+ return $1.to_i if caller[0].rindex( /:(\d+)(:in `.*')?$/ )
116
+ end
117
+
118
+ def current_method # __method__ (except aliases)
119
+ return $1.to_sym if caller(1)[0].rindex( /\`([^\']+)\'/ )
120
+ end
121
+
122
+ def current_callstack
123
+ caller
124
+ end
125
+
126
+ # # #
127
+ # input / string info
128
+
129
+ def last_input_file
130
+ $FILENAME
131
+ end
132
+
133
+ def last_input_line_number
134
+ $.
135
+ end
136
+
137
+ def last_input
138
+ $_
139
+ end
140
+
141
+ def gets_separator
142
+ $/
143
+ end
144
+
145
+ def join_separator
146
+ $,
147
+ end
148
+
149
+ def print_separator
150
+ $,
151
+ end
152
+
153
+ def split_separator
154
+ $;
155
+ end
156
+
157
+ def external_encoding
158
+ Encoding.default_external
159
+ end
160
+
161
+ def internal_encoding
162
+ Encoding.default_internal
163
+ end
164
+
165
+ def encodings
166
+ Encoding.name_list
167
+ end
168
+
169
+ def encoding_aliases
170
+ Encoding.aliases
171
+ end
172
+
173
+ # # #
174
+ # misc
175
+
176
+ def security_level
177
+ $SAFE
178
+ end
179
+
180
+ def verbose
181
+ $VERBOSE
182
+ end
183
+
184
+ def warnings_activated?
185
+ !! $VERBOSE
186
+ end
187
+
188
+ def debug
189
+ $DEBUG
190
+ end
191
+
192
+ def debug_activated?
193
+ !! $DEBUG
194
+ end
195
+
196
+ def last_exception
197
+ $!
198
+ end
199
+
200
+ # # #
201
+ # ruby objects
202
+
203
+ def global_variables
204
+ Object.send :global_variables
205
+ end
206
+
207
+ def global_constants
208
+ Object.constants
209
+ end
210
+
211
+ def system_call_errors
212
+ Errno.constants
213
+ end
214
+
215
+ def signals
216
+ Signal.list
217
+ end
218
+
219
+ # # #
220
+ # ruby info
221
+
222
+ def ruby_version # also see the ruby_version gem
223
+ ::RUBY_VERSION
224
+ end
225
+
226
+ def ruby_patchlevel
227
+ ::RUBY_PATCHLEVEL
228
+ end
229
+
230
+ def ruby_description
231
+ ::RUBY_DESCRIPTION
232
+ end
233
+
234
+ def ruby_release_date
235
+ ::RUBY_RELEASE_DATE
236
+ end
237
+
238
+ def ruby_engine # also see the ruby_engine gem
239
+ defined?(::RUBY_ENGINE) && ::RUBY_ENGINE
240
+ end
241
+
242
+ def ruby_platform
243
+ ::RUBY_PLATFORM
244
+ end
245
+
246
+ def ruby_revision
247
+ defined?(::RUBY_REVISION) && ::RUBY_REVISION
248
+ end
249
+
250
+ def ruby_copyright
251
+ defined?(::RUBY_COPYRIGHT) && ::RUBY_COPYRIGHT
252
+ end
253
+ end
254
+
data/ruby_info.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ require File.expand_path('../lib/ruby_info/version', __FILE__)
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = "ruby_info"
7
+ gem.version = RubyInfo::VERSION
8
+ gem.summary = 'Adds the RubyInfo pseudo-constant.'
9
+ gem.description = 'Provides a RubyInfo class that simplifies accessing global information. Run RubyInfo.list to get started.'
10
+ gem.license = "MIT"
11
+ gem.authors = ["Jan Lelis"]
12
+ gem.email = "mail@janlelis.de"
13
+ gem.homepage = "https://github.com/janlelis/ruby_info"
14
+
15
+ gem.files = Dir['{**/}{.*,*}'].select { |path| File.file?(path) }
16
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
17
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
18
+ gem.require_paths = ['lib']
19
+
20
+ gem.add_development_dependency 'bundler', '~> 1.0'
21
+ gem.add_development_dependency 'rake', '~> 10.1'
22
+ gem.add_development_dependency 'rdoc', '~> 3.0'
23
+ gem.add_development_dependency 'rspec', '~> 2.4'
24
+ gem.add_development_dependency 'rubygems-tasks', '~> 0.2'
25
+ end
metadata ADDED
@@ -0,0 +1,125 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ruby_info
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Jan Lelis
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-01-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.1'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.1'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rdoc
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rspec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '2.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '2.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubygems-tasks
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '0.2'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '0.2'
83
+ description: Provides a RubyInfo class that simplifies accessing global information.
84
+ Run RubyInfo.list to get started.
85
+ email: mail@janlelis.de
86
+ executables: []
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - ".gitignore"
91
+ - ".rspec"
92
+ - ChangeLog.rdoc
93
+ - Gemfile
94
+ - Gemfile.lock
95
+ - LICENSE.txt
96
+ - README.rdoc
97
+ - Rakefile
98
+ - lib/ruby_info.rb
99
+ - lib/ruby_info/version.rb
100
+ - ruby_info.gemspec
101
+ homepage: https://github.com/janlelis/ruby_info
102
+ licenses:
103
+ - MIT
104
+ metadata: {}
105
+ post_install_message:
106
+ rdoc_options: []
107
+ require_paths:
108
+ - lib
109
+ required_ruby_version: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ version: '0'
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - ">="
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ requirements: []
120
+ rubyforge_project:
121
+ rubygems_version: 2.2.0
122
+ signing_key:
123
+ specification_version: 4
124
+ summary: Adds the RubyInfo pseudo-constant.
125
+ test_files: []