raq 0.1.0 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -4,17 +4,19 @@ gem "eventmachine", "~> 1.0"
4
4
  gem "amqp", "~> 1.0"
5
5
 
6
6
  group :development do
7
+ gem "bcat", "~> 0.6.2"
7
8
  gem "bundler", "~> 1.3.0"
8
9
  gem "guard", "~> 1.8.0"
9
10
  gem "guard-cucumber", "~> 1.4.0"
10
11
  gem "guard-rspec", "~> 3.0.2"
11
12
  gem "pry", "~> 0.9.12"
12
- gem "rdoc", "~> 3.12"
13
+ gem "rdoc", "~> 4.0.0"
14
+ gem "rdiscount", "~> 2.1.6"
13
15
  gem "travis-lint", "~> 1.7.0"
14
16
  end
15
17
 
16
18
  group :test do
17
- gem "aruba", "~> 0.5.3"
19
+ gem "aruba", github: 'cpb/aruba', branch: 'reporting_argument_error'
18
20
  gem "cucumber", "~> 1.3.0"
19
21
  gem "jeweler", "~> 1.8.4"
20
22
  gem "rake", "~> 10.0.4"
data/README.md CHANGED
@@ -1,7 +1,69 @@
1
- Raq [![Build Status](https://travis-ci.org/cpb/raq.png?branch=master)](https://travis-ci.org/cpb/raq) [![Dependency Status](https://gemnasium.com/cpb/raq.png)](https://gemnasium.com/cpb/raq) [![Code Climate](https://codeclimate.com/github/cpb/raq.png)](https://codeclimate.com/github/cpb/raq)
2
- =====
1
+ Raq [![Build Status](https://travis-ci.org/cpb/raq.png?branch=master)](https://travis-ci.org/cpb/raq) [![Dependency Status](https://gemnasium.com/cpb/raq.png)](https://gemnasium.com/cpb/raq) [![Code Climate](https://codeclimate.com/repos/51d5c98289af7e2eda089f9a/badges/f4cb8a49dee9210b9775/gpa.png)](https://codeclimate.com/repos/51d5c98289af7e2eda089f9a/feed)
2
+ ===
3
3
 
4
- Description goes here.
4
+ Raq makes it easy to create durable message queue consumers. It tries to learn from [Thin](https://github.com/macournoyer/thin) and [Rack](https://github.com/rack/rack) in order to provide a reasonably familiar way of creating and running AMQP consumers.
5
+
6
+ Raq expresses the opinion that, like database configuration, queue configuration should be configured by the environment. Raq offers the ability to specify message broker connection information and queue names as command line flags, or in an separate configuration file.
7
+
8
+ Installation
9
+ ------------
10
+
11
+ Add this to your Gemfile:
12
+
13
+ ```ruby
14
+ gem 'raq'
15
+ ```
16
+
17
+ Then install it by running Bundler:
18
+
19
+ ```bash
20
+ $ bundle
21
+ ```
22
+
23
+ Usage
24
+ -----
25
+
26
+ Raq provides a Rack-like api for creating consumers and message middleware by implementing ```run``` and ```use```.
27
+
28
+ However, unlike Rack, Raq does not infer anything about the payload. It exposes the protocol level meta information, and the unmodified payload body directly as arguments to your consumers. Though, you can quickly chain together middleware to satisfy your application.
29
+
30
+ Consider this example.rb:
31
+
32
+ ```ruby
33
+ require 'raq'
34
+
35
+ class Echo < Struct.new(:app)
36
+ def call(meta, payload)
37
+ puts "Echo: #{payload}"
38
+ app.call(meta,payload)
39
+ end
40
+ end
41
+
42
+ runner = Raq::Runner.new(ARGV)
43
+ server = Raq::Server.new(
44
+ connection: runner.connection_options,
45
+ queues: runner.options[:queue]) do
46
+
47
+ use Echo
48
+
49
+ run do |meta, payload|
50
+ puts "Acknowledging #{payload}"
51
+ meta.ack
52
+
53
+ # Not for long lived processes...
54
+ server.connection.close { EM.stop }
55
+ end
56
+ end
57
+
58
+ server.run
59
+ ```
60
+
61
+ When run like so:
62
+ ```bash
63
+ $ ruby example.rb --queue a.queue.with.messages
64
+ ```
65
+
66
+ It will print the payload to stdout a couple times, acknowledge the message, and exit.
5
67
 
6
68
  == Contributing to raq
7
69
 
@@ -15,6 +77,5 @@ Description goes here.
15
77
 
16
78
  == Copyright
17
79
 
18
- Copyright (c) 2013 Caleb Buxton. See LICENSE.txt for
19
- further details.
80
+ Copyright (c) 2013 Caleb Buxton. See LICENSE.txt for further details.
20
81
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.1.2
@@ -0,0 +1,47 @@
1
+ Feature: The README instructions and examples
2
+
3
+ @disable-bundler
4
+ Scenario: Installation
5
+ Given a file named "Gemfile" with:
6
+ """
7
+ gem 'raq', path: '../../'
8
+ """
9
+ When I run `bundle install`
10
+ Then the output should match /Using raq \(\d+\.\d+\.\d+\) from source at ../
11
+
12
+ @amqp
13
+ Scenario: Usage
14
+ Given a file named "example.rb" with:
15
+ """
16
+ $: << '../../lib'
17
+ require 'raq'
18
+
19
+ class Echo < Struct.new(:app)
20
+ def call(meta, payload)
21
+ puts "Echo: #{payload}"
22
+ app.call(meta,payload)
23
+ end
24
+ end
25
+
26
+ runner = Raq::Runner.new(ARGV)
27
+ server = Raq::Server.new(
28
+ connection: runner.connection_options,
29
+ queues: runner.options[:queue]) do
30
+
31
+ use Echo
32
+
33
+ run do |meta, payload|
34
+ puts "Acknowledging #{payload}"
35
+ meta.ack
36
+
37
+ # Not for long lived processes...
38
+ server.connection.close { EM.stop }
39
+ end
40
+ end
41
+
42
+ server.run
43
+ """
44
+ And I produce a message "Usage\ Example" on the queue "readme.usage.examples"
45
+ When I run `ruby example.rb --queue readme.usage.examples`
46
+ Then the output should contain "Echo: Usage Example"
47
+ And the output should contain "Acknowledging Usage Example"
@@ -44,6 +44,7 @@ Feature: Raq provides a friendly and familiar way of consuming messages off a du
44
44
  And a consumer with:
45
45
  """
46
46
  runner = Raq::Runner.new(ARGV)
47
+
47
48
  server = Raq::Server.new(
48
49
  connection: runner.connection_options,
49
50
  queues: runner.options[:queue]) do
@@ -76,11 +77,7 @@ Feature: Raq provides a friendly and familiar way of consuming messages off a du
76
77
  """
77
78
  And a consumer with:
78
79
  """
79
- begin
80
- require 'always_ack'
81
- rescue LoadError => e
82
- puts $LOAD_PATH
83
- end
80
+ require 'always_ack'
84
81
 
85
82
  runner = Raq::Runner.new(ARGV)
86
83
  server = Raq::Server.new(
@@ -37,14 +37,11 @@ THE_CONSUMER = Transform /^the consumer(?: "(.*?)")?$/ do |possible_name|
37
37
  end
38
38
 
39
39
  Given(/^a raq agent file named "(.*?)" with:$/) do |name, content|
40
- steps %{
41
- Given a file named "#{name}" with:
42
- """
43
- #{simplecov_for(name)}
44
- require 'raq'
40
+ step %{a file named "#{name}" with:},%{
41
+ #{simplecov_for(name)}
42
+ require 'raq'
45
43
 
46
- #{content}
47
- """
44
+ #{content}
48
45
  }
49
46
  end
50
47
 
@@ -74,12 +71,7 @@ Given(/^I produce (#{SOME_MESSAGE}) on (#{QUEUE})/) do |message, queue|
74
71
  end
75
72
 
76
73
  Given(/^(#{A_CONSUMER}) with:$/) do |consumer_path, consumer_implementation|
77
- steps %{
78
- Given a raq agent file named "#{consumer_path}" with:
79
- """
80
- #{consumer_implementation}
81
- """
82
- }
74
+ step %{a raq agent file named "#{consumer_path}" with:},consumer_implementation
83
75
  end
84
76
 
85
77
  When(/^I run the raq agent "(.*?)"(, failing)?(, again)?$/) do |agent_run_string, failing, again|
@@ -124,4 +116,5 @@ Then(/^it should never return$/) do
124
116
  end
125
117
  end
126
118
  end.to raise_error(Timeout::Error)
119
+ terminate_processes!
127
120
  end
@@ -35,7 +35,7 @@ module CoverageHelper
35
35
  SimpleCov.command_name(#{path.inspect})
36
36
  SimpleCov.start
37
37
  SimpleCov.root(#{File.join(File.dirname(__FILE__),'..','..').inspect})
38
- }
38
+ } unless ENV.has_key?('ARUBA_REPORT_DIR')
39
39
  end
40
40
  end
41
41
 
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "raq"
8
- s.version = "0.1.0"
8
+ s.version = "0.1.2"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Caleb Buxton"]
12
- s.date = "2013-07-04"
12
+ s.date = "2013-07-05"
13
13
  s.description = "The elegance of Rack with none of the unreliability of HTTP"
14
14
  s.email = "me@cpb.ca"
15
15
  s.extra_rdoc_files = [
@@ -27,6 +27,7 @@ Gem::Specification.new do |s|
27
27
  "README.md",
28
28
  "Rakefile",
29
29
  "VERSION",
30
+ "features/README.md.feature",
30
31
  "features/raq.feature",
31
32
  "features/step_definitions/raq_steps.rb",
32
33
  "features/support/env.rb",
@@ -57,33 +58,39 @@ Gem::Specification.new do |s|
57
58
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
58
59
  s.add_runtime_dependency(%q<eventmachine>, ["~> 1.0"])
59
60
  s.add_runtime_dependency(%q<amqp>, ["~> 1.0"])
61
+ s.add_development_dependency(%q<bcat>, ["~> 0.6.2"])
60
62
  s.add_development_dependency(%q<bundler>, ["~> 1.3.0"])
61
63
  s.add_development_dependency(%q<guard>, ["~> 1.8.0"])
62
64
  s.add_development_dependency(%q<guard-cucumber>, ["~> 1.4.0"])
63
65
  s.add_development_dependency(%q<guard-rspec>, ["~> 3.0.2"])
64
66
  s.add_development_dependency(%q<pry>, ["~> 0.9.12"])
65
- s.add_development_dependency(%q<rdoc>, ["~> 3.12"])
67
+ s.add_development_dependency(%q<rdoc>, ["~> 4.0.0"])
68
+ s.add_development_dependency(%q<rdiscount>, ["~> 2.1.6"])
66
69
  s.add_development_dependency(%q<travis-lint>, ["~> 1.7.0"])
67
70
  else
68
71
  s.add_dependency(%q<eventmachine>, ["~> 1.0"])
69
72
  s.add_dependency(%q<amqp>, ["~> 1.0"])
73
+ s.add_dependency(%q<bcat>, ["~> 0.6.2"])
70
74
  s.add_dependency(%q<bundler>, ["~> 1.3.0"])
71
75
  s.add_dependency(%q<guard>, ["~> 1.8.0"])
72
76
  s.add_dependency(%q<guard-cucumber>, ["~> 1.4.0"])
73
77
  s.add_dependency(%q<guard-rspec>, ["~> 3.0.2"])
74
78
  s.add_dependency(%q<pry>, ["~> 0.9.12"])
75
- s.add_dependency(%q<rdoc>, ["~> 3.12"])
79
+ s.add_dependency(%q<rdoc>, ["~> 4.0.0"])
80
+ s.add_dependency(%q<rdiscount>, ["~> 2.1.6"])
76
81
  s.add_dependency(%q<travis-lint>, ["~> 1.7.0"])
77
82
  end
78
83
  else
79
84
  s.add_dependency(%q<eventmachine>, ["~> 1.0"])
80
85
  s.add_dependency(%q<amqp>, ["~> 1.0"])
86
+ s.add_dependency(%q<bcat>, ["~> 0.6.2"])
81
87
  s.add_dependency(%q<bundler>, ["~> 1.3.0"])
82
88
  s.add_dependency(%q<guard>, ["~> 1.8.0"])
83
89
  s.add_dependency(%q<guard-cucumber>, ["~> 1.4.0"])
84
90
  s.add_dependency(%q<guard-rspec>, ["~> 3.0.2"])
85
91
  s.add_dependency(%q<pry>, ["~> 0.9.12"])
86
- s.add_dependency(%q<rdoc>, ["~> 3.12"])
92
+ s.add_dependency(%q<rdoc>, ["~> 4.0.0"])
93
+ s.add_dependency(%q<rdiscount>, ["~> 2.1.6"])
87
94
  s.add_dependency(%q<travis-lint>, ["~> 1.7.0"])
88
95
  end
89
96
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: raq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-04 00:00:00.000000000 Z
12
+ date: 2013-07-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: eventmachine
@@ -43,6 +43,22 @@ dependencies:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
45
  version: '1.0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: bcat
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ~>
52
+ - !ruby/object:Gem::Version
53
+ version: 0.6.2
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 0.6.2
46
62
  - !ruby/object:Gem::Dependency
47
63
  name: bundler
48
64
  requirement: !ruby/object:Gem::Requirement
@@ -130,7 +146,23 @@ dependencies:
130
146
  requirements:
131
147
  - - ~>
132
148
  - !ruby/object:Gem::Version
133
- version: '3.12'
149
+ version: 4.0.0
150
+ type: :development
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ~>
156
+ - !ruby/object:Gem::Version
157
+ version: 4.0.0
158
+ - !ruby/object:Gem::Dependency
159
+ name: rdiscount
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ~>
164
+ - !ruby/object:Gem::Version
165
+ version: 2.1.6
134
166
  type: :development
135
167
  prerelease: false
136
168
  version_requirements: !ruby/object:Gem::Requirement
@@ -138,7 +170,7 @@ dependencies:
138
170
  requirements:
139
171
  - - ~>
140
172
  - !ruby/object:Gem::Version
141
- version: '3.12'
173
+ version: 2.1.6
142
174
  - !ruby/object:Gem::Dependency
143
175
  name: travis-lint
144
176
  requirement: !ruby/object:Gem::Requirement
@@ -173,6 +205,7 @@ files:
173
205
  - README.md
174
206
  - Rakefile
175
207
  - VERSION
208
+ - features/README.md.feature
176
209
  - features/raq.feature
177
210
  - features/step_definitions/raq_steps.rb
178
211
  - features/support/env.rb
@@ -205,7 +238,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
205
238
  version: '0'
206
239
  segments:
207
240
  - 0
208
- hash: 705315900894353883
241
+ hash: -107125167469032534
209
242
  required_rubygems_version: !ruby/object:Gem::Requirement
210
243
  none: false
211
244
  requirements: