iron_mq 1.4.1 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 1
3
- :minor: 4
4
- :patch: 1
3
+ :minor: 5
4
+ :patch: 0
5
5
  :build: !!null
data/iron_mq.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "iron_mq"
8
- s.version = "1.4.1"
8
+ s.version = "1.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Travis Reeder"]
12
- s.date = "2012-02-08"
12
+ s.date = "2012-03-02"
13
13
  s.description = "Ruby client for IronMQ"
14
14
  s.email = "travis@iron.io"
15
15
  s.extra_rdoc_files = [
@@ -29,7 +29,9 @@ Gem::Specification.new do |s|
29
29
  "test/long_run.rb",
30
30
  "test/long_run_worker.rb",
31
31
  "test/quick_run.rb",
32
+ "test/schedule_abt.rb",
32
33
  "test/test_base.rb",
34
+ "test/test_beanstalkd.rb",
33
35
  "test/test_iron_mq.rb"
34
36
  ]
35
37
  s.homepage = "http://www.iron.io"
@@ -105,11 +105,16 @@ module IronMQ
105
105
  # todo: check content-type == application/json before parsing
106
106
  @logger.debug "response code=" + status.to_s
107
107
  @logger.debug "response body=" + body.inspect
108
- res = JSON.parse(body)
108
+ begin
109
+ res = JSON.parse(body)
110
+ rescue => ex
111
+ # an unexpected error response
112
+ raise IronMQ::Error.new("Status #{status}: #{ex.class.name}: #{ex.message}", :status=>status)
113
+ end
109
114
  if status < 400
110
115
 
111
116
  else
112
- raise IronMQ::Error.new(res["msg"], :status=>status)
117
+ raise IronMQ::Error.new("Status #{status}: #{res["msg"]}", :status=>status)
113
118
  end
114
119
  res
115
120
  end
@@ -69,7 +69,7 @@ module IronMQ
69
69
  def delete(message_id, options={})
70
70
  path2 = "#{self.path(options)}/#{message_id}"
71
71
  res, status = @client.delete(path2)
72
- res
72
+ return ResponseBase.new(res)
73
73
  end
74
74
 
75
75
  end
data/test/long_run.rb CHANGED
@@ -20,11 +20,11 @@ end
20
20
  worker = LongRunWorker.new
21
21
  worker.config = @config
22
22
  worker.num_to_add = @num_to_add
23
- #worker.run_local
24
- worker.queue
25
- status = worker.wait_until_complete
26
- p status
27
- puts worker.get_log
23
+ worker.run_local
24
+ #worker.queue
25
+ #status = worker.wait_until_complete
26
+ #p status
27
+ #puts worker.get_log
28
28
 
29
29
 
30
30
 
@@ -0,0 +1,4 @@
1
+ worker = Abt::TestWorker.new
2
+ worker.git_url = "git://github.com/iron-io/iron_mq_ruby.git"
3
+ worker.test_config = @test_config
4
+ worker.run_local
@@ -0,0 +1,53 @@
1
+ # Put config.yml file in ~/Dropbox/configs/ironmq_gem/test/config.yml
2
+
3
+ #$abt_config = {:hello=>'abt_config_ya'}
4
+
5
+ gem 'test-unit'
6
+ require 'test/unit'
7
+ require 'beanstalk-client'
8
+ require 'yaml'
9
+ require_relative 'test_base'
10
+
11
+ class IronMQTests < TestBase
12
+ def setup
13
+ super
14
+
15
+ end
16
+
17
+ def test_beanstalk
18
+ puts 'test_beanstalk'
19
+ config = @config['iron_mq']
20
+ h = "#{config['host']||"mq-aws-us-east-1.iron.io"}:#{config['beanstalkd_port']||11300}"
21
+ puts "beanstalkd url: #{h}"
22
+ beanstalk = Beanstalk::Connection.new(h)
23
+ beanstalk.put("oauth #{config['token']} #{config['project_id']}")
24
+ queue_name = "beanstalk_test"
25
+ clear_queue(queue_name)
26
+ beanstalk.use(queue_name)
27
+ beanstalk.watch(queue_name)
28
+
29
+ msg = "hello #{Time.now}"
30
+ beanstalk.put(msg)
31
+ job = beanstalk.reserve
32
+ assert_equal msg, job.body, "body not the same as message."
33
+ job.delete
34
+ job = assert_raise(Beanstalk::TimedOut) {
35
+ beanstalk.reserve(1)
36
+ }
37
+
38
+ hasher = {:x => 1, :y => "hello", "yo" => "scooby doo"}
39
+ beanstalk.put(hasher.to_json)
40
+ job = beanstalk.reserve(1)
41
+ got = JSON.parse(job.body)
42
+ assert got.is_a?(Hash)
43
+ assert_equal hasher[:x], got['x']
44
+ job.delete
45
+
46
+ msg = "hello there\nthis is a new line"
47
+ beanstalk.put(msg)
48
+ job = beanstalk.reserve(1)
49
+ assert_equal msg, job.body, "#{job.body} does not equal #{msg}"
50
+ job.delete
51
+ end
52
+
53
+ end
data/test/test_iron_mq.rb CHANGED
@@ -12,6 +12,9 @@ class IronMQTests < TestBase
12
12
  def setup
13
13
  super
14
14
 
15
+ queues = @client.queues.list
16
+ p queues
17
+
15
18
  clear_queue()
16
19
 
17
20
  end
@@ -73,6 +76,7 @@ class IronMQTests < TestBase
73
76
 
74
77
  msg = @client.messages.get()
75
78
  p msg
79
+ assert msg
76
80
 
77
81
  msg4 = @client.messages.get()
78
82
  p msg4
@@ -93,6 +97,20 @@ class IronMQTests < TestBase
93
97
 
94
98
  msg2.delete
95
99
 
100
+ # now try explicit timeout
101
+ res = @client.messages.post("hello world timeout2!", :timeout=>10)
102
+ p res
103
+ msg = @client.messages.get()
104
+ p msg
105
+ assert msg
106
+ msg4 = @client.messages.get()
107
+ p msg4
108
+ assert msg4.nil?
109
+ puts 'sleeping 15 seconds...'
110
+ msg2 = @client.messages.get()
111
+ assert msg2
112
+ assert msg.id == msg2.id
113
+
96
114
  end
97
115
 
98
116
  def test_queues
@@ -160,37 +178,5 @@ class IronMQTests < TestBase
160
178
  end
161
179
  end
162
180
 
163
- def test_beanstalk
164
- puts 'test_beanstalk'
165
- config = @config['iron_mq']
166
- h = "#{config['host']||"mq-aws-us-east-1.iron.io"}:#{config['beanstalkd_port']||11300}"
167
- beanstalk = Beanstalk::Connection.new(h)
168
- beanstalk.put("oauth #{config['token']} #{config['project_id']}")
169
- beanstalk.use(@client.queue_name)
170
- beanstalk.watch(@client.queue_name)
171
-
172
- msg = "hello #{Time.now}"
173
- beanstalk.put(msg)
174
- job = beanstalk.reserve
175
- assert_equal msg, job.body, "body not the same as message."
176
- job.delete
177
- job = assert_raise(Beanstalk::TimedOut) {
178
- beanstalk.reserve(1)
179
- }
180
-
181
- hasher = {:x=>1, :y=>"hello", "yo"=>"scooby doo"}
182
- beanstalk.put(hasher.to_json)
183
- job = beanstalk.reserve(1)
184
- got = JSON.parse(job.body)
185
- assert got.is_a?(Hash)
186
- assert_equal hasher[:x], got['x']
187
- job.delete
188
-
189
- msg = "hello there\nthis is a new line"
190
- beanstalk.put(msg)
191
- job = beanstalk.reserve(1)
192
- assert_equal msg, job.body, "#{job.body} does not equal #{msg}"
193
- job.delete
194
- end
195
181
  end
196
182
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iron_mq
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.5.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-08 00:00:00.000000000Z
12
+ date: 2012-03-02 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rest-client
16
- requirement: &22831660 !ruby/object:Gem::Requirement
16
+ requirement: &14061040 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *22831660
24
+ version_requirements: *14061040
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rest
27
- requirement: &22830400 !ruby/object:Gem::Requirement
27
+ requirement: &14060480 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *22830400
35
+ version_requirements: *14060480
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rest-client
38
- requirement: &22829360 !ruby/object:Gem::Requirement
38
+ requirement: &14059900 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *22829360
46
+ version_requirements: *14059900
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: rest
49
- requirement: &22828720 !ruby/object:Gem::Requirement
49
+ requirement: &14059100 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *22828720
57
+ version_requirements: *14059100
58
58
  description: Ruby client for IronMQ
59
59
  email: travis@iron.io
60
60
  executables: []
@@ -75,7 +75,9 @@ files:
75
75
  - test/long_run.rb
76
76
  - test/long_run_worker.rb
77
77
  - test/quick_run.rb
78
+ - test/schedule_abt.rb
78
79
  - test/test_base.rb
80
+ - test/test_beanstalkd.rb
79
81
  - test/test_iron_mq.rb
80
82
  homepage: http://www.iron.io
81
83
  licenses: []