message-driver 0.3.0 → 0.4.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.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +18 -0
  3. data/.rubocop_todo.yml +160 -0
  4. data/.travis.yml +5 -4
  5. data/CHANGELOG.md +5 -0
  6. data/Gemfile +9 -8
  7. data/Guardfile +14 -7
  8. data/README.md +2 -0
  9. data/Rakefile +16 -10
  10. data/examples/basic_producer_and_consumer/Gemfile +2 -2
  11. data/examples/basic_producer_and_consumer/common.rb +3 -3
  12. data/examples/basic_producer_and_consumer/consumer.rb +5 -5
  13. data/examples/basic_producer_and_consumer/producer.rb +7 -7
  14. data/features/CHANGELOG.md +5 -0
  15. data/features/message_consumers/transactional_ack_consumers.feature +1 -0
  16. data/features/rabbitmq_specific_features/publisher_acknowledgements.feature +51 -0
  17. data/features/step_definitions/error_handling_steps.rb +2 -2
  18. data/features/step_definitions/logging_steps.rb +4 -4
  19. data/features/step_definitions/message_consumers_steps.rb +8 -8
  20. data/features/step_definitions/rabbitmq_specific_steps.rb +10 -0
  21. data/features/step_definitions/steps.rb +15 -15
  22. data/features/support/env.rb +3 -0
  23. data/features/support/firewall_helper.rb +5 -6
  24. data/features/support/message_table_matcher.rb +3 -4
  25. data/features/support/no_error_matcher.rb +3 -3
  26. data/features/support/test_runner.rb +11 -3
  27. data/features/support/transforms.rb +1 -1
  28. data/lib/message-driver.rb +1 -1
  29. data/lib/message_driver.rb +0 -1
  30. data/lib/message_driver/adapters/base.rb +10 -10
  31. data/lib/message_driver/adapters/bunny_adapter.rb +57 -30
  32. data/lib/message_driver/adapters/in_memory_adapter.rb +4 -5
  33. data/lib/message_driver/adapters/stomp_adapter.rb +4 -6
  34. data/lib/message_driver/broker.rb +5 -4
  35. data/lib/message_driver/client.rb +6 -6
  36. data/lib/message_driver/destination.rb +2 -2
  37. data/lib/message_driver/errors.rb +1 -4
  38. data/lib/message_driver/logging.rb +1 -1
  39. data/lib/message_driver/message.rb +2 -2
  40. data/lib/message_driver/subscription.rb +1 -1
  41. data/lib/message_driver/version.rb +1 -1
  42. data/lib/{message_driver/vendor → vendor}/.document +0 -0
  43. data/lib/vendor/nesty.rb +1 -0
  44. data/lib/vendor/nesty/nested_error.rb +28 -0
  45. data/message-driver.gemspec +15 -14
  46. data/spec/integration/bunny/amqp_integration_spec.rb +43 -43
  47. data/spec/integration/bunny/bunny_adapter_spec.rb +117 -101
  48. data/spec/integration/in_memory/in_memory_adapter_spec.rb +35 -35
  49. data/spec/integration/stomp/stomp_adapter_spec.rb +42 -42
  50. data/spec/spec_helper.rb +4 -1
  51. data/spec/support/shared/adapter_examples.rb +7 -7
  52. data/spec/support/shared/client_ack_examples.rb +6 -6
  53. data/spec/support/shared/context_examples.rb +4 -4
  54. data/spec/support/shared/destination_examples.rb +10 -10
  55. data/spec/support/shared/subscription_examples.rb +29 -29
  56. data/spec/support/shared/transaction_examples.rb +10 -10
  57. data/spec/units/message_driver/adapters/base_spec.rb +19 -19
  58. data/spec/units/message_driver/broker_spec.rb +57 -58
  59. data/spec/units/message_driver/client_spec.rb +84 -84
  60. data/spec/units/message_driver/destination_spec.rb +4 -4
  61. data/spec/units/message_driver/message_spec.rb +19 -19
  62. data/spec/units/message_driver/subscription_spec.rb +4 -4
  63. data/test_lib/broker_config.rb +2 -2
  64. metadata +27 -6
  65. data/lib/message_driver/vendor/nesty.rb +0 -1
  66. data/lib/message_driver/vendor/nesty/nested_error.rb +0 -26
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c03ff5c533ab9ffdb8a6a3fce6b2ffe0b7239d56
4
- data.tar.gz: 44614cda7f594028f587e7dfd79f608c7b3fb0c3
3
+ metadata.gz: 38055d94b5d7646e9e1501075908bfc77a7432c5
4
+ data.tar.gz: 68779796fd11f2f43b0cf563402d871a2e1fba2f
5
5
  SHA512:
6
- metadata.gz: 335cc2f27f8b2a70ec0abb4523c1fee62abea0664fb80a4ea09e1936da6d66f6012087b05961bdcd6acbc3ff2a3dd396013b48021ca3f185fb1b0e2ffd56ccc2
7
- data.tar.gz: 8ded01de5e953bf8486d2d139de8e677db11e138b6a6e221fbec35dcd12d905605c95403856f2c5da8ad922141a284b348f61093f874e17ce5177f661452e311
6
+ metadata.gz: 607bb4df0b16a2858481caa86a76202a36a3736322c118ea54eb4107ca7b42556eadc921ff2b3216b39eff9f23088c8d59da7402d30c36569f83aff86f024621
7
+ data.tar.gz: b16ace077a6b7b5b1d8094a1d4599a939d017aee51d00854145f1384eee8ab37abeaa82cdbd7047f433027ed51aab787c4879d0b2441fbe66b6ba0cffde4420b
data/.rubocop.yml ADDED
@@ -0,0 +1,18 @@
1
+ inherit_from: '.rubocop_todo.yml'
2
+
3
+ AllCops:
4
+ Include:
5
+ - 'message-driver.gemspec'
6
+ - '**/Gemfile'
7
+ - 'Guardfile'
8
+ - 'Rakefile'
9
+
10
+ Style/AccessorMethodName:
11
+ Enabled: false
12
+
13
+ Style/BlockNesting:
14
+ Max: 4
15
+
16
+ Style/FileName:
17
+ Exclude:
18
+ - 'lib/message-driver.rb'
data/.rubocop_todo.yml ADDED
@@ -0,0 +1,160 @@
1
+ # This configuration was generated by `rubocop --auto-gen-config`
2
+ # on 2014-06-25 16:30:49 -0500 using RuboCop version 0.24.0.
3
+ # The point is for the user to remove these configuration records
4
+ # one by one as the offenses are removed from the code base.
5
+ # Note that changes in the inspected code, or installation of new
6
+ # versions of RuboCop, may require this file to be generated again.
7
+
8
+ # Offense count: 84
9
+ # Cop supports --auto-correct.
10
+ Style/Blocks:
11
+ Enabled: false
12
+
13
+ # Offense count: 2
14
+ # Configuration parameters: IndentWhenRelativeTo, SupportedStyles, IndentOneStep.
15
+ Style/CaseIndentation:
16
+ Enabled: false
17
+
18
+ # Offense count: 7
19
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
20
+ Style/ClassAndModuleChildren:
21
+ Enabled: false
22
+
23
+ # Offense count: 2
24
+ # Configuration parameters: CountComments.
25
+ Style/ClassLength:
26
+ Enabled: false
27
+
28
+ # Offense count: 4
29
+ Style/CyclomaticComplexity:
30
+ Max: 12
31
+
32
+ # Offense count: 50
33
+ Style/Documentation:
34
+ Enabled: false
35
+
36
+ # Offense count: 8
37
+ # Configuration parameters: MinBodyLength.
38
+ Style/GuardClause:
39
+ Enabled: false
40
+
41
+ # Offense count: 4
42
+ # Configuration parameters: MaxLineLength.
43
+ Style/IfUnlessModifier:
44
+ Enabled: false
45
+
46
+ # Offense count: 9
47
+ Style/Lambda:
48
+ Enabled: false
49
+
50
+ # Offense count: 6
51
+ # Cop supports --auto-correct.
52
+ Style/LeadingCommentSpace:
53
+ Enabled: false
54
+
55
+ # Offense count: 165
56
+ # Configuration parameters: AllowURI.
57
+ Style/LineLength:
58
+ Max: 181
59
+
60
+ # Offense count: 14
61
+ # Configuration parameters: CountComments.
62
+ Style/MethodLength:
63
+ Max: 29
64
+
65
+ # Offense count: 2
66
+ Style/ModuleFunction:
67
+ Enabled: false
68
+
69
+ # Offense count: 2
70
+ Style/MultilineBlockChain:
71
+ Enabled: false
72
+
73
+ # Offense count: 1
74
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
75
+ Style/Next:
76
+ Enabled: false
77
+
78
+ # Offense count: 2
79
+ # Cop supports --auto-correct.
80
+ Style/NumericLiterals:
81
+ MinDigits: 6
82
+
83
+ # Offense count: 1
84
+ # Configuration parameters: NamePrefixBlacklist.
85
+ Style/PredicateName:
86
+ Enabled: false
87
+
88
+ # Offense count: 1
89
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
90
+ Style/RaiseArgs:
91
+ Enabled: false
92
+
93
+ # Offense count: 7
94
+ # Cop supports --auto-correct.
95
+ Style/RedundantBegin:
96
+ Enabled: false
97
+
98
+ # Offense count: 4
99
+ # Cop supports --auto-correct.
100
+ Style/RedundantSelf:
101
+ Enabled: false
102
+
103
+ # Offense count: 2
104
+ Style/RegexpLiteral:
105
+ MaxSlashes: 0
106
+
107
+ # Offense count: 1
108
+ Style/SelfAssignment:
109
+ Enabled: false
110
+
111
+ # Offense count: 41
112
+ # Cop supports --auto-correct.
113
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
114
+ Style/SignalException:
115
+ Enabled: false
116
+
117
+ # Offense count: 1
118
+ # Cop supports --auto-correct.
119
+ Style/SpaceAfterComma:
120
+ Enabled: false
121
+
122
+ # Offense count: 61
123
+ # Cop supports --auto-correct.
124
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
125
+ Style/SpaceAroundEqualsInParameterDefault:
126
+ Enabled: false
127
+
128
+ # Offense count: 9
129
+ # Cop supports --auto-correct.
130
+ Style/SpaceAroundOperators:
131
+ Enabled: false
132
+
133
+ # Offense count: 11
134
+ # Cop supports --auto-correct.
135
+ # Configuration parameters: EnforcedStyle, SupportedStyles.
136
+ Style/SpaceBeforeBlockBraces:
137
+ Enabled: false
138
+
139
+ # Offense count: 22
140
+ # Cop supports --auto-correct.
141
+ # Configuration parameters: EnforcedStyle, SupportedStyles, EnforcedStyleForEmptyBraces, SpaceBeforeBlockParameters.
142
+ Style/SpaceInsideBlockBraces:
143
+ Enabled: false
144
+
145
+ # Offense count: 101
146
+ # Cop supports --auto-correct.
147
+ # Configuration parameters: EnforcedStyle, EnforcedStyleForEmptyBraces, SupportedStyles.
148
+ Style/SpaceInsideHashLiteralBraces:
149
+ Enabled: false
150
+
151
+ # Offense count: 3
152
+ # Cop supports --auto-correct.
153
+ Style/SpecialGlobalVars:
154
+ Enabled: false
155
+
156
+ # Offense count: 7
157
+ # Cop supports --auto-correct.
158
+ # Configuration parameters: ExactNameMatch, AllowPredicates, AllowDSLWriters, Whitelist.
159
+ Style/TrivialAccessors:
160
+ Enabled: false
data/.travis.yml CHANGED
@@ -5,19 +5,20 @@ services:
5
5
  - rabbitmq
6
6
  before_script:
7
7
  - ci/travis_setup
8
+ script: bundle exec rake ci
8
9
  rvm:
9
- - 2.1.0
10
+ - 2.1
10
11
  - 2.0.0
11
12
  - 1.9.3
12
13
  - jruby-19mode
13
14
  - 1.9.2
14
- - rbx
15
+ - rbx-2
15
16
  env:
16
17
  - ADAPTER=in_memory
17
18
  - ADAPTER=stomp
18
- - ADAPTER=bunny:1.1.3
19
+ - ADAPTER=bunny:1.2.2
20
+ - ADAPTER=bunny:1.3.1
19
21
  matrix:
20
22
  allow_failures:
21
- - rvm: rbx
22
23
  - rvm: jruby-19mode
23
24
  env: ADAPTER=stomp
data/CHANGELOG.md CHANGED
@@ -1,5 +1,10 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.0 - 2014-07-03
4
+
5
+ * require bunny 1.2.2 or later
6
+ * add support for publish confirmations
7
+
3
8
  ## 0.3.0 - 2014-02-26
4
9
 
5
10
  * Support for handling multiple broker connections
data/Gemfile CHANGED
@@ -12,22 +12,21 @@ group :tools do
12
12
  gem 'guard-bundler'
13
13
  gem 'guard-rspec'
14
14
  gem 'guard-cucumber'
15
+ gem 'guard-rubocop'
15
16
  gem 'pry'
16
- platform :ruby_19 do
17
- gem 'pry-debugger'
18
- end
19
- platform :ruby_20 do
20
- gem 'pry-byebug'
21
- end
17
+ gem 'pry-byebug', platform: [:mri_20, :mri_21]
22
18
  group :darwin do
23
19
  gem 'ruby_gntp'
24
20
  gem 'rb-fsevent'
25
21
  gem 'relish'
26
22
  gem 'lunchy'
27
23
  end
28
- end
24
+ gem 'yard'
25
+ gem 'redcarpet'
26
+ gem 'launchy'
27
+ end if RUBY_VERSION >= '1.9.3'
29
28
 
30
- require File.expand_path("../test_lib/broker_config", __FILE__)
29
+ require File.expand_path('../test_lib/broker_config', __FILE__)
31
30
 
32
31
  adapter = BrokerConfig.current_adapter.to_s
33
32
  version = BrokerConfig.adapter_version
@@ -42,3 +41,5 @@ else
42
41
  gem adapter.to_s, "~> #{version}"
43
42
  end
44
43
  end
44
+
45
+ gem 'coveralls', require: false
data/Guardfile CHANGED
@@ -9,15 +9,19 @@ guard 'bundler' do
9
9
  end
10
10
 
11
11
  common_rspec_opts = { all_after_pass: true }
12
- unit_spec_opts = common_rspec_opts.merge({ spec_paths: ["spec/units"], cmd: 'bundle exec rspec -f doc', run_all: { cmd: 'bundle exec rspec' } })
13
- integration_spec_opts = common_rspec_opts.merge({ spec_paths: ["spec/integration/#{BrokerConfig.current_adapter}"], cmd: 'bundle exec rspec -f doc -t all_adapters', run_all: { cmd: 'bundle exec rspec -t all_adapters' } })
12
+ unit_spec_opts = common_rspec_opts.merge(spec_paths: ['spec/units'], cmd: 'bundle exec rspec -f doc', run_all: { cmd: 'bundle exec rspec' })
13
+ integration_spec_opts = common_rspec_opts.merge(
14
+ spec_paths: ["spec/integration/#{BrokerConfig.current_adapter}"],
15
+ cmd: 'bundle exec rspec -f doc -t all_adapters',
16
+ run_all: { cmd: 'bundle exec rspec -t all_adapters' }
17
+ )
14
18
 
15
19
  group 'specs' do
16
20
  guard 'rspec', unit_spec_opts do
17
21
  watch(%r{^spec/units/.+_spec\.rb$})
18
22
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/units/#{m[1]}_spec.rb" }
19
- watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
20
- watch('spec/spec_helper.rb') { "spec" }
23
+ watch(%r{^spec/support/(.+)\.rb$}) { 'spec' }
24
+ watch('spec/spec_helper.rb') { 'spec' }
21
25
  end
22
26
  end
23
27
 
@@ -25,8 +29,8 @@ group 'integration' do
25
29
  guard 'rspec', integration_spec_opts do
26
30
  watch(%r{^spec/integration/.+_spec\.rb$})
27
31
  watch(%r{^lib/(.+)\.rb$}) { |m| "spec/integration/#{m[1]}_spec.rb" }
28
- watch(%r{^spec/support/(.+)\.rb$}) { "spec" }
29
- watch('spec/spec_helper.rb') { "spec" }
32
+ watch(%r{^spec/support/(.+)\.rb$}) { 'spec' }
33
+ watch('spec/spec_helper.rb') { 'spec' }
30
34
  end
31
35
  end
32
36
 
@@ -40,4 +44,7 @@ group 'features' do
40
44
  end
41
45
  end
42
46
 
43
-
47
+ guard :rubocop do
48
+ watch(/.+\.rb/)
49
+ watch(%r{(?:.+/)?\.rubocop(?:_.+)*\.yml$}) { |m| File.dirname(m[0]) }
50
+ end
data/README.md CHANGED
@@ -10,6 +10,8 @@ Easy message queues for ruby
10
10
 
11
11
  [![Code Climate](https://codeclimate.com/github/message-driver/message-driver.png)](https://codeclimate.com/github/message-driver/message-driver)
12
12
 
13
+ [![Coverage Status](https://img.shields.io/coveralls/message-driver/message-driver.svg)](https://coveralls.io/r/message-driver/message-driver)
14
+
13
15
  ## Installation
14
16
 
15
17
  Add this line to your application's Gemfile:
data/Rakefile CHANGED
@@ -6,33 +6,35 @@ require 'bundler/gem_tasks'
6
6
  require 'rspec/core/rake_task'
7
7
  require 'cucumber/rake/task'
8
8
 
9
+ require 'coveralls/rake/task'
10
+
9
11
  namespace :spec do
10
- desc "Run unit specs"
12
+ desc 'Run unit specs'
11
13
  RSpec::Core::RakeTask.new(:units) do |t|
12
- t.pattern = "./spec/units{,/*/**}/*_spec.rb"
14
+ t.pattern = './spec/units{,/*/**}/*_spec.rb'
13
15
  end
14
16
 
15
- desc "Run the integration specs"
17
+ desc 'Run the integration specs'
16
18
  RSpec::Core::RakeTask.new(:integrations) do |t|
17
- t.rspec_opts = "--tag all_adapters"
19
+ t.rspec_opts = '--tag all_adapters'
18
20
  t.pattern = "./spec/integration/#{BrokerConfig.current_adapter}{,/*/**}/*_spec.rb"
19
21
  end
20
22
 
21
23
  cucumber_opts = "--format progress --tag @all_adapters,@#{BrokerConfig.current_adapter} --tag ~@wip"
22
- cucumber_opts += " --tag ~@no_ci" if ENV['CI']=='true' && ENV['ADAPTER'] && ENV['ADAPTER'].start_with?('bunny')
24
+ cucumber_opts += ' --tag ~@no_ci' if ENV['CI']=='true' && ENV['ADAPTER'] && ENV['ADAPTER'].start_with?('bunny')
23
25
  Cucumber::Rake::Task.new(:features) do |t|
24
26
  t.cucumber_opts = cucumber_opts
25
27
  end
26
28
 
27
- desc "run all the specs"
28
- task :all => [:units, :integrations, :features]
29
+ desc 'run all the specs'
30
+ task all: [:units, :integrations, :features]
29
31
 
30
- desc "run all the specs for each adapter"
32
+ desc 'run all the specs for each adapter'
31
33
  task :all_adapters do
32
34
  current_adapter = BrokerConfig.current_adapter
33
35
  BrokerConfig.all_adapters.each do |adapter|
34
36
  set_adapter_under_test(adapter)
35
- system("rake spec:all")
37
+ system('rake spec:all')
36
38
  end
37
39
  set_adapter_under_test(current_adapter)
38
40
  end
@@ -42,6 +44,10 @@ def set_adapter_under_test(adapter)
42
44
  system "echo #{adapter} > #{File.join(File.dirname(__FILE__), '.adapter_under_test')}"
43
45
  end
44
46
 
47
+ Coveralls::RakeTask.new
48
+ desc 'run with code coverage'
49
+ task ci: ['spec:all', 'coveralls:push']
50
+
45
51
  namespace :undertest do
46
52
  BrokerConfig.all_adapters.each do |adapter|
47
53
  desc "set the adapter under test to #{adapter}"
@@ -51,4 +57,4 @@ namespace :undertest do
51
57
  end
52
58
  end
53
59
 
54
- task :default => ["spec:all"]
60
+ task default: ['spec:all']
@@ -1,5 +1,5 @@
1
- source "https://rubygems.org"
1
+ source 'https://rubygems.org'
2
2
 
3
- gem "message-driver", path: "../.."
3
+ gem 'message-driver', path: '../..'
4
4
 
5
5
  gem 'bunny'
@@ -6,12 +6,12 @@ LOG = Logger.new(STDOUT)
6
6
  LOG.level = Logger::DEBUG
7
7
 
8
8
  MessageDriver.configure(
9
- adapter: "bunny",
10
- vhost: "message-driver-dev",
9
+ adapter: 'bunny',
10
+ vhost: 'message-driver-dev',
11
11
  heartbeat_interval: 2,
12
12
  logger: LOG
13
13
  )
14
14
 
15
15
  MessageDriver::Broker.define do |b|
16
- b.destination :basic_consumer_producer, "basic.consumer.producer", durable: true
16
+ b.destination :basic_consumer_producer, 'basic.consumer.producer', durable: true
17
17
  end
@@ -1,10 +1,10 @@
1
- require_relative "./common"
1
+ require_relative './common'
2
2
 
3
- LOG.info("starting consumer")
3
+ LOG.info('starting consumer')
4
4
 
5
5
  end_thread = Thread.new do
6
6
  Thread.stop
7
- LOG.info("stopping consumer")
7
+ LOG.info('stopping consumer')
8
8
  MessageDriver::Broker.stop
9
9
  end
10
10
 
@@ -12,8 +12,8 @@ ending_proc = proc do
12
12
  end_thread.wakeup
13
13
  end
14
14
 
15
- trap "TERM", &ending_proc
16
- trap "INT", &ending_proc
15
+ trap 'TERM', &ending_proc
16
+ trap 'INT', &ending_proc
17
17
 
18
18
  MessageDriver::Broker.consumer(:basic_consumer) do |message|
19
19
  LOG.info("I got a message! #{message.body}")
@@ -1,6 +1,6 @@
1
- require_relative "./common"
1
+ require_relative './common'
2
2
 
3
- LOG.info("starting producer")
3
+ LOG.info('starting producer')
4
4
 
5
5
  stopping = false
6
6
 
@@ -8,12 +8,12 @@ ending_proc = proc do
8
8
  stopping = true
9
9
  end
10
10
 
11
- trap "TERM", &ending_proc
12
- trap "INT", &ending_proc
11
+ trap 'TERM', &ending_proc
12
+ trap 'INT', &ending_proc
13
13
 
14
14
  counter = 0
15
15
 
16
- while !stopping do
16
+ until stopping
17
17
  10.times do
18
18
  counter += 1
19
19
  begin
@@ -21,7 +21,7 @@ while !stopping do
21
21
  rescue MessageDriver::ConnectionError => e
22
22
  LOG.info("The connection is closed! #{e}")
23
23
  sleep 1
24
- LOG.info("retrying...")
24
+ LOG.info('retrying...')
25
25
  retry
26
26
  end
27
27
  end
@@ -29,5 +29,5 @@ while !stopping do
29
29
  sleep 1
30
30
  end
31
31
 
32
- LOG.info("stopping producer")
32
+ LOG.info('stopping producer')
33
33
  MessageDriver::Broker.stop