sysinfo 0.8.1 → 0.9.0.pre.RC1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +7 -0
  2. data/lib/sysinfo.rb +47 -47
  3. data/sysinfo.gemspec +20 -39
  4. metadata +26 -39
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 41eb7522683b4f474f8cf49d15c03891eb5ba2718a549a8cec52b57afd21922d
4
+ data.tar.gz: 9d235a1c5f590f5088a55e4c15dfe0ff189dd19b0bd6037677c9530de8ff321c
5
+ SHA512:
6
+ metadata.gz: b84c9a323f1a5a399d0821ef8b85c3e82d2dba38e5ef85f742155a5beb13c46e582e30ad0486299e9428dab41638525ec17db50a7653825a4f2be644412b5194
7
+ data.tar.gz: 4c8860fb1ec0305b623839bdfa07beeb9826ab20a07b939a3c8bde424f513bf1c1cf5a58739da8f6e492cd34441e539a60d835d0efabe612d42371cbdb599ccc
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.9.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 ],
@@ -64,14 +64,14 @@ class SysInfo < Storable
64
64
  field :ipaddress_internal => String
65
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,7 +82,7 @@ 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
88
  vm, os, impl, arch = :ruby, :unknown, :unknown, :unknow
@@ -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. "
1
+ Gem::Specification.new do |s|
2
+ s.name = "sysinfo"
3
+ s.version = "0.9.0-RC1"
4
+ s.summary = "SysInfo: All your system-independent infoz in one handy class. "
6
5
  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.
6
+ s.author = "Delano Mandelbaum"
7
+ s.email = "delano@solutious.com"
8
+ s.homepage = "https://github.com/username/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.pre.RC1'
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
+ CHANGES.txt
18
+ LICENSE.txt
19
+ README.rdoc
20
+ Rakefile
21
+ bin/sysinfo
22
+ lib/sysinfo.rb
23
+ sysinfo.gemspec
36
24
  )
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
-
44
25
  end
metadata CHANGED
@@ -1,56 +1,49 @@
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.9.0.pre.RC1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Delano Mandelbaum
9
- autorequire:
8
+ autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2014-02-13 00:00:00.000000000 Z
11
+ date: 2024-04-03 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.pre.RC1
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.pre.RC1
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.'
40
+ version: '1.0'
41
+ description: 'SysInfo: All your system-independent infoz in one handy class.'
47
42
  email: delano@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
48
  - CHANGES.txt
56
49
  - LICENSE.txt
@@ -59,33 +52,27 @@ files:
59
52
  - bin/sysinfo
60
53
  - lib/sysinfo.rb
61
54
  - sysinfo.gemspec
62
- homepage: http://solutious.com/
63
- licenses: []
64
- 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
55
+ homepage: https://github.com/username/sysinfo
56
+ licenses:
57
+ - MIT
58
+ metadata: {}
59
+ post_install_message:
60
+ rdoc_options: []
71
61
  require_paths:
72
62
  - lib
73
63
  required_ruby_version: !ruby/object:Gem::Requirement
74
- none: false
75
64
  requirements:
76
- - - ! '>='
65
+ - - ">="
77
66
  - !ruby/object:Gem::Version
78
67
  version: '0'
79
68
  required_rubygems_version: !ruby/object:Gem::Requirement
80
- none: false
81
69
  requirements:
82
- - - ! '>='
70
+ - - ">"
83
71
  - !ruby/object:Gem::Version
84
- version: '0'
72
+ version: 1.3.1
85
73
  requirements: []
86
- rubyforge_project: sysinfo
87
- rubygems_version: 1.8.23
88
- signing_key:
89
- specification_version: 3
90
- summary: ! 'SysInfo: All your system-independent infoz in one handy class.'
74
+ rubygems_version: 3.3.26
75
+ signing_key:
76
+ specification_version: 4
77
+ summary: 'SysInfo: All your system-independent infoz in one handy class.'
91
78
  test_files: []