sqs-queue-locator 0.0.1
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/.gitignore +4 -0
- data/Gemfile +9 -0
- data/README.markdown +30 -0
- data/Rakefile +13 -0
- data/lib/sqs-queue-locator.rb +29 -0
- data/lib/sqs-queue-locator/version.rb +7 -0
- data/spec/queue_locator_spec.rb +37 -0
- data/spec/spec_helper.rb +1 -0
- data/sqs-queue-locator.gemspec +33 -0
- metadata +97 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.markdown
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
SQS Queue Locator
|
2
|
+
=================
|
3
|
+
|
4
|
+
Amazon SQS queue names need to be unique at the account level.
|
5
|
+
This gem implements a simple naming convention of <environment>-<queue-name> to
|
6
|
+
allow your app to have keep track of queues per environment.
|
7
|
+
|
8
|
+
For the development environment, an extra prefix is added based on your machine's
|
9
|
+
hostname so that multiple developers can work at the same time without stepping
|
10
|
+
on each others' queues.
|
11
|
+
|
12
|
+
Usage
|
13
|
+
-----
|
14
|
+
|
15
|
+
in your Gemfile:
|
16
|
+
|
17
|
+
gem 'sqs-queue-locator'
|
18
|
+
|
19
|
+
Somewhere in your app's initialization:
|
20
|
+
|
21
|
+
AWS.config :access_key_id => YOUR_ACCESS_KEY_ID,
|
22
|
+
:secret_access_key => YOUR_SECRET_ACCESS_KEY
|
23
|
+
|
24
|
+
Where you need to locate the queue:
|
25
|
+
|
26
|
+
queue = SQSQueueLocator.locate :env => Rails.env,
|
27
|
+
:queue => 'your-queue-name'
|
28
|
+
|
29
|
+
Note: Locate will create the queue if it doesn't exist, or return a reference to
|
30
|
+
the existing queue.
|
data/Rakefile
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require "sqs-queue-locator/version"
|
2
|
+
|
3
|
+
module SQSQueueLocator
|
4
|
+
def self.locate(options)
|
5
|
+
name = queue_name(options)
|
6
|
+
sqs = AWS::SQS.new
|
7
|
+
sqs.queues.create name
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.queue_name(options)
|
11
|
+
if options[:env].to_s.empty?
|
12
|
+
raise ArgumentError, ":env option in required for QueueLocator.queue_name"
|
13
|
+
end
|
14
|
+
|
15
|
+
if options[:queue].to_s.empty?
|
16
|
+
raise ArgumentError, ":queue option in required for QueueLocator.queue_name"
|
17
|
+
end
|
18
|
+
|
19
|
+
"#{options[:env]}-#{options[:queue]}#{uniqifier(options[:env])}"
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.uniqifier(env)
|
23
|
+
if env == "development"
|
24
|
+
"-#{Digest::MD5.hexdigest Socket.gethostname}"
|
25
|
+
else
|
26
|
+
""
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe SQSQueueLocator do
|
4
|
+
describe "queue_name" do
|
5
|
+
it "concatenates environment and name" do
|
6
|
+
SQSQueueLocator.queue_name(
|
7
|
+
env: "production",
|
8
|
+
queue: "foo"
|
9
|
+
).should == "production-foo"
|
10
|
+
end
|
11
|
+
|
12
|
+
it "adds something special in development env" do
|
13
|
+
name = SQSQueueLocator.queue_name env: "development", queue: "foo"
|
14
|
+
name.should =~ /\Adevelopment-foo.*/
|
15
|
+
name.length.should > "development-foo".length
|
16
|
+
name.length.should <= 80
|
17
|
+
end
|
18
|
+
|
19
|
+
it "uniqifies development queues consistently on this same machine" do
|
20
|
+
SQSQueueLocator.uniqifier("development").should ==
|
21
|
+
SQSQueueLocator.uniqifier("development")
|
22
|
+
end
|
23
|
+
|
24
|
+
it "raises error if env is omitted" do
|
25
|
+
-> do
|
26
|
+
SQSQueueLocator.queue_name env: "", queue: "foo"
|
27
|
+
end.should raise_error
|
28
|
+
end
|
29
|
+
|
30
|
+
it "raises error if queue is omitted" do
|
31
|
+
-> do
|
32
|
+
SQSQueueLocator.queue_name env: "production", queue: ""
|
33
|
+
end.should raise_error
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require_relative '../lib/sqs-queue-locator'
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "sqs-queue-locator/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "sqs-queue-locator"
|
7
|
+
s.version = Sqs::Queue::Locator::VERSION
|
8
|
+
s.authors = ["David Vollbracht"]
|
9
|
+
s.email = ["david@flipstone.com"]
|
10
|
+
s.homepage = "http://github.com/flipstone/sqs-queue/locator"
|
11
|
+
s.summary = %q{Implements a naming conversion for SQS queues in multiple environments}
|
12
|
+
s.description = <<-end_desc
|
13
|
+
Amazon SQS queue names need to be unique at the account level.
|
14
|
+
This gem implements a simple naming convention of <environment>-<queue-name> to
|
15
|
+
allow your app to have keep track of queues per environment.
|
16
|
+
|
17
|
+
For the development environment, an extra prefix is added based on your machine's
|
18
|
+
hostname so that multiple developers can work at the same time without stepping
|
19
|
+
on each others' queues.
|
20
|
+
end_desc
|
21
|
+
|
22
|
+
s.rubyforge_project = "sqs-queue-locator"
|
23
|
+
|
24
|
+
s.files = `git ls-files`.split("\n")
|
25
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
26
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
27
|
+
s.require_paths = ["lib"]
|
28
|
+
|
29
|
+
# specify any dependencies here; for example:
|
30
|
+
s.add_development_dependency "rspec"
|
31
|
+
s.add_development_dependency "rake"
|
32
|
+
# s.add_runtime_dependency "rest-client"
|
33
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sqs-queue-locator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- David Vollbracht
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-05-18 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rspec
|
16
|
+
requirement: &2156775000 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *2156775000
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rake
|
27
|
+
requirement: &2156774420 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :development
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *2156774420
|
36
|
+
description: ! 'Amazon SQS queue names need to be unique at the account level.
|
37
|
+
|
38
|
+
This gem implements a simple naming convention of <environment>-<queue-name> to
|
39
|
+
|
40
|
+
allow your app to have keep track of queues per environment.
|
41
|
+
|
42
|
+
|
43
|
+
For the development environment, an extra prefix is added based on your machine''s
|
44
|
+
|
45
|
+
hostname so that multiple developers can work at the same time without stepping
|
46
|
+
|
47
|
+
on each others'' queues.
|
48
|
+
|
49
|
+
'
|
50
|
+
email:
|
51
|
+
- david@flipstone.com
|
52
|
+
executables: []
|
53
|
+
extensions: []
|
54
|
+
extra_rdoc_files: []
|
55
|
+
files:
|
56
|
+
- .gitignore
|
57
|
+
- Gemfile
|
58
|
+
- README.markdown
|
59
|
+
- Rakefile
|
60
|
+
- lib/sqs-queue-locator.rb
|
61
|
+
- lib/sqs-queue-locator/version.rb
|
62
|
+
- spec/queue_locator_spec.rb
|
63
|
+
- spec/spec_helper.rb
|
64
|
+
- sqs-queue-locator.gemspec
|
65
|
+
homepage: http://github.com/flipstone/sqs-queue/locator
|
66
|
+
licenses: []
|
67
|
+
post_install_message:
|
68
|
+
rdoc_options: []
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
segments:
|
78
|
+
- 0
|
79
|
+
hash: 1563020620707368870
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
hash: 1563020620707368870
|
89
|
+
requirements: []
|
90
|
+
rubyforge_project: sqs-queue-locator
|
91
|
+
rubygems_version: 1.8.6
|
92
|
+
signing_key:
|
93
|
+
specification_version: 3
|
94
|
+
summary: Implements a naming conversion for SQS queues in multiple environments
|
95
|
+
test_files:
|
96
|
+
- spec/queue_locator_spec.rb
|
97
|
+
- spec/spec_helper.rb
|