sys-uptime 0.4.5-mswin32 → 0.5.0-mswin32
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +10 -0
- data/MANIFEST +13 -17
- data/README +8 -10
- data/doc/uptime.txt +8 -6
- data/lib/sys/uptime.rb +5 -4
- data/test/tc_uptime.rb +9 -24
- metadata +3 -3
data/CHANGES
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
== 0.5.0 - 31-Mar-2007
|
2
|
+
* For platforms that use C code, the code now always uses the sysctl()
|
3
|
+
function if supported by your system. This replaces the platform specific
|
4
|
+
checks I was doing for the various BSD flavors.
|
5
|
+
* Fix for OS X - the Uptime.boot_time method now works.
|
6
|
+
* UptimeError is now Uptime::Error.
|
7
|
+
* Improved RDoc in the uptime.c source code.
|
8
|
+
* Added a Rakefile - users should now use the 'test' and 'install' rake tasks.
|
9
|
+
* Updates to the MANIFEST, README and uptime.txt files.
|
10
|
+
|
1
11
|
== 0.4.5 - 19-Nov-2006
|
2
12
|
* Internal layout changes, minor doc updates and gemspec improvements.
|
3
13
|
* No code changes.
|
data/MANIFEST
CHANGED
@@ -1,17 +1,13 @@
|
|
1
|
-
CHANGES
|
2
|
-
MANIFEST
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
doc/uptime.txt
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
lib/sys/linux.rb
|
15
|
-
lib/sys/windows.rb
|
16
|
-
|
17
|
-
test/tc_uptime.rb
|
1
|
+
* CHANGES
|
2
|
+
* MANIFEST
|
3
|
+
* Rakefile
|
4
|
+
* README
|
5
|
+
* install.rb
|
6
|
+
* sys-uptime.gemspec
|
7
|
+
* doc/uptime.txt
|
8
|
+
* examples/test.rb
|
9
|
+
* ext/extconf.rb
|
10
|
+
* ext/uptime.c
|
11
|
+
* lib/sys/linux.rb
|
12
|
+
* lib/sys/windows.rb
|
13
|
+
* test/tc_uptime.rb
|
data/README
CHANGED
@@ -4,17 +4,15 @@
|
|
4
4
|
= Prerequisites
|
5
5
|
Ruby 1.8.0 or later.
|
6
6
|
Ruby 1.8.2 or later is recommended on MS Windows.
|
7
|
+
A C compiler, except for MS Windows.
|
7
8
|
|
8
9
|
= Installation
|
9
|
-
===
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
=== Windows and Linux:
|
16
|
-
ruby test\tc_uptime.rb (optional)
|
17
|
-
ruby install.rb
|
10
|
+
=== Manual
|
11
|
+
rake test (optional)
|
12
|
+
rake install
|
13
|
+
=== Gems
|
14
|
+
ruby sys-uptime.gemspec
|
15
|
+
gem install sys-uptime-X.Y.Z.gem # Where 'X.Y.Z' are version numbers
|
18
16
|
|
19
17
|
== Notes
|
20
|
-
For additional documentation see doc/uptime.txt.
|
18
|
+
For additional documentation see doc/uptime.txt.
|
data/doc/uptime.txt
CHANGED
@@ -43,10 +43,12 @@ Uptime.uptime
|
|
43
43
|
seconds the system has been running as a colon-separated string.
|
44
44
|
|
45
45
|
== Exceptions
|
46
|
-
|
47
|
-
Raised if something goes wrong.
|
48
|
-
failure of the times() function.
|
49
|
-
|
46
|
+
Uptime::Error
|
47
|
+
Raised if something goes wrong. On Unix, this would likely mean a
|
48
|
+
failure of the times() function. That would be highly unusual.
|
49
|
+
|
50
|
+
On Windows, it probably means you failed to connect to WMI properly. The
|
51
|
+
mostly likely reason would be that the WMI service wasn't running.
|
50
52
|
|
51
53
|
== Notes
|
52
54
|
On MS Windows each of the class methods optionally takes a host name as
|
@@ -73,7 +75,7 @@ UptimeError
|
|
73
75
|
Ruby's
|
74
76
|
|
75
77
|
== Copyright
|
76
|
-
Copyright 2002-
|
78
|
+
Copyright 2002-2007, Daniel J. Berger
|
77
79
|
|
78
80
|
All Rights Reserved. This module is free software. It may be used,
|
79
81
|
redistributed and/or modified under the same terms as Ruby itself.
|
@@ -90,7 +92,7 @@ UptimeError
|
|
90
92
|
|
91
93
|
== Author
|
92
94
|
Daniel J. Berger
|
93
|
-
djberg96 at gmail dot com
|
95
|
+
djberg96 at nospam at gmail dot com
|
94
96
|
imperator on IRC (Freenode)
|
95
97
|
|
96
98
|
== See Also
|
data/lib/sys/uptime.rb
CHANGED
@@ -3,9 +3,10 @@ require 'socket'
|
|
3
3
|
require 'parsedate'
|
4
4
|
|
5
5
|
module Sys
|
6
|
-
class UptimeError < StandardError; end
|
7
6
|
class Uptime
|
8
|
-
|
7
|
+
class Error < StandardError; end
|
8
|
+
|
9
|
+
VERSION = '0.5.0'
|
9
10
|
|
10
11
|
# Returns the boot time as a Time object.
|
11
12
|
#
|
@@ -14,7 +15,7 @@ module Sys
|
|
14
15
|
begin
|
15
16
|
wmi = WIN32OLE.connect(cs)
|
16
17
|
rescue WIN32OLERuntimeError => e
|
17
|
-
raise
|
18
|
+
raise Error, e
|
18
19
|
else
|
19
20
|
query = "select LastBootupTime from Win32_OperatingSystem"
|
20
21
|
results = wmi.ExecQuery(query)
|
@@ -71,7 +72,7 @@ module Sys
|
|
71
72
|
begin
|
72
73
|
wmi = WIN32OLE.connect(cs)
|
73
74
|
rescue WIN32OLERuntimeError => e
|
74
|
-
raise
|
75
|
+
raise Error, e
|
75
76
|
else
|
76
77
|
query = "select LastBootupTime from Win32_OperatingSystem"
|
77
78
|
results = wmi.ExecQuery(query)
|
data/test/tc_uptime.rb
CHANGED
@@ -1,35 +1,16 @@
|
|
1
|
-
|
1
|
+
#####################################################################
|
2
2
|
# tc_uptime.rb
|
3
3
|
#
|
4
|
-
# Test suite for sys-uptime.
|
5
|
-
|
6
|
-
|
7
|
-
if base == 'test' || base =~ /sys-uptime.*/
|
8
|
-
require 'fileutils'
|
9
|
-
Dir.chdir('..') if base == 'test'
|
10
|
-
Dir.mkdir('sys') unless File.exists?('sys')
|
11
|
-
|
12
|
-
if RUBY_PLATFORM.match('mswin')
|
13
|
-
FileUtils.cp('lib/sys/windows.rb', 'sys/uptime.rb') rescue nil
|
14
|
-
elsif RUBY_PLATFORM.match('linux')
|
15
|
-
FileUtils.cp('lib/sys/linux.rb', 'sys/uptime.rb') rescue nil
|
16
|
-
else
|
17
|
-
require 'rbconfig'
|
18
|
-
file = 'ext/uptime.' + Config::CONFIG['DLEXT']
|
19
|
-
FileUtils.cp(file, 'sys')
|
20
|
-
end
|
21
|
-
|
22
|
-
$LOAD_PATH.unshift(Dir.pwd)
|
23
|
-
$LOAD_PATH.unshift(Dir.pwd + '/lib')
|
24
|
-
end
|
25
|
-
|
4
|
+
# Test suite for sys-uptime. This should generally be run via the
|
5
|
+
# 'rake test' task, since it handles the pre-setup code for you.
|
6
|
+
#####################################################################
|
26
7
|
require 'sys/uptime'
|
27
8
|
require 'test/unit'
|
28
9
|
include Sys
|
29
10
|
|
30
11
|
class TC_Uptime < Test::Unit::TestCase
|
31
12
|
def test_version
|
32
|
-
assert_equal('0.
|
13
|
+
assert_equal('0.5.0', Uptime::VERSION)
|
33
14
|
end
|
34
15
|
|
35
16
|
def test_seconds
|
@@ -77,4 +58,8 @@ class TC_Uptime < Test::Unit::TestCase
|
|
77
58
|
assert_nothing_raised{ Uptime.boot_time }
|
78
59
|
assert_kind_of(Time, Uptime.boot_time)
|
79
60
|
end
|
61
|
+
|
62
|
+
def test_uptime_error
|
63
|
+
assert_kind_of(StandardError, Uptime::Error.new)
|
64
|
+
end
|
80
65
|
end
|
metadata
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.
|
2
|
+
rubygems_version: 0.9.2
|
3
3
|
specification_version: 1
|
4
4
|
name: sys-uptime
|
5
5
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.
|
7
|
-
date:
|
6
|
+
version: 0.5.0
|
7
|
+
date: 2007-03-30 00:00:00 -06:00
|
8
8
|
summary: A Ruby interface for getting system uptime information.
|
9
9
|
require_paths:
|
10
10
|
- lib
|