sys-cpu 0.5.4-mswin32 → 0.5.5-mswin32

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,13 @@
1
+ == 0.5.5 - 17-Nov-2006
2
+ * Fixed a bug in the Linux version where there could be a key but no
3
+ associated value, causing a String#strip! call to fail. Now the value is
4
+ simply left at nil.
5
+ * Refactored the CPU.processors method on Linux, including the removal of '?'
6
+ from the CPUStruct members for the boolean methods (Ruby doesn't like them).
7
+ * Minor tweaks and updates to the documentation, including the README.
8
+ * Modified the gemspec so that it sets the platform properly for Linux
9
+ and Windows.
10
+
1
11
  == 0.5.4 - 12-Jul-2006
2
12
  * Added a gemspec (and a gem on RubyForge).
3
13
  * The CPU.architecture method on HP-UX now returns nil if it cannot be
data/README CHANGED
@@ -1,51 +1,78 @@
1
- == Description
2
- A Ruby interface for getting cpu information.
1
+ = Description
2
+ A Ruby interface for getting cpu information.
3
3
 
4
- == Installation
4
+ = Installation
5
5
  === Linux and Windows:
6
- ruby test/ts_all.rb (optional)
7
- ruby install.rb
6
+ ruby test/ts_all.rb (optional)
7
+ ruby install.rb
8
8
 
9
9
  === All other platforms:
10
- ruby extconf.rb
11
- make
12
- ruby test/ts_all.rb (optional)
13
- make site-install
10
+ ruby extconf.rb
11
+ make
12
+ ruby test/ts_all.rb (optional)
13
+ make site-install
14
14
 
15
- == Notes
15
+ = Notes
16
16
  === All Platforms
17
- As of version 0.5.0 Ruby 1.8.0 or later is required. It may work with
18
- earlier versions, but I will not support it. In addition, a test file is
19
- no longer auto-generated for you. If wish to run the test suite, cd to the
20
- 'test' directory and run the test suite appropriate for your platform.
17
+ As of version 0.5.0 Ruby 1.8.0 or later is required. It may work with
18
+ earlier versions, but I will not support it. In addition, a test file is
19
+ no longer auto-generated for you. If wish to run the test suite, cd to the
20
+ 'test' directory and run the test suite appropriate for your platform.
21
21
 
22
22
  === Solaris
23
- Currently there is no 'processors()' iterative method for multi-cpu systems.
24
- I plan to add it this in a future release.
23
+ Currently there is no 'processors()' iterative method for multi-cpu systems.
24
+ I plan to add it this in a future release.
25
25
 
26
26
  === Linux
27
- This is pure Ruby. This version reads information out of /proc/cpuinfo and
28
- /proc/loadavg, so if /proc isn't mounted it won't work.
27
+ This is pure Ruby. This version reads information out of /proc/cpuinfo and
28
+ /proc/loadavg, so if /proc isn't mounted it won't work.
29
29
 
30
- The key-value information in /proc/cpuinfo is stored internally (i.e. in
31
- memory) as an array of hashes when you first 'require' this package. This
32
- overhead is exceptionally minimal, given that your average cpuinfo file
33
- contains less than 1k of text (and I don't store whitespace or newlines).
30
+ The key-value information in /proc/cpuinfo is stored internally (i.e. in
31
+ memory) as an array of hashes when you first 'require' this package. This
32
+ overhead is exceptionally minimal, given that your average cpuinfo file
33
+ contains less than 1k of text (and I don't store whitespace or newlines).
34
34
 
35
- The text documentation for Linux is dynamically generating during the
36
- build process. So, don't look at it until *after* you've run make. :)
37
- You will see a doc/linux.txt file after you run install.rb.
35
+ The text documentation for Linux is dynamically generated during the
36
+ build process because the fields vary depending on your setup. So, don't
37
+ look at it until *after* you've installed it. You will see a doc/linux.txt
38
+ file after you run install.rb.
38
39
 
39
40
  === HP-UX
40
- Unlike other platforms, you can get load averages for an individual cpu (in
41
- multi-cpu systems). See documentation for more details.
41
+ Unlike other platforms, you can get load averages for an individual cpu (in
42
+ multi-cpu systems). See documentation for more details.
42
43
 
43
44
  === Win32
44
- This is a pure Ruby implementation using the win32ole package + WMI. The C
45
- version has been scrapped.
46
-
47
- As of version 0.5.0, the CPU.usage method has been removed in favor of the
48
- CPU.load_avg method. This does not (currently) use a perf counter, so there
49
- is no longer any delay. Also, the 'processors' method has been
50
- added and the 'supported' method has been dropped. See the documentation
51
- for other changes.
45
+ This is a pure Ruby implementation using the win32ole package + WMI. The C
46
+ version has been scrapped.
47
+
48
+ As of version 0.5.0, the CPU.usage method has been removed in favor of the
49
+ CPU.load_avg method. This does not (currently) use a perf counter, so there
50
+ is no longer any delay. Also, the 'processors' method has been
51
+ added and the 'supported' method has been dropped. See the documentation
52
+ for other changes.
53
+
54
+ = Known Bugs
55
+ None that I'm aware of. Please report bugs on the project page at
56
+ http://www.rubyforge.org/projects/sysutils.
57
+
58
+ = Future Plans
59
+ === Solaris
60
+ Add iterative CPU.processors method.
61
+ Add more information in general, such as what 'prtdiag' shows.
62
+
63
+ = License
64
+ Ruby's.
65
+
66
+ = Copyright
67
+ (C) 2003-2006 Daniel J. Berger
68
+ All Rights Reserved
69
+
70
+ = Warranty
71
+ This package is provided "as is" and without any express or
72
+ implied warranties, including, without limitation, the implied
73
+ warranties of merchantability and fitness for a particular purpose.
74
+
75
+ = Author
76
+ Daniel J. Berger
77
+ djberg96 at gmail dot com
78
+ imperator on IRC (irc.freenode.net)
data/doc/freebsd.txt CHANGED
@@ -1,7 +1,7 @@
1
- == Description
1
+ = Description
2
2
  Sys::CPU - An interface for various cpu statistics
3
3
 
4
- == Synopsis
4
+ = Synopsis
5
5
  require "sys/cpu"
6
6
  include Sys
7
7
 
@@ -13,14 +13,14 @@
13
13
  puts "CPU model: " + CPU.model
14
14
  puts "Load averages: " + CPU.load_avg.join(", ")
15
15
 
16
- == Constants
16
+ = Constants
17
17
  VERSION
18
18
  Returns the current version number for this package.
19
19
 
20
- == Class Methods
20
+ = Class Methods
21
21
  CPU.architecture
22
22
  Returns the cpu's architecture.
23
-
23
+
24
24
  CPU.freq
25
25
  Returns an integer indicating the speed (i.e. frequency in Mhz) of
26
26
  the cpu.
@@ -30,36 +30,36 @@ CPU.load_avg
30
30
  average.
31
31
 
32
32
  CPU.machine
33
- Returns the class of cpu (probably identical to the architecture).
34
-
33
+ Returns the class of cpu (probably identical to the architecture).
34
+
35
35
  CPU.model
36
36
  Returns a string indicating the cpu model.
37
37
 
38
38
  CPU.num_cpu
39
39
  Returns an integer indicating the number of cpu's on the system.
40
40
 
41
- == Error Classes
41
+ = Error Classes
42
42
  CPUError < StandardError
43
43
  Raised is response to internal function errors, usually relating to an
44
44
  invalid cpu number.
45
45
 
46
- == Known Bugs
46
+ = Known Bugs
47
47
  None known. Please post bug reports to the SourceForge home page at
48
48
  http://www.rubyforge.org/projects/sysutils
49
49
 
50
- == Copyright
51
- (C) 2003-2005 Daniel J. Berger
50
+ = Copyright
51
+ (C) 2003-2006 Daniel J. Berger
52
52
  All Rights Reserved
53
53
 
54
- == Warranty
55
- This package is provided "as is" and without any express or
56
- implied warranties, including, without limitation, the implied
57
- warranties of merchantability and fitness for a particular purpose.
58
-
59
- == License
54
+ = Warranty
55
+ This package is provided "as is" and without any express or
56
+ implied warranties, including, without limitation, the implied
57
+ warranties of merchantability and fitness for a particular purpose.
58
+
59
+ = License
60
60
  Ruby's
61
61
 
62
- == Author
62
+ = Author
63
63
  Daniel J. Berger
64
64
  djberg96 at yahoo dot com
65
65
  imperator/rubyhacker1 on IRC (Freenode)
data/doc/hpux.txt CHANGED
@@ -1,7 +1,7 @@
1
- == Description
1
+ = Description
2
2
  Sys::CPU - An interface for various cpu statistics
3
3
 
4
- == Synopsis
4
+ = Synopsis
5
5
  require "sys/cpu"
6
6
  include Sys
7
7
 
@@ -11,11 +11,11 @@
11
11
  puts "Number of active cpu's: " + CPU.num_active_cpu.to_s
12
12
  puts "Load averages: " + CPU.load_avg.join(", ")
13
13
 
14
- == Constants
14
+ = Constants
15
15
  VERSION
16
16
  Returns the current version number for this package.
17
17
 
18
- == Class Methods
18
+ = Class Methods
19
19
  CPU.architecture
20
20
  Returns the cpu architecture, e.g. PA RISC 1.2, etc.
21
21
 
@@ -45,31 +45,31 @@ CPU.num_cpu
45
45
  CPU.num_active_cpu
46
46
  Returns an integer indicating the number of active cpu's on the system.
47
47
 
48
- == Error Classes
48
+ = Error Classes
49
49
  CPUError < StandardError
50
50
  Raised is response to internal function errors, usually relating to an
51
51
  invalid cpu number.
52
52
 
53
- == Known Bugs
53
+ = Known Bugs
54
54
  No bugs known. Please log any bugs at
55
55
  http://www.rubyforge.org/projects/sysutils
56
56
 
57
- == Future Plans
57
+ = Future Plans
58
58
  Add cpu model and type
59
59
 
60
- == Copyright
61
- (C) 2003-2005 Daniel J. Berger
60
+ = Copyright
61
+ (C) 2003-2006 Daniel J. Berger
62
62
  All Rights Reserved
63
63
 
64
- == Warranty
65
- This package is provided "as is" and without any express or
66
- implied warranties, including, without limitation, the implied
67
- warranties of merchantability and fitness for a particular purpose.
64
+ = Warranty
65
+ This package is provided "as is" and without any express or
66
+ implied warranties, including, without limitation, the implied
67
+ warranties of merchantability and fitness for a particular purpose.
68
68
 
69
- == License
69
+ = License
70
70
  Ruby's
71
71
 
72
- == Author
72
+ = Author
73
73
  Daniel J. Berger
74
74
  djberg96 at yahoo dot com
75
75
  imperator/rubyhacker1 on IRC (Freenode)
data/doc/sunos.txt CHANGED
@@ -1,7 +1,7 @@
1
- == Description
1
+ = Description
2
2
  Sys::CPU - An interface for various cpu statistics
3
3
 
4
- == Synopsis
4
+ = Synopsis
5
5
  require "sys/cpu"
6
6
  include Sys
7
7
 
@@ -14,11 +14,11 @@
14
14
  puts "CPU model: " + CPU.model
15
15
  puts "Load averages: " + CPU.load_avg.join(", ")
16
16
 
17
- == Constants
17
+ = Constants
18
18
  VERSION
19
19
  Returns the current version number for this package.
20
20
 
21
- == Class Methods
21
+ = Class Methods
22
22
  CPU.freq(cpu_num=0)
23
23
  Returns an integer indicating the speed (i.e. frequency in Mhz) of
24
24
  'cpu_num', or CPU 0 if no number is provided.
@@ -47,30 +47,30 @@ CPU.num_cpu
47
47
  CPU.state(cpu_num)
48
48
  Returns a string indicating the cpu state of 'cpu_num'.
49
49
 
50
- == Error Classes
50
+ = Error Classes
51
51
  CPUError < StandardError
52
52
  Raised is response to internal function errors, usually relating to an
53
53
  invalid cpu number.
54
54
 
55
- == Known Bugs
55
+ = Known Bugs
56
56
  None known. Please post bug reports to the SourceForge home page at
57
57
  http://www.rubyforge.org/projects/sysutils
58
58
 
59
- == Future Plans
59
+ = Future Plans
60
60
  Add more information, such as what prtdiag shows.
61
61
  Get the model() method to display more specific information.
62
62
 
63
- == Copyright
63
+ = Copyright
64
64
  (C) 2003-2006 Daniel J. Berger
65
65
  All Rights Reserved
66
66
 
67
- == Warranty
68
- This package is provided "as is" and without any express or
69
- implied warranties, including, without limitation, the implied
70
- warranties of merchantability and fitness for a particular purpose.
67
+ = Warranty
68
+ This package is provided "as is" and without any express or
69
+ implied warranties, including, without limitation, the implied
70
+ warranties of merchantability and fitness for a particular purpose.
71
71
 
72
- == License
72
+ = License
73
73
  Ruby's
74
74
 
75
- == Author
75
+ = Author
76
76
  Daniel J. Berger
data/doc/windows.txt CHANGED
@@ -1,11 +1,11 @@
1
- == Description
1
+ = Description
2
2
  Sys::CPU - An interface for various cpu statistics
3
3
 
4
- == Synopsis
4
+ = Synopsis
5
5
  require "sys/cpu"
6
6
  include Sys
7
7
 
8
- CPU.processors{ |cs|
8
+ CPU.processors{ |cs|
9
9
  cs.members.each{ |m|
10
10
  puts "#{m}: " + cs[m].to_s
11
11
  }
@@ -18,11 +18,11 @@
18
18
  puts "Model: " + CPU.model
19
19
  puts "Architecture: " + CPU.architecture
20
20
 
21
- == Constants
21
+ = Constants
22
22
  VERSION
23
23
  Returns the current version number for this package.
24
24
 
25
- == Class Methods
25
+ = Class Methods
26
26
  CPU.architecture(host=localhost)
27
27
  Returns the architecture of the cpu, e.g. x86 Family 15 Model 2
28
28
 
@@ -33,12 +33,12 @@ CPU.freq(cpu_num=0, host=localhost)
33
33
  is raised.
34
34
 
35
35
  CPU.load_avg(host=localhost)
36
- Returns the load capacity of each processor, averaged to the last second.
37
- Processor loading refers to the total computing burden for each
38
- processor at one time.
36
+ Returns the load capacity of each processor, averaged to the last second.
37
+ Processor loading refers to the total computing burden for each
38
+ processor at one time.
39
39
 
40
- Note that this attribute is actually the LoadPercentage. I may use
41
- one of the Win32_Perf* classes in the future.
40
+ Note that this attribute is actually the LoadPercentage. I may use
41
+ one of the Win32_Perf* classes in the future.
42
42
 
43
43
  CPU.model(host=localhost)
44
44
  Returns a string indicating the cpu model, e.g. Intel Pentium 4
@@ -47,10 +47,10 @@ CPU.num_cpu(host=localhost)
47
47
  Returns an integer indicating the number of cpu's on the system.
48
48
 
49
49
  CPU.processors(host=localhost){ |cpu| ... }
50
- Returns a CPUStruct for each CPU on the system containing the following
51
- members:
50
+ Returns a CPUStruct for each CPU on the system containing the following
51
+ members:
52
52
 
53
- * address_width
53
+ * address_width
54
54
  * architecture
55
55
  * availability
56
56
  * caption
@@ -101,52 +101,52 @@ CPU.processors(host=localhost){ |cpu| ... }
101
101
  CPU.type(host=localhost)
102
102
  Returns a string indicating the type of processor, e.g. GenuineIntel.
103
103
 
104
- == Exception Classes
104
+ = Exception Classes
105
105
  CPUError < StandardError
106
106
  Raised is response to internal function errors, most likely to be raised
107
107
  in the event that in invalid cpu number is provided for the 'freq'
108
108
  method.
109
109
 
110
- == Notes
111
- Some of the CPUStruct members may be nil. As far as I can tell, this
112
- means that Windows is unable to determine the value for the attribute due
113
- to your BIOS and/or BIOS settings. There is nothing clear in the
114
- documentation I could find for this, however.
110
+ = Notes
111
+ Some of the CPUStruct members may be nil. As far as I can tell, this
112
+ means that Windows is unable to determine the value for the attribute due
113
+ to your BIOS and/or BIOS settings. There is nothing clear in the
114
+ documentation I could find for this, however.
115
115
 
116
- The 'family' attribute may contain the trademark symbol.
116
+ The 'family' attribute may contain the trademark symbol.
117
117
 
118
- The 'status_info' attribute was not converted to a string because the
119
- 'status' attribute already is a string. I'm not even sure why MS has both
120
- versions.
118
+ The 'status_info' attribute was not converted to a string because the
119
+ 'status' attribute already is a string. I'm not even sure why MS has both
120
+ versions.
121
121
 
122
- The 'system_name' attribute appears to be the hostname. I have no idea
123
- why this is included as part of the CPU information, but there you go.
122
+ The 'system_name' attribute appears to be the hostname. I have no idea
123
+ why this is included as part of the CPU information, but there you go.
124
124
 
125
- See http://tinyurl.com/2mros (and click on 'Win32_Processor' in the left
126
- frame) for a list of attributes and their meaning. Link courtesy of
127
- tinyurl.com.
125
+ See http://tinyurl.com/2mros (and click on 'Win32_Processor' in the left
126
+ frame) for a list of attributes and their meaning. Link courtesy of
127
+ tinyurl.com.
128
128
 
129
- == Known Bugs
129
+ = Known Bugs
130
130
  No bugs known. Please log any bugs at
131
131
  http://www.rubyforge.org/projects/sysutils
132
-
133
- == Future Plans
132
+
133
+ = Future Plans
134
134
  Add more detailed CPU usage information via the
135
135
  Win32_PerfFormattedData_PerfOS_Processor class.
136
136
 
137
- == Copyright
138
- (C) 2003-2004 Daniel J. Berger
137
+ = Copyright
138
+ (C) 2003-2006 Daniel J. Berger
139
139
  All Rights Reserved
140
140
 
141
- == Warranty
142
- This package is provided "as is" and without any express or
143
- implied warranties, including, without limitation, the implied
144
- warranties of merchantability and fitness for a particular purpose.
145
-
146
- == License
141
+ = Warranty
142
+ This package is provided "as is" and without any express or
143
+ implied warranties, including, without limitation, the implied
144
+ warranties of merchantability and fitness for a particular purpose.
145
+
146
+ = License
147
147
  Ruby's
148
148
 
149
- == Author
149
+ = Author
150
150
  Daniel J. Berger
151
151
  djberg96 at yahoo dot com
152
152
  imperator/rubyhacker1 on IRC (Freenode)
data/lib/sys/cpu.rb CHANGED
@@ -5,7 +5,7 @@ module Sys
5
5
  class CPUError < StandardError; end
6
6
 
7
7
  class CPU
8
- VERSION = '0.5.4'
8
+ VERSION = '0.5.5'
9
9
 
10
10
  fields = %w/
11
11
  address_width
data/test/tc_linux.rb CHANGED
@@ -8,7 +8,7 @@ if base == "test" || base =~ /sys-cpu/
8
8
  require "ftools"
9
9
  Dir.chdir ".." if base == "test"
10
10
  Dir.mkdir("sys") unless File.exists?("sys")
11
- File.copy("lib/os/linux.rb","sys/cpu.rb")
11
+ File.copy("lib/sys/linux.rb","sys/cpu.rb")
12
12
  $LOAD_PATH.unshift Dir.pwd
13
13
  end
14
14
 
data/test/tc_version.rb CHANGED
@@ -6,16 +6,27 @@
6
6
  # for the VERSION constant in every single test case.
7
7
  ###########################################################
8
8
  base = File.basename(Dir.pwd)
9
+
9
10
  if base == "test" || base =~ /sys-cpu/
10
11
  require "ftools"
11
- Dir.chdir ".." if base == "test"
12
-
12
+
13
+ Dir.chdir("..") if base == "test"
13
14
  Dir.mkdir("sys") unless File.exist?("sys")
14
15
 
15
- if File.exist?("cpu.so")
16
- File.copy("cpu.so","sys")
16
+ case RUBY_PLATFORM
17
+ when /mswin|dos|cygwin|mingw/i
18
+ file = 'lib/sys/windows.rb'
19
+ when /linux/i
20
+ file = 'lib/sys/linux.rb'
21
+ else
22
+ require "rbconfig"
23
+ file = "cpu." << Config::CONFIG["DLEXT"]
24
+ end
25
+
26
+ if File.exist?(file)
27
+ File.copy(file, "sys/cpu.rb")
17
28
  else
18
- puts "No cpu.so file found. Please run extconf.rb and make first"
29
+ puts "No '#{file}' file found. Please run extconf.rb and make first"
19
30
  exit
20
31
  end
21
32
 
@@ -28,6 +39,6 @@ include Sys
28
39
 
29
40
  class TC_Sys_CPU_VERSION < Test::Unit::TestCase
30
41
  def test_version
31
- assert_equal('0.5.4', CPU::VERSION)
42
+ assert_equal('0.5.5', CPU::VERSION)
32
43
  end
33
44
  end
data/test/tc_windows.rb CHANGED
@@ -8,7 +8,7 @@ if base == "test" || base =~ /sys-cpu/
8
8
  require "ftools" if base == "test"
9
9
  Dir.chdir '..'
10
10
  Dir.mkdir("sys") unless File.exists?("sys")
11
- File.copy("lib/os/windows.rb","sys/cpu.rb")
11
+ File.copy("lib/sys/windows.rb","sys/cpu.rb")
12
12
  $LOAD_PATH.unshift Dir.pwd
13
13
  end
14
14
 
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: sys-cpu
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.5.4
7
- date: 2006-11-17 00:00:00 -07:00
6
+ version: 0.5.5
7
+ date: 2006-11-18 00:00:00 -07:00
8
8
  summary: A Ruby interface for providing CPU information
9
9
  require_paths:
10
10
  - lib