msgr 0.15.0.1.b136 → 0.15.0.1.b139

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: 2a04f6da157c82653ba50c5d81741fd32b897db3
4
- data.tar.gz: 1aeebed739de7c091fcc6e8ab5fd5b8d81e0022f
3
+ metadata.gz: dc6380bab1ce06ee0a36d47942d9a6c3fa56efb5
4
+ data.tar.gz: 92bb7ec6e91aeb2edab35d1b1af12aa0097de34c
5
5
  SHA512:
6
- metadata.gz: 567bea8bc94f5d70aa6796d0f11a17d21545327698ad99a82875b7ea62b5ff2d53e344d0b058b18b8f2ef2203f20091ae83e83b73334475799a54b25f9a27043
7
- data.tar.gz: a1274b7044da7ace1fa3927bff548ed01f7496833e0d14a0ab309c496fe22921cd78f437539093b09af53495bf7acd253d73e46a6ad03bc0efc9b7a7757a86a1
6
+ metadata.gz: 2653a9e0db967ccdd1a4869c77f645ddca8bfffa6961edb3c1d8837462bf237bfcf5671f27f438121d827a0f75a65a1ca5a4ea7409c55dada63997f7c0bc5e1a
7
+ data.tar.gz: 8546dffaf7a57db1bc58bb531f66d884a04cb3f97018b4061f4f19b31c70864e8109734781e658b85a73bb67ec105232ce6801911e0b29d10bbd85198d39e25d
@@ -18,6 +18,8 @@ script:
18
18
  - bundle exec rake spec:integration
19
19
 
20
20
  jobs:
21
+ allow_failures:
22
+ - gemfile: gemfiles/Gemfile.rails-master
21
23
  include:
22
24
  - stage: Beta release
23
25
  rvm: '2.4.1'
data/Gemfile CHANGED
@@ -1,23 +1,25 @@
1
+ # frozen_string_literal: true
2
+
1
3
  source 'https://rubygems.org'
2
4
 
3
5
  # Development gems
4
6
  #
7
+ gem 'coveralls'
8
+ gem 'fuubar'
5
9
  gem 'rake'
6
10
  gem 'rspec', '~> 3.0'
7
- gem 'fuubar'
8
- gem 'coveralls'
9
11
 
10
12
  # Doc
11
13
  group :development do
12
- gem 'yard', '~> 0.9.8'
13
- gem 'listen'
14
- gem 'guard-yard'
15
14
  gem 'guard-rspec'
15
+ gem 'guard-yard'
16
+ gem 'listen'
16
17
  gem 'redcarpet'
18
+ gem 'yard', '~> 0.9.8'
17
19
  end
18
20
 
19
21
  group :rails do
20
- gem 'rails', '>= 3.2'
22
+ gem 'rails', '>= 3.2' unless $RAILS
21
23
  gem 'rspec-rails'
22
24
  gem 'sqlite3'
23
25
  end
@@ -5,3 +5,9 @@ self.instance_eval Bundler.read_file 'Gemfile'
5
5
 
6
6
  gem 'activesupport', git: 'https://github.com/rails/rails'
7
7
  gem 'bunny', ENV['BUNNY_VERSION'] if ENV['BUNNY_VERSION']
8
+
9
+ group :rails do
10
+ $RAILS = true
11
+ gem 'rails', '>= 3.2', git: 'https://github.com/rails/rails'
12
+ gem 'arel', git: 'https://github.com/rails/arel'
13
+ end
@@ -1,25 +1,25 @@
1
1
  # frozen_string_literal: true
2
+
3
+ require 'uri'
4
+ require 'cgi'
5
+
2
6
  module Msgr
3
7
  # rubocop:disable Metrics/ClassLength
4
8
  class Client
5
9
  include Logging
6
- attr_reader :uri, :config
7
10
 
8
- # rubocop:disable Metrics/AbcSize
9
- # rubocop:disable Metrics/MethodLength
10
- def initialize(config = {})
11
- @uri = ::URI.parse config[:uri] ? config.delete(:uri) : 'amqp://localhost/'
12
- config[:pass] ||= @uri.password
11
+ attr_reader :config
13
12
 
14
- @uri.user = config[:user] ||= @uri.user || 'guest'
15
- @uri.scheme = (config[:ssl] ||= @uri.scheme.to_s.casecmp('amqps').zero?) ? 'amqps' : 'amqp'
16
- @uri.host = config[:host] ||= @uri.host || '127.0.0.1'
17
- @uri.port = config[:port] ||= @uri.port
18
- @uri.path = config[:vhost] ||= @uri.path.present? ? @uri.path : '/'
19
- config.reject! {|_, v| v.nil? }
13
+ # rubocop:disable MethodLength
14
+ def initialize(config = {})
15
+ @config = {
16
+ host: '127.0.0.1',
17
+ vhost: '/',
18
+ max: 2
19
+ }
20
20
 
21
- @config = config
22
- @config[:max] ||= 2
21
+ @config.merge! parse(config.delete(:uri)) if config.key?(:uri)
22
+ @config.merge! config.symbolize_keys
23
23
 
24
24
  @mutex = ::Mutex.new
25
25
  @routes = Routes.new
@@ -27,6 +27,30 @@ module Msgr
27
27
 
28
28
  log(:debug) { "Created new client on process ##{@pid}..." }
29
29
  end
30
+ # rubocop:enable all
31
+
32
+ # rubocop:disable AbcSize
33
+ # rubocop:disable MethodLength
34
+ # rubocop:disable PerceivedComplexity
35
+ # rubocop:disable CyclomaticComplexity
36
+ def uri
37
+ @uri = begin
38
+ uri = ::URI.parse('amqp://localhost')
39
+
40
+ uri.user = CGI.escape(config[:user]) if config.key?(:user)
41
+ uri.password = '****' if config.key?(:pass)
42
+ uri.host = config[:host] if config.key?(:host)
43
+ uri.port = config[:port] if config.key?(:port)
44
+ uri.scheme = config[:ssl] ? 'amqps' : 'amqp'
45
+
46
+ if config.key?(:vhost) && config[:vhost] != '/'
47
+ uri.path = "/#{CGI.escape(config[:vhost])}"
48
+ end
49
+
50
+ uri
51
+ end
52
+ end
53
+ # rubocop:enable all
30
54
 
31
55
  def running?
32
56
  mutex.synchronize do
@@ -35,6 +59,7 @@ module Msgr
35
59
  end
36
60
  end
37
61
 
62
+ # rubocop:disable AbcSize
38
63
  def start
39
64
  mutex.synchronize do
40
65
  check_process!
@@ -47,6 +72,7 @@ module Msgr
47
72
  connection.bind(@routes)
48
73
  end
49
74
  end
75
+ # rubocop:enable all
50
76
 
51
77
  def connect
52
78
  mutex.synchronize do
@@ -59,6 +85,7 @@ module Msgr
59
85
  end
60
86
  end
61
87
 
88
+ # rubocop:disable AbcSize
62
89
  def stop(opts = {})
63
90
  mutex.synchronize do
64
91
  check_process!
@@ -73,6 +100,7 @@ module Msgr
73
100
  reset
74
101
  end
75
102
  end
103
+ # rubocop:enable all
76
104
 
77
105
  def purge(release: false)
78
106
  mutex.synchronize do
@@ -155,5 +183,23 @@ module Msgr
155
183
  @bindings = nil
156
184
  @dispatcher = nil
157
185
  end
186
+
187
+ # rubocop:disable AbcSize
188
+ def parse(uri)
189
+ # Legacy parsing of URI configuration; does not follow usual
190
+ # AMQP vhost encoding but used regular URL path
191
+ uri = ::URI.parse(uri)
192
+
193
+ config = {}
194
+ config[:user] ||= uri.user if uri.user
195
+ config[:pass] ||= uri.password if uri.password
196
+ config[:host] ||= uri.host if uri.host
197
+ config[:port] ||= uri.port if uri.port
198
+ config[:vhost] ||= uri.path if uri.path
199
+ config[:ssl] ||= uri.scheme.casecmp('amqps').zero?
200
+
201
+ config
202
+ end
203
+ # rubocop:enable all
158
204
  end
159
205
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: msgr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.15.0.1.b136
4
+ version: 0.15.0.1.b139
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jan Graichen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-20 00:00:00.000000000 Z
11
+ date: 2017-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport