symphony 0.4.0 → 0.5.0

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,9 +1,11 @@
1
1
  #!/usr/bin/env rspec -wfd
2
+ # vim: set nosta noet ts=4 sw=4:
2
3
 
3
4
  require_relative '../helpers'
4
5
 
5
6
  require 'symphony/mixins'
6
7
 
8
+ using Symphony::TimeRefinements
7
9
 
8
10
  describe Symphony, 'mixins' do
9
11
 
@@ -75,4 +77,53 @@ describe Symphony, 'mixins' do
75
77
 
76
78
  end
77
79
 
80
+
81
+ describe "numeric constant methods" do
82
+
83
+ SECONDS_IN_A_MINUTE = 60
84
+ SECONDS_IN_AN_HOUR = SECONDS_IN_A_MINUTE * 60
85
+ SECONDS_IN_A_DAY = SECONDS_IN_AN_HOUR * 24
86
+ SECONDS_IN_A_WEEK = SECONDS_IN_A_DAY * 7
87
+ SECONDS_IN_A_FORTNIGHT = SECONDS_IN_A_WEEK * 2
88
+ SECONDS_IN_A_MONTH = SECONDS_IN_A_DAY * 30
89
+ SECONDS_IN_A_YEAR = Integer( SECONDS_IN_A_DAY * 365.25 )
90
+
91
+ it "can calculate the number of seconds for various units of time" do
92
+ expect( 1.second ).to eq( 1 )
93
+ expect( 14.seconds ).to eq( 14 )
94
+
95
+ expect( 1.minute ).to eq( SECONDS_IN_A_MINUTE )
96
+ expect( 18.minutes ).to eq( SECONDS_IN_A_MINUTE * 18 )
97
+
98
+ expect( 1.hour ).to eq( SECONDS_IN_AN_HOUR )
99
+ expect( 723.hours ).to eq( SECONDS_IN_AN_HOUR * 723 )
100
+
101
+ expect( 1.day ).to eq( SECONDS_IN_A_DAY )
102
+ expect( 3.days ).to eq( SECONDS_IN_A_DAY * 3 )
103
+
104
+ expect( 1.week ).to eq( SECONDS_IN_A_WEEK )
105
+ expect( 28.weeks ).to eq( SECONDS_IN_A_WEEK * 28 )
106
+
107
+ expect( 1.fortnight ).to eq( SECONDS_IN_A_FORTNIGHT )
108
+ expect( 31.fortnights ).to eq( SECONDS_IN_A_FORTNIGHT * 31 )
109
+
110
+ expect( 1.month ).to eq( SECONDS_IN_A_MONTH )
111
+ expect( 67.months ).to eq( SECONDS_IN_A_MONTH * 67 )
112
+
113
+ expect( 1.year ).to eq( SECONDS_IN_A_YEAR )
114
+ expect( 13.years ).to eq( SECONDS_IN_A_YEAR * 13 )
115
+ end
116
+
117
+
118
+ it "can calculate various time offsets" do
119
+ starttime = Time.now
120
+
121
+ expect( 1.second.after( starttime ) ).to eq( starttime + 1 )
122
+ expect( 18.seconds.from_now ).to be_within( 10.seconds ).of( starttime + 18 )
123
+
124
+ expect( 1.second.before( starttime ) ).to eq( starttime - 1 )
125
+ expect( 3.hours.ago ).to be_within( 10.seconds ).of( starttime - 10800 )
126
+ end
127
+ end
78
128
  end
129
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: symphony
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Granger
@@ -31,8 +31,22 @@ cert_chain:
31
31
  c7ZKPJcWBv0sm81+FCZXNACn2f9jfF8OQinxVs0O052KbGuEQaaiGIYeuuwQE2q6
32
32
  ggcrPfcYeTwWlfZPu2LrBg==
33
33
  -----END CERTIFICATE-----
34
- date: 2014-03-29 00:00:00.000000000 Z
34
+ date: 2014-04-08 00:00:00.000000000 Z
35
35
  dependencies:
36
+ - !ruby/object:Gem::Dependency
37
+ name: loggability
38
+ requirement: !ruby/object:Gem::Requirement
39
+ requirements:
40
+ - - ~>
41
+ - !ruby/object:Gem::Version
42
+ version: '0.10'
43
+ type: :runtime
44
+ prerelease: false
45
+ version_requirements: !ruby/object:Gem::Requirement
46
+ requirements:
47
+ - - ~>
48
+ - !ruby/object:Gem::Version
49
+ version: '0.10'
36
50
  - !ruby/object:Gem::Dependency
37
51
  name: pluggability
38
52
  requirement: !ruby/object:Gem::Requirement
@@ -145,20 +159,34 @@ dependencies:
145
159
  - - ~>
146
160
  - !ruby/object:Gem::Version
147
161
  version: 1.4.0
162
+ - !ruby/object:Gem::Dependency
163
+ name: hoe-deveiate
164
+ requirement: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ~>
167
+ - !ruby/object:Gem::Version
168
+ version: '0.5'
169
+ type: :development
170
+ prerelease: false
171
+ version_requirements: !ruby/object:Gem::Requirement
172
+ requirements:
173
+ - - ~>
174
+ - !ruby/object:Gem::Version
175
+ version: '0.5'
148
176
  - !ruby/object:Gem::Dependency
149
177
  name: hoe-highline
150
178
  requirement: !ruby/object:Gem::Requirement
151
179
  requirements:
152
180
  - - ~>
153
181
  - !ruby/object:Gem::Version
154
- version: 0.1.0
182
+ version: '0.2'
155
183
  type: :development
156
184
  prerelease: false
157
185
  version_requirements: !ruby/object:Gem::Requirement
158
186
  requirements:
159
187
  - - ~>
160
188
  - !ruby/object:Gem::Version
161
- version: 0.1.0
189
+ version: '0.2'
162
190
  - !ruby/object:Gem::Dependency
163
191
  name: rdoc
164
192
  requirement: !ruby/object:Gem::Requirement
@@ -235,14 +263,14 @@ dependencies:
235
263
  requirements:
236
264
  - - ~>
237
265
  - !ruby/object:Gem::Version
238
- version: '3.9'
266
+ version: '3.11'
239
267
  type: :development
240
268
  prerelease: false
241
269
  version_requirements: !ruby/object:Gem::Requirement
242
270
  requirements:
243
271
  - - ~>
244
272
  - !ruby/object:Gem::Version
245
- version: '3.9'
273
+ version: '3.11'
246
274
  description: |-
247
275
  Symphony is a subscription-based asynchronous job system. It
248
276
  allows you to define jobs that watch for lightweight events from a
@@ -285,6 +313,7 @@ files:
285
313
  - etc/config.yml.example
286
314
  - lib/symphony.rb
287
315
  - lib/symphony/daemon.rb
316
+ - lib/symphony/intervalexpression.rb
288
317
  - lib/symphony/metrics.rb
289
318
  - lib/symphony/mixins.rb
290
319
  - lib/symphony/queue.rb
@@ -293,12 +322,12 @@ files:
293
322
  - lib/symphony/task.rb
294
323
  - lib/symphony/tasks/auditor.rb
295
324
  - lib/symphony/tasks/failure_logger.rb
296
- - lib/symphony/tasks/pinger.rb
297
325
  - lib/symphony/tasks/simulator.rb
298
326
  - lib/symphony/tasks/ssh.rb
299
327
  - lib/symphony/tasks/sshscript.rb
300
328
  - spec/helpers.rb
301
329
  - spec/symphony/daemon_spec.rb
330
+ - spec/symphony/intervalexpression_spec.rb
302
331
  - spec/symphony/mixins_spec.rb
303
332
  - spec/symphony/queue_spec.rb
304
333
  - spec/symphony/task_spec.rb
@@ -326,7 +355,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
326
355
  - !ruby/object:Gem::Version
327
356
  version: 2.0.3
328
357
  requirements: []
329
- rubyforge_project: symphony
358
+ rubyforge_project:
330
359
  rubygems_version: 2.2.2
331
360
  signing_key:
332
361
  specification_version: 4
metadata.gz.sig CHANGED
Binary file
@@ -1,64 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'socket'
4
- require 'timeout'
5
- require 'symphony/task' unless defined?( Symphony::Task )
6
-
7
-
8
- ### A proof-of-concept task to determine ssh availability of a host.
9
- class Symphony::Task::Pinger < Symphony::Task
10
-
11
- # The topic key to subscribe to
12
- subscribe_to 'monitor.availability.port',
13
- 'host.ping'
14
-
15
- # Send success/failure back to the queue on job completion. Then true, the
16
- # work isn't considered complete until receiving a success ack. When false,
17
- # a worker simply consuming the task is sufficient.
18
- acknowledge false # default: true
19
-
20
- # Timeout for performing work. NOT to be confused with the message TTL
21
- # during queue lifetime.
22
- timeout 10.minutes # default: no timeout
23
-
24
- # Whether the task should exit after doing its work
25
- work_model :oneshot # default: :longlived
26
-
27
-
28
- # The default port
29
- DEFAULT_PORT = 'ssh'
30
-
31
-
32
- ### Create a new Pinger task for the given +job+ and +queue+.
33
- def initialize
34
- super
35
- end
36
-
37
-
38
- ######
39
- public
40
- ######
41
-
42
- # The hostname to ping
43
- attr_reader :hostname
44
-
45
- # The (TCP) port to ping
46
- attr_reader :port
47
-
48
- # If there is a problem pinging the remote host, this is set to the exception
49
- # raised when doing so.
50
- attr_reader :problem
51
-
52
-
53
- #
54
- # Task API
55
- #
56
-
57
- ### Do the ping.
58
- def work( payload, metadata )
59
- return ping( payload['hostname'], payload['port'] )
60
- end
61
-
62
-
63
- end # class Symphony::Task::Pinger
64
-