hutch 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 49a9fedccdbf581b5874f8a546ce20545d683b96
4
- data.tar.gz: 1783f96443d36488ed329271e5f382123ed79a98
3
+ metadata.gz: 4ad7051316dda86d731e7422ebd9c126618210e3
4
+ data.tar.gz: e5a4e0fa91debe583046b45076b3373768c77d2e
5
5
  SHA512:
6
- metadata.gz: d59463f950dd59b7a5cb575b6eeb47d97400fcea4626d168902b7d5c442f791d907ece465a2841c68c6c09a85b253da33eae08d3b6228cf1b19315680bf972b2
7
- data.tar.gz: 3f7d8abae79d3227d656c427bc3d6201060545a8fab2523d89c1048011b52506481f8041e0ed7923e2c32a18d1db78ca2e9ff36d5eee07c8edbccb6f4f70c92b
6
+ metadata.gz: 5b7444175bfd7abbbe2219214506a1a884da83f4ba9e0182547acc65ce2e5285691cb786d04985e16be7cabee26acbf94d4e51052a30192f8fbf4cdafb9951f4
7
+ data.tar.gz: d0b377c4b5d9f695d0e247c456352209f5e8798d52a3e8c025c88dbdd1598280f6a2766fb7a49d4f5810f64ca0965a141a2a0bb069812d9ecf62d464a26039c4
data/.gitignore CHANGED
@@ -4,3 +4,4 @@ Gemfile.lock
4
4
  .ruby-version
5
5
  .ruby-gemset
6
6
  .idea
7
+ coverage
@@ -0,0 +1,5 @@
1
+ rvm:
2
+ - 2.0.0
3
+ - 1.9.3
4
+ services:
5
+ - rabbitmq
@@ -1,3 +1,7 @@
1
+ ## 0.6.0 - November 4, 2013
2
+
3
+ - Metadata can now be passed in to `#publish`
4
+
1
5
  ## 0.5.1 - October 17, 2013
2
6
 
3
7
  - Raise an exception when publishing fails
data/Gemfile CHANGED
@@ -10,6 +10,7 @@ end
10
10
 
11
11
  group :development, :test do
12
12
  gem "sentry-raven"
13
+ gem "coveralls", require: false
13
14
  end
14
15
 
15
16
  group :development, :darwin do
data/README.md CHANGED
@@ -3,34 +3,21 @@
3
3
  Hutch is a Ruby library for enabling asynchronous inter-service communication
4
4
  in a service-oriented architecture, using RabbitMQ.
5
5
 
6
-
7
- ## Project Maturity
8
-
9
- Hutch is a relatively young project that was extracted from production systems.
10
-
11
-
12
-
13
- ## Installation & Bundler Dependency
14
-
15
- ### Most Recent Release
16
-
17
6
  [![Gem Version](https://badge.fury.io/rb/hutch.png)](http://badge.fury.io/rb/hutch)
18
-
19
- ### With Rubygems
7
+ [![Build Status](https://travis-ci.org/gocardless/hutch.png?branch=master)](https://travis-ci.org/gocardless/hutch)
8
+ [![Dependency Status](https://gemnasium.com/gocardless/hutch.png)](https://gemnasium.com/gocardless/hutch)
9
+ [![Code Climate](https://codeclimate.com/github/gocardless/hutch.png)](https://codeclimate.com/github/gocardless/hutch)
20
10
 
21
11
  To install with RubyGems:
22
12
 
23
13
  ```
24
- gem install hutch
14
+ $ gem install hutch
25
15
  ```
26
16
 
27
- ### Bundler Dependency
17
+ ## Project Maturity
28
18
 
29
- To use in a project managed with Bundler:
19
+ Hutch is a relatively young project that was extracted from production systems.
30
20
 
31
- ``` ruby
32
- gem "hutch", "~> 0.5.1"
33
- ```
34
21
 
35
22
  ## Overview
36
23
 
@@ -95,6 +82,8 @@ usage: hutch [options]
95
82
  --mq-host HOST Set the RabbitMQ host
96
83
  --mq-port PORT Set the RabbitMQ port
97
84
  --mq-tls Use TLS for the AMQP connection
85
+ --mq-tls-cert FILE Certificate for TLS client verification
86
+ --mq-tls-key FILE Private key for TLS client verification
98
87
  --mq-exchange EXCHANGE Set the RabbitMQ exchange
99
88
  --mq-vhost VHOST Set the RabbitMQ vhost
100
89
  --mq-username USERNAME Set the RabbitMQ username
@@ -103,8 +92,8 @@ usage: hutch [options]
103
92
  --mq-api-port PORT Set the RabbitMQ API port
104
93
  --mq-api-ssl Use SSL for the RabbitMQ API
105
94
  --config FILE Load Hutch configuration from a file
106
-
107
95
  --require PATH Require a Rails app or path
96
+ --[no-]autoload-rails Require the current rails app directory
108
97
  -q, --quiet Quiet logging
109
98
  -v, --verbose Verbose logging
110
99
  --version Print the version and exit
@@ -196,3 +185,6 @@ are recommended.
196
185
  [pc-issue]: https://github.com/ruby-amqp/amqp/issues/92
197
186
  [pc-gist]: https://gist.github.com/3042381
198
187
 
188
+ ---
189
+
190
+ GoCardless ♥ open source. If you do too, come [join us](https://gocardless.com/jobs/backend_developer).
@@ -1,10 +1,11 @@
1
1
  require File.expand_path('../lib/hutch/version', __FILE__)
2
2
 
3
3
  Gem::Specification.new do |gem|
4
- gem.add_runtime_dependency 'bunny', '>= 0.10.8'
4
+ gem.add_runtime_dependency 'bunny', '~> 1.0.0'
5
5
  gem.add_runtime_dependency 'carrot-top', '~> 0.0.7'
6
6
  gem.add_runtime_dependency 'multi_json', '~> 1.5'
7
7
  gem.add_development_dependency 'rspec', '~> 2.12.0'
8
+ gem.add_development_dependency 'simplecov', '~> 0.7.1'
8
9
 
9
10
  gem.name = 'hutch'
10
11
  gem.summary = 'Easy inter-service communication using RabbitMQ.'
@@ -148,7 +148,7 @@ module Hutch
148
148
  @channel.ack(delivery_tag, false)
149
149
  end
150
150
 
151
- def publish(routing_key, message)
151
+ def publish(routing_key, message, properties = {})
152
152
  payload = JSON.dump(message)
153
153
 
154
154
  unless @connection
@@ -165,9 +165,15 @@ module Hutch
165
165
  raise PublishError, msg
166
166
  end
167
167
 
168
+ non_overridable_properties = {
169
+ routing_key: routing_key, timestamp: Time.now.to_i
170
+ }
171
+ properties[:message_id] ||= generate_id
172
+
168
173
  logger.info("publishing message '#{message.inspect}' to #{routing_key}")
169
- @exchange.publish(payload, routing_key: routing_key, persistent: true,
170
- timestamp: Time.now.to_i, message_id: generate_id)
174
+ @exchange.publish(payload, {persistent: true}.
175
+ merge(properties).
176
+ merge(non_overridable_properties))
171
177
  end
172
178
 
173
179
  private
@@ -1,4 +1,4 @@
1
1
  module Hutch
2
- VERSION = '0.5.1'.freeze
2
+ VERSION = '0.6.0'.freeze
3
3
  end
4
4
 
@@ -144,6 +144,11 @@ describe Hutch::Broker do
144
144
  broker.exchange.should_receive(:publish).once
145
145
  broker.publish('test.key', 'message')
146
146
  end
147
+
148
+ it "allows passing message properties" do
149
+ broker.exchange.should_receive(:publish).once
150
+ broker.publish('test.key', 'message', {expiration: "2000", persistent: false})
151
+ end
147
152
  end
148
153
 
149
154
  context 'without a valid connection' do
@@ -1,3 +1,14 @@
1
+ require 'simplecov'
2
+ if ENV['TRAVIS']
3
+ require 'coveralls'
4
+ SimpleCov.formatter = Coveralls::SimpleCov::Formatter
5
+ end
6
+
7
+ SimpleCov.start do
8
+ add_filter '/spec/'
9
+ add_filter '/.bundle/'
10
+ end
11
+
1
12
  require 'raven'
2
13
  require 'hutch'
3
14
  require 'logger'
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hutch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harry Marr
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-17 00:00:00.000000000 Z
11
+ date: 2013-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - '>='
17
+ - - ~>
18
18
  - !ruby/object:Gem::Version
19
- version: 0.10.8
19
+ version: 1.0.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - '>='
24
+ - - ~>
25
25
  - !ruby/object:Gem::Version
26
- version: 0.10.8
26
+ version: 1.0.0
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: carrot-top
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ~>
67
67
  - !ruby/object:Gem::Version
68
68
  version: 2.12.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: simplecov
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 0.7.1
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 0.7.1
69
83
  description: Hutch is a Ruby library for enabling asynchronous inter-service communication
70
84
  using RabbitMQ.
71
85
  email:
@@ -76,6 +90,7 @@ extensions: []
76
90
  extra_rdoc_files: []
77
91
  files:
78
92
  - .gitignore
93
+ - .travis.yml
79
94
  - CHANGELOG.md
80
95
  - Gemfile
81
96
  - Guardfile