win32-mutex 0.3.1 → 0.3.2

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,7 @@
1
+ == 0.3.2 - 18-Mar-2011
2
+ * Updates to the Rakefile and gemspec.
3
+ * One test file change for Ruby 1.9.
4
+
1
5
  == 0.3.1 - 8-Aug-2009
2
6
  * Changed license to Artistic 2.0.
3
7
  * Updated the gemspec, including addition of license and description update.
@@ -36,4 +40,4 @@
36
40
  * Moved the test.rb script to doc/examples
37
41
 
38
42
  == 0.1.0 - 3-May-2004
39
- * Initial release
43
+ * Initial release
data/README CHANGED
@@ -5,19 +5,15 @@
5
5
  win32-ipc 0.5.0 or later
6
6
 
7
7
  == Installation
8
- === Gem Installation
9
8
  gem install win32-mutex
10
- === Local Installation
11
- rake test (optional)
12
- rake install
13
9
 
14
10
  == Synopsis
15
11
  require 'win32/mutex'
16
12
 
17
13
  # Do not leave out the 'Win32::', otherwise you're using Ruby's Mutex class.
18
14
  Win32::Mutex.new(false, 'test') do |m|
19
- # Do stuff
20
- m.release
15
+ # Do stuff
16
+ m.release
21
17
  end
22
18
 
23
19
  == Documentation
@@ -29,21 +25,21 @@
29
25
 
30
26
  == Notes
31
27
  The Mutex class is a subclass of Win32::Ipc (win32-ipc). This library
32
- require's the win32-ipc library internally (you don't need to explicitly
33
- call it).
28
+ require's the win32-ipc library internally. You don't need to explicitly
29
+ call it.
34
30
 
35
31
  == Acknowledgements
36
32
  Originally adapted from the Win32::Mutex Perl module.
37
33
 
38
34
  == Known Bugs
39
- None that I know of. Please log any other bug reports on the RubyForge
40
- project page at http://www.rubyforge.net/projects/win32utils
35
+ None that I know of. Please log any other bug reports on the
36
+ project page at https://github.com/djberg96/win32-mutex.
41
37
 
42
38
  == License
43
39
  Artistic 2.0
44
40
 
45
41
  == Copyright
46
- (C) 2003-2009 Daniel J. Berger, All Rights Reserved
42
+ (C) 2003-2012 Daniel J. Berger, All Rights Reserved
47
43
 
48
44
  == Warranty
49
45
  This package is provided "as is" and without any express or
data/Rakefile CHANGED
@@ -1,24 +1,31 @@
1
1
  require 'rake'
2
2
  require 'rake/testtask'
3
- require 'rbconfig'
4
- include Config
3
+ require 'rake/clean'
5
4
 
6
- desc 'Install the win32-mutex package (non-gem)'
7
- task :install do
8
- sitelibdir = CONFIG['sitelibdir']
9
- installdir = File.join(sitelibdir, 'win32')
10
- file = 'lib\win32\mutex.rb'
5
+ CLEAN.include("**/*.gem")
11
6
 
12
- Dir.mkdir(installdir) unless File.exists?(installdir)
13
- FileUtils.cp(file, installdir, :verbose => true)
7
+ namespace :gem do
8
+ desc 'Create the win32-mutex gem'
9
+ task :create => [:clean] do
10
+ spec = eval(IO.read('win32-mutex.gemspec'))
11
+ Gem::Builder.new(spec).build
12
+ end
13
+
14
+ desc 'Install the win32-mutex gem'
15
+ task :install => [:create] do
16
+ file = Dir["*.gem"].first
17
+ sh "gem install #{file}"
18
+ end
14
19
  end
15
20
 
16
21
  desc 'Run the example program'
17
22
  task :example do
18
- ruby '-Ilib examples/example_win32_mutex.rb'
23
+ ruby '-Ilib examples/example_win32_mutex.rb'
19
24
  end
20
25
 
21
26
  Rake::TestTask.new do |t|
22
- t.verbose = true
23
- t.warning = true
27
+ t.verbose = true
28
+ t.warning = true
24
29
  end
30
+
31
+ task :default => :test
data/lib/win32/mutex.rb CHANGED
@@ -2,20 +2,20 @@ require 'win32/ipc'
2
2
 
3
3
  # The Win32 module serves as a namespace only.
4
4
  module Win32
5
-
5
+
6
6
  # The Mutex class encapsulates Windows mutex objects.
7
7
  class Mutex < Ipc
8
-
8
+
9
9
  # This is the error raised if any of the Mutex methods fail.
10
10
  class Error < StandardError; end
11
-
11
+
12
12
  extend Windows::Synchronize
13
13
  extend Windows::Error
14
14
  extend Windows::Handle
15
-
15
+
16
16
  # The version of the win32-mutex library
17
- VERSION = '0.3.1'
18
-
17
+ VERSION = '0.3.2'
18
+
19
19
  # The name of the mutex object.
20
20
  attr_reader :name
21
21
 
@@ -38,12 +38,12 @@ module Win32
38
38
  @initial_owner = initial_owner
39
39
  @name = name
40
40
  @inherit = inherit
41
-
41
+
42
42
  # Used to prevent potential segfaults.
43
43
  if name && !name.is_a?(String)
44
44
  raise TypeError, 'name must be a string'
45
45
  end
46
-
46
+
47
47
  if inherit
48
48
  sec = 0.chr * 12 # sizeof(SECURITY_ATTRIBUTES)
49
49
  sec[0,4] = [12].pack('L')
@@ -51,17 +51,17 @@ module Win32
51
51
  else
52
52
  sec = 0
53
53
  end
54
-
54
+
55
55
  initial = initial_owner ? 1 : 0
56
-
56
+
57
57
  handle = CreateMutex(sec, initial, name)
58
-
58
+
59
59
  if handle == 0 || handle == INVALID_HANDLE_VALUE
60
60
  raise Error, get_last_error
61
61
  end
62
-
62
+
63
63
  super(handle)
64
-
64
+
65
65
  if block_given?
66
66
  begin
67
67
  yield self
@@ -87,7 +87,7 @@ module Win32
87
87
  if name && !name.is_a?(String)
88
88
  raise TypeError, 'name must be a string'
89
89
  end
90
-
90
+
91
91
  bool = inherit ? 1 : 0
92
92
 
93
93
  # The OpenMutex() call here is strictly to force an error if the user
@@ -109,17 +109,17 @@ module Win32
109
109
  #
110
110
  def release
111
111
  unless ReleaseMutex(@handle)
112
- raise Error, get_last_error
112
+ raise Error, get_last_error
113
113
  end
114
114
  end
115
-
115
+
116
116
  # Returns whether or not the calling thread has initial ownership of
117
117
  # the mutex object.
118
118
  #
119
119
  def initial_owner?
120
120
  @initial_owner
121
121
  end
122
-
122
+
123
123
  # Returns whether or not the object was opened such that a process
124
124
  # created by the CreateProcess() function (a Windows API function) can
125
125
  # inherit the handle. The default is true.
@@ -1,5 +1,6 @@
1
+ # encoding: utf-8
1
2
  #######################################################################
2
- # tc_Win32::Mutex.rb
3
+ # test_Win32::Mutex.rb
3
4
  #
4
5
  # Test suite for the win32-Win32::Mutex package. This test suite
5
6
  # should be run via the 'rake test' task.
@@ -11,57 +12,57 @@ require 'test/unit'
11
12
  require 'win32/mutex'
12
13
 
13
14
  class TC_Win32_Mutex < Test::Unit::TestCase
14
- def setup
15
- @mutex = Win32::Mutex.new(true, 'test')
16
- @umutex = Win32::Mutex.new(false, 'Ηελλας')
17
- end
18
-
19
- def test_version
20
- assert_equal('0.3.1', Win32::Mutex::VERSION)
21
- end
15
+ def setup
16
+ @mutex = Win32::Mutex.new(true, 'test')
17
+ @umutex = Win32::Mutex.new(false, 'Ηελλας')
18
+ end
22
19
 
23
- def test_open
24
- assert_respond_to(Win32::Mutex, :open)
25
- assert_nothing_raised{ Win32::Mutex.open('test'){} }
26
- assert_nothing_raised{ Win32::Mutex.open('Ηελλας'){} }
27
- end
20
+ def test_version
21
+ assert_equal('0.3.2', Win32::Mutex::VERSION)
22
+ end
28
23
 
29
- def test_open_expected_errors
30
- assert_raise(Win32::Mutex::Error){ Win32::Mutex.open('bogus'){} }
31
- end
32
-
33
- def test_release
34
- assert_respond_to(@mutex, :release)
35
- assert_nothing_raised{ @mutex.release }
36
- end
37
-
38
- def test_initial_owner
39
- assert_respond_to(@mutex, :initial_owner?)
40
- assert_true(@mutex.initial_owner?)
41
- assert_false(@umutex.initial_owner?)
42
- end
43
-
44
- def test_inheritable
45
- assert_respond_to(@mutex, :inheritable?)
46
- assert_true(@mutex.inheritable?)
47
- end
48
-
49
- def test_wait
50
- assert_respond_to(@mutex, :wait)
51
- end
52
-
53
- def test_wait_any
54
- assert_respond_to(@mutex, :wait_any)
55
- end
56
-
57
- def test_wait_all
58
- assert_respond_to(@mutex, :wait_all)
59
- end
60
-
61
- def teardown
62
- @mutex.close
63
- @umutex.close
64
- @mutex = nil
65
- @umutex = nil
66
- end
24
+ def test_open
25
+ assert_respond_to(Win32::Mutex, :open)
26
+ assert_nothing_raised{ Win32::Mutex.open('test'){} }
27
+ assert_nothing_raised{ Win32::Mutex.open('Ηελλας'){} }
28
+ end
29
+
30
+ def test_open_expected_errors
31
+ assert_raise(Win32::Mutex::Error){ Win32::Mutex.open('bogus'){} }
32
+ end
33
+
34
+ def test_release
35
+ assert_respond_to(@mutex, :release)
36
+ assert_nothing_raised{ @mutex.release }
37
+ end
38
+
39
+ def test_initial_owner
40
+ assert_respond_to(@mutex, :initial_owner?)
41
+ assert_true(@mutex.initial_owner?)
42
+ assert_false(@umutex.initial_owner?)
43
+ end
44
+
45
+ def test_inheritable
46
+ assert_respond_to(@mutex, :inheritable?)
47
+ assert_true(@mutex.inheritable?)
48
+ end
49
+
50
+ def test_wait
51
+ assert_respond_to(@mutex, :wait)
52
+ end
53
+
54
+ def test_wait_any
55
+ assert_respond_to(@mutex, :wait_any)
56
+ end
57
+
58
+ def test_wait_all
59
+ assert_respond_to(@mutex, :wait_all)
60
+ end
61
+
62
+ def teardown
63
+ @mutex.close
64
+ @umutex.close
65
+ @mutex = nil
66
+ @umutex = nil
67
+ end
67
68
  end
data/win32-mutex.gemspec CHANGED
@@ -1,33 +1,29 @@
1
1
  require 'rubygems'
2
2
 
3
- spec = Gem::Specification.new do |gem|
4
- gem.name = 'win32-mutex'
5
- gem.version = '0.3.1'
6
- gem.author = 'Daniel J. Berger'
7
- gem.license = 'Artistic 2.0'
8
- gem.email = 'djberg96@gmail.com'
9
- gem.homepage = 'http://www.rubyforge.org/projects/win32utils'
10
- gem.platform = Gem::Platform::RUBY
11
- gem.summary = 'Interface to MS Windows Mutex objects.'
12
- gem.test_file = 'test/test_win32_mutex.rb'
13
- gem.has_rdoc = true
14
- gem.files = Dir['**/*'].reject{ |f| f.include?('CVS') }
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'win32-mutex'
5
+ spec.version = '0.3.2'
6
+ spec.author = 'Daniel J. Berger'
7
+ spec.license = 'Artistic 2.0'
8
+ spec.email = 'djberg96@gmail.com'
9
+ spec.homepage = 'http://www.rubyforge.org/projects/win32utils'
10
+ spec.summary = 'Interface to MS Windows Mutex objects.'
11
+ spec.test_file = 'test/test_win32_mutex.rb'
12
+ spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
15
13
 
16
- gem.rubyforge_project = 'win32utils'
17
- gem.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST']
14
+ spec.rubyforge_project = 'win32utils'
15
+ spec.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST']
18
16
 
19
- gem.add_dependency('win32-ipc', '>= 0.5.0')
17
+ spec.add_dependency('win32-ipc', '>= 0.5.0')
20
18
 
21
- gem.add_development_dependency('test-unit', '>= 2.0.3')
22
- gem.add_development_dependency('win32-process', '>= 0.6.1')
23
- gem.add_development_dependency('win32-mmap', '>= 0.2.2')
19
+ spec.add_development_dependency('test-unit', '>= 2.0.3')
20
+ spec.add_development_dependency('win32-process', '>= 0.6.1')
21
+ spec.add_development_dependency('win32-mmap', '>= 0.2.2')
24
22
 
25
- gem.description = <<-EOF
26
- The win32-mutex library provides an interface for creating mutex objects
27
- on MS Windows. A mutex object is a synchronization object whose state
28
- is set to signaled when it is not owned by any thread, and non-signaled
29
- when it is owned.
30
- EOF
23
+ spec.description = <<-EOF
24
+ The win32-mutex library provides an interface for creating mutex objects
25
+ on MS Windows. A mutex object is a synchronization object whose state
26
+ is set to signaled when it is not owned by any thread, and non-signaled
27
+ when it is owned.
28
+ EOF
31
29
  end
32
-
33
- Gem::Builder.new(spec).build
metadata CHANGED
@@ -1,68 +1,72 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: win32-mutex
3
- version: !ruby/object:Gem::Version
4
- version: 0.3.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.2
5
+ prerelease:
5
6
  platform: ruby
6
- authors:
7
+ authors:
7
8
  - Daniel J. Berger
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
-
12
- date: 2009-08-08 00:00:00 -06:00
13
- default_executable:
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
12
+ date: 2012-03-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
16
15
  name: win32-ipc
17
- type: :runtime
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
20
- requirements:
21
- - - ">="
22
- - !ruby/object:Gem::Version
16
+ requirement: &5842660 !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
23
21
  version: 0.5.0
24
- version:
25
- - !ruby/object:Gem::Dependency
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *5842660
25
+ - !ruby/object:Gem::Dependency
26
26
  name: test-unit
27
- type: :development
28
- version_requirement:
29
- version_requirements: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - ">="
32
- - !ruby/object:Gem::Version
27
+ requirement: &5841950 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
33
32
  version: 2.0.3
34
- version:
35
- - !ruby/object:Gem::Dependency
36
- name: win32-process
37
33
  type: :development
38
- version_requirement:
39
- version_requirements: !ruby/object:Gem::Requirement
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
34
+ prerelease: false
35
+ version_requirements: *5841950
36
+ - !ruby/object:Gem::Dependency
37
+ name: win32-process
38
+ requirement: &5841220 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
43
  version: 0.6.1
44
- version:
45
- - !ruby/object:Gem::Dependency
46
- name: win32-mmap
47
44
  type: :development
48
- version_requirement:
49
- version_requirements: !ruby/object:Gem::Requirement
50
- requirements:
51
- - - ">="
52
- - !ruby/object:Gem::Version
45
+ prerelease: false
46
+ version_requirements: *5841220
47
+ - !ruby/object:Gem::Dependency
48
+ name: win32-mmap
49
+ requirement: &5840660 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
53
54
  version: 0.2.2
54
- version:
55
- description: " The win32-mutex library provides an interface for creating mutex objects\n on MS Windows. A mutex object is a synchronization object whose state\n is set to signaled when it is not owned by any thread, and non-signaled\n when it is owned.\n"
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *5840660
58
+ description: ! " The win32-mutex library provides an interface for creating mutex
59
+ objects\n on MS Windows. A mutex object is a synchronization object whose state\n
60
+ \ is set to signaled when it is not owned by any thread, and non-signaled\n when
61
+ it is owned.\n"
56
62
  email: djberg96@gmail.com
57
63
  executables: []
58
-
59
64
  extensions: []
60
-
61
- extra_rdoc_files:
65
+ extra_rdoc_files:
62
66
  - README
63
67
  - CHANGES
64
68
  - MANIFEST
65
- files:
69
+ files:
66
70
  - CHANGES
67
71
  - examples/example_win32_mutex.rb
68
72
  - lib/win32/mutex.rb
@@ -71,33 +75,30 @@ files:
71
75
  - README
72
76
  - test/test_win32_mutex.rb
73
77
  - win32-mutex.gemspec
74
- has_rdoc: true
75
78
  homepage: http://www.rubyforge.org/projects/win32utils
76
- licenses:
79
+ licenses:
77
80
  - Artistic 2.0
78
81
  post_install_message:
79
82
  rdoc_options: []
80
-
81
- require_paths:
83
+ require_paths:
82
84
  - lib
83
- required_ruby_version: !ruby/object:Gem::Requirement
84
- requirements:
85
- - - ">="
86
- - !ruby/object:Gem::Version
87
- version: "0"
88
- version:
89
- required_rubygems_version: !ruby/object:Gem::Requirement
90
- requirements:
91
- - - ">="
92
- - !ruby/object:Gem::Version
93
- version: "0"
94
- version:
85
+ required_ruby_version: !ruby/object:Gem::Requirement
86
+ none: false
87
+ requirements:
88
+ - - ! '>='
89
+ - !ruby/object:Gem::Version
90
+ version: '0'
91
+ required_rubygems_version: !ruby/object:Gem::Requirement
92
+ none: false
93
+ requirements:
94
+ - - ! '>='
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
95
97
  requirements: []
96
-
97
98
  rubyforge_project: win32utils
98
- rubygems_version: 1.3.5
99
+ rubygems_version: 1.8.11
99
100
  signing_key:
100
101
  specification_version: 3
101
102
  summary: Interface to MS Windows Mutex objects.
102
- test_files:
103
+ test_files:
103
104
  - test/test_win32_mutex.rb