win32-job 0.1.3 → 0.1.4

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.
@@ -1,25 +1,25 @@
1
- require 'ffi'
2
-
3
- module Windows
4
- module Functions
5
- extend FFI::Library
6
- ffi_lib :kernel32
7
-
8
- typedef :uintptr_t, :handle
9
- typedef :ulong, :dword
10
-
11
- attach_function :AssignProcessToJobObject, [:handle, :handle], :bool
12
- attach_function :CloseHandle, [:handle], :bool
13
- attach_function :CreateJobObject, :CreateJobObjectA, [:pointer, :string], :handle
14
- attach_function :CreateIoCompletionPort, [:handle, :handle, :uintptr_t, :dword], :handle
15
- attach_function :GetQueuedCompletionStatus, [:handle, :pointer, :pointer, :pointer, :dword], :bool
16
- attach_function :IsProcessInJob, [:handle, :handle, :pointer], :bool
17
- attach_function :OpenProcess, [:dword, :bool, :dword], :handle
18
- attach_function :OpenJobObject, :OpenJobObjectA, [:dword, :bool, :string], :handle
19
- attach_function :QueryInformationJobObject, [:handle, :int, :pointer, :dword, :pointer], :bool
20
- attach_function :ResumeThread, [:handle], :dword
21
- attach_function :SetInformationJobObject, [:handle, :int, :pointer, :dword], :bool
22
- attach_function :TerminateJobObject, [:handle, :uint], :bool
23
- attach_function :WaitForSingleObjectEx, [:handle, :dword, :bool], :dword
24
- end
25
- end
1
+ require 'ffi'
2
+
3
+ module Windows
4
+ module Functions
5
+ extend FFI::Library
6
+ ffi_lib :kernel32
7
+
8
+ typedef :uintptr_t, :handle
9
+ typedef :ulong, :dword
10
+
11
+ attach_function :AssignProcessToJobObject, [:handle, :handle], :bool
12
+ attach_function :CloseHandle, [:handle], :bool
13
+ attach_function :CreateJobObject, :CreateJobObjectA, [:pointer, :string], :handle
14
+ attach_function :CreateIoCompletionPort, [:handle, :handle, :uintptr_t, :dword], :handle
15
+ attach_function :GetQueuedCompletionStatus, [:handle, :pointer, :pointer, :pointer, :dword], :bool
16
+ attach_function :IsProcessInJob, [:handle, :handle, :pointer], :bool
17
+ attach_function :OpenProcess, [:dword, :bool, :dword], :handle
18
+ attach_function :OpenJobObject, :OpenJobObjectA, [:dword, :bool, :string], :handle
19
+ attach_function :QueryInformationJobObject, [:handle, :int, :pointer, :dword, :pointer], :bool
20
+ attach_function :ResumeThread, [:handle], :dword
21
+ attach_function :SetInformationJobObject, [:handle, :int, :pointer, :dword], :bool
22
+ attach_function :TerminateJobObject, [:handle, :uint], :bool
23
+ attach_function :WaitForSingleObjectEx, [:handle, :dword, :bool], :dword
24
+ end
25
+ end
@@ -1,139 +1,139 @@
1
- #######################################################################
2
- # test_win32_job.rb
3
- #
4
- # Test suite for the win32-job library. You should run these tests
5
- # via the "rake test" command.
6
- #######################################################################
7
- require 'test-unit'
8
- require 'win32/job'
9
-
10
- class TC_Win32_Job < Test::Unit::TestCase
11
- def setup
12
- @name = 'ruby_xxxxxx'
13
- @job = Win32::Job.new(@name)
14
- @pid = Process.spawn('notepad')
15
- end
16
-
17
- test "version number is what we expect" do
18
- assert_equal('0.1.3', Win32::Job::VERSION)
19
- end
20
-
21
- test "constructor argument may be omitted" do
22
- assert_nothing_raised{ Win32::Job.new }
23
- end
24
-
25
- test "constructor accepts a name for the job" do
26
- assert_nothing_raised{ Win32::Job.new(@name) }
27
- end
28
-
29
- test "constructor accepts a second argument" do
30
- assert_nothing_raised{ Win32::Job.new(@name, true) }
31
- end
32
-
33
- test "argument to constructor must be a string" do
34
- assert_raise(TypeError){ Win32::Job.new(1) }
35
- end
36
-
37
- test "if second argument to constructor is false, an error is raised if the same job is reopened" do
38
- @job = Win32::Job.new('test')
39
- assert_raise(ArgumentError){ Win32::Job.new('test', false) }
40
- end
41
-
42
- test "job_name basic functionality" do
43
- assert_respond_to(@job, :job_name)
44
- assert_nothing_raised{ @job.job_name }
45
- assert_kind_of(String, @job.job_name)
46
- end
47
-
48
- test "job_name is read-only" do
49
- assert_raise(NoMethodError){ @job.job_name = 'foo' }
50
- end
51
-
52
- test "name is an alias for job_name" do
53
- assert_alias_method(@job, :name, :job_name)
54
- end
55
-
56
- test "close basic functionality" do
57
- assert_respond_to(@job, :close)
58
- assert_nothing_raised{ @job.close }
59
- end
60
-
61
- test "calling close multiple times has no effect" do
62
- assert_nothing_raised{ @job.close }
63
- assert_nothing_raised{ @job.close }
64
- assert_nothing_raised{ @job.close }
65
- end
66
-
67
- test "close method does not accept any arguments" do
68
- assert_raise(ArgumentError){ @job.close(1) }
69
- end
70
-
71
- test "add_process basic functionality" do
72
- assert_respond_to(@job, :add_process)
73
- end
74
-
75
- test "add_process works as expected" do
76
- assert_nothing_raised{ @job.add_process(@pid) }
77
- end
78
-
79
- test "add process requires a single argument" do
80
- assert_raise(ArgumentError){ @job.add_process }
81
- end
82
-
83
- test "kill basic functionality" do
84
- assert_respond_to(@job, :kill)
85
- end
86
-
87
- test "kill works as expected" do
88
- @job.add_process(@pid)
89
- assert_equal(@pid, @job.process_list.first)
90
- assert_nothing_raised{ @job.kill }
91
- assert_true(@job.process_list.empty?)
92
- end
93
-
94
- test "terminate is an alias for kill" do
95
- assert_alias_method(@job, :kill, :terminate)
96
- end
97
-
98
- test "configure_limit basic functionality" do
99
- assert_nothing_raised{ @job.configure_limit }
100
- end
101
-
102
- test "configure_limit works as expected" do
103
- assert_nothing_raised{
104
- @job.configure_limit(
105
- :breakaway_ok => true,
106
- :kill_on_job_close => true,
107
- :process_memory => 1024 * 8,
108
- :process_time => 1000
109
- )
110
- }
111
- end
112
-
113
- test "configure_limit raises an error if it detects an invalid option" do
114
- assert_raise(ArgumentError){ @job.configure_limit(:bogus => 1) }
115
- end
116
-
117
- test "wait method basic functionality" do
118
- assert_respond_to(@job, :wait)
119
- end
120
-
121
- test "priority constants are defined" do
122
- assert_not_nil(Win32::Job::ABOVE_NORMAL_PRIORITY_CLASS)
123
- assert_not_nil(Win32::Job::BELOW_NORMAL_PRIORITY_CLASS)
124
- assert_not_nil(Win32::Job::HIGH_PRIORITY_CLASS)
125
- assert_not_nil(Win32::Job::IDLE_PRIORITY_CLASS)
126
- assert_not_nil(Win32::Job::NORMAL_PRIORITY_CLASS)
127
- assert_not_nil(Win32::Job::REALTIME_PRIORITY_CLASS)
128
- end
129
-
130
- def teardown
131
- @name = nil
132
-
133
- @job.close
134
- @job = nil
135
-
136
- Process.kill(9, @pid) rescue nil
137
- @pid = nil
138
- end
139
- end
1
+ #######################################################################
2
+ # test_win32_job.rb
3
+ #
4
+ # Test suite for the win32-job library. You should run these tests
5
+ # via the "rake test" command.
6
+ #######################################################################
7
+ require 'test-unit'
8
+ require 'win32/job'
9
+
10
+ class TC_Win32_Job < Test::Unit::TestCase
11
+ def setup
12
+ @name = 'ruby_xxxxxx'
13
+ @job = Win32::Job.new(@name)
14
+ @pid = Process.spawn('notepad')
15
+ end
16
+
17
+ test "version number is what we expect" do
18
+ assert_equal('0.1.4', Win32::Job::VERSION)
19
+ end
20
+
21
+ test "constructor argument may be omitted" do
22
+ assert_nothing_raised{ Win32::Job.new }
23
+ end
24
+
25
+ test "constructor accepts a name for the job" do
26
+ assert_nothing_raised{ Win32::Job.new(@name) }
27
+ end
28
+
29
+ test "constructor accepts a second argument" do
30
+ assert_nothing_raised{ Win32::Job.new(@name, true) }
31
+ end
32
+
33
+ test "argument to constructor must be a string" do
34
+ assert_raise(TypeError){ Win32::Job.new(1) }
35
+ end
36
+
37
+ test "if second argument to constructor is false, an error is raised if the same job is reopened" do
38
+ @job = Win32::Job.new('test')
39
+ assert_raise(ArgumentError){ Win32::Job.new('test', false) }
40
+ end
41
+
42
+ test "job_name basic functionality" do
43
+ assert_respond_to(@job, :job_name)
44
+ assert_nothing_raised{ @job.job_name }
45
+ assert_kind_of(String, @job.job_name)
46
+ end
47
+
48
+ test "job_name is read-only" do
49
+ assert_raise(NoMethodError){ @job.job_name = 'foo' }
50
+ end
51
+
52
+ test "name is an alias for job_name" do
53
+ assert_alias_method(@job, :name, :job_name)
54
+ end
55
+
56
+ test "close basic functionality" do
57
+ assert_respond_to(@job, :close)
58
+ assert_nothing_raised{ @job.close }
59
+ end
60
+
61
+ test "calling close multiple times has no effect" do
62
+ assert_nothing_raised{ @job.close }
63
+ assert_nothing_raised{ @job.close }
64
+ assert_nothing_raised{ @job.close }
65
+ end
66
+
67
+ test "close method does not accept any arguments" do
68
+ assert_raise(ArgumentError){ @job.close(1) }
69
+ end
70
+
71
+ test "add_process basic functionality" do
72
+ assert_respond_to(@job, :add_process)
73
+ end
74
+
75
+ test "add_process works as expected" do
76
+ assert_nothing_raised{ @job.add_process(@pid) }
77
+ end
78
+
79
+ test "add process requires a single argument" do
80
+ assert_raise(ArgumentError){ @job.add_process }
81
+ end
82
+
83
+ test "kill basic functionality" do
84
+ assert_respond_to(@job, :kill)
85
+ end
86
+
87
+ test "kill works as expected" do
88
+ @job.add_process(@pid)
89
+ assert_equal(@pid, @job.process_list.first)
90
+ assert_nothing_raised{ @job.kill }
91
+ assert_true(@job.process_list.empty?)
92
+ end
93
+
94
+ test "terminate is an alias for kill" do
95
+ assert_alias_method(@job, :kill, :terminate)
96
+ end
97
+
98
+ test "configure_limit basic functionality" do
99
+ assert_nothing_raised{ @job.configure_limit }
100
+ end
101
+
102
+ test "configure_limit works as expected" do
103
+ assert_nothing_raised{
104
+ @job.configure_limit(
105
+ :breakaway_ok => true,
106
+ :kill_on_job_close => true,
107
+ :process_memory => 1024 * 8,
108
+ :process_time => 1000
109
+ )
110
+ }
111
+ end
112
+
113
+ test "configure_limit raises an error if it detects an invalid option" do
114
+ assert_raise(ArgumentError){ @job.configure_limit(:bogus => 1) }
115
+ end
116
+
117
+ test "wait method basic functionality" do
118
+ assert_respond_to(@job, :wait)
119
+ end
120
+
121
+ test "priority constants are defined" do
122
+ assert_not_nil(Win32::Job::ABOVE_NORMAL_PRIORITY_CLASS)
123
+ assert_not_nil(Win32::Job::BELOW_NORMAL_PRIORITY_CLASS)
124
+ assert_not_nil(Win32::Job::HIGH_PRIORITY_CLASS)
125
+ assert_not_nil(Win32::Job::IDLE_PRIORITY_CLASS)
126
+ assert_not_nil(Win32::Job::NORMAL_PRIORITY_CLASS)
127
+ assert_not_nil(Win32::Job::REALTIME_PRIORITY_CLASS)
128
+ end
129
+
130
+ def teardown
131
+ @name = nil
132
+
133
+ @job.close
134
+ @job = nil
135
+
136
+ Process.kill(9, @pid) rescue nil
137
+ @pid = nil
138
+ end
139
+ end
@@ -1,27 +1,28 @@
1
- require 'rubygems'
2
-
3
- Gem::Specification.new do |spec|
4
- spec.name = 'win32-job'
5
- spec.version = '0.1.3'
6
- spec.authors = ['Daniel J. Berger', 'Park Heesob']
7
- spec.license = 'Artistic 2.0'
8
- spec.email = 'djberg96@gmail.com'
9
- spec.homepage = 'http://github.com/djberg96/win32-job'
10
- spec.summary = 'Interface for Windows jobs (process groups)'
11
- spec.test_file = 'test/test_win32_job.rb'
12
- spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
13
-
14
- spec.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST']
15
- spec.required_ruby_version = '> 1.9.3'
16
-
17
- spec.add_dependency('ffi')
18
-
19
- spec.add_development_dependency('rake')
20
- spec.add_development_dependency('test-unit')
21
-
22
- spec.description = <<-EOF
23
- The win32-job library provides an interface for jobs (process groups)
24
- on MS Windows. This allows you to apply various limits and behavior to
25
- groups of processes on Windows.
26
- EOF
27
- end
1
+ require 'rubygems'
2
+
3
+ Gem::Specification.new do |spec|
4
+ spec.name = 'win32-job'
5
+ spec.version = '0.1.4'
6
+ spec.authors = ['Daniel J. Berger', 'Park Heesob']
7
+ spec.license = 'Artistic 2.0'
8
+ spec.email = 'djberg96@gmail.com'
9
+ spec.homepage = 'http://github.com/djberg96/win32-job'
10
+ spec.summary = 'Interface for Windows jobs (process groups)'
11
+ spec.test_file = 'test/test_win32_job.rb'
12
+ spec.files = Dir['**/*'].reject{ |f| f.include?('git') }
13
+ spec.cert_chain = ['certs/djberg96_pub.pem']
14
+
15
+ spec.extra_rdoc_files = ['README', 'CHANGES', 'MANIFEST']
16
+ spec.required_ruby_version = '> 1.9.3'
17
+
18
+ spec.add_dependency('ffi')
19
+
20
+ spec.add_development_dependency('rake')
21
+ spec.add_development_dependency('test-unit')
22
+
23
+ spec.description = <<-EOF
24
+ The win32-job library provides an interface for jobs (process groups)
25
+ on MS Windows. This allows you to apply various limits and behavior to
26
+ groups of processes on Windows.
27
+ EOF
28
+ end
metadata CHANGED
@@ -1,15 +1,37 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: win32-job
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel J. Berger
8
8
  - Park Heesob
9
9
  autorequire:
10
10
  bindir: bin
11
- cert_chain: []
12
- date: 2014-10-20 00:00:00.000000000 Z
11
+ cert_chain:
12
+ - |
13
+ -----BEGIN CERTIFICATE-----
14
+ MIIDcDCCAligAwIBAgIBATANBgkqhkiG9w0BAQUFADA/MREwDwYDVQQDDAhkamJl
15
+ cmc5NjEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPyLGQBGRYDY29t
16
+ MB4XDTE1MDkwMjIwNDkxOFoXDTE2MDkwMTIwNDkxOFowPzERMA8GA1UEAwwIZGpi
17
+ ZXJnOTYxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDETMBEGCgmSJomT8ixkARkWA2Nv
18
+ bTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoCggEBAMyTkvXqRp6hLs9eoJOS
19
+ Hmi8kRYbq9Vkf15/hMxJpotYMgJVHHWrmDcC5Dye2PbnXjTkKf266Zw0PtT9h+lI
20
+ S3ts9HO+vaCFSMwFFZmnWJSpQ3CNw2RcHxjWkk9yF7imEM8Kz9ojhiDXzBetdV6M
21
+ gr0lV/alUr7TNVBDngbXEfTWscyXh1qd7xZ4EcOdsDktCe5G45N/o3662tPQvJsi
22
+ FOF0CM/KuBsa/HL1/eoEmF4B3EKIRfTHrQ3hu20Kv3RJ88QM4ec2+0dd97uX693O
23
+ zv6981fyEg+aXLkxrkViM/tz2qR2ZE0jPhHTREPYeMEgptRkTmWSKAuLVWrJEfgl
24
+ DtkCAwEAAaN3MHUwCQYDVR0TBAIwADALBgNVHQ8EBAMCBLAwHQYDVR0OBBYEFEwe
25
+ nn6bfJADmuIDiMSOzedOrL+xMB0GA1UdEQQWMBSBEmRqYmVyZzk2QGdtYWlsLmNv
26
+ bTAdBgNVHRIEFjAUgRJkamJlcmc5NkBnbWFpbC5jb20wDQYJKoZIhvcNAQEFBQAD
27
+ ggEBAHmNOCWoDVD75zHFueY0viwGDVP1BNGFC+yXcb7u2GlK+nEMCORqzURbYPf7
28
+ tL+/hzmePIRz7i30UM//64GI1NLv9jl7nIwjhPpXpf7/lu2I9hOTsvwSumb5UiKC
29
+ /sqBxI3sfj9pr79Wpv4MuikX1XPik7Ncb7NPsJPw06Lvyc3Hkg5X2XpPtLtS+Gr2
30
+ wKJnmzb5rIPS1cmsqv0M9LPWflzfwoZ/SpnmhagP+g05p8bRNKjZSA2iImM/GyYZ
31
+ EJYzxdPOrx2n6NYR3Hk+vHP0U7UBSveI6+qx+ndQYaeyCn+GRX2PKS9h66YF/Q1V
32
+ tGSHgAmcLlkdGgan182qsE/4kKM=
33
+ -----END CERTIFICATE-----
34
+ date: 2015-11-10 00:00:00.000000000 Z
13
35
  dependencies:
14
36
  - !ruby/object:Gem::Dependency
15
37
  name: ffi
@@ -65,16 +87,25 @@ extra_rdoc_files:
65
87
  - CHANGES
66
88
  - MANIFEST
67
89
  files:
90
+ - appveyor.yml
91
+ - certs
92
+ - certs/djberg96_pub.pem
68
93
  - CHANGES
69
- - MANIFEST
70
- - README
71
- - Rakefile
94
+ - examples
72
95
  - examples/example_job.rb
73
- - lib/win32/job.rb
96
+ - lib
97
+ - lib/win32
98
+ - lib/win32/job
74
99
  - lib/win32/job/constants.rb
75
100
  - lib/win32/job/functions.rb
76
101
  - lib/win32/job/helper.rb
77
102
  - lib/win32/job/structs.rb
103
+ - lib/win32/job.rb
104
+ - lib/win32-job.rb
105
+ - MANIFEST
106
+ - Rakefile
107
+ - README
108
+ - test
78
109
  - test/test_win32_job.rb
79
110
  - win32-job.gemspec
80
111
  homepage: http://github.com/djberg96/win32-job
@@ -97,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
97
128
  version: '0'
98
129
  requirements: []
99
130
  rubyforge_project:
100
- rubygems_version: 2.2.2
131
+ rubygems_version: 2.4.8
101
132
  signing_key:
102
133
  specification_version: 4
103
134
  summary: Interface for Windows jobs (process groups)