sys-uptime 0.4.4 → 0.4.5

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.
data/CHANGES CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.4.5 - 19-Nov-2006
2
+ * Internal layout changes, minor doc updates and gemspec improvements.
3
+ * No code changes.
4
+
1
5
  == 0.4.4 - 30-Jun-2006
2
6
  * Added inline rdoc documentation to the source files.
3
7
  * Added a gemspec.
data/MANIFEST CHANGED
@@ -1,7 +1,6 @@
1
1
  CHANGES
2
2
  MANIFEST
3
3
  README
4
- extconf.rb
5
4
  install.rb
6
5
  sys-uptime.gemspec
7
6
 
@@ -9,7 +8,10 @@ doc/uptime.txt
9
8
 
10
9
  examples/test.rb
11
10
 
12
- lib/os/unix.c
13
- lib/os/windows.rb
11
+ ext/extconf.rb
12
+ ext/uptime.c
14
13
 
15
- test/tc_uptime.rb
14
+ lib/sys/linux.rb
15
+ lib/sys/windows.rb
16
+
17
+ test/tc_uptime.rb
data/README CHANGED
@@ -1,20 +1,20 @@
1
- == Description
1
+ = Description
2
2
  A Ruby interface for getting system uptime information.
3
3
 
4
- == Prerequisites
4
+ = Prerequisites
5
5
  Ruby 1.8.0 or later.
6
- On Win32 systems, Ruby 1.8.2 or later is recommended.
6
+ Ruby 1.8.2 or later is recommended on MS Windows.
7
7
 
8
- == Installation
8
+ = Installation
9
9
  === Unix:
10
- ruby extconf.rb
11
- make
12
- ruby test/tc_uptime.rb (optional)
13
- make site-install
10
+ ruby extconf.rb
11
+ make
12
+ ruby test/tc_uptime.rb (optional)
13
+ make install
14
14
 
15
15
  === Windows and Linux:
16
- ruby test\tc_uptime.rb (optional)
17
- ruby install.rb
16
+ ruby test\tc_uptime.rb (optional)
17
+ ruby install.rb
18
18
 
19
19
  == Notes
20
- For additional documentation see doc/uptime.txt.
20
+ For additional documentation see doc/uptime.txt.
data/ext/extconf.rb ADDED
@@ -0,0 +1,29 @@
1
+ ################################################
2
+ # extconf.rb
3
+ #
4
+ # Configuration & build script for sys-uptime.
5
+ ################################################
6
+ require 'mkmf'
7
+ require 'fileutils'
8
+
9
+ if RUBY_PLATFORM =~ /windows|win32|cygwin|mingw|dos|linux/i
10
+ STDERR.puts 'Run the "install.rb" script instead on this platform'
11
+ exit
12
+ else
13
+ # Don't install the pure Ruby libraries during 'make install'.
14
+ if File.basename(Dir.pwd) =~ /ext|sys-uptime/i
15
+ Dir.chdir('..'){
16
+ if File.exists?('lib/sys/windows.rb')
17
+ FileUtils.mv('lib/sys/windows.rb', 'lib/sys/windows.orig')
18
+ end
19
+
20
+ if File.exists?('lib/sys/linux.rb')
21
+ FileUtils.mv('lib/sys/linux.rb', 'lib/sys/linux.orig')
22
+ end
23
+ }
24
+ end
25
+ end
26
+
27
+ have_header('sys/loadavg.h')
28
+ have_header('utmpx.h')
29
+ create_makefile('sys/uptime')
@@ -1,5 +1,5 @@
1
1
  /******************************************************************************
2
- * unix.c (uptime.c)
2
+ * uptime.c
3
3
  *
4
4
  * Authors:
5
5
  * Daniel Berger
@@ -7,7 +7,7 @@
7
7
  *
8
8
  * sys-uptime source code for most *nix platforms
9
9
  *****************************************************************************/
10
- #include "ruby.h"
10
+ #include <ruby.h>
11
11
 
12
12
  #if defined (__FreeBSD__) || defined (__NetBSD__)
13
13
  #include <sys/time.h>
@@ -45,7 +45,7 @@
45
45
 
46
46
  #define MAXSTRINGSIZE 32 /* reasonable limit */
47
47
 
48
- #define SYS_UPTIME_VERSION "0.4.4"
48
+ #define SYS_UPTIME_VERSION "0.4.5"
49
49
 
50
50
  VALUE cUptimeError;
51
51
 
@@ -59,7 +59,7 @@ unsigned long get_uptime_secs()
59
59
  mib[0] = CTL_KERN;
60
60
  mib[1] = KERN_BOOTTIME;
61
61
  if(sysctl(mib, 2, &tv, &tvlen, NULL, 0)){
62
- rb_raise(cUptimeError,"sysctl() call failed");
62
+ rb_raise(cUptimeError, "sysctl() call failed");
63
63
  }
64
64
  return time(NULL) - tv.tv_sec;
65
65
  #else
data/test/tc_uptime.rb CHANGED
@@ -1,76 +1,74 @@
1
1
  #################################
2
2
  # tc_uptime.rb
3
3
  #
4
- # Test suite for sys-uptime
4
+ # Test suite for sys-uptime.
5
5
  #################################
6
6
  base = File.basename(Dir.pwd)
7
- if base == "test" || base =~ /sys-uptime.*/
8
- require "ftools"
9
- Dir.chdir("..") if base == "test"
7
+ if base == 'test' || base =~ /sys-uptime.*/
8
+ require 'fileutils'
9
+ Dir.chdir('..') if base == 'test'
10
+ Dir.mkdir('sys') unless File.exists?('sys')
10
11
 
11
- extension = ".so"
12
- extension = ".bundle" if RUBY_PLATFORM =~ /powerpc|darwin/i
13
- extension = ".sl" if RUBY_PLATFORM =~ /hpux/i
14
-
15
- Dir.mkdir("sys") unless File.exists?("sys")
16
-
17
- if PLATFORM.match("mswin")
18
- File.copy("lib/os/windows.rb", "sys/uptime.rb")
19
- elsif PLATFORM.match("linux")
20
- File.copy("lib/os/linux.rb", "sys/uptime.rb")
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
21
16
  else
22
- file = "uptime" + extension
23
- File.copy(file,"sys")
17
+ require 'rbconfig'
18
+ file = 'ext/uptime.' + Config::CONFIG['DLEXT']
19
+ FileUtils.cp(file, 'sys')
24
20
  end
25
- $LOAD_PATH.unshift Dir.pwd
21
+
22
+ $LOAD_PATH.unshift(Dir.pwd)
23
+ $LOAD_PATH.unshift(Dir.pwd + '/lib')
26
24
  end
27
25
 
28
- require "sys/uptime"
29
- require "test/unit"
26
+ require 'sys/uptime'
27
+ require 'test/unit'
30
28
  include Sys
31
29
 
32
30
  class TC_Uptime < Test::Unit::TestCase
33
31
  def test_version
34
- assert_equal('0.4.4', Uptime::VERSION, "Bad VERSION")
32
+ assert_equal('0.4.5', Uptime::VERSION)
35
33
  end
36
34
 
37
35
  def test_seconds
38
36
  assert_respond_to(Uptime, :seconds)
39
37
  assert_nothing_raised{ Uptime.seconds }
40
- assert_kind_of(Fixnum, Uptime.seconds,"Bad seconds() type")
41
- assert_equal(true, Uptime.seconds > 0, "Bad seconds() return value")
38
+ assert_kind_of(Fixnum, Uptime.seconds)
39
+ assert_equal(true, Uptime.seconds > 0)
42
40
  end
43
41
 
44
42
  def test_minutes
45
43
  assert_respond_to(Uptime, :minutes)
46
44
  assert_nothing_raised{ Uptime.minutes }
47
- assert_kind_of(Fixnum, Uptime.minutes,"Bad minutes() type")
45
+ assert_kind_of(Fixnum, Uptime.minutes)
48
46
  end
49
47
 
50
48
  def test_hours
51
49
  assert_respond_to(Uptime, :hours)
52
50
  assert_nothing_raised{ Uptime.hours }
53
- assert_kind_of(Fixnum, Uptime.hours,"Bad hours() type")
51
+ assert_kind_of(Fixnum, Uptime.hours)
54
52
  end
55
53
 
56
54
  def test_days
57
55
  assert_respond_to(Uptime,:days)
58
56
  assert_nothing_raised{ Uptime.days }
59
- assert_kind_of(Fixnum, Uptime.days,"Bad days() type")
57
+ assert_kind_of(Fixnum, Uptime.days)
60
58
  end
61
59
 
62
60
  def test_uptime
63
61
  assert_respond_to(Uptime,:uptime)
64
62
  assert_nothing_raised{ Uptime.uptime }
65
- assert_kind_of(String, Uptime.uptime,"Bad uptime() type")
66
- assert_equal(false, Uptime.uptime.empty?,"Empty string uptime()")
63
+ assert_kind_of(String, Uptime.uptime)
64
+ assert_equal(false, Uptime.uptime.empty?)
67
65
  end
68
66
 
69
67
  def test_dhms
70
68
  assert_respond_to(Uptime,:dhms)
71
69
  assert_nothing_raised{ Uptime.dhms }
72
- assert_kind_of(Array, Uptime.dhms,"Bad uptime() type")
73
- assert_equal(false, Uptime.dhms.empty?,"Empty array from dhms()")
70
+ assert_kind_of(Array, Uptime.dhms)
71
+ assert_equal(false, Uptime.dhms.empty?)
74
72
  assert_equal(4, Uptime.dhms.length)
75
73
  end
76
74
 
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: sys-uptime
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.4.4
7
- date: 2006-06-30 00:00:00 -06:00
6
+ version: 0.4.5
7
+ date: 2006-11-20 00:00:00 -07:00
8
8
  summary: A Ruby interface for getting system uptime information.
9
9
  require_paths:
10
10
  - lib
@@ -32,10 +32,10 @@ files:
32
32
  - doc/uptime.txt
33
33
  - test/tc_uptime.rb
34
34
  - CHANGES
35
- - MANIFEST
36
35
  - README
37
- - extconf.rb
38
- - lib/os/unix.c
36
+ - MANIFEST
37
+ - ext/uptime.c
38
+ - ext/extconf.rb
39
39
  test_files:
40
40
  - test/tc_uptime.rb
41
41
  rdoc_options: []
@@ -43,10 +43,13 @@ rdoc_options: []
43
43
  extra_rdoc_files:
44
44
  - CHANGES
45
45
  - README
46
+ - MANIFEST
47
+ - doc/uptime.txt
48
+ - ext/uptime.c
46
49
  executables: []
47
50
 
48
51
  extensions:
49
- - extconf.rb
52
+ - ext/extconf.rb
50
53
  requirements: []
51
54
 
52
55
  dependencies: []
data/extconf.rb DELETED
@@ -1,36 +0,0 @@
1
- ##############################################
2
- # extconf.rb
3
- #
4
- # Configuration & build script for sys-uptime
5
- ##############################################
6
- require 'mkmf'
7
- require 'ftools'
8
-
9
- #######################################################################
10
- # In case this is run more than one time, delete the link/copy if it
11
- # already exists.
12
- #######################################################################
13
- uptime_file = "uptime.c"
14
- File.delete(uptime_file) if File.exists?(uptime_file)
15
-
16
- case RUBY_PLATFORM
17
- when /windows|win32|cygwin|mingw|dos|linux/i
18
- STDERR.puts "Run the 'install.rb' script instead on this platform"
19
- exit
20
- else
21
- have_header("sys/loadavg.h")
22
- c_file = "lib/os/unix.c"
23
-
24
- File.symlink(c_file, uptime_file)
25
-
26
- if File.exists?("lib/os/windows.rb")
27
- File.move("lib/os/windows.rb", "lib/os/windows.orig") # Don't install
28
- end
29
-
30
- if File.exists?("lib/os/linux.rb")
31
- File.move("lib/os/linux.rb", "lib/os/linux.orig") # Don't install
32
- end
33
- end
34
-
35
- have_header("utmpx.h")
36
- create_makefile('sys/uptime')