ironmq 1.2.6 → 1.2.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +7 -0
- data/VERSION.yml +1 -1
- data/ironmq.gemspec +15 -12
- data/lib/ironmq.rb +1 -0
- data/lib/ironmq/client.rb +5 -0
- data/lib/ironmq/queues.rb +72 -0
- data/test/long_run.rb +1 -1
- data/test/quick_run.rb +28 -0
- data/test/test_base.rb +21 -0
- data/test/{ironmq_tests.rb → test_ironmq.rb} +35 -12
- metadata +11 -8
data/README.markdown
CHANGED
@@ -47,3 +47,10 @@ One of the following:
|
|
47
47
|
1. `@client.queue_name = 'my_queue'`
|
48
48
|
1. Pass `:queue_name=>'my_queue'` into any post(), get(), or delete()
|
49
49
|
|
50
|
+
Queue Information
|
51
|
+
=================
|
52
|
+
|
53
|
+
queue = @client.queues.get(:name=>@client.queue_name)
|
54
|
+
puts "size: #{queue.size}"
|
55
|
+
|
56
|
+
|
data/VERSION.yml
CHANGED
data/ironmq.gemspec
CHANGED
@@ -4,14 +4,14 @@
|
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
|
-
s.name =
|
8
|
-
s.version = "1.2.
|
7
|
+
s.name = "ironmq"
|
8
|
+
s.version = "1.2.7"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
|
-
s.authors = [
|
12
|
-
s.date =
|
13
|
-
s.description =
|
14
|
-
s.email =
|
11
|
+
s.authors = ["Travis Reeder"]
|
12
|
+
s.date = "2011-12-08"
|
13
|
+
s.description = "Ruby client for IronMQ"
|
14
|
+
s.email = "travis@iron.io"
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"README.markdown"
|
17
17
|
]
|
@@ -23,14 +23,17 @@ Gem::Specification.new do |s|
|
|
23
23
|
"lib/ironmq.rb",
|
24
24
|
"lib/ironmq/client.rb",
|
25
25
|
"lib/ironmq/messages.rb",
|
26
|
-
"
|
27
|
-
"test/long_run.rb"
|
26
|
+
"lib/ironmq/queues.rb",
|
27
|
+
"test/long_run.rb",
|
28
|
+
"test/quick_run.rb",
|
29
|
+
"test/test_base.rb",
|
30
|
+
"test/test_ironmq.rb"
|
28
31
|
]
|
29
|
-
s.homepage =
|
30
|
-
s.require_paths = [
|
32
|
+
s.homepage = "http://www.iron.io"
|
33
|
+
s.require_paths = ["lib"]
|
31
34
|
s.required_ruby_version = Gem::Requirement.new(">= 1.9")
|
32
|
-
s.rubygems_version =
|
33
|
-
s.summary =
|
35
|
+
s.rubygems_version = "1.8.11"
|
36
|
+
s.summary = "Ruby client for IronMQ"
|
34
37
|
|
35
38
|
if s.respond_to? :specification_version then
|
36
39
|
s.specification_version = 3
|
data/lib/ironmq.rb
CHANGED
data/lib/ironmq/client.rb
CHANGED
@@ -27,6 +27,10 @@ module IronMQ
|
|
27
27
|
return Messages.new(self)
|
28
28
|
end
|
29
29
|
|
30
|
+
def queues
|
31
|
+
return Queues.new(self)
|
32
|
+
end
|
33
|
+
|
30
34
|
def base_url
|
31
35
|
#"#{scheme}://#{host}:#{port}/1"
|
32
36
|
@base_url
|
@@ -65,6 +69,7 @@ module IronMQ
|
|
65
69
|
@logger.debug 'url=' + url
|
66
70
|
req_hash = common_req_hash
|
67
71
|
req_hash[:params] = params
|
72
|
+
@logger.debug 'req_hash=' + req_hash.inspect
|
68
73
|
response = Typhoeus::Request.get(url, req_hash)
|
69
74
|
res = check_response(response)
|
70
75
|
return res, response.code
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module IronMQ
|
2
|
+
class Queues
|
3
|
+
|
4
|
+
attr_accessor :client
|
5
|
+
|
6
|
+
def initialize(client)
|
7
|
+
@client = client
|
8
|
+
end
|
9
|
+
|
10
|
+
def path(options={})
|
11
|
+
path = "/projects/#{@client.project_id}/queues"
|
12
|
+
end
|
13
|
+
|
14
|
+
def list(options={})
|
15
|
+
ret = []
|
16
|
+
res, status = @client.get("#{path(options)}", options)
|
17
|
+
res.each do |q|
|
18
|
+
#p q
|
19
|
+
q = Queue.new(self, q)
|
20
|
+
ret << q
|
21
|
+
end
|
22
|
+
ret
|
23
|
+
end
|
24
|
+
|
25
|
+
# options:
|
26
|
+
# :name => can specify an alternative queue name
|
27
|
+
def get(options={})
|
28
|
+
res, status = @client.get("#{path(options)}/#{options[:name]}")
|
29
|
+
return Queue.new(self, res)
|
30
|
+
end
|
31
|
+
|
32
|
+
|
33
|
+
end
|
34
|
+
|
35
|
+
class Queue
|
36
|
+
|
37
|
+
def initialize(queues, res)
|
38
|
+
@queues = queues
|
39
|
+
@data = res
|
40
|
+
end
|
41
|
+
|
42
|
+
def raw
|
43
|
+
@data
|
44
|
+
end
|
45
|
+
|
46
|
+
def [](key)
|
47
|
+
raw[key]
|
48
|
+
end
|
49
|
+
|
50
|
+
def id
|
51
|
+
raw["id"]
|
52
|
+
end
|
53
|
+
|
54
|
+
def name
|
55
|
+
raw["name"]
|
56
|
+
end
|
57
|
+
|
58
|
+
def size
|
59
|
+
return raw["size"] if raw["size"]
|
60
|
+
return @size if @size
|
61
|
+
q = @queues.get(:name=>name)
|
62
|
+
@size = q.size
|
63
|
+
return @size
|
64
|
+
end
|
65
|
+
|
66
|
+
# def delete
|
67
|
+
# @messages.delete(self.id)
|
68
|
+
# end
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
|
data/test/long_run.rb
CHANGED
data/test/quick_run.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# Put config.yml file in ~/Dropbox/configs/ironmq_gem/test/config.yml
|
2
|
+
require_relative 'test_base'
|
3
|
+
|
4
|
+
class QuickRun < TestBase
|
5
|
+
|
6
|
+
def setup
|
7
|
+
super
|
8
|
+
@client.queue_name = 'ironmq-gem-quick'
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_basics
|
12
|
+
res = @client.messages.post("hello world!")
|
13
|
+
p res
|
14
|
+
|
15
|
+
res = @client.messages.get()
|
16
|
+
p res
|
17
|
+
|
18
|
+
res = @client.messages.delete(res["id"])
|
19
|
+
p res
|
20
|
+
|
21
|
+
res = @client.messages.get()
|
22
|
+
p res
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
end
|
28
|
+
|
data/test/test_base.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
gem 'test-unit'
|
2
|
+
require 'test/unit'
|
3
|
+
require 'yaml'
|
4
|
+
begin
|
5
|
+
require File.join(File.dirname(__FILE__), '../lib/ironmq')
|
6
|
+
rescue Exception => ex
|
7
|
+
puts "Could NOT load current ironmq: " + ex.message
|
8
|
+
raise ex
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
class TestBase < Test::Unit::TestCase
|
13
|
+
def setup
|
14
|
+
puts 'setup'
|
15
|
+
@config = YAML::load_file(File.expand_path(File.join("~", "Dropbox", "configs", "ironmq_gem", "test", "config.yml")))
|
16
|
+
@client = IronMQ::Client.new(@config['ironmq'])
|
17
|
+
@client.logger.level = Logger::DEBUG
|
18
|
+
@client.queue_name = 'ironmq-ruby-tests'
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
@@ -3,20 +3,11 @@
|
|
3
3
|
gem 'test-unit'
|
4
4
|
require 'test/unit'
|
5
5
|
require 'yaml'
|
6
|
-
|
7
|
-
require File.join(File.dirname(__FILE__), '../lib/ironmq')
|
8
|
-
rescue Exception => ex
|
9
|
-
puts "Could NOT load current ironmq: " + ex.message
|
10
|
-
raise ex
|
11
|
-
end
|
6
|
+
require_relative 'test_base'
|
12
7
|
|
13
|
-
class IronMQTests <
|
8
|
+
class IronMQTests < TestBase
|
14
9
|
def setup
|
15
|
-
|
16
|
-
@config = YAML::load_file(File.expand_path(File.join("~", "Dropbox", "configs", "ironmq_gem", "test", "config.yml")))
|
17
|
-
@client = IronMQ::Client.new(@config['ironmq'])
|
18
|
-
#@client.logger.level = Logger::DEBUG
|
19
|
-
@client.queue_name = 'ironmq-gem-tests'
|
10
|
+
super
|
20
11
|
|
21
12
|
puts 'clearing queue'
|
22
13
|
while res = @client.messages.get()
|
@@ -29,8 +20,11 @@ class IronMQTests < Test::Unit::TestCase
|
|
29
20
|
end
|
30
21
|
|
31
22
|
def test_basics
|
23
|
+
|
32
24
|
res = @client.messages.post("hello world!")
|
33
25
|
p res
|
26
|
+
queue = @client.queues.get(:name=>@client.queue_name)
|
27
|
+
assert queue.size == 1
|
34
28
|
|
35
29
|
res = @client.messages.get()
|
36
30
|
p res
|
@@ -42,6 +36,9 @@ class IronMQTests < Test::Unit::TestCase
|
|
42
36
|
p res
|
43
37
|
assert res.nil?
|
44
38
|
|
39
|
+
queue = @client.queues.get(:name=>@client.queue_name)
|
40
|
+
assert queue.size == 0
|
41
|
+
|
45
42
|
res = @client.messages.post("hello world 2!")
|
46
43
|
p res
|
47
44
|
|
@@ -57,6 +54,7 @@ class IronMQTests < Test::Unit::TestCase
|
|
57
54
|
assert res.nil?
|
58
55
|
end
|
59
56
|
|
57
|
+
# TODO: pass :timeout in post/get messages and test those
|
60
58
|
def test_timeout
|
61
59
|
res = @client.messages.post("hello world timeout!")
|
62
60
|
p res
|
@@ -84,5 +82,30 @@ class IronMQTests < Test::Unit::TestCase
|
|
84
82
|
msg2.delete
|
85
83
|
|
86
84
|
end
|
85
|
+
|
86
|
+
def test_queues
|
87
|
+
res = @client.queues.list()
|
88
|
+
puts "res.size=" + res.size.to_s
|
89
|
+
res.each do |q|
|
90
|
+
puts "queue_name: " + q.name
|
91
|
+
puts "queue size: " + q.size.to_s
|
92
|
+
assert q.size >= 0
|
93
|
+
end
|
94
|
+
assert res.size > 0
|
95
|
+
|
96
|
+
res = @client.queues.list(:page=>2)
|
97
|
+
puts "res.size=" + res.size.to_s
|
98
|
+
res.each do |q|
|
99
|
+
p q.name
|
100
|
+
end
|
101
|
+
assert res.size == 0
|
102
|
+
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
def test_delay
|
107
|
+
# TODO
|
108
|
+
end
|
109
|
+
|
87
110
|
end
|
88
111
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ironmq
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.7
|
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: 2011-
|
12
|
+
date: 2011-12-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: typhoeus
|
16
|
-
requirement: &
|
16
|
+
requirement: &16958660 !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: *
|
24
|
+
version_requirements: *16958660
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: typhoeus
|
27
|
-
requirement: &
|
27
|
+
requirement: &16958160 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *16958160
|
36
36
|
description: Ruby client for IronMQ
|
37
37
|
email: travis@iron.io
|
38
38
|
executables: []
|
@@ -47,8 +47,11 @@ files:
|
|
47
47
|
- lib/ironmq.rb
|
48
48
|
- lib/ironmq/client.rb
|
49
49
|
- lib/ironmq/messages.rb
|
50
|
-
-
|
50
|
+
- lib/ironmq/queues.rb
|
51
51
|
- test/long_run.rb
|
52
|
+
- test/quick_run.rb
|
53
|
+
- test/test_base.rb
|
54
|
+
- test/test_ironmq.rb
|
52
55
|
homepage: http://www.iron.io
|
53
56
|
licenses: []
|
54
57
|
post_install_message:
|
@@ -69,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
69
72
|
version: '0'
|
70
73
|
requirements: []
|
71
74
|
rubyforge_project:
|
72
|
-
rubygems_version: 1.8.
|
75
|
+
rubygems_version: 1.8.11
|
73
76
|
signing_key:
|
74
77
|
specification_version: 3
|
75
78
|
summary: Ruby client for IronMQ
|