ruby_rabbitmq_janus 2.6.0.pre.238 → 2.6.0.pre.239

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: efde12f76763a47d2ab00dc286e8c3c0b9802012db3c6863b03804afa02d654c
4
- data.tar.gz: 6657d907ecb53eaa105b7124d27953b7910a2357a2768b3a7fb50896fa4b3bf1
3
+ metadata.gz: d9a36af6916660c564b4874d7aaf410df1a4a0885a68ad644acc562c76affe99
4
+ data.tar.gz: 3d70e4fb0ad83d810d49e11a2a8454d3b9710fa84ac7c749b6b07c8b0246ccf5
5
5
  SHA512:
6
- metadata.gz: a2ebbde4eadfa93afa908652731b8a034aab1110b8d24d06ff4c2bd49ac63dcee3db84e46408f4c55132df8cd57b3a7645c009253fd2704cb4ef843dc9aa772c
7
- data.tar.gz: 49df1efc0995b3484946384b279aa212182229438a683c6043daefbacacb5f0cf4a95884ded476c2d9c4b5ad6c3b649f63eded86d1113253c9bb6498b806da2c
6
+ metadata.gz: 74264999b596be0f8a5dc2488c74835bb2fd55eba263d004c046825de443d637881399a46b310c612f496c5839beb834dafdbce2a9955de854f1bd653aac498e
7
+ data.tar.gz: 9b5a311f94382e03730075d9624768d7fc03ae9b3c35118afe92076e595715cf7b2c4740629bea22964411bdba978b78728cbbefbf31d6b94bf4a6a90093ea0f
data/config/default.md CHANGED
@@ -13,6 +13,7 @@ rabbit:
13
13
  pass: guest
14
14
  admin_pass: janusoverlord
15
15
  level: :info
16
+ test: false
16
17
 
17
18
  queues:
18
19
  standard:
data/config/default.yml CHANGED
@@ -14,6 +14,8 @@ rabbit:
14
14
  admin_pass: janusoverlord
15
15
  # Logger level for rabbitmq message
16
16
  level: info
17
+ # Test execution (with rspec ...)
18
+ test: false
17
19
 
18
20
  # RabbitMQ Queue information
19
21
  queues:
@@ -56,6 +56,12 @@ module RubyRabbitmqJanus
56
56
  end
57
57
  end
58
58
 
59
+ class RabbitTester < RubyRabbitmqJanus::Errors::Tools::BaseConfig
60
+ def initialize
61
+ super '[RabbitTester] Error for reading option rabbitmq tester', :warn
62
+ end
63
+ end
64
+
59
65
  class TimeToLive < RubyRabbitmqJanus::Errors::Tools::BaseConfig
60
66
  def initialize
61
67
  super '[TimeToLive] Keepalive TTL option is not reading in config file', :warn
data/lib/rrj/init.rb CHANGED
@@ -14,9 +14,6 @@ require 'erb'
14
14
 
15
15
  # Primary module for this gem
16
16
  module RubyRabbitmqJanus
17
- # Constant used for checked if execution it's with RSpec
18
- RRJ_RSPEC = false
19
-
20
17
  # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
21
18
 
22
19
  # # RubyRabbitmqJanus - RRJ
@@ -10,9 +10,12 @@ module RubyRabbitmqJanus
10
10
  class Connect
11
11
  # Initialize connection to server RabbitMQ
12
12
  def initialize
13
- @rabbit = if RubyRabbitmqJanus::RRJ_RSPEC
13
+ @rabbit = if Tools::Config.instance.tester?
14
+ require 'bunny-mock'
15
+ p 'Connect to fake rabbitmq'
14
16
  BunnyMock.new.start
15
17
  else
18
+ p 'Connect to rabbitmq'
16
19
  Bunny.new(read_options_server.merge!(option_log_rabbit))
17
20
  end
18
21
  rescue => exception
@@ -21,7 +24,7 @@ module RubyRabbitmqJanus
21
24
 
22
25
  # Create an transaction with rabbitmq and close after response is received
23
26
  def transaction_short
24
- response = if RubyRabbitmqJanus::RRJ_RSPEC
27
+ response = if Tools::Config.instance.tester?
25
28
  fake_transaction
26
29
  else
27
30
  transaction_long { yield }
@@ -35,7 +38,7 @@ module RubyRabbitmqJanus
35
38
  # Create an transaction with rabbitmq and not close
36
39
  def transaction_long
37
40
  start
38
- if RubyRabbitmqJanus::RRJ_RSPEC
41
+ if Tools::Config.instance.tester?
39
42
  @rabbit.channel.queue.pop[:message]
40
43
  else
41
44
  yield
@@ -60,7 +63,7 @@ module RubyRabbitmqJanus
60
63
 
61
64
  # Create an channel
62
65
  def channel
63
- if RubyRabbitmqJanus::RRJ_RSPEC
66
+ if Tools::Config.instance.tester?
64
67
  @rabbit.channel
65
68
  else
66
69
  @rabbit.create_channel
data/lib/rrj/rspec.rb CHANGED
@@ -1,11 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bunny-mock'
4
-
5
3
  module RubyRabbitmqJanus
6
- # Specify RSpec is used when gem is instantiate
7
- RRJ_RSPEC = true
8
-
9
4
  # # RRJRSpec
10
5
  #
11
6
  # Initializer to use with RSpec execution
@@ -6,12 +6,14 @@
6
6
  require 'rrj/info'
7
7
  require 'ruby_rabbitmq_janus'
8
8
 
9
+ # rubocop:disable Naming/ConstantName
9
10
  ::Log = if @logger_default
10
11
  RubyRabbitmqJanus::Tools::Log.instance
11
12
  else
12
13
  require_relative @logger_path
13
14
  @logger_class.constantize.instance
14
15
  end
16
+ # rubocop:enable Naming/ConstantName
15
17
 
16
18
  Log.info "RRJ Version : #{RubyRabbitmqJanus::VERSION}"
17
19
  Log.info RubyRabbitmqJanus::BANNER
@@ -92,12 +92,20 @@ module RubyRabbitmqJanus
92
92
  raise Errors::Tools::Config::LogLevel
93
93
  end
94
94
 
95
+ # @return [Symbol] read configuration for bunny log level
95
96
  def log_level_rabbit
96
97
  @options['rabbit']['level'].upcase.to_sym || :INFO
97
98
  rescue
98
99
  raise Errors::Tools::Config::LogLevelRabbit
99
100
  end
100
101
 
102
+ # @return [Boolean] read configuration for bunny execution
103
+ def tester?
104
+ @options['rabbit']['test'].to_s.match?('true') ? true : false
105
+ rescue
106
+ raise Errors::Tools::Config::RabbitTester
107
+ end
108
+
101
109
  # @return [Integer]
102
110
  # read configuration for janus time to live for keepalive messages
103
111
  def time_to_live
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_rabbitmq_janus
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.6.0.pre.238
4
+ version: 2.6.0.pre.239
5
5
  platform: ruby
6
6
  authors:
7
7
  - VAILLANT Jeremy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-02 00:00:00.000000000 Z
11
+ date: 2019-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord