sys-cpu 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,9 @@
1
+ == 0.7.1 - 2-May-2013
2
+ * Added a workaround for a win32ole bug in the Windows version.
3
+ * Reorganized code so that there is now a single gem rather than three
4
+ separate platform gems.
5
+ * Updated test-unit dependency which let me simplify the test files a bit.
6
+
1
7
  == 0.7.0 - 14-Dec-2011
2
8
  * Code base now uses FFI. However, HP-UX is not currently supported.
3
9
  HP-UX users should continue to use the 0.6.x version. Note that
data/MANIFEST CHANGED
@@ -14,13 +14,10 @@
14
14
  * examples/example_sys_cpu_linux.rb
15
15
  * examples/example_sys_cpu_sunos.rb
16
16
  * examples/example_sys_cpu_windows.rb
17
- * ext/extconf.rb
18
- * ext/version.h
19
- * ext/bsd/bsd.c
20
- * ext/hpux/hpux.c
21
- * ext/sunos/sunos.c
22
- * lib/linux/sys/cpu.rb
23
- * lib/windows/sys/cpu.rb
17
+ * lib/sys/cpu.rb
18
+ * lib/sys/linux/sys/cpu.rb
19
+ * lib/sys/unix/sys/cpu.rb
20
+ * lib/sys/windows/sys/cpu.rb
24
21
  * test/test_sys_cpu.rb
25
22
  * test/test_sys_cpu_bsd.rb
26
23
  * test/test_sys_cpu_hpux.rb
data/README CHANGED
@@ -4,11 +4,6 @@
4
4
  = Installation
5
5
  gem install sys-cpu
6
6
 
7
- If that doesn't work try one of these:
8
-
9
- gem install sys-cpu --platform linux # Linux
10
- gem install sys-cpu --platform mingw32 # MS Windows
11
-
12
7
  = Notes
13
8
  == Solaris
14
9
  Currently there is no 'processors()' iterative method for multi-cpu systems.
@@ -66,7 +61,7 @@
66
61
  Artistic 2.0
67
62
 
68
63
  = Copyright
69
- (C) 2003-2011 Daniel J. Berger, All Rights Reserved
64
+ (C) 2003-2013 Daniel J. Berger, All Rights Reserved
70
65
 
71
66
  = Warranty
72
67
  This package is provided "as is" and without any express or
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rake'
2
2
  require 'rake/clean'
3
3
  require 'rake/testtask'
4
4
  require 'rbconfig'
5
- include Config
5
+ include RbConfig
6
6
 
7
7
  CLEAN.include('**/*.gem', '**/*.rbc', '**/*.rbx')
8
8
 
@@ -43,14 +43,6 @@ task :example => [:clean] do
43
43
  end
44
44
 
45
45
  Rake::TestTask.new do |t|
46
- if CONFIG['host_os'] =~ /mswin|win32|mingw|cygwin|dos|windows/i
47
- t.libs << 'lib/windows'
48
- elsif CONFIG['host_os'] =~ /linux/i
49
- t.libs << 'lib/linux'
50
- else
51
- t.libs << 'lib/unix'
52
- end
53
-
54
46
  t.libs << 'test'
55
47
  t.test_files = FileList['test/test_sys_cpu.rb']
56
48
  end
data/lib/sys/cpu.rb ADDED
@@ -0,0 +1,12 @@
1
+ # This is just a stub file that requires the appropriate version
2
+ # depending on which platform you're on.
3
+ require 'rbconfig'
4
+
5
+ case RbConfig::CONFIG['host_os']
6
+ when /linux/i
7
+ require File.join(File.dirname(__FILE__), 'linux', 'sys', 'cpu')
8
+ when /windows|mswin|mingw|cygwin|dos/i
9
+ require File.join(File.dirname(__FILE__), 'windows', 'sys', 'cpu')
10
+ else
11
+ require File.join(File.dirname(__FILE__), 'unix', 'sys', 'cpu')
12
+ end
@@ -42,7 +42,7 @@ module Sys
42
42
  class CPU
43
43
 
44
44
  # The version of the sys-cpu library.
45
- VERSION = '0.7.0'
45
+ VERSION = '0.7.1'
46
46
 
47
47
  # :stopdoc:
48
48
 
@@ -59,7 +59,7 @@ module Sys
59
59
  array = []
60
60
  $cpu_array.each{ |hash|
61
61
  struct = CPUStruct.new
62
- struct.members.each{ |m| struct.send("#{m}=", hash[m]) }
62
+ struct.members.each{ |m| struct.send("#{m}=", hash["#{m}"]) }
63
63
  if block_given?
64
64
  yield struct
65
65
  else
@@ -10,7 +10,7 @@ module Sys
10
10
  class Error < StandardError; end
11
11
 
12
12
  # The version of the sys-cpu library
13
- VERSION = '0.7.0'
13
+ VERSION = '0.7.1'
14
14
 
15
15
  CTL_HW = 6 # Generic hardware/cpu
16
16
 
@@ -1,6 +1,15 @@
1
1
  require 'win32ole'
2
2
  require 'socket'
3
3
 
4
+ # See Ruby bugs #2618 and #7681. This is a workaround.
5
+ BEGIN{
6
+ require 'win32ole'
7
+ if RUBY_VERSION.to_f < 2.0
8
+ WIN32OLE.ole_initialize
9
+ at_exit { WIN32OLE.ole_uninitialize }
10
+ end
11
+ }
12
+
4
13
  # The Sys module serves only as a namespace
5
14
  module Sys
6
15
  # Encapsulates system CPU information
@@ -9,7 +18,7 @@ module Sys
9
18
  class Error < StandardError; end
10
19
 
11
20
  # The version of the sys-cpu library
12
- VERSION = '0.7.0'
21
+ VERSION = '0.7.1'
13
22
 
14
23
  private
15
24
 
data/sys-cpu.gemspec CHANGED
@@ -2,11 +2,10 @@ require 'rubygems'
2
2
 
3
3
  Gem::Specification.new do |spec|
4
4
  spec.name = 'sys-cpu'
5
- spec.version = '0.7.0'
5
+ spec.version = '0.7.1'
6
6
  spec.author = 'Daniel J. Berger'
7
7
  spec.email = 'djberg96 at nospam at gmail dot com'
8
- spec.homepage = 'http://www.rubyforge.org/projects/sysutils'
9
- spec.platform = Gem::Platform::RUBY
8
+ spec.homepage = 'https://github.com/djberg96/sys-cpu'
10
9
  spec.summary = 'A Ruby interface for providing CPU information'
11
10
  spec.test_file = 'test/test_sys_cpu.rb'
12
11
  spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
@@ -14,30 +13,16 @@ Gem::Specification.new do |spec|
14
13
  spec.rubyforge_project = 'sysutils'
15
14
  spec.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST']
16
15
 
16
+ # The ffi dependency is only relevent for the Unix version. Given the
17
+ # ubiquity of ffi these days, I felt a bogus dependency on ffi for Windows
18
+ # and Linux was worth the tradeoff of having to create 3 separate gems.
17
19
  spec.add_dependency('ffi', '>= 1.0.0')
18
- spec.add_development_dependency('test-unit', '>= 2.1.2')
20
+
21
+ spec.add_development_dependency('test-unit', '>= 2.4.0')
19
22
 
20
23
  spec.description = <<-EOF
21
24
  The sys-cpu library provides an interface for gathering information
22
25
  about your system's processor(s). Information includes speed, type,
23
26
  and load average.
24
27
  EOF
25
-
26
- case Config::CONFIG['host_os']
27
- when /mswin|dos|windows|win32|mingw|cygwin/i
28
- spec.require_paths = ['lib', 'lib/windows']
29
- spec.extra_rdoc_files << 'lib/windows/sys/cpu.rb'
30
- spec.platform = Gem::Platform::CURRENT
31
- spec.platform.cpu = 'universal'
32
- spec.platform.version = nil
33
- spec.original_platform = spec.platform
34
- when /linux/i
35
- spec.require_paths = ['lib', 'lib/linux']
36
- spec.extra_rdoc_files << 'lib/linux/sys/cpu.rb'
37
- spec.platform = Gem::Platform.new('universal-linux')
38
- spec.original_platform = spec.platform
39
- else
40
- spec.require_paths = ['lib', 'lib/unix']
41
- spec.extra_rdoc_files << 'lib/unix/sys/cpu.rb'
42
- end
43
28
  end
data/test/test_sys_cpu.rb CHANGED
@@ -7,7 +7,7 @@
7
7
  require 'rbconfig'
8
8
  require 'test_sys_cpu_version'
9
9
 
10
- case Config::CONFIG['host_os']
10
+ case RbConfig::CONFIG['host_os']
11
11
  when /bsd|darwin|mach|osx/i
12
12
  require 'test_sys_cpu_bsd'
13
13
  when /hpux/i
@@ -3,12 +3,9 @@
3
3
  #
4
4
  # The test case for sys-cpu on BSD flavors, including OS X.
5
5
  #############################################################
6
- require 'rubygems'
7
- gem 'test-unit'
8
-
9
6
  require 'sys/cpu'
10
7
  require 'rbconfig'
11
- require 'test/unit'
8
+ require 'test-unit'
12
9
  require 'test_sys_cpu_version'
13
10
  include Sys
14
11
 
@@ -4,11 +4,8 @@
4
4
  # Test suite for the HP-UX platform. This should be run via the
5
5
  # 'rake test' task.
6
6
  #####################################################################
7
- require 'rubygems'
8
- gem 'test-unit'
9
-
10
7
  require 'sys/cpu'
11
- require 'test/unit'
8
+ require 'test-unit'
12
9
  require 'test_sys_cpu_version'
13
10
  include Sys
14
11
 
@@ -46,7 +43,7 @@ class TC_Sys_CPU_HPUX < Test::Unit::TestCase
46
43
  assert_raises(ArgumentError){ CPU.load_avg(0){ } }
47
44
  assert_kind_of(Array, CPU.load_avg, 'Invalid Type')
48
45
  assert_kind_of(Array, CPU.load_avg(0), 'Invalid Type')
49
- assert_equal(3, CPU.load_avg.length, 'Bad number of elements')
46
+ assert_equal(3, CPU.load_avg.length, 'Bad number of elements')
50
47
  assert_equal(3, CPU.load_avg(0).length, 'Bad number of elements')
51
48
  end
52
49
  end
@@ -4,11 +4,8 @@
4
4
  # Test Suite for sys-cpu for Linux. This should be run via
5
5
  # the 'rake test' task.
6
6
  ###########################################################
7
- require 'rubygems'
8
- gem 'test-unit'
9
-
10
7
  require 'sys/cpu'
11
- require 'test/unit'
8
+ require 'test-unit'
12
9
  require 'test_sys_cpu_version'
13
10
  include Sys
14
11
 
@@ -4,10 +4,8 @@
4
4
  # Test suite for sys-cpu on Solaris. This should be run
5
5
  # via the 'rake test' task.
6
6
  ###########################################################
7
- require 'rubygems'
8
- gem 'test-unit'
9
7
  require 'sys/cpu'
10
- require 'test/unit'
8
+ require 'test-unit'
11
9
  include Sys
12
10
 
13
11
  class TC_Sys_CPU_SunOS < Test::Unit::TestCase
@@ -5,14 +5,11 @@
5
5
  # This reduces the pain of having separate tests for the VERSION
6
6
  # constant in every single test case.
7
7
  #######################################################################
8
- require 'rubygems'
9
- gem 'test-unit'
10
-
11
8
  require 'sys/cpu'
12
- require 'test/unit'
9
+ require 'test-unit'
13
10
 
14
11
  class TC_Sys_CPU_VERSION < Test::Unit::TestCase
15
12
  test "version number is set to the expected value" do
16
- assert_equal('0.7.0', Sys::CPU::VERSION)
13
+ assert_equal('0.7.1', Sys::CPU::VERSION)
17
14
  end
18
15
  end
metadata CHANGED
@@ -1,125 +1,109 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: sys-cpu
3
- version: !ruby/object:Gem::Version
4
- hash: 3
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.7.1
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 7
9
- - 0
10
- version: 0.7.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Daniel J. Berger
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-12-14 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2013-05-07 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: ffi
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 23
29
- segments:
30
- - 1
31
- - 0
32
- - 0
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
33
21
  version: 1.0.0
34
22
  type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: test-unit
38
23
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: 1.0.0
30
+ - !ruby/object:Gem::Dependency
31
+ name: test-unit
32
+ requirement: !ruby/object:Gem::Requirement
40
33
  none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 15
45
- segments:
46
- - 2
47
- - 1
48
- - 2
49
- version: 2.1.2
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: 2.4.0
50
38
  type: :development
51
- version_requirements: *id002
52
- description: " The sys-cpu library provides an interface for gathering information\n about your system's processor(s). Information includes speed, type,\n and load average.\n"
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: 2.4.0
46
+ description: ! " The sys-cpu library provides an interface for gathering information\n
47
+ \ about your system's processor(s). Information includes speed, type,\n and
48
+ load average.\n"
53
49
  email: djberg96 at nospam at gmail dot com
54
50
  executables: []
55
-
56
51
  extensions: []
57
-
58
- extra_rdoc_files:
52
+ extra_rdoc_files:
59
53
  - CHANGES
60
54
  - README
61
55
  - MANIFEST
62
- - lib/unix/sys/cpu.rb
63
- files:
64
- - CHANGES
56
+ files:
57
+ - doc/windows.txt
58
+ - doc/sunos.txt
65
59
  - doc/bsd.txt
66
60
  - doc/hpux.txt
67
61
  - doc/linux.txt
68
- - doc/sunos.txt
69
- - doc/windows.txt
70
- - examples/example_sys_cpu_bsd.rb
71
- - examples/example_sys_cpu_hpux.rb
72
- - examples/example_sys_cpu_linux.rb
73
- - examples/example_sys_cpu_sunos.rb
74
- - examples/example_sys_cpu_windows.rb
75
- - install.rb
76
- - lib/linux/sys/cpu.rb
77
- - lib/unix/sys/cpu.rb
78
- - lib/windows/sys/cpu.rb
79
- - MANIFEST
80
- - Rakefile
81
- - README
82
- - sys-cpu.gemspec
83
- - test/test_sys_cpu.rb
84
- - test/test_sys_cpu_bsd.rb
85
- - test/test_sys_cpu_hpux.rb
86
- - test/test_sys_cpu_linux.rb
87
- - test/test_sys_cpu_sunos.rb
88
62
  - test/test_sys_cpu_version.rb
63
+ - test/test_sys_cpu_linux.rb
89
64
  - test/test_sys_cpu_windows.rb
90
- homepage: http://www.rubyforge.org/projects/sysutils
65
+ - test/test_sys_cpu_bsd.rb
66
+ - test/test_sys_cpu.rb
67
+ - test/test_sys_cpu_sunos.rb
68
+ - test/test_sys_cpu_hpux.rb
69
+ - Rakefile
70
+ - MANIFEST
71
+ - CHANGES
72
+ - sys-cpu.gemspec
73
+ - lib/sys/cpu.rb
74
+ - lib/sys/unix/sys/cpu.rb
75
+ - lib/sys/linux/sys/cpu.rb
76
+ - lib/sys/windows/sys/cpu.rb
77
+ - install.rb
78
+ - README
79
+ - examples/example_sys_cpu_windows.rb
80
+ - examples/example_sys_cpu_hpux.rb
81
+ - examples/example_sys_cpu_sunos.rb
82
+ - examples/example_sys_cpu_linux.rb
83
+ - examples/example_sys_cpu_bsd.rb
84
+ homepage: https://github.com/djberg96/sys-cpu
91
85
  licenses: []
92
-
93
86
  post_install_message:
94
87
  rdoc_options: []
95
-
96
- require_paths:
88
+ require_paths:
97
89
  - lib
98
- - lib/unix
99
- required_ruby_version: !ruby/object:Gem::Requirement
90
+ required_ruby_version: !ruby/object:Gem::Requirement
100
91
  none: false
101
- requirements:
102
- - - ">="
103
- - !ruby/object:Gem::Version
104
- hash: 3
105
- segments:
106
- - 0
107
- version: "0"
108
- required_rubygems_version: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
96
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
97
  none: false
110
- requirements:
111
- - - ">="
112
- - !ruby/object:Gem::Version
113
- hash: 3
114
- segments:
115
- - 0
116
- version: "0"
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
117
102
  requirements: []
118
-
119
103
  rubyforge_project: sysutils
120
- rubygems_version: 1.8.10
104
+ rubygems_version: 1.8.23
121
105
  signing_key:
122
106
  specification_version: 3
123
107
  summary: A Ruby interface for providing CPU information
124
- test_files:
108
+ test_files:
125
109
  - test/test_sys_cpu.rb