msgr 0.14.1.1.b125 → 0.14.1.1.b126

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +48 -0
  3. data/lib/msgr/binding.rb +3 -2
  4. data/lib/msgr/client.rb +17 -14
  5. data/lib/msgr/connection.rb +17 -10
  6. data/lib/msgr/consumer.rb +6 -2
  7. data/lib/msgr/dispatcher.rb +14 -10
  8. data/lib/msgr/errors.rb +2 -3
  9. data/lib/msgr/logging.rb +2 -2
  10. data/lib/msgr/message.rb +10 -9
  11. data/lib/msgr/railtie.rb +11 -8
  12. data/lib/msgr/route.rb +16 -8
  13. data/lib/msgr/routes.rb +12 -12
  14. data/lib/msgr/test_pool.rb +5 -2
  15. data/lib/msgr/version.rb +4 -1
  16. data/lib/msgr.rb +2 -4
  17. data/scripts/simple_test.rb +4 -4
  18. data/spec/fixtures/msgr-routes-test-1.rb +1 -0
  19. data/spec/integration/dummy/app/consumers/application_consumer.rb +1 -1
  20. data/spec/integration/dummy/app/consumers/test_consumer.rb +3 -3
  21. data/spec/integration/dummy/app/controllers/application_controller.rb +1 -0
  22. data/spec/integration/dummy/app/controllers/test_controller.rb +2 -2
  23. data/spec/integration/dummy/app/helpers/application_helper.rb +1 -0
  24. data/spec/integration/dummy/bin/bundle +1 -0
  25. data/spec/integration/dummy/bin/rails +2 -1
  26. data/spec/integration/dummy/bin/rake +1 -0
  27. data/spec/integration/dummy/config/application.rb +1 -1
  28. data/spec/integration/dummy/config/boot.rb +1 -0
  29. data/spec/integration/dummy/config/environment.rb +1 -0
  30. data/spec/integration/dummy/config/environments/development.rb +1 -0
  31. data/spec/integration/dummy/config/environments/production.rb +1 -0
  32. data/spec/integration/dummy/config/environments/test.rb +2 -1
  33. data/spec/integration/dummy/config/initializers/backtrace_silencers.rb +1 -0
  34. data/spec/integration/dummy/config/initializers/filter_parameter_logging.rb +1 -0
  35. data/spec/integration/dummy/config/initializers/inflections.rb +1 -0
  36. data/spec/integration/dummy/config/initializers/mime_types.rb +1 -0
  37. data/spec/integration/dummy/config/initializers/secret_token.rb +1 -0
  38. data/spec/integration/dummy/config/initializers/session_store.rb +1 -0
  39. data/spec/integration/dummy/config/initializers/wrap_parameters.rb +1 -0
  40. data/spec/integration/dummy/config/msgr.rb +1 -0
  41. data/spec/integration/dummy/config/routes.rb +2 -2
  42. data/spec/integration/msgr/dispatcher_spec.rb +6 -5
  43. data/spec/integration/msgr/railtie_spec.rb +18 -18
  44. data/spec/integration/msgr_spec.rb +1 -0
  45. data/spec/integration/spec_helper.rb +2 -2
  46. data/spec/msgr/msgr/connection_spec.rb +1 -1
  47. data/spec/msgr/msgr/consumer_spec.rb +1 -0
  48. data/spec/msgr/msgr/route_spec.rb +9 -8
  49. data/spec/msgr/msgr/routes_spec.rb +6 -5
  50. data/spec/msgr/msgr_spec.rb +3 -2
  51. data/spec/msgr/spec_helper.rb +2 -1
  52. data/spec/support/setup.rb +2 -1
  53. metadata +2 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2001d4982c46db6d24deff4a4224ea3ab324d356
4
- data.tar.gz: 897ee73e929eeb57fdc851985d754002e43c9d12
3
+ metadata.gz: 58d8c36902cdf5dd4d97ea60e27e7ff0cd61d3bf
4
+ data.tar.gz: ac9c00107a12baf9d1c1fb522760721820e6b570
5
5
  SHA512:
6
- metadata.gz: 9c6106196c3f0fbe1bec232bbdaac6f795c104937f4a9582765c19e1b4e56656460da183d0bde6dcdc7726bb1b2e06162b0dbd1f0952698b24d46f759d8712d0
7
- data.tar.gz: 5b94e72a33b0cfabd76721f09e16524ea8265ee056c53d09632cfcc3887174075138e4256621bac31a442bfa5c0a230a35b4509c88a3212121e190d18603ea7d
6
+ metadata.gz: ed786680950674203f4ec550b7e8709925295dca09e5568254e72cf6257855fe1cfdd48ef07a072fdfc43871487df4295d7876fe2995679d76ab7d6a248a2e2e
7
+ data.tar.gz: 3c975a75f71c80ccb820ca5f731382020a278ad6c6a4fb00356744e02052b6dc752807beeb31b8650a3a4e27409d86934ee56a5753f269e91d48ad4c92faeaca
data/.rubocop.yml ADDED
@@ -0,0 +1,48 @@
1
+ AllCops:
2
+ Include:
3
+ - '**/*.rb'
4
+ TargetRubyVersion: 2.4
5
+
6
+ Metrics/BlockLength:
7
+ Exclude:
8
+ - 'spec/**/*_spec.rb'
9
+
10
+ Metrics/LineLength:
11
+ Exclude:
12
+ - 'spec/**/*_spec.rb'
13
+
14
+ Style/AlignParameters:
15
+ EnforcedStyle: with_fixed_indentation
16
+
17
+ Style/BracesAroundHashParameters:
18
+ EnforcedStyle: context_dependent
19
+
20
+ Style/SpaceInsideHashLiteralBraces:
21
+ EnforcedStyle: no_space
22
+
23
+ Style/RaiseArgs:
24
+ EnforcedStyle: compact
25
+
26
+ Style/Documentation:
27
+ Enabled: false
28
+
29
+ Style/SpaceInsideBlockBraces:
30
+ EnforcedStyle: space
31
+ EnforcedStyleForEmptyBraces: no_space
32
+ SpaceBeforeBlockParameters: false
33
+
34
+ Style/SignalException:
35
+ EnforcedStyle: only_raise
36
+
37
+ Style/CaseIndentation:
38
+ EnforcedStyle: end
39
+ SupportedStyles:
40
+ - case
41
+ - end
42
+ IndentOneStep: true
43
+
44
+ Style/ClassAndModuleChildren:
45
+ Enabled: false
46
+
47
+ Style/TrivialAccessors:
48
+ AllowPredicates: true
data/lib/msgr/binding.rb CHANGED
@@ -1,5 +1,5 @@
1
+ # frozen_string_literal: true
1
2
  module Msgr
2
-
3
3
  class Binding
4
4
  include Logging
5
5
 
@@ -45,7 +45,8 @@ module Msgr
45
45
  dispatcher.call Message.new(connection, *args, route)
46
46
  rescue => err
47
47
  log(:error) do
48
- "Rescued error from subscribe: #{err.class.name}: #{err}\n#{err.backtrace.join("\n")}"
48
+ "Rescued error from subscribe: #{err.class.name}: " \
49
+ "#{err}\n#{err.backtrace.join("\n")}"
49
50
  end
50
51
  end
51
52
  end
data/lib/msgr/client.rb CHANGED
@@ -1,26 +1,29 @@
1
+ # frozen_string_literal: true
1
2
  module Msgr
2
-
3
+ # rubocop:disable Metrics/ClassLength
3
4
  class Client
4
5
  include Logging
5
6
  attr_reader :uri, :config
6
7
 
8
+ # rubocop:disable Metrics/AbcSize
9
+ # rubocop:disable Metrics/MethodLength
7
10
  def initialize(config = {})
8
- @uri = ::URI.parse config[:uri] ? config.delete(:uri) : 'amqp://localhost/'
11
+ @uri = ::URI.parse config[:uri] ? config.delete(:uri) : 'amqp://localhost/'
9
12
  config[:pass] ||= @uri.password
10
13
 
11
14
  @uri.user = config[:user] ||= @uri.user || 'guest'
12
- @uri.scheme = (config[:ssl] ||= @uri.scheme.to_s.downcase == 'amqps') ? 'amqps' : 'amqp'
15
+ @uri.scheme = (config[:ssl] ||= @uri.scheme.to_s.casecmp('amqps').zero?) ? 'amqps' : 'amqp'
13
16
  @uri.host = config[:host] ||= @uri.host || '127.0.0.1'
14
17
  @uri.port = config[:port] ||= @uri.port
15
18
  @uri.path = config[:vhost] ||= @uri.path.present? ? @uri.path : '/'
16
- config.reject! { |_, v| v.nil? }
19
+ config.reject! {|_, v| v.nil? }
17
20
 
18
- @config = config
21
+ @config = config
19
22
  @config[:max] ||= 2
20
23
 
21
24
  @mutex = ::Mutex.new
22
25
  @routes = Routes.new
23
- @pid ||= ::Process.pid
26
+ @pid ||= ::Process.pid
24
27
 
25
28
  log(:debug) { "Created new client on process ##{@pid}..." }
26
29
  end
@@ -120,17 +123,17 @@ module Msgr
120
123
  connection.publish message, opts
121
124
  end
122
125
 
123
- def mutex
124
- @mutex
125
- end
126
+ attr_reader :mutex
126
127
 
127
128
  def check_process!
128
- unless ::Process.pid == @pid
129
- log(:warn) { "Fork detected. Reset internal state. (Old PID: #{@pid} / New PID: #{::Process.pid}" }
130
-
131
- reset
132
- @pid = ::Process.pid
129
+ return if ::Process.pid == @pid
130
+ log(:warn) do
131
+ "Fork detected. Reset internal state. (Old PID: #{@pid} / " \
132
+ "New PID: #{::Process.pid}"
133
133
  end
134
+
135
+ reset
136
+ @pid = ::Process.pid
134
137
  end
135
138
 
136
139
  def connection
@@ -1,8 +1,9 @@
1
+ # frozen_string_literal: true
1
2
  require 'bunny'
2
3
  require 'multi_json'
3
4
 
4
5
  module Msgr
5
-
6
+ # rubocop:disable Metrics/ClassLength
6
7
  class Connection
7
8
  include Logging
8
9
 
@@ -29,7 +30,7 @@ module Msgr
29
30
  end
30
31
 
31
32
  def connection
32
- @connection ||= ::Bunny.new(config).tap { |b| b.start }
33
+ @connection ||= ::Bunny.new(config).tap(&:start)
33
34
  end
34
35
 
35
36
  def connect
@@ -48,14 +49,14 @@ module Msgr
48
49
  return if bindings.empty?
49
50
  log(:debug) { "Release bindings (#{bindings.size})..." }
50
51
 
51
- bindings.each { |binding| binding.release }
52
+ bindings.each(&:release)
52
53
  end
53
54
 
54
55
  def delete
55
56
  return if bindings.empty?
56
57
  log(:debug) { "Delete bindings (#{bindings.size})..." }
57
58
 
58
- bindings.each { |binding| binding.delete }
59
+ bindings.each(&:delete)
59
60
  end
60
61
 
61
62
  def purge(**kwargs)
@@ -78,10 +79,12 @@ module Msgr
78
79
  end
79
80
 
80
81
  def exchange
81
- @exchange ||= channel.topic(prefix(EXCHANGE_NAME), durable: true).tap do |ex|
82
- log(:debug) do
83
- "Created exchange #{ex.name} (type: #{ex.type}, " \
84
- "durable: #{ex.durable?}, auto_delete: #{ex.auto_delete?})"
82
+ @exchange ||= begin
83
+ channel.topic(prefix(EXCHANGE_NAME), durable: true).tap do |ex|
84
+ log(:debug) do
85
+ "Created exchange #{ex.name} (type: #{ex.type}, " \
86
+ "durable: #{ex.durable?}, auto_delete: #{ex.auto_delete?})"
87
+ end
85
88
  end
86
89
  end
87
90
  end
@@ -97,7 +100,10 @@ module Msgr
97
100
 
98
101
  def bind(routes)
99
102
  if routes.empty?
100
- log(:warn) { "No routes to bound to. Bind will have no effect. (#{routes.inspect})" }
103
+ log(:warn) do
104
+ "No routes to bound to. Bind will have no effect:\n" \
105
+ " #{routes.inspect}"
106
+ end
101
107
  else
102
108
  bind_all(routes)
103
109
  end
@@ -125,8 +131,9 @@ module Msgr
125
131
  end
126
132
 
127
133
  private
134
+
128
135
  def bind_all(routes)
129
- routes.each { |route| bindings << Binding.new(self, route, @dispatcher) }
136
+ routes.each {|route| bindings << Binding.new(self, route, @dispatcher) }
130
137
  end
131
138
  end
132
139
  end
data/lib/msgr/consumer.rb CHANGED
@@ -1,5 +1,5 @@
1
+ # frozen_string_literal: true
1
2
  module Msgr
2
-
3
3
  class Consumer
4
4
  include Logging
5
5
 
@@ -12,7 +12,11 @@ module Msgr
12
12
  @message = message
13
13
 
14
14
  action = message.route.action.to_sym
15
- raise Msgr::NoAction.new "No action `#{action}` for `#{self.class.name}`." unless respond_to? action
15
+
16
+ unless respond_to?(action)
17
+ raise Msgr::NoAction.new \
18
+ "No action `#{action}` for `#{self.class.name}`."
19
+ end
16
20
 
17
21
  log(:debug) { "Invoke action #{action.inspect}." }
18
22
 
@@ -1,5 +1,5 @@
1
+ # frozen_string_literal: true
1
2
  module Msgr
2
-
3
3
  # The Dispatcher receives incoming messages,
4
4
  # process them through a middleware stack and
5
5
  # delegate them to a new and fresh consumer instance.
@@ -12,18 +12,23 @@ module Msgr
12
12
  def initialize(config)
13
13
  config[:pool_class] ||= 'Msgr::Dispatcher::NullPool'
14
14
 
15
- log(:debug) { "Initialize new dispatcher (#{config[:pool_class]}: #{config})..." }
15
+ log(:debug) do
16
+ "Initialize new dispatcher (#{config[:pool_class]}: #{config})..."
17
+ end
16
18
 
17
19
  @config = config
18
20
  @pool = config[:pool_class].constantize.new config
19
21
  end
20
22
 
21
23
  def call(message)
22
- pool.post(message) do |message|
23
- dispatch message
24
+ pool.post(message) do |msg|
25
+ dispatch msg
24
26
  end
25
27
  end
26
28
 
29
+ # rubocop:disable Metrics/AbcSize
30
+ # rubocop:disable Metrics/MethodLength
31
+ # rubocop:disable Metrics/CyclomaticComplexity
27
32
  def dispatch(message)
28
33
  consumer_class = Object.const_get message.route.consumer
29
34
 
@@ -38,27 +43,26 @@ module Msgr
38
43
 
39
44
  log(:error) do
40
45
  "Dispatcher error: #{error.class.name}: #{error}\n" +
41
- error.backtrace.join("\n")
46
+ error.backtrace.join("\n")
42
47
  end
43
48
 
44
49
  raise error if config[:raise_exceptions]
45
50
  ensure
46
- if defined?(ActiveRecord) && ActiveRecord::Base.connection_pool.active_connection?
51
+ if defined?(ActiveRecord) &&
52
+ ActiveRecord::Base.connection_pool.active_connection?
47
53
  log(:debug) { 'Release used AR connection for dispatcher thread.' }
48
54
  ActiveRecord::Base.connection_pool.release_connection
49
55
  end
50
56
  end
51
57
 
52
- def shutdown
53
- end
58
+ def shutdown; end
54
59
 
55
60
  def to_s
56
61
  self.class.name
57
62
  end
58
63
 
59
64
  class NullPool
60
- def initialize(*)
61
- end
65
+ def initialize(*); end
62
66
 
63
67
  def post(*args)
64
68
  yield(*args)
data/lib/msgr/errors.rb CHANGED
@@ -1,5 +1,5 @@
1
+ # frozen_string_literal: true
1
2
  module Msgr
2
-
3
3
  # Abstract error base class
4
4
  class CausedByError < StandardError
5
5
  attr_accessor :cause
@@ -11,11 +11,10 @@ module Msgr
11
11
  end
12
12
 
13
13
  def message
14
- cause ? "#{super}\n caused by:\n#{cause.to_s}" : super
14
+ cause ? "#{super}\n caused by:\n#{cause}" : super
15
15
  end
16
16
  end
17
17
 
18
18
  class ConnectionError < CausedByError
19
-
20
19
  end
21
20
  end
data/lib/msgr/logging.rb CHANGED
@@ -1,8 +1,8 @@
1
+ # frozen_string_literal: true
1
2
  module Msgr
2
-
3
3
  module Logging
4
4
  def log(level)
5
- Msgr.logger.send(level) { "#{self.log_name} #{yield}" } if Msgr.logger
5
+ Msgr.logger.send(level) { "#{log_name} #{yield}" } if Msgr.logger
6
6
  end
7
7
 
8
8
  def log_name
data/lib/msgr/message.rb CHANGED
@@ -1,5 +1,5 @@
1
+ # frozen_string_literal: true
1
2
  module Msgr
2
-
3
3
  class Message
4
4
  attr_reader :delivery_info, :metadata, :payload, :route
5
5
 
@@ -10,6 +10,7 @@ module Msgr
10
10
  @payload = payload
11
11
  @route = route
12
12
 
13
+ # rubocop:disable Style/GuardClause
13
14
  if content_type == 'application/json'
14
15
  @payload = MultiJson.load(payload)
15
16
  @payload.symbolize_keys! if @payload.respond_to? :symbolize_keys!
@@ -35,10 +36,10 @@ module Msgr
35
36
  # @api public
36
37
  #
37
38
  def ack
38
- unless acked?
39
- @acked = true
40
- @connection.ack delivery_info.delivery_tag
41
- end
39
+ return if acked?
40
+
41
+ @acked = true
42
+ @connection.ack delivery_info.delivery_tag
42
43
  end
43
44
 
44
45
  # Send negative message acknowledge to broker unless
@@ -47,10 +48,10 @@ module Msgr
47
48
  # @api public
48
49
  #
49
50
  def nack
50
- unless acked?
51
- @acked = true
52
- @connection.nack delivery_info.delivery_tag
53
- end
51
+ return if acked?
52
+
53
+ @acked = true
54
+ @connection.nack delivery_info.delivery_tag
54
55
  end
55
56
  end
56
57
  end
data/lib/msgr/railtie.rb CHANGED
@@ -1,8 +1,11 @@
1
+ # frozen_string_literal: true
1
2
  module Msgr
2
-
3
3
  class Railtie < ::Rails::Railtie
4
4
  config.msgr = ActiveSupport::OrderedOptions.new
5
- config.autoload_paths << File.expand_path("#{Rails.root}/app/consumers") if File.exist?("#{Rails.root}/app/consumers")
5
+
6
+ if File.exist?("#{Rails.root}/app/consumers")
7
+ config.autoload_paths << File.expand_path("#{Rails.root}/app/consumers")
8
+ end
6
9
 
7
10
  initializer 'msgr.logger' do |app|
8
11
  app.config.msgr.logger ||= Rails.logger
@@ -40,7 +43,7 @@ module Msgr
40
43
 
41
44
  cfg = HashWithIndifferentAccess.new cfg[Rails.env]
42
45
  unless cfg[:uri]
43
- raise ArgumentError, 'Could not load rabbitmq environment config: URI missing.'
46
+ raise ArgumentError.new('Could not load rabbitmq environment config: URI missing.')
44
47
  end
45
48
 
46
49
  case cfg[:autostart]
@@ -49,7 +52,7 @@ module Msgr
49
52
  when false, 'false', 'disabled', nil
50
53
  cfg[:autostart] = false
51
54
  else
52
- raise ArgumentError, "Invalid value for rabbitmq config autostart: \"#{cfg[:autostart]}\""
55
+ raise ArgumentError.new("Invalid value for rabbitmq config autostart: \"#{cfg[:autostart]}\"")
53
56
  end
54
57
 
55
58
  case cfg[:checkcredentials]
@@ -58,7 +61,7 @@ module Msgr
58
61
  when false, 'false', 'disabled'
59
62
  cfg[:checkcredentials] = false
60
63
  else
61
- raise ArgumentError, "Invalid value for rabbitmq config checkcredentials: \"#{cfg[:checkcredentials]}\""
64
+ raise ArgumentError.new("Invalid value for rabbitmq config checkcredentials: \"#{cfg[:checkcredentials]}\"")
62
65
  end
63
66
 
64
67
  case cfg[:raise_exceptions]
@@ -67,7 +70,7 @@ module Msgr
67
70
  when false, 'false', 'disabled', nil
68
71
  cfg[:raise_exceptions] = false
69
72
  else
70
- raise ArgumentError, "Invalid value for rabbitmq config raise_exceptions: \"#{cfg[:raise_exceptions]}\""
73
+ raise ArgumentError.new("Invalid value for rabbitmq config raise_exceptions: \"#{cfg[:raise_exceptions]}\"")
71
74
  end
72
75
 
73
76
  cfg[:routing_file] ||= Rails.root.join('config/msgr.rb').to_s
@@ -76,7 +79,7 @@ module Msgr
76
79
 
77
80
  def load_config(options)
78
81
  if options.rabbitmq_config || !Rails.application.respond_to?(:config_for)
79
- load_file options.rabbitmq_config || Rails.root.join(*%w(config rabbitmq.yml))
82
+ load_file options.rabbitmq_config || Rails.root.join('config', 'rabbitmq.yml')
80
83
  else
81
84
  conf = Rails.application.config_for :rabbitmq
82
85
 
@@ -85,7 +88,7 @@ module Msgr
85
88
  end
86
89
 
87
90
  def load_file(path)
88
- YAML.load ERB.new(File.read(path)).result
91
+ YAML.safe_load ERB.new(File.read(path)).result
89
92
  end
90
93
  end
91
94
  end
data/lib/msgr/route.rb CHANGED
@@ -1,26 +1,34 @@
1
+ # frozen_string_literal: true
1
2
  module Msgr
2
-
3
3
  class Route
4
4
  attr_reader :consumer, :action, :opts
5
5
 
6
+ MATCH_REGEXP = /\A(?<consumer>\w+)#(?<action>\w+)\z/
7
+
8
+ # rubocop:disable Metrics/AbcSize
9
+ # rubocop:disable Metrics/MethodLength
6
10
  def initialize(key, opts = {})
7
11
  @opts = opts
8
12
  raise ArgumentError.new 'Missing `to` options.' unless @opts[:to]
9
13
 
10
14
  add key
11
15
 
12
- if (match = /\A(?<consumer>\w+)#(?<action>\w+)\z/.match(opts[:to].strip.to_s))
13
- @consumer = "#{match[:consumer].camelize}Consumer"
14
- @action = match[:action].underscore
15
- else
16
- raise ArgumentError.new "Invalid consumer format: #{opts[:to].strip.to_s.inspect}. Must be `consumer_class#action`."
16
+ result = MATCH_REGEXP.match(opts[:to].strip.to_s)
17
+
18
+ unless result
19
+ raise ArgumentError.new \
20
+ "Invalid consumer format: #{opts[:to].strip.to_s.inspect}. " \
21
+ 'Must be `consumer_class#action`.'
17
22
  end
23
+
24
+ @consumer = "#{result[:consumer].camelize}Consumer"
25
+ @action = result[:action].underscore
18
26
  end
19
27
 
20
28
  def keys
21
29
  @keys ||= []
22
30
  end
23
- alias_method :routing_keys, :keys
31
+ alias routing_keys keys
24
32
 
25
33
  def add(key)
26
34
  raise ArgumentError.new 'Routing key required.' unless key.present?
@@ -28,7 +36,7 @@ module Msgr
28
36
  keys << key
29
37
  end
30
38
 
31
- def accept?(key, opts)
39
+ def accept?(_key, opts)
32
40
  self.opts == opts
33
41
  end
34
42
 
data/lib/msgr/routes.rb CHANGED
@@ -1,5 +1,5 @@
1
+ # frozen_string_literal: true
1
2
  module Msgr
2
-
3
3
  class Routes
4
4
  include Logging
5
5
  attr_reader :routes
@@ -11,7 +11,7 @@ module Msgr
11
11
 
12
12
  def configure(&block)
13
13
  blocks << block
14
- instance_eval &block
14
+ instance_eval(&block)
15
15
  end
16
16
 
17
17
  def files
@@ -32,10 +32,10 @@ module Msgr
32
32
 
33
33
  def reload
34
34
  routes.clear
35
- blocks.each { |block| instance_eval(&block) }
35
+ blocks.each {|block| instance_eval(&block) }
36
36
  files.uniq!
37
37
  files.each do |file|
38
- if File.exists? file
38
+ if File.exist? file
39
39
  load file
40
40
  else
41
41
  log(:warn) { "Routes file `#{file}` does not exists (anymore)." }
@@ -44,19 +44,19 @@ module Msgr
44
44
  end
45
45
 
46
46
  def load(file)
47
- raise ArgumentError.new "File `#{file}` does not exists." unless File.exists? file
47
+ unless File.exist?(file)
48
+ raise ArgumentError.new "File `#{file}` does not exists."
49
+ end
50
+
48
51
  instance_eval File.read file
49
52
  end
50
53
 
51
54
  def route(key, opts = {})
52
- routes.each do |route|
53
- if route.accept? key, opts
54
- route.add key
55
- return
56
- end
55
+ if (route = routes.find {|r| r.accept?(key, opts) })
56
+ route.add key
57
+ else
58
+ routes << Msgr::Route.new(key, opts)
57
59
  end
58
-
59
- routes << Msgr::Route.new(key, opts)
60
60
  end
61
61
  end
62
62
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Msgr
2
3
  class TestPool
3
4
  def initialize(*)
@@ -25,10 +26,12 @@ module Msgr
25
26
  end
26
27
  end
27
28
 
28
- alias_method :reset, :clear
29
+ alias reset clear
29
30
 
30
31
  private
31
32
 
33
+ # rubocop:disable Metrics/AbcSize
34
+ # rubocop:disable Metrics/MethodLength
32
35
  def ns_run(count: 1, timeout: 5)
33
36
  received = 0
34
37
 
@@ -66,7 +69,7 @@ module Msgr
66
69
  @instance ? @instance.clear : nil
67
70
  end
68
71
 
69
- alias_method :reset, :clear
72
+ alias reset clear
70
73
  end
71
74
  end
72
75
  end
data/lib/msgr/version.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Msgr
2
3
  module VERSION
3
4
  MAJOR = 0
@@ -6,6 +7,8 @@ module Msgr
6
7
  STAGE = nil
7
8
  STRING = [MAJOR, MINOR, PATCH, STAGE].reject(&:nil?).join('.')
8
9
 
9
- def self.to_s; STRING end
10
+ def self.to_s
11
+ STRING
12
+ end
10
13
  end
11
14
  end
data/lib/msgr.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'msgr/version'
2
3
  require 'active_support'
3
4
  require 'active_support/core_ext/object/blank'
@@ -21,7 +22,6 @@ require 'msgr/test_pool'
21
22
  require 'msgr/railtie' if defined? Rails
22
23
 
23
24
  module Msgr
24
-
25
25
  class << self
26
26
  attr_writer :client, :config
27
27
  delegate :publish, to: :client
@@ -43,9 +43,7 @@ module Msgr
43
43
  @logger
44
44
  end
45
45
 
46
- def logger=(logger)
47
- @logger = logger
48
- end
46
+ attr_writer :logger
49
47
 
50
48
  def start
51
49
  client.start
@@ -1,4 +1,5 @@
1
- $:.unshift File.join File.dirname(__FILE__), '../lib'
1
+ # frozen_string_literal: true
2
+ $LOAD_PATH.unshift File.join File.dirname(__FILE__), '../lib'
2
3
  require 'msgr'
3
4
 
4
5
  Msgr.logger.level = Logger::Severity::INFO
@@ -19,8 +20,7 @@ end
19
20
 
20
21
  #
21
22
  class NullPool
22
- def initialize(*)
23
- end
23
+ def initialize(*); end
24
24
 
25
25
  def post(*args)
26
26
  yield(*args)
@@ -28,7 +28,7 @@ class NullPool
28
28
  end
29
29
 
30
30
  @client = Msgr::Client.new user: 'guest', password: 'guest',
31
- max: 4#, pool_class: 'NullPool'
31
+ max: 4 # , pool_class: 'NullPool'
32
32
 
33
33
  @client.routes.configure do
34
34
  route 'abc.#', to: 'test#index'
@@ -1,2 +1,3 @@
1
+ # frozen_string_literal: true
1
2
  # Test routes
2
3
  route 'abc.#', to: 'test#index'
@@ -1,3 +1,3 @@
1
+ # frozen_string_literal: true
1
2
  class ApplicationConsumer < Msgr::Consumer
2
-
3
3
  end
@@ -1,12 +1,12 @@
1
+ # frozen_string_literal: true
1
2
  class TestConsumer < ApplicationConsumer
2
-
3
3
  def index
4
- data = { fuubar: 'abc' }
4
+ data = {fuubar: 'abc'}
5
5
 
6
6
  publish data, to: 'local.test.another_action'
7
7
  end
8
8
 
9
9
  def another_action
10
- puts "#{payload.inspect}"
10
+ puts payload.inspect.to_s
11
11
  end
12
12
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  class ApplicationController < ActionController::Base
2
3
  # Prevent CSRF attacks by raising an exception.
3
4
  # For APIs, you may want to use :null_session instead.
@@ -1,7 +1,7 @@
1
+ # frozen_string_literal: true
1
2
  class TestController < ApplicationController
2
-
3
3
  def index
4
- @data = { abc: 'abc' }
4
+ @data = {abc: 'abc'}
5
5
 
6
6
  Msgr.publish @data, to: 'local.test.index'
7
7
 
@@ -1,2 +1,3 @@
1
+ # frozen_string_literal: true
1
2
  module ApplicationHelper
2
3
  end
@@ -1,3 +1,4 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
  ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
4
  load Gem.bin_path('bundler', 'bundle')
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
- APP_PATH = File.expand_path('../../config/application', __FILE__)
2
+ # frozen_string_literal: true
3
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
4
  require_relative '../config/boot'
4
5
  require 'rails/commands'
@@ -1,4 +1,5 @@
1
1
  #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
2
3
  require_relative '../config/boot'
3
4
  require 'rake'
4
5
  Rake.application.run
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require File.expand_path('../boot', __FILE__)
2
3
 
3
4
  require 'rails/all'
@@ -21,4 +22,3 @@ module Dummy
21
22
  config.msgr.logger = Logger.new $stdout
22
23
  end
23
24
  end
24
-
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Set up gems listed in the Gemfile.
2
3
  ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Load the Rails application.
2
3
  require File.expand_path('../application', __FILE__)
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  Dummy::Application.configure do
2
3
  # Settings specified here will take precedence over those in config/application.rb.
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  Dummy::Application.configure do
2
3
  # Settings specified here will take precedence over those in config/application.rb.
3
4
 
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  Dummy::Application.configure do
2
3
  # Settings specified here will take precedence over those in config/application.rb.
3
4
 
@@ -14,7 +15,7 @@ Dummy::Application.configure do
14
15
 
15
16
  # Configure static asset server for tests with Cache-Control for performance.
16
17
  config.serve_static_assets = true
17
- config.static_cache_control = "public, max-age=3600"
18
+ config.static_cache_control = 'public, max-age=3600'
18
19
 
19
20
  # Show full error reports and disable caching.
20
21
  config.consider_all_requests_local = true
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Be sure to restart your server when you modify this file.
2
3
 
3
4
  # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Be sure to restart your server when you modify this file.
2
3
 
3
4
  # Configure sensitive parameters which will be filtered from the log file.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Be sure to restart your server when you modify this file.
2
3
 
3
4
  # Add new inflection rules using the following format. Inflections
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Be sure to restart your server when you modify this file.
2
3
 
3
4
  # Add new mime types for use in respond_to blocks:
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Be sure to restart your server when you modify this file.
2
3
 
3
4
  # Your secret key is used for verifying the integrity of signed cookies.
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Be sure to restart your server when you modify this file.
2
3
 
3
4
  Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Be sure to restart your server when you modify this file.
2
3
 
3
4
  # This file contains settings for ActionController::ParamsWrapper which
@@ -1,3 +1,4 @@
1
1
 
2
+ # frozen_string_literal: true
2
3
  route 'local.test.index', to: 'test#index'
3
4
  route 'local.test.another_action', to: 'test#another_action'
@@ -1,5 +1,5 @@
1
+ # frozen_string_literal: true
1
2
  Dummy::Application.routes.draw do
2
-
3
3
  root to: 'test#index'
4
4
  # The priority is based upon order of creation: first created -> highest priority.
5
5
  # See how all your routes lay out with "rake routes".
@@ -41,7 +41,7 @@ Dummy::Application.routes.draw do
41
41
  # get 'recent', on: :collection
42
42
  # end
43
43
  # end
44
-
44
+
45
45
  # Example resource route with concerns:
46
46
  # concern :toggleable do
47
47
  # post 'toggle'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  class DispatcherTestConsumer < Msgr::Consumer
@@ -8,13 +9,13 @@ end
8
9
 
9
10
  class DispatcherRaiseConsumer < Msgr::Consumer
10
11
  def index
11
- raise ArgumentError, 'Not happy with the payload'
12
+ raise ArgumentError.new('Not happy with the payload')
12
13
  end
13
14
  end
14
15
 
15
16
  describe Msgr::Dispatcher do
16
17
  let(:dispatcher) { described_class.new config }
17
- let(:config) { { max: 1 } }
18
+ let(:config) { {max: 1} }
18
19
  let(:consumer) { 'DispatcherTestConsumer' }
19
20
  let(:route) do
20
21
  double(:route).tap do |t|
@@ -28,8 +29,8 @@ describe Msgr::Dispatcher do
28
29
  end
29
30
  end
30
31
  let(:delivery_info) do
31
- double(:delivery_info).tap do |ti|
32
- allow(ti).to receive(:delivery_tag).and_return(3)
32
+ double(:delivery_info).tap do |ti|
33
+ allow(ti).to receive(:delivery_tag).and_return(3)
33
34
  end
34
35
  end
35
36
  let(:payload) { {} }
@@ -39,7 +40,7 @@ describe Msgr::Dispatcher do
39
40
  end
40
41
  end
41
42
  let(:message) { Msgr::Message.new connection, delivery_info, metadata, payload, route }
42
- let(:action) { -> { dispatcher.call message }}
43
+ let(:action) { -> { dispatcher.call message } }
43
44
 
44
45
  it 'should consume message' do
45
46
  expect_any_instance_of(DispatcherTestConsumer).to receive(:index)
@@ -1,7 +1,7 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Msgr::Railtie do
4
-
5
5
  describe 'configuration options' do
6
6
  let(:config) { Rails.configuration }
7
7
 
@@ -19,32 +19,32 @@ describe Msgr::Railtie do
19
19
  subject { -> { action } }
20
20
 
21
21
  context 'with config without url' do
22
- let(:settings) { {"test" => { hans: 'otto'}} }
22
+ let(:settings) { {'test' => {hans: 'otto'}} }
23
23
 
24
24
  it { should raise_error 'Could not load rabbitmq environment config: URI missing.' }
25
25
  end
26
26
 
27
27
  context 'with invalid autostart value' do
28
- let(:settings) { {"test" => { uri: 'hans', autostart: 'unvalid'}} }
28
+ let(:settings) { {'test' => {uri: 'hans', autostart: 'unvalid'}} }
29
29
 
30
- it { should raise_error 'Invalid value for rabbitmq config autostart: "unvalid"'}
30
+ it { should raise_error 'Invalid value for rabbitmq config autostart: "unvalid"' }
31
31
  end
32
32
 
33
33
  context 'with invalid checkcredentials value' do
34
- let(:settings) { {"test" => { uri: 'hans', checkcredentials: 'unvalid'}} }
34
+ let(:settings) { {'test' => {uri: 'hans', checkcredentials: 'unvalid'}} }
35
35
 
36
- it { should raise_error 'Invalid value for rabbitmq config checkcredentials: "unvalid"'}
36
+ it { should raise_error 'Invalid value for rabbitmq config checkcredentials: "unvalid"' }
37
37
  end
38
38
 
39
39
  context 'with invalid raise_exceptions value' do
40
- let(:settings) { {"test" => { uri: 'franz', raise_exceptions: 'unvalid'}} }
40
+ let(:settings) { {'test' => {uri: 'franz', raise_exceptions: 'unvalid'}} }
41
41
 
42
- it { should raise_error 'Invalid value for rabbitmq config raise_exceptions: "unvalid"'}
42
+ it { should raise_error 'Invalid value for rabbitmq config raise_exceptions: "unvalid"' }
43
43
  end
44
44
  end
45
45
 
46
46
  context 'without set routes file' do
47
- let(:settings) { {"test" => { uri: 'test'}} }
47
+ let(:settings) { {'test' => {uri: 'test'}} }
48
48
 
49
49
  context '[:routing_file]' do
50
50
  subject { super()[:routing_file] }
@@ -53,7 +53,7 @@ describe Msgr::Railtie do
53
53
  end
54
54
 
55
55
  context 'with set routes file' do
56
- let(:settings) { {"test" => { uri: 'test', 'routing_file' => 'my fancy file' }} }
56
+ let(:settings) { {'test' => {uri: 'test', 'routing_file' => 'my fancy file'}} }
57
57
 
58
58
  context '[:routing_file]' do
59
59
  subject { super()[:routing_file] }
@@ -62,7 +62,7 @@ describe Msgr::Railtie do
62
62
  end
63
63
 
64
64
  context 'with uri as symbol' do
65
- let(:settings) { {"test" => { uri: "hans"}}}
65
+ let(:settings) { {'test' => {uri: 'hans'}} }
66
66
 
67
67
  context '[:uri]' do
68
68
  subject { super()[:uri] }
@@ -71,7 +71,7 @@ describe Msgr::Railtie do
71
71
  end
72
72
 
73
73
  context 'with uri as string' do
74
- let(:settings) { {"test" => { 'uri' => "hans"}}}
74
+ let(:settings) { {'test' => {'uri' => 'hans'}} }
75
75
 
76
76
  context '[:uri]' do
77
77
  subject { super()[:uri] }
@@ -80,7 +80,7 @@ describe Msgr::Railtie do
80
80
  end
81
81
 
82
82
  context 'without raise_exceptions config' do
83
- let(:settings) { {"test" => { 'uri' => 'hans'}, "development" => { 'uri' => 'hans_dev'}}}
83
+ let(:settings) { {'test' => {'uri' => 'hans'}, 'development' => {'uri' => 'hans_dev'}} }
84
84
 
85
85
  describe '[:raise_exceptions]' do
86
86
  subject { super()[:raise_exceptions] }
@@ -92,14 +92,14 @@ describe Msgr::Railtie do
92
92
  describe '#load' do
93
93
  let(:config) do
94
94
  cfg = ActiveSupport::OrderedOptions.new
95
- cfg.rabbitmq_config = Rails.root.join *%w(config rabbitmq.yml)
95
+ cfg.rabbitmq_config = Rails.root.join 'config', 'rabbitmq.yml'
96
96
  cfg
97
97
  end
98
98
 
99
99
  context 'with autostart is true' do
100
100
  it 'should not start Msgr' do
101
101
  expect(Msgr).to receive(:start)
102
- expect(Msgr::Railtie).to receive(:load_config).and_return({ "test" => { uri: 'test', autostart: true} })
102
+ expect(Msgr::Railtie).to receive(:load_config).and_return('test' => {uri: 'test', autostart: true})
103
103
  Msgr::Railtie.load config
104
104
  end
105
105
  end
@@ -107,7 +107,7 @@ describe Msgr::Railtie do
107
107
  context 'without autostart value' do
108
108
  it 'should not start Msgr' do
109
109
  expect(Msgr).to_not receive(:start)
110
- expect(Msgr::Railtie).to receive(:load_config).and_return({ "test" => { uri: 'test' } })
110
+ expect(Msgr::Railtie).to receive(:load_config).and_return('test' => {uri: 'test'})
111
111
  Msgr::Railtie.load config
112
112
  end
113
113
  end
@@ -115,7 +115,7 @@ describe Msgr::Railtie do
115
115
  context 'without checkcredentials value' do
116
116
  it 'should connect to rabbitmq directly to check credentials' do
117
117
  expect_any_instance_of(Msgr::Client).to receive(:connect)
118
- expect(Msgr::Railtie).to receive(:load_config).and_return({ "test" => { uri: 'test' } })
118
+ expect(Msgr::Railtie).to receive(:load_config).and_return('test' => {uri: 'test'})
119
119
  Msgr::Railtie.load config
120
120
  end
121
121
  end
@@ -123,7 +123,7 @@ describe Msgr::Railtie do
123
123
  context 'with checkcredentials is false' do
124
124
  it 'should connect to rabbitmq directly to check credentials' do
125
125
  expect_any_instance_of(Msgr::Client).to_not receive(:connect)
126
- expect(Msgr::Railtie).to receive(:load_config).and_return({ "test" => { uri: 'test', checkcredentials: false } })
126
+ expect(Msgr::Railtie).to receive(:load_config).and_return('test' => {uri: 'test', checkcredentials: false})
127
127
  Msgr::Railtie.load config
128
128
  end
129
129
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe TestController, type: :request do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Bundler setup
2
3
  require 'bundler'
3
4
  Bundler.require :default, :test, :rails
@@ -16,14 +17,13 @@ require 'rspec/rails'
16
17
 
17
18
  # Requires supporting ruby files with custom matchers and macros, etc,
18
19
  # in spec/support/ and its subdirectories.
19
- Dir[File.expand_path('../support/**/*.rb', __FILE__)].each { |f| require f }
20
+ Dir[File.expand_path('../support/**/*.rb', __FILE__)].each {|f| require f }
20
21
 
21
22
  # Checks for pending migrations before tests are run.
22
23
  # If you are not using ActiveRecord, you can remove this line.
23
24
  ActiveRecord::Migration.check_pending! if defined?(ActiveRecord::Migration) && Rails::VERSION::MAJOR >= 4
24
25
 
25
26
  RSpec.configure do |config|
26
-
27
27
  # If you're not using ActiveRecord, or you'd prefer not to run each of your
28
28
  # examples within a transaction, remove the following line or assign false
29
29
  # instead of true.
@@ -1,7 +1,7 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Msgr::Connection do
4
-
5
5
  describe '#rebind' do
6
6
  let(:conn) { double }
7
7
  let(:routes) { Msgr::Routes.new }
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  # describe Msgr::Consumer do
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Msgr::Route do
@@ -9,27 +10,27 @@ describe Msgr::Route do
9
10
 
10
11
  describe '#initialize' do
11
12
  it 'should require `to` option' do
12
- expect {
13
+ expect do
13
14
  Msgr::Route.new(routing_key, {})
14
- }.to raise_error(ArgumentError)
15
+ end.to raise_error(ArgumentError)
15
16
  end
16
17
 
17
18
  it 'should require routing_key' do
18
- expect {
19
+ expect do
19
20
  Msgr::Route.new nil, options
20
- }.to raise_error(ArgumentError)
21
+ end.to raise_error(ArgumentError)
21
22
  end
22
23
 
23
24
  it 'should require not empty routing_key' do
24
- expect {
25
+ expect do
25
26
  Msgr::Route.new '', options
26
- }.to raise_error ArgumentError, /routing key required/i
27
+ end.to raise_error ArgumentError, /routing key required/i
27
28
  end
28
29
 
29
30
  it 'should require `to: "consumer#action` format' do
30
- expect {
31
+ expect do
31
32
  Msgr::Route.new routing_key, to: 'abc'
32
- }.to raise_error ArgumentError, /invalid consumer format/i
33
+ end.to raise_error ArgumentError, /invalid consumer format/i
33
34
  end
34
35
  end
35
36
 
@@ -1,10 +1,11 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  describe Msgr::Routes do
4
5
  let(:routes) { Msgr::Routes.new }
5
6
 
6
7
  describe '#configure' do
7
- let(:block) { Proc.new{} }
8
+ let(:block) { proc {} }
8
9
 
9
10
  it 'should evaluate given block within instance context' do
10
11
  expect(routes).to receive(:instance_eval) do |&p|
@@ -47,7 +48,7 @@ describe Msgr::Routes do
47
48
  let(:last_route) { routes.routes.last }
48
49
 
49
50
  it 'should add a new route' do
50
- expect { subject.call }.to change{ routes.routes.size }.from(0).to(1)
51
+ expect { subject.call }.to change { routes.routes.size }.from(0).to(1)
51
52
  end
52
53
 
53
54
  it 'should add given route' do
@@ -60,14 +61,14 @@ describe Msgr::Routes do
60
61
 
61
62
  context 'with same target' do
62
63
  let(:subject) do
63
- -> do
64
+ lambda do
64
65
  routes.route 'routing.key', to: 'test#index'
65
66
  routes.route 'another.routing.key', to: 'test#index'
66
67
  end
67
68
  end
68
69
 
69
70
  it 'should only add one new route' do
70
- expect { subject.call }.to change{ routes.routes.size }.from(0).to(1)
71
+ expect { subject.call }.to change { routes.routes.size }.from(0).to(1)
71
72
  end
72
73
 
73
74
  it 'should add second binding to first route' do
@@ -87,7 +88,7 @@ describe Msgr::Routes do
87
88
  end
88
89
 
89
90
  describe 'reload' do
90
- before { File.stub(:exists?).and_return(true) }
91
+ before { File.stub(:exist?).and_return(true) }
91
92
 
92
93
  it 'should trigger load for all files' do
93
94
  expect(routes).to receive(:load).with('cde.rb').ordered
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'spec_helper'
2
3
 
3
4
  class Receiver
@@ -36,7 +37,7 @@ describe Msgr do
36
37
 
37
38
  client.publish 'Payload', to: 'test.index'
38
39
 
39
- Timeout::timeout(4) { queue.pop }
40
+ Timeout.timeout(4) { queue.pop }
40
41
  end
41
42
 
42
43
  it 'should redelivery failed messages' do
@@ -45,6 +46,6 @@ describe Msgr do
45
46
 
46
47
  client.publish 'Payload', to: 'test.error'
47
48
 
48
- Timeout::timeout(4) { queue.pop }
49
+ Timeout.timeout(4) { queue.pop }
49
50
  end
50
51
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  # Bundler setup
2
3
  require 'bundler'
3
4
  Bundler.setup :default, :test
@@ -10,7 +11,7 @@ end
10
11
 
11
12
  require 'msgr'
12
13
 
13
- Dir[File.expand_path('../support/**/*.rb', __FILE__)].each { |f| require f }
14
+ Dir[File.expand_path('../support/**/*.rb', __FILE__)].each {|f| require f }
14
15
 
15
16
  RSpec.configure do |config|
16
17
  config.order = 'random'
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require 'bundler'
2
3
 
3
4
  # Somewhere between
@@ -16,7 +17,7 @@ require 'bundler'
16
17
 
17
18
  module Bundler
18
19
  class << self
19
- alias :old_setup :setup
20
+ alias old_setup setup
20
21
  def setup(*groups)
21
22
  old_setup(*groups) unless groups.empty?
22
23
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: msgr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.14.1.1.b125
4
+ version: 0.14.1.1.b126
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Graichen
@@ -80,6 +80,7 @@ extensions: []
80
80
  extra_rdoc_files: []
81
81
  files:
82
82
  - ".gitignore"
83
+ - ".rubocop.yml"
83
84
  - ".travis.yml"
84
85
  - CHANGELOG.md
85
86
  - Gemfile