ironmq 1.2.1 → 1.2.2
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.
- data/README.markdown +10 -0
- data/Rakefile +1 -1
- data/VERSION.yml +1 -1
- data/lib/ironmq/client.rb +25 -12
- metadata +2 -2
data/README.markdown
CHANGED
@@ -33,3 +33,13 @@ a timeout if you don't delete it (default timeout is 10 minutes).
|
|
33
33
|
p res
|
34
34
|
|
35
35
|
Delete a message from the queue when you're done with it.
|
36
|
+
|
37
|
+
Queue Selection
|
38
|
+
===============
|
39
|
+
|
40
|
+
One of the following:
|
41
|
+
|
42
|
+
1. Pass `:queue_name=>'my_queue'` into IronMQ::Client.new
|
43
|
+
1. `@client.queue_name = 'my_queue'`
|
44
|
+
1. Pass `:queue_name=>'my_queue'` into any post(), get(), or delete()
|
45
|
+
|
data/Rakefile
CHANGED
data/VERSION.yml
CHANGED
data/lib/ironmq/client.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
require 'json'
|
2
|
-
require '
|
2
|
+
require 'patron'
|
3
3
|
|
4
4
|
|
5
5
|
module IronMQ
|
@@ -11,12 +11,20 @@ module IronMQ
|
|
11
11
|
def initialize(options={})
|
12
12
|
@token = options[:token] || options['token']
|
13
13
|
@project_id = options[:project_id] || options['project_id']
|
14
|
-
@queue_name = options[:queue_name] || options['queue_name']
|
14
|
+
@queue_name = options[:queue_name] || options['queue_name'] || "default"
|
15
15
|
@scheme = options[:scheme] || options['scheme'] || "http"
|
16
16
|
@host = options[:host] || options['host'] || "mq-aws-us-east-1.iron.io"
|
17
17
|
@port = options[:port] || options['port'] || 80
|
18
18
|
# todo: default https
|
19
19
|
@base_url = "#{@scheme}://#{@host}:#{@port}/1"
|
20
|
+
|
21
|
+
sess = Patron::Session.new
|
22
|
+
sess.timeout = 10
|
23
|
+
sess.base_url = @base_url
|
24
|
+
sess.headers['User-Agent'] = 'IronMQ Ruby Client'
|
25
|
+
#sess.enable_debug "/tmp/patron.debug"
|
26
|
+
@http_sess = sess
|
27
|
+
|
20
28
|
end
|
21
29
|
|
22
30
|
def messages
|
@@ -27,28 +35,33 @@ module IronMQ
|
|
27
35
|
def post(path, params={})
|
28
36
|
url = "#{@base_url}#{path}"
|
29
37
|
puts 'url=' + url
|
30
|
-
response =
|
31
|
-
|
38
|
+
response = @http_sess.post(path, {'oauth' => @token}.merge(params))
|
39
|
+
#{:content_type => 'application/json'})
|
32
40
|
puts 'response: ' + response.inspect
|
33
|
-
|
41
|
+
body = response.body
|
42
|
+
res = JSON.parse(body)
|
34
43
|
res
|
35
44
|
end
|
36
45
|
|
37
46
|
def get(path, params={})
|
38
47
|
url = "#{@base_url}#{path}"
|
39
48
|
puts 'url=' + url
|
40
|
-
response =
|
41
|
-
|
42
|
-
|
49
|
+
response = @http_sess.request(:get, path,
|
50
|
+
{},
|
51
|
+
:query=>{'oauth'=>@token}.merge(params))
|
52
|
+
body = response.body
|
53
|
+
res = JSON.parse(body)
|
43
54
|
res
|
44
55
|
end
|
45
56
|
|
46
57
|
def delete(path, params={})
|
47
58
|
url = "#{@base_url}#{path}"
|
48
59
|
puts 'url=' + url
|
49
|
-
response =
|
50
|
-
|
51
|
-
|
60
|
+
response = @http_sess.request(:delete, path,
|
61
|
+
{},
|
62
|
+
:query=>{'oauth'=>@token}.merge(params))
|
63
|
+
body = response.body
|
64
|
+
res = JSON.parse(body)
|
52
65
|
puts 'response: ' + res.inspect
|
53
66
|
res
|
54
67
|
end
|
@@ -64,7 +77,7 @@ module IronMQ
|
|
64
77
|
end
|
65
78
|
|
66
79
|
def path(options={})
|
67
|
-
|
80
|
+
path = "/projects/#{@client.project_id}/queues/#{options[:queue_name] || @client.queue_name}/messages"
|
68
81
|
end
|
69
82
|
|
70
83
|
# options:
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: ironmq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.2.
|
5
|
+
version: 1.2.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Travis Reeder
|
@@ -13,7 +13,7 @@ cert_chain: []
|
|
13
13
|
date: 2011-10-12 00:00:00 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
|
-
name:
|
16
|
+
name: patron
|
17
17
|
prerelease: false
|
18
18
|
requirement: &id001 !ruby/object:Gem::Requirement
|
19
19
|
none: false
|