qs 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. data/.gitignore +1 -0
  2. data/Gemfile +6 -1
  3. data/LICENSE.txt +1 -1
  4. data/bench/config.qs +46 -0
  5. data/bench/queue.rb +8 -0
  6. data/bench/report.rb +114 -0
  7. data/bench/report.txt +11 -0
  8. data/bin/qs +7 -0
  9. data/lib/qs/cli.rb +124 -0
  10. data/lib/qs/client.rb +121 -0
  11. data/lib/qs/config_file.rb +79 -0
  12. data/lib/qs/daemon.rb +350 -0
  13. data/lib/qs/daemon_data.rb +46 -0
  14. data/lib/qs/error_handler.rb +58 -0
  15. data/lib/qs/job.rb +70 -0
  16. data/lib/qs/job_handler.rb +90 -0
  17. data/lib/qs/logger.rb +23 -0
  18. data/lib/qs/payload_handler.rb +136 -0
  19. data/lib/qs/pid_file.rb +42 -0
  20. data/lib/qs/process.rb +136 -0
  21. data/lib/qs/process_signal.rb +20 -0
  22. data/lib/qs/qs_runner.rb +49 -0
  23. data/lib/qs/queue.rb +69 -0
  24. data/lib/qs/redis_item.rb +33 -0
  25. data/lib/qs/route.rb +52 -0
  26. data/lib/qs/runner.rb +26 -0
  27. data/lib/qs/test_helpers.rb +17 -0
  28. data/lib/qs/test_runner.rb +43 -0
  29. data/lib/qs/version.rb +1 -1
  30. data/lib/qs.rb +92 -2
  31. data/qs.gemspec +7 -2
  32. data/test/helper.rb +8 -1
  33. data/test/support/app_daemon.rb +74 -0
  34. data/test/support/config.qs +7 -0
  35. data/test/support/config_files/empty.qs +0 -0
  36. data/test/support/config_files/invalid.qs +1 -0
  37. data/test/support/config_files/valid.qs +7 -0
  38. data/test/support/config_invalid_run.qs +3 -0
  39. data/test/support/config_no_run.qs +0 -0
  40. data/test/support/factory.rb +14 -0
  41. data/test/support/pid_file_spy.rb +19 -0
  42. data/test/support/runner_spy.rb +17 -0
  43. data/test/system/daemon_tests.rb +226 -0
  44. data/test/unit/cli_tests.rb +188 -0
  45. data/test/unit/client_tests.rb +269 -0
  46. data/test/unit/config_file_tests.rb +59 -0
  47. data/test/unit/daemon_data_tests.rb +96 -0
  48. data/test/unit/daemon_tests.rb +702 -0
  49. data/test/unit/error_handler_tests.rb +163 -0
  50. data/test/unit/job_handler_tests.rb +253 -0
  51. data/test/unit/job_tests.rb +132 -0
  52. data/test/unit/logger_tests.rb +38 -0
  53. data/test/unit/payload_handler_tests.rb +276 -0
  54. data/test/unit/pid_file_tests.rb +70 -0
  55. data/test/unit/process_signal_tests.rb +61 -0
  56. data/test/unit/process_tests.rb +371 -0
  57. data/test/unit/qs_runner_tests.rb +166 -0
  58. data/test/unit/qs_tests.rb +217 -0
  59. data/test/unit/queue_tests.rb +132 -0
  60. data/test/unit/redis_item_tests.rb +49 -0
  61. data/test/unit/route_tests.rb +81 -0
  62. data/test/unit/runner_tests.rb +63 -0
  63. data/test/unit/test_helper_tests.rb +61 -0
  64. data/test/unit/test_runner_tests.rb +128 -0
  65. metadata +180 -15
@@ -0,0 +1,128 @@
1
+ require 'assert'
2
+ require 'qs/test_runner'
3
+
4
+ require 'qs'
5
+
6
+ class Qs::TestRunner
7
+
8
+ class UnitTests < Assert::Context
9
+ desc "Qs::TestRunner"
10
+ setup do
11
+ Qs.init
12
+ @runner_class = Qs::TestRunner
13
+ end
14
+ teardown do
15
+ Qs.reset!
16
+ end
17
+ subject{ @runner_class }
18
+
19
+ should "be a runner" do
20
+ assert_true subject < Qs::Runner
21
+ end
22
+
23
+ end
24
+
25
+ class InitTests < UnitTests
26
+ desc "when init"
27
+ setup do
28
+ @handler_class = TestJobHandler
29
+ @args = {
30
+ :job => Factory.string,
31
+ :params => { Factory.string => Factory.string },
32
+ :logger => Factory.string,
33
+ :flag => Factory.boolean
34
+ }
35
+ @original_args = @args.dup
36
+ @runner = @runner_class.new(@handler_class, @args)
37
+ @handler = @runner.handler
38
+ end
39
+ subject{ @runner }
40
+
41
+ should have_imeths :run
42
+
43
+ should "know its job, params and logger" do
44
+ assert_equal @args[:job], subject.job
45
+ assert_equal @args[:params], subject.params
46
+ assert_equal @args[:logger], subject.logger
47
+ end
48
+
49
+ should "write extra args to its job handler" do
50
+ assert_equal @args[:flag], @handler.flag
51
+ end
52
+
53
+ should "not alter the args passed to it" do
54
+ assert_equal @original_args, @args
55
+ end
56
+
57
+ should "not call its job handler's before callbacks" do
58
+ assert_nil @handler.before_called
59
+ end
60
+
61
+ should "call its job handler's init" do
62
+ assert_true @handler.init_called
63
+ end
64
+
65
+ should "not run its job handler" do
66
+ assert_nil @handler.run_called
67
+ end
68
+
69
+ should "not call its job handler's after callbacks" do
70
+ assert_nil @handler.after_called
71
+ end
72
+
73
+ should "stringify and serialize the params passed to it" do
74
+ key, value = Factory.string.to_sym, Factory.string
75
+ params = {
76
+ key => value,
77
+ 'date' => Date.today
78
+ }
79
+ runner = @runner_class.new(@handler_class, :params => params)
80
+ exp = {
81
+ key.to_s => value,
82
+ 'date' => params['date'].to_s
83
+ }
84
+ assert_equal exp, runner.params
85
+ end
86
+
87
+ should "raise an invalid error when not passed a job handler" do
88
+ assert_raises(Qs::InvalidJobHandlerError){ @runner_class.new(Class.new) }
89
+ end
90
+
91
+ end
92
+
93
+ class RunTests < InitTests
94
+ desc "and run"
95
+ setup do
96
+ @runner.run
97
+ end
98
+
99
+ should "run its job handler" do
100
+ assert_true @handler.run_called
101
+ end
102
+
103
+ should "not call its job handler's after callbacks" do
104
+ assert_nil @handler.after_called
105
+ end
106
+
107
+ end
108
+
109
+ class TestJobHandler
110
+ include Qs::JobHandler
111
+
112
+ attr_reader :before_called, :after_called
113
+ attr_reader :init_called, :run_called
114
+ attr_accessor :flag
115
+
116
+ before{ @before_called = true }
117
+ after{ @after_called = true }
118
+
119
+ def init!
120
+ @init_called = true
121
+ end
122
+
123
+ def run!
124
+ @run_called = true
125
+ end
126
+ end
127
+
128
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: qs
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 27
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
- - 0
9
8
  - 1
10
- version: 0.0.1
9
+ - 0
10
+ version: 0.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - Kelly Redding
@@ -16,28 +16,104 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2013-02-18 00:00:00 Z
19
+ date: 2015-04-24 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
+ requirement: &id001 !ruby/object:Gem::Requirement
23
+ none: false
24
+ requirements:
25
+ - - ~>
26
+ - !ruby/object:Gem::Version
27
+ hash: 1
28
+ segments:
29
+ - 0
30
+ - 5
31
+ version: "0.5"
32
+ version_requirements: *id001
33
+ type: :runtime
34
+ name: dat-worker-pool
35
+ prerelease: false
36
+ - !ruby/object:Gem::Dependency
37
+ requirement: &id002 !ruby/object:Gem::Requirement
38
+ none: false
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ hash: 15
43
+ segments:
44
+ - 0
45
+ - 2
46
+ version: "0.2"
47
+ version_requirements: *id002
48
+ type: :runtime
49
+ name: hella-redis
50
+ prerelease: false
51
+ - !ruby/object:Gem::Dependency
52
+ requirement: &id003 !ruby/object:Gem::Requirement
53
+ none: false
54
+ requirements:
55
+ - - ~>
56
+ - !ruby/object:Gem::Version
57
+ hash: 13
58
+ segments:
59
+ - 1
60
+ - 1
61
+ version: "1.1"
62
+ version_requirements: *id003
63
+ type: :runtime
64
+ name: ns-options
65
+ prerelease: false
66
+ - !ruby/object:Gem::Dependency
67
+ requirement: &id004 !ruby/object:Gem::Requirement
68
+ none: false
69
+ requirements:
70
+ - - ~>
71
+ - !ruby/object:Gem::Version
72
+ hash: 11
73
+ segments:
74
+ - 1
75
+ - 2
76
+ version: "1.2"
77
+ version_requirements: *id004
78
+ type: :runtime
79
+ name: SystemTimer
80
+ prerelease: false
81
+ - !ruby/object:Gem::Dependency
82
+ requirement: &id005 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ~>
86
+ - !ruby/object:Gem::Version
87
+ hash: 31
88
+ segments:
89
+ - 2
90
+ - 14
91
+ version: "2.14"
92
+ version_requirements: *id005
22
93
  type: :development
23
94
  name: assert
24
- version_requirements: &id001 !ruby/object:Gem::Requirement
95
+ prerelease: false
96
+ - !ruby/object:Gem::Dependency
97
+ requirement: &id006 !ruby/object:Gem::Requirement
25
98
  none: false
26
99
  requirements:
27
- - - ">="
100
+ - - ~>
28
101
  - !ruby/object:Gem::Version
29
- hash: 3
102
+ hash: 5
30
103
  segments:
31
- - 0
32
- version: "0"
33
- requirement: *id001
104
+ - 2
105
+ - 3
106
+ version: "2.3"
107
+ version_requirements: *id006
108
+ type: :development
109
+ name: scmd
34
110
  prerelease: false
35
111
  description: Define message queues. Process jobs and events. Profit.
36
112
  email:
37
113
  - kelly@kellyredding.com
38
114
  - collin.redding@me.com
39
- executables: []
40
-
115
+ executables:
116
+ - qs
41
117
  extensions: []
42
118
 
43
119
  extra_rdoc_files: []
@@ -48,15 +124,72 @@ files:
48
124
  - LICENSE.txt
49
125
  - README.md
50
126
  - Rakefile
127
+ - bench/config.qs
128
+ - bench/queue.rb
129
+ - bench/report.rb
130
+ - bench/report.txt
131
+ - bin/qs
51
132
  - lib/qs.rb
133
+ - lib/qs/cli.rb
134
+ - lib/qs/client.rb
135
+ - lib/qs/config_file.rb
136
+ - lib/qs/daemon.rb
137
+ - lib/qs/daemon_data.rb
138
+ - lib/qs/error_handler.rb
139
+ - lib/qs/job.rb
140
+ - lib/qs/job_handler.rb
141
+ - lib/qs/logger.rb
142
+ - lib/qs/payload_handler.rb
143
+ - lib/qs/pid_file.rb
144
+ - lib/qs/process.rb
145
+ - lib/qs/process_signal.rb
146
+ - lib/qs/qs_runner.rb
147
+ - lib/qs/queue.rb
148
+ - lib/qs/redis_item.rb
149
+ - lib/qs/route.rb
150
+ - lib/qs/runner.rb
151
+ - lib/qs/test_helpers.rb
152
+ - lib/qs/test_runner.rb
52
153
  - lib/qs/version.rb
53
154
  - log/.gitkeep
54
155
  - qs.gemspec
55
156
  - test/helper.rb
157
+ - test/support/app_daemon.rb
158
+ - test/support/config.qs
159
+ - test/support/config_files/empty.qs
160
+ - test/support/config_files/invalid.qs
161
+ - test/support/config_files/valid.qs
162
+ - test/support/config_invalid_run.qs
163
+ - test/support/config_no_run.qs
164
+ - test/support/factory.rb
165
+ - test/support/pid_file_spy.rb
166
+ - test/support/runner_spy.rb
167
+ - test/system/daemon_tests.rb
168
+ - test/unit/cli_tests.rb
169
+ - test/unit/client_tests.rb
170
+ - test/unit/config_file_tests.rb
171
+ - test/unit/daemon_data_tests.rb
172
+ - test/unit/daemon_tests.rb
173
+ - test/unit/error_handler_tests.rb
174
+ - test/unit/job_handler_tests.rb
175
+ - test/unit/job_tests.rb
176
+ - test/unit/logger_tests.rb
177
+ - test/unit/payload_handler_tests.rb
178
+ - test/unit/pid_file_tests.rb
179
+ - test/unit/process_signal_tests.rb
180
+ - test/unit/process_tests.rb
181
+ - test/unit/qs_runner_tests.rb
182
+ - test/unit/qs_tests.rb
183
+ - test/unit/queue_tests.rb
184
+ - test/unit/redis_item_tests.rb
185
+ - test/unit/route_tests.rb
186
+ - test/unit/runner_tests.rb
187
+ - test/unit/test_helper_tests.rb
188
+ - test/unit/test_runner_tests.rb
56
189
  - tmp/.gitkeep
57
190
  homepage: http://github.com/redding/qs
58
- licenses: []
59
-
191
+ licenses:
192
+ - MIT
60
193
  post_install_message:
61
194
  rdoc_options: []
62
195
 
@@ -83,9 +216,41 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
216
  requirements: []
84
217
 
85
218
  rubyforge_project:
86
- rubygems_version: 1.8.25
219
+ rubygems_version: 1.8.29
87
220
  signing_key:
88
221
  specification_version: 3
89
222
  summary: Define message queues. Process jobs and events. Profit.
90
223
  test_files:
91
224
  - test/helper.rb
225
+ - test/support/app_daemon.rb
226
+ - test/support/config.qs
227
+ - test/support/config_files/empty.qs
228
+ - test/support/config_files/invalid.qs
229
+ - test/support/config_files/valid.qs
230
+ - test/support/config_invalid_run.qs
231
+ - test/support/config_no_run.qs
232
+ - test/support/factory.rb
233
+ - test/support/pid_file_spy.rb
234
+ - test/support/runner_spy.rb
235
+ - test/system/daemon_tests.rb
236
+ - test/unit/cli_tests.rb
237
+ - test/unit/client_tests.rb
238
+ - test/unit/config_file_tests.rb
239
+ - test/unit/daemon_data_tests.rb
240
+ - test/unit/daemon_tests.rb
241
+ - test/unit/error_handler_tests.rb
242
+ - test/unit/job_handler_tests.rb
243
+ - test/unit/job_tests.rb
244
+ - test/unit/logger_tests.rb
245
+ - test/unit/payload_handler_tests.rb
246
+ - test/unit/pid_file_tests.rb
247
+ - test/unit/process_signal_tests.rb
248
+ - test/unit/process_tests.rb
249
+ - test/unit/qs_runner_tests.rb
250
+ - test/unit/qs_tests.rb
251
+ - test/unit/queue_tests.rb
252
+ - test/unit/redis_item_tests.rb
253
+ - test/unit/route_tests.rb
254
+ - test/unit/runner_tests.rb
255
+ - test/unit/test_helper_tests.rb
256
+ - test/unit/test_runner_tests.rb