queue_fetcher 0.1.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.
data/.gitignore ADDED
@@ -0,0 +1 @@
1
+ pkg
data/MIT-LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2009 Capital Thought.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
data/README.textile ADDED
@@ -0,0 +1,4 @@
1
+ h1. Queue Fetcher
2
+
3
+
4
+ Copyright (c) 2009 Mike Subelsky, released under the MIT license.
data/Rakefile ADDED
@@ -0,0 +1,17 @@
1
+ begin
2
+ require 'jeweler'
3
+ Jeweler::Tasks.new do |gemspec|
4
+ gemspec.name = "queue_fetcher"
5
+ gemspec.summary = "Namespaces and encapsulates your SQS queues"
6
+ gemspec.description = "Encapsulates design decisions about how to namespace SQS queues with environment-specific prefixes, as well as the dependency on the existence of a queueing interface like RightAws::SqsGen2."
7
+ gemspec.email = "mike@otherinbox.com"
8
+ gemspec.homepage = "http://github.com/otherinbox/queue_fetcher"
9
+ gemspec.authors = ["Mike Subelsky"]
10
+ gemspec.add_development_dependency "mocha"
11
+ gemspec.test_files = %w(test/queue_fetcher_test.rb)
12
+ end
13
+
14
+ Jeweler::GemcutterTasks.new
15
+ rescue LoadError
16
+ puts "Jeweler not available. Install it with: sudo gem install jeweler"
17
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,27 @@
1
+ # Encapsulates the design decision about how to namespace SQS queues with environment-specific prefixes,
2
+ # as well as the dependency on the existence of a queueing interface. Typically this class only gets
3
+ # used at initialization time, a la this example from a Rails production.rb config file:
4
+ #
5
+ # config.after_initialize do
6
+ # interface = RightAws::SqsGen2.new(aws_access_key_id,aws_secret_access_key)
7
+ # qf = QueueFetcher.new(interface,"production")
8
+ # DatawarehouseLoader.queue = qf.fetch("datawarehouse_loader")
9
+ # end
10
+ #
11
+ # In tests, the queue interface could be set to a mock object
12
+
13
+ class QueueFetcher
14
+
15
+ attr_accessor :queue_interface
16
+ attr_accessor :queue_prefix
17
+
18
+ def initialize(queue_interface,queue_prefix)
19
+ @queue_interface = queue_interface
20
+ @queue_prefix = queue_prefix
21
+ end
22
+
23
+ def fetch(queue_name)
24
+ queue_interface.queue("#{queue_prefix}_#{queue_name}")
25
+ end
26
+
27
+ end
@@ -0,0 +1,50 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{queue_fetcher}
8
+ s.version = "0.1.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Mike Subelsky"]
12
+ s.date = %q{2010-01-04}
13
+ s.description = %q{Encapsulates design decisions about how to namespace SQS queues with environment-specific prefixes, as well as the dependency on the existence of a queueing interface like RightAws::SqsGen2.}
14
+ s.email = %q{mike@otherinbox.com}
15
+ s.extra_rdoc_files = [
16
+ "README.textile"
17
+ ]
18
+ s.files = [
19
+ ".gitignore",
20
+ "MIT-LICENSE",
21
+ "README.textile",
22
+ "Rakefile",
23
+ "VERSION",
24
+ "lib/queue_fetcher.rb",
25
+ "queue_fetcher.gemspec",
26
+ "test/queue_fetcher_test.rb"
27
+ ]
28
+ s.homepage = %q{http://github.com/otherinbox/queue_fetcher}
29
+ s.rdoc_options = ["--charset=UTF-8"]
30
+ s.require_paths = ["lib"]
31
+ s.rubygems_version = %q{1.3.5}
32
+ s.summary = %q{Namespaces and encapsulates your SQS queues}
33
+ s.test_files = [
34
+ "test/queue_fetcher_test.rb"
35
+ ]
36
+
37
+ if s.respond_to? :specification_version then
38
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
39
+ s.specification_version = 3
40
+
41
+ if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
42
+ s.add_development_dependency(%q<mocha>, [">= 0"])
43
+ else
44
+ s.add_dependency(%q<mocha>, [">= 0"])
45
+ end
46
+ else
47
+ s.add_dependency(%q<mocha>, [">= 0"])
48
+ end
49
+ end
50
+
@@ -0,0 +1,21 @@
1
+ require 'test/unit'
2
+ require 'rubygems'
3
+ require 'mocha'
4
+ require File.join(File.dirname(__FILE__),'..','lib','queue_fetcher')
5
+
6
+ class TestHash < Test::Unit::TestCase
7
+
8
+ def test_should_call_the_queue_method_on_the_provided_interface_with_the_correct_prefix
9
+ interface = mock()
10
+ qf = QueueFetcher.new(interface,"production")
11
+ interface.expects(:queue).with("production_specialwork")
12
+ qf.fetch("specialwork")
13
+ end
14
+
15
+ def test_should_return_the_results_of_calling_the_queue_method
16
+ queue = mock()
17
+ interface = mock(:queue => queue)
18
+ qf = QueueFetcher.new(interface,"production")
19
+ assert_equal queue, qf.fetch("specialwork")
20
+ end
21
+ end
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: queue_fetcher
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Mike Subelsky
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+
12
+ date: 2010-01-04 00:00:00 -05:00
13
+ default_executable:
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: mocha
17
+ type: :development
18
+ version_requirement:
19
+ version_requirements: !ruby/object:Gem::Requirement
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ version:
25
+ description: Encapsulates design decisions about how to namespace SQS queues with environment-specific prefixes, as well as the dependency on the existence of a queueing interface like RightAws::SqsGen2.
26
+ email: mike@otherinbox.com
27
+ executables: []
28
+
29
+ extensions: []
30
+
31
+ extra_rdoc_files:
32
+ - README.textile
33
+ files:
34
+ - .gitignore
35
+ - MIT-LICENSE
36
+ - README.textile
37
+ - Rakefile
38
+ - VERSION
39
+ - lib/queue_fetcher.rb
40
+ - queue_fetcher.gemspec
41
+ - test/queue_fetcher_test.rb
42
+ has_rdoc: true
43
+ homepage: http://github.com/otherinbox/queue_fetcher
44
+ licenses: []
45
+
46
+ post_install_message:
47
+ rdoc_options:
48
+ - --charset=UTF-8
49
+ require_paths:
50
+ - lib
51
+ required_ruby_version: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: "0"
56
+ version:
57
+ required_rubygems_version: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: "0"
62
+ version:
63
+ requirements: []
64
+
65
+ rubyforge_project:
66
+ rubygems_version: 1.3.5
67
+ signing_key:
68
+ specification_version: 3
69
+ summary: Namespaces and encapsulates your SQS queues
70
+ test_files:
71
+ - test/queue_fetcher_test.rb