sysinfo 0.8.1 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (8) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +79 -0
  3. data/lib/sysinfo.rb +49 -49
  4. data/sysinfo.gemspec +20 -39
  5. metadata +25 -40
  6. data/CHANGES.txt +0 -65
  7. data/README.rdoc +0 -87
  8. data/Rakefile +0 -115
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: e6abf6718a66e70853ccef46d557ed6ff68757c3af0188c8f4cf633bc863681d
4
+ data.tar.gz: 263db44cde8523ca128165a9ac9b6c0fc87e1c25515af328515196ed820db83c
5
+ SHA512:
6
+ metadata.gz: 96c41cd390897307c845e88e3f086b909724013cfc31d05d45ac83a555a44d2ff90330c85eac37ee412bbab8345a3120a11777282d22293dcbbf5f764d7c27d1
7
+ data.tar.gz: a4aeba2408675885745631e69e6c27142d6309816d204aac27151ec92ded195e8f8204ddfec65d2bc4019587157005f26729dc7ef7c72271817d41009fec3c42
data/README.md ADDED
@@ -0,0 +1,79 @@
1
+ # SysInfo - v0.10
2
+
3
+ All your system-independent infoz in one handy class.
4
+
5
+ SysInfo does a takes a very quick glance at the system it's running on and exposes the results as YAML, JSON, CSV, or TSV. It also determines a platform identifier for the system that takes the form: VM-OS-IMPLEMENTATION-ARCHITECTURE.
6
+
7
+ ## Platform Identifier Examples
8
+
9
+ - ruby-unix-osx-i386
10
+ - ruby-unix-osx-powerpc
11
+ - ruby-unix-linux-x86_64
12
+ - java-win32-windows-i386
13
+ - java-win32-mingw-i386
14
+
15
+ For the complete list of operating systems, implementations and architectures that SysInfo is aware of, see:
16
+
17
+ * `$ sysinfo os`
18
+ * `$ sysinfo impl`
19
+ * `$ sysinfo arch`
20
+
21
+
22
+ ## Usage -- Library
23
+
24
+ ```ruby
25
+ sysinfo = SysInfo.new
26
+ sysinfo.vm # => ruby
27
+ sysinfo.os # => unix
28
+ sysinfo.impl # => osx
29
+ sysinfo.arch # => i386
30
+ sysinfo.platform # => ruby-unix
31
+ sysinfo.to_s # => ruby-unix-osx-i386
32
+
33
+ sysinfo.user # => delano
34
+ sysinfo.home # => /Users/delano
35
+ sysinfo.uptime # => 290.429 (hours)
36
+ sysinfo.shell # => /bin/bash
37
+ sysinfo.paths # => [/sbin, /bin, /usr/bin, ...]
38
+
39
+ sysinfo.hostname # => walter
40
+ sysinfo.ipaddress_internal # => 10.0.1.2
41
+ sysinfo.uptime # => 290.573655656974
42
+ sysinfo.ruby # => [1,9,1]
43
+ ```
44
+
45
+ ## Usage -- Executable
46
+
47
+ ```bash
48
+ $ sysinfo
49
+ ruby-unix-osx-i386
50
+
51
+ $ /usr/jruby/bin/sysinfo
52
+ java-unix-osx-x86_64
53
+
54
+ $ sysinfo -f yaml
55
+ :vm: :ruby
56
+ :os: :unix
57
+ :impl: :osx
58
+ ...
59
+ :shell: :"/bin/bash"
60
+ :user: delano
61
+
62
+ $ sysinfo -f json
63
+ {"vm":"ruby","os":"unix","impl":"osx", ..., "shell":"\/bin\/bash","user":"delano"}
64
+
65
+ $ sysinfo -f csv
66
+ ruby,unix,osx, ... /bin/bash,delano
67
+ ```
68
+
69
+ ## Installation
70
+
71
+ ```bash
72
+ $ sudo gem install sysinfo
73
+ ```
74
+
75
+
76
+ ## Prerequisites
77
+
78
+ * Ruby 1.9+, 2.6.8+, 3.1.4+, or JRuby 1.2+
79
+ * [Storable](https://github.com/delano/storable)
data/lib/sysinfo.rb CHANGED
@@ -4,25 +4,25 @@ require 'time'
4
4
  require 'tmpdir'
5
5
 
6
6
  # = SysInfo
7
- #
8
- # A container for the platform specific system information.
9
- # Portions of this code were originally from Amazon's EC2 AMI tools,
10
- # specifically lib/platform.rb.
7
+ #
8
+ # A container for the platform specific system information.
9
+ # Portions of this code were originally from Amazon's EC2 AMI tools,
10
+ # specifically lib/platform.rb.
11
11
  class SysInfo < Storable
12
12
  unless defined?(IMPLEMENTATIONS)
13
- VERSION = "0.8.1".freeze
13
+ VERSION = "0.10.0".freeze
14
14
  IMPLEMENTATIONS = [
15
-
16
- # These are for JRuby, System.getproperty('os.name').
15
+
16
+ # These are for JRuby, System.getproperty('os.name').
17
17
  # For a list of all values, see: http://lopica.sourceforge.net/os.html
18
-
18
+
19
19
  #regexp matcher os implementation
20
- [/mac\s*os\s*x/i, :unix, :osx ],
21
- [/sunos/i, :unix, :solaris ],
20
+ [/mac\s*os\s*x/i, :unix, :osx ],
21
+ [/sunos/i, :unix, :solaris ],
22
22
  [/windows\s*ce/i, :windows, :wince ],
23
- [/windows/i, :windows, :windows ],
23
+ [/windows/i, :windows, :windows ],
24
24
  [/osx/i, :unix, :osx ],
25
-
25
+
26
26
  # These are for RUBY_PLATFORM and JRuby
27
27
  [/java/i, :java, :java ],
28
28
  [/darwin/i, :unix, :osx ],
@@ -52,6 +52,7 @@ class SysInfo < Storable
52
52
  [/mips/i, :mips ],
53
53
  [/powerpc/i, :powerpc ],
54
54
  [/universal/i,:x86_64 ],
55
+ [/arm64/i, :arm64 ],
55
56
  [nil, :unknown ],
56
57
  ].freeze
57
58
  end
@@ -62,16 +63,15 @@ class SysInfo < Storable
62
63
  field :arch => String
63
64
  field :hostname => String
64
65
  field :ipaddress_internal => String
65
- #field :ipaddress_external => String
66
66
  field :uptime => Float
67
-
67
+
68
68
  field :paths
69
69
  field :tmpdir
70
70
  field :home
71
71
  field :shell
72
72
  field :user
73
73
  field :ruby
74
-
74
+
75
75
  alias :implementation :impl
76
76
  alias :architecture :arch
77
77
 
@@ -82,10 +82,10 @@ class SysInfo < Storable
82
82
  @user = getpwattr(:name) || ENV['USER']
83
83
  require 'Win32API' if @os == :windows && @vm == :ruby
84
84
  end
85
-
85
+
86
86
  # Returns [vm, os, impl, arch]
87
87
  def find_platform_info
88
- vm, os, impl, arch = :ruby, :unknown, :unknown, :unknow
88
+ vm, os, impl, arch = :ruby, :unknown, :unknown, :unknown
89
89
  IMPLEMENTATIONS.each do |r, o, i|
90
90
  next unless RUBY_PLATFORM =~ r
91
91
  os, impl = [o, i]
@@ -98,25 +98,25 @@ class SysInfo < Storable
98
98
  end
99
99
  os == :java ? guess_java : [vm, os, impl, arch]
100
100
  end
101
-
101
+
102
102
  # Returns [hostname, ipaddr (internal), uptime]
103
103
  def find_network_info
104
104
  hostname, ipaddr, uptime = :unknown, :unknown, :unknown
105
105
  begin
106
106
  hostname = find_hostname
107
107
  ipaddr = find_ipaddress_internal
108
- uptime = find_uptime
108
+ uptime = find_uptime
109
109
  rescue => ex # Be silent!
110
110
  end
111
111
  [hostname, ipaddr, uptime]
112
112
  end
113
-
113
+
114
114
  # Return the hostname for the local machine
115
115
  def find_hostname; Socket.gethostname; end
116
-
117
- # Returns the local uptime in hours. Use Win32API in Windows,
116
+
117
+ # Returns the local uptime in hours. Use Win32API in Windows,
118
118
  # 'sysctl -b kern.boottime' os osx, and 'who -b' on unix.
119
- # Based on Ruby Quiz solutions by: Matthias Reitinger
119
+ # Based on Ruby Quiz solutions by: Matthias Reitinger
120
120
  # On Windows, see also: net statistics server
121
121
  def find_uptime
122
122
  hours = 0
@@ -129,24 +129,24 @@ class SysInfo < Storable
129
129
  hours
130
130
  end
131
131
 
132
-
132
+
133
133
  # Return the local IP address which receives external traffic
134
134
  # from: http://coderrr.wordpress.com/2008/05/28/get-your-local-ip-address/
135
- # NOTE: This <em>does not</em> open a connection to the IP address.
135
+ # NOTE: This <em>does not</em> open a connection to the IP address.
136
136
  def find_ipaddress_internal
137
- # turn off reverse DNS resolution temporarily
138
- orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true
137
+ # turn off reverse DNS resolution temporarily
138
+ orig, Socket.do_not_reverse_lookup = Socket.do_not_reverse_lookup, true
139
139
  UDPSocket.open {|s| s.connect('65.74.177.129', 1); s.addr.last } # GitHub IP
140
- ensure
140
+ ensure
141
141
  Socket.do_not_reverse_lookup = orig
142
142
  end
143
-
143
+
144
144
  # Returns a String of the full platform descriptor in the format: VM-OS-IMPL-ARCH
145
145
  # e.g. <tt>java-unix-osx-x86_64</tt>
146
146
  def platform
147
147
  "#{@vm}-#{@os}-#{@impl}-#{@arch}"
148
148
  end
149
-
149
+
150
150
  # Returns the environment paths as an Array
151
151
  def paths; execute_platform_specific(:paths); end
152
152
  # Returns the path to the current user's home directory
@@ -155,10 +155,10 @@ class SysInfo < Storable
155
155
  def shell; execute_platform_specific(:shell); end
156
156
  # Returns the path to the current temp directory
157
157
  def tmpdir; execute_platform_specific(:tmpdir); end
158
-
158
+
159
159
  private
160
-
161
- # Look for and execute a platform specific method.
160
+
161
+ # Look for and execute a platform specific method.
162
162
  # The name of the method will be in the format: +dtype-VM-OS-IMPL+.
163
163
  # e.g. find_uptime_ruby_unix_osx
164
164
  #
@@ -169,28 +169,28 @@ class SysInfo < Storable
169
169
  return self.send(meth) if SysInfo.private_method_defined?(meth)
170
170
  criteria.pop
171
171
  end
172
- raise "#{dtype}_#{@vm}_#{@os}_#{@impl} not implemented"
172
+ raise "#{dtype}_#{@vm}_#{@os}_#{@impl} not implemented"
173
173
  end
174
-
174
+
175
175
  def paths_ruby_unix; (ENV['PATH'] || '').split(':'); end
176
176
  def paths_ruby_windows; (ENV['PATH'] || '').split(';'); end # Not tested!
177
177
  def paths_java
178
178
  delim = @impl == :windows ? ';' : ':'
179
179
  (ENV['PATH'] || '').split(delim)
180
180
  end
181
-
181
+
182
182
  def tmpdir_ruby_unix; (Dir.tmpdir || '/tmp'); end
183
183
  def tmpdir_ruby_windows; (Dir.tmpdir || 'C:\\temp'); end
184
184
  def tmpdir_java
185
185
  default = @impl == :windows ? 'C:\\temp' : '/tmp'
186
186
  (Dir.tmpdir || default)
187
187
  end
188
-
188
+
189
189
  def shell_ruby_unix; (ENV['SHELL'] || getpwattr(:shell) || 'bash').to_sym; end
190
190
  def shell_ruby_windows; :dos; end
191
191
  alias_method :shell_java_unix, :shell_ruby_unix
192
192
  alias_method :shell_java_windows, :shell_ruby_windows
193
-
193
+
194
194
  def home_ruby_unix; File.expand_path(getpwattr(:dir)); end
195
195
  def home_ruby_windows; File.expand_path(ENV['USERPROFILE']); end
196
196
  def home_java
@@ -200,9 +200,9 @@ class SysInfo < Storable
200
200
  File.expand_path(getpwattr(:dir))
201
201
  end
202
202
  end
203
-
203
+
204
204
  # Ya, this is kinda wack. Ruby -> Java -> Kernel32. See:
205
- # http://www.oreillynet.com/ruby/blog/2008/01/jruby_meets_the_windows_api_1.html
205
+ # http://www.oreillynet.com/ruby/blog/2008/01/jruby_meets_the_windows_api_1.html
206
206
  # http://msdn.microsoft.com/en-us/library/ms724408(VS.85).aspx
207
207
  # Ruby 1.9.1: Win32API is now deprecated in favor of using the DL library.
208
208
  def find_uptime_java_windows_windows
@@ -216,30 +216,30 @@ class SysInfo < Storable
216
216
  ((getTickCount.call()).to_f / 1000).to_f
217
217
  end
218
218
  def find_uptime_ruby_unix_osx
219
- # This is faster than "who" and could work on BSD also.
219
+ # This is faster than "who" and could work on BSD also.
220
220
  (Time.now.to_f - Time.at(`sysctl -b kern.boottime 2>/dev/null`.unpack('L').first).to_f).to_f
221
221
  end
222
-
222
+
223
223
  # This should work for most unix flavours.
224
224
  def find_uptime_ruby_unix
225
225
  # who is sloooooow. Use File.read('/proc/uptime')
226
226
  (Time.now.to_i - Time.parse(`who -b 2>/dev/null`).to_f)
227
227
  end
228
228
  alias_method :find_uptime_java_unix_osx, :find_uptime_ruby_unix
229
-
230
- # Determine the values for vm, os, impl, and arch when running on Java.
229
+
230
+ # Determine the values for vm, os, impl, and arch when running on Java.
231
231
  def guess_java
232
232
  vm, os, impl, arch = :java, :unknown, :unknown, :unknown
233
233
  require 'java'
234
234
  include_class java.lang.System unless defined?(System)
235
-
235
+
236
236
  osname = System.getProperty("os.name")
237
237
  IMPLEMENTATIONS.each do |r, o, i|
238
238
  next unless osname =~ r
239
239
  os, impl = [o, i]
240
240
  break
241
241
  end
242
-
242
+
243
243
  osarch = System.getProperty("os.arch")
244
244
  ARCHITECTURES.each do |r, a|
245
245
  next unless osarch =~ r
@@ -248,12 +248,12 @@ class SysInfo < Storable
248
248
  end
249
249
  [vm, os, impl, arch]
250
250
  end
251
-
252
- # Returns the local IP address based on the hostname.
251
+
252
+ # Returns the local IP address based on the hostname.
253
253
  # According to coderrr (see comments on blog link above), this implementation
254
254
  # doesn't guarantee that it will return the address for the interface external
255
255
  # traffic goes through. It's also possible the hostname isn't resolvable to the
256
- # local IP.
256
+ # local IP.
257
257
  #
258
258
  # NOTE: This code predates the current ip_address_internal. It was just as well
259
259
  # but the other code is cleaner. I'm keeping this old version here for now.
data/sysinfo.gemspec CHANGED
@@ -1,44 +1,25 @@
1
- @spec = Gem::Specification.new do |s|
2
- s.name = "sysinfo"
3
- s.rubyforge_project = "sysinfo"
4
- s.version = "0.8.1"
5
- s.summary = "SysInfo: All your system-independent infoz in one handy class. "
6
- s.description = s.summary
7
- s.author = "Delano Mandelbaum"
8
- s.email = "delano@solutious.com"
9
- s.homepage = "http://solutious.com/"
10
-
11
-
12
- # = EXECUTABLES =
13
- # The list of executables in your project (if any). Don't include the path,
14
- # just the base filename.
1
+ Gem::Specification.new do |s|
2
+ s.name = "sysinfo"
3
+ s.version = "0.10.0"
4
+ s.summary = "All your system-independent infoz in one handy class."
5
+ s.description = "SysInfo: #{s.summary}"
6
+ s.author = "Delano Mandelbaum"
7
+ s.email = "gems@solutious.com"
8
+ s.homepage = "https://github.com/delano/sysinfo" # replace with actual URL
9
+ s.license = "MIT" # replace with actual license
10
+
15
11
  s.executables = %w[sysinfo]
16
-
17
- # = DEPENDENCIES =
18
- # Add all gem dependencies
19
- s.add_dependency 'storable'
20
- s.add_dependency 'drydock'
21
-
22
- # = MANIFEST =
23
- # The complete list of files to be included in the release. When GitHub packages your gem,
24
- # it doesn't allow you to run any command that accesses the filesystem. You will get an
25
- # error. You can ask your VCS for the list of versioned files:
26
- # git ls-files
27
- # svn list -R
12
+
13
+ s.add_dependency 'storable', '~> 0.10'
14
+ s.add_dependency 'drydock', '<1.0'
15
+
28
16
  s.files = %w(
29
- CHANGES.txt
30
- LICENSE.txt
31
- README.rdoc
32
- Rakefile
33
- bin/sysinfo
34
- lib/sysinfo.rb
35
- sysinfo.gemspec
17
+ LICENSE.txt
18
+ README.md
19
+ bin/sysinfo
20
+ lib/sysinfo.rb
21
+ sysinfo.gemspec
36
22
  )
37
-
38
- s.extra_rdoc_files = %w[README.rdoc LICENSE.txt]
39
- s.has_rdoc = true
40
- s.rdoc_options = ["--line-numbers", "--title", s.summary, "--main", "README.rdoc"]
41
- s.require_paths = %w[lib]
42
- s.rubygems_version = '1.3.0'
43
23
 
24
+ s.required_ruby_version = '>= 2.6.8'
44
25
  end
metadata CHANGED
@@ -1,91 +1,76 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sysinfo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.1
5
- prerelease:
4
+ version: 0.10.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Delano Mandelbaum
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-02-13 00:00:00.000000000 Z
11
+ date: 2024-04-05 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: storable
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - "~>"
20
18
  - !ruby/object:Gem::Version
21
- version: '0'
19
+ version: '0.10'
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - "~>"
28
25
  - !ruby/object:Gem::Version
29
- version: '0'
26
+ version: '0.10'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: drydock
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - "<"
36
32
  - !ruby/object:Gem::Version
37
- version: '0'
33
+ version: '1.0'
38
34
  type: :runtime
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - "<"
44
39
  - !ruby/object:Gem::Version
45
- version: '0'
46
- description: ! 'SysInfo: All your system-independent infoz in one handy class.'
47
- email: delano@solutious.com
40
+ version: '1.0'
41
+ description: 'SysInfo: All your system-independent infoz in one handy class.'
42
+ email: gems@solutious.com
48
43
  executables:
49
44
  - sysinfo
50
45
  extensions: []
51
- extra_rdoc_files:
52
- - README.rdoc
53
- - LICENSE.txt
46
+ extra_rdoc_files: []
54
47
  files:
55
- - CHANGES.txt
56
48
  - LICENSE.txt
57
- - README.rdoc
58
- - Rakefile
49
+ - README.md
59
50
  - bin/sysinfo
60
51
  - lib/sysinfo.rb
61
52
  - sysinfo.gemspec
62
- homepage: http://solutious.com/
63
- licenses: []
53
+ homepage: https://github.com/delano/sysinfo
54
+ licenses:
55
+ - MIT
56
+ metadata: {}
64
57
  post_install_message:
65
- rdoc_options:
66
- - --line-numbers
67
- - --title
68
- - ! 'SysInfo: All your system-independent infoz in one handy class.'
69
- - --main
70
- - README.rdoc
58
+ rdoc_options: []
71
59
  require_paths:
72
60
  - lib
73
61
  required_ruby_version: !ruby/object:Gem::Requirement
74
- none: false
75
62
  requirements:
76
- - - ! '>='
63
+ - - ">="
77
64
  - !ruby/object:Gem::Version
78
- version: '0'
65
+ version: 2.6.8
79
66
  required_rubygems_version: !ruby/object:Gem::Requirement
80
- none: false
81
67
  requirements:
82
- - - ! '>='
68
+ - - ">="
83
69
  - !ruby/object:Gem::Version
84
70
  version: '0'
85
71
  requirements: []
86
- rubyforge_project: sysinfo
87
- rubygems_version: 1.8.23
72
+ rubygems_version: 3.2.3
88
73
  signing_key:
89
- specification_version: 3
90
- summary: ! 'SysInfo: All your system-independent infoz in one handy class.'
74
+ specification_version: 4
75
+ summary: All your system-independent infoz in one handy class.
91
76
  test_files: []
data/CHANGES.txt DELETED
@@ -1,65 +0,0 @@
1
- SYSINFO, CHANGES
2
-
3
-
4
- #### 0.8.1 (2014-02-11) #############################
5
-
6
- * CHANGE: Use Etc.getpwuid [jperville]
7
-
8
- #### 0.8.0 (2012-04-30) #############################
9
-
10
- * CHANGE: Removed #to_s
11
- * CHANGE: #platform now returns VM-OS-IMPL-ARCH
12
- * CHANGE: json is the default output format
13
-
14
-
15
- #### 0.7.2 (2010-02-12) #############################
16
-
17
- * CHANGE: Removed hanna dependency [Diego Elio 'Flameeyes' Pettenò]
18
-
19
- #### 0.7.1 (2009-11-02) #############################
20
-
21
- * CHANGE: Include ruby version and user name in standard dump.
22
-
23
- #### 0.7.0 (2009-08-24) #############################
24
-
25
- NOTE: SysInfo strings are not compatible with previous releases.
26
-
27
- * FIXED: Don't require Win32API when running in JRuby
28
- * CHANGE: All references to "win32" are now "windows". This resolves
29
- the ambiguity between the OS and the Win32 API.
30
- * CHANGE: All references to "i386" are now "x86"
31
-
32
-
33
- #### 0.6.3 (2009-08-03) #############################
34
-
35
- * FIXED: "warning: already initialized constant System" in JRuby
36
-
37
- #### 0.6.2 (2009-06-30) #############################
38
-
39
- * CHANGE: Updated bin/sysinfo for Drydock 0.6.6
40
- * CHANGE: Removed "require 'rubygems'"
41
-
42
- #### 0.6.1 (2009-05-25) #############################
43
-
44
- * CHANGE: Removed RedCloth dependency from gemspec.
45
-
46
- #### 0.6.0 (2009-06-09) ###############################
47
-
48
- * CHANGE: "universal" mapped to "i386". Now: "x86_64"
49
- * CHANGE: "x86" mapped to "386". Now: "x86"
50
- * CHANGE: /i\d86/ mapped to "386". Now: "x86"
51
-
52
-
53
- #### 0.5.1 (2009-05-07) ###############################
54
-
55
- * CHANGE: Hella cleanup in preparation for future expansion.
56
- * CHANGE: Modified platform, now returns VM-OS instead of OS-IMPL
57
- * ADDED: to_s which returns a full platform string
58
- * ADDED: sysinfo executable
59
-
60
-
61
- #### 0.5 (2009-05-07) ###############################
62
-
63
- * First public release. See commit history for solutious-stella, solutious-rudy,
64
- and delano-rye for complete history of SysInfo (was SystemInfo).
65
-
data/README.rdoc DELETED
@@ -1,87 +0,0 @@
1
- = SysInfo - v0.6
2
-
3
- All your system-independent infoz in one handy class.
4
-
5
- SysInfo does a takes a very quick glance at the system it's running on and exposes the results as YAML, JSON, CSV, or TSV. It also determines a platform identifier for the system that takes the form: VM-OS-IMPLEMENTATION-ARCHITECTURE.
6
-
7
- === Platform Identifier Examples
8
-
9
- ruby-unix-osx-i386
10
- ruby-unix-osx-powerpc
11
- ruby-unix-linux-x86_64
12
- java-win32-windows-i386
13
- java-win32-mingw-i386
14
-
15
- For the complete list of operating systems, implementations and architectures that SysInfo is aware of, see:
16
-
17
- * <tt>$ sysinfo os</tt>
18
- * <tt>$ sysinfo impl</tt>
19
- * <tt>$ sysinfo arch</tt>
20
-
21
- == Usage -- Library
22
-
23
- sysinfo = SysInfo.new
24
- p sysinfo.vm # => ruby
25
- p sysinfo.os # => unix
26
- p sysinfo.impl # => osx
27
- p sysinfo.arch # => i386
28
- p sysinfo.platform # => ruby-unix
29
- p sysinfo.to_s # => ruby-unix-osx-i386
30
-
31
- p sysinfo.user # => delano
32
- p sysinfo.home # => /Users/delano
33
- p sysinfo.uptime # => 290.429 (hours)
34
- p sysinfo.shell # => /bin/bash
35
- p sysinfo.paths # => [/sbin, /bin, /usr/bin, ...]
36
-
37
- p sysinfo.hostname # => walter
38
- p sysinfo.ipaddress_internal # => 10.0.1.2
39
- p sysinfo.uptime # => 290.573655656974
40
- p sysinfo.ruby # => [1,9,1]
41
-
42
- == Usage -- Executable
43
-
44
- $ sysinfo
45
- ruby-unix-osx-i386
46
-
47
- $ /usr/jruby/bin/sysinfo
48
- java-unix-osx-x86_64
49
-
50
- $ sysinfo -f yaml
51
- :vm: :ruby
52
- :os: :unix
53
- :impl: :osx
54
- ...
55
- :shell: :"/bin/bash"
56
- :user: delano
57
-
58
- $ sysinfo -f json
59
- {"vm":"ruby","os":"unix","impl":"osx", ..., "shell":"\/bin\/bash","user":"delano"}
60
-
61
- $ sysinfo -f csv
62
- ruby,unix,osx, ... /bin/bash,delano
63
-
64
- == Installation
65
-
66
- Via Rubygems, one of:
67
-
68
- $ sudo gem install sysinfo
69
- $ sudo gem install delano-sysinfo --source http://gems.github.com/
70
-
71
- or via download:
72
- * sysinfo-latest.tar.gz[http://github.com/delano/sysinfo/tarball/latest]
73
- * sysinfo-latest.zip[http://github.com/delano/sysinfo/zipball/latest]
74
-
75
- == Prerequisites
76
-
77
- * Ruby 1.8, Ruby 1.9, or JRuby 1.2
78
- * Storable[http://github.com/delano/storable]
79
-
80
- == Credits
81
-
82
- * Delano Mandelbaum (delano@solutious.com)
83
- * Portions of this code were originally from Amazon's EC2 AMI tools, specifically lib/platform.rb.
84
-
85
- == License
86
-
87
- See: LICENSE.txt
data/Rakefile DELETED
@@ -1,115 +0,0 @@
1
- require 'rubygems'
2
- require 'rake/clean'
3
- require 'rake/gempackagetask'
4
- require 'fileutils'
5
- include FileUtils
6
-
7
- begin
8
- require 'hanna/rdoctask'
9
- rescue LoadError
10
- require 'rake/rdoctask'
11
- end
12
-
13
-
14
- task :default => :package
15
-
16
- # CONFIG =============================================================
17
-
18
- # Change the following according to your needs
19
- README = "README.rdoc"
20
- CHANGES = "CHANGES.txt"
21
- LICENSE = "LICENSE.txt"
22
-
23
- # Files and directories to be deleted when you run "rake clean"
24
- CLEAN.include [ 'pkg', '*.gem', '.config']
25
-
26
- # Virginia assumes your project and gemspec have the same name
27
- name = (Dir.glob('*.gemspec') || ['virginia']).first.split('.').first
28
- load "#{name}.gemspec"
29
- version = @spec.version
30
-
31
- # That's it! The following defaults should allow you to get started
32
- # on other things.
33
-
34
-
35
- # TESTS/SPECS =========================================================
36
-
37
-
38
-
39
- # INSTALL =============================================================
40
-
41
- Rake::GemPackageTask.new(@spec) do |p|
42
- p.need_tar = true if RUBY_PLATFORM !~ /mswin/
43
- end
44
-
45
- task :release => [ :rdoc, :package ]
46
- task :install => [ :rdoc, :package ] do
47
- sh %{sudo gem install pkg/#{name}-#{version}.gem}
48
- end
49
- task :uninstall => [ :clean ] do
50
- sh %{sudo gem uninstall #{name}}
51
- end
52
-
53
-
54
- # RUBYFORGE RELEASE / PUBLISH TASKS ==================================
55
-
56
- if @spec.rubyforge_project
57
- desc 'Publish website to rubyforge'
58
- task 'publish:rdoc' => 'doc/index.html' do
59
- sh "scp -rp doc/* rubyforge.org:/var/www/gforge-projects/#{name}/"
60
- end
61
-
62
- desc 'Public release to rubyforge'
63
- task 'publish:gem' => [:package] do |t|
64
- sh <<-end
65
- rubyforge add_release -o Any -a #{CHANGES} -f -n #{README} #{name} #{name} #{@spec.version} pkg/#{name}-#{@spec.version}.gem &&
66
- rubyforge add_file -o Any -a #{CHANGES} -f -n #{README} #{name} #{name} #{@spec.version} pkg/#{name}-#{@spec.version}.tgz
67
- end
68
- end
69
- end
70
-
71
-
72
-
73
- # RUBY DOCS TASK ==================================
74
- begin
75
- require 'hanna/rdoctask'
76
- rescue LoadError
77
- require 'rake/rdoctask'
78
- end
79
-
80
- Rake::RDocTask.new do |t|
81
- t.rdoc_dir = 'doc'
82
- t.title = @spec.summary
83
- t.options << '--line-numbers' << '--inline-source' << '-A cattr_accessor=object'
84
- t.options << '--charset' << 'utf-8'
85
- t.rdoc_files.include(LICENSE)
86
- t.rdoc_files.include(README)
87
- t.rdoc_files.include(CHANGES)
88
- t.rdoc_files.include('bin/*')
89
- t.rdoc_files.include('lib/**/*.rb')
90
- end
91
-
92
-
93
-
94
-
95
- #Hoe.new('rspec', Spec::VERSION::STRING) do |p|
96
- # p.summary = Spec::VERSION::SUMMARY
97
- # p.description = "Behaviour Driven Development for Ruby."
98
- # p.rubyforge_name = 'rspec'
99
- # p.developer('RSpec Development Team', 'rspec-devel@rubyforge.org')
100
- # p.extra_dev_deps = [["cucumber",">= 0.1.13"]]
101
- # p.remote_rdoc_dir = "rspec/#{Spec::VERSION::STRING}"
102
- # p.rspec_options = ['--options', 'spec/spec.opts']
103
- # p.history_file = 'History.rdoc'
104
- # p.readme_file = 'README.rdoc'
105
- # p.post_install_message = <<-POST_INSTALL_MESSAGE
106
- ##{'*'*50}
107
- #
108
- # Thank you for installing rspec-#{Spec::VERSION::STRING}
109
- #
110
- # Please be sure to read History.rdoc and Upgrade.rdoc
111
- # for useful information about this release.
112
- #
113
- #{'*'*50}
114
- #POST_INSTALL_MESSAGE
115
- #end