ruby_rabbitmq_janus 1.1.8 → 1.1.9

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 (70) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +14 -0
  3. data/config/default.yml +5 -3
  4. data/config/requests/channel/README.md +29 -0
  5. data/config/requests/channel/answer.json +13 -0
  6. data/config/requests/channel/create.json +9 -0
  7. data/config/requests/channel/describe.json +10 -0
  8. data/config/requests/channel/destroy.json +10 -0
  9. data/config/requests/channel/exists.json +10 -0
  10. data/config/requests/channel/join.json +11 -0
  11. data/config/requests/channel/leave.json +11 -0
  12. data/config/requests/channel/list.json +9 -0
  13. data/config/requests/channel/offer.json +14 -0
  14. data/config/requests/channel/select.json +11 -0
  15. data/config/requests/channel/trickle.json +10 -0
  16. data/config/requests/peer/trickle.json +7 -0
  17. data/config/requests/videocast/join.json +12 -0
  18. data/config/requests/videocast/leave.json +11 -0
  19. data/config/ruby-rabbitmq-janus.yml +27 -0
  20. data/lib/generators/ruby_rabbitmq_janus/initializer_generator.rb +15 -24
  21. data/lib/generators/ruby_rabbitmq_janus/install_generator.rb +49 -0
  22. data/lib/rrj/info.rb +1 -1
  23. data/lib/rrj/init.rb +0 -2
  24. data/lib/rrj/rabbit/publish/listener.rb +38 -12
  25. data/lib/rrj/tools/config.rb +10 -6
  26. data/lib/rrj/tools/log.rb +5 -5
  27. data/spec/request/admin/request_handle_info_spec.rb +13 -0
  28. data/spec/request/admin/request_sessions_spec.rb +12 -0
  29. data/spec/request/base/request_attach_spec.rb +25 -0
  30. data/spec/request/base/request_create_spec.rb +17 -0
  31. data/spec/request/base/request_destroy_spec.rb +17 -0
  32. data/spec/request/base/request_detach_spec.rb +23 -0
  33. data/spec/request/base/request_info_spec.rb +17 -0
  34. data/spec/request/base/request_keepalive_spec.rb +17 -0
  35. data/spec/request/peer/request_trickle_spec.rb +42 -0
  36. data/spec/rrj/rrj_config_spec.rb +10 -0
  37. data/spec/rrj/rrj_log_spec.rb +21 -0
  38. data/spec/rrj/rrj_rabbitmq_spec.rb +18 -0
  39. data/spec/rrj/rrj_spec.rb +25 -0
  40. data/spec/spec_helper.rb +53 -0
  41. data/spec/support/aruba.rb +3 -0
  42. data/spec/support/examples.rb +83 -0
  43. data/spec/support/examples_peer.rb +18 -0
  44. data/spec/support/schemas/config/config.json +101 -0
  45. data/spec/support/schemas/config/rabbit.json +13 -0
  46. data/spec/support/schemas/request/admin/handle_info.json +17 -0
  47. data/spec/support/schemas/request/admin/sessions.json +13 -0
  48. data/spec/support/schemas/request/base/attach.json +19 -0
  49. data/spec/support/schemas/request/base/create.json +17 -0
  50. data/spec/support/schemas/request/base/destroy.json +13 -0
  51. data/spec/support/schemas/request/base/detach.json +13 -0
  52. data/spec/support/schemas/request/base/info.json +25 -0
  53. data/spec/support/schemas/request/base/keepalive.json +13 -0
  54. data/spec/support/schemas/request/channel/create.json +39 -0
  55. data/spec/support/schemas/request/channel/destroy.json +39 -0
  56. data/spec/support/schemas/request/channel/exist.json +41 -0
  57. data/spec/support/schemas/request/channel/list.json +37 -0
  58. data/spec/support/schemas/request/peer/trickle.json +21 -0
  59. metadata +57 -32
  60. data/.gitignore +0 -77
  61. data/.overcommit.yml +0 -12
  62. data/.reek +0 -7
  63. data/.rspec +0 -2
  64. data/.rubocop.yml +0 -12
  65. data/.travis.yml +0 -5
  66. data/.yardopts +0 -5
  67. data/CHANGELOG.md +0 -27
  68. data/CODE_OF_CONDUCT.md +0 -49
  69. data/README.md +0 -177
  70. data/rrj.gemspec +0 -41
@@ -9,14 +9,18 @@ module RubyRabbitmqJanus
9
9
 
10
10
  attr_reader :options
11
11
 
12
- # Define a default path to file configuration
13
- DEFAULT_PATH = File.realpath(File.join(File.dirname(__FILE__), '..', '..'))
12
+ # Define HOME RRJ
13
+ RRJ_HOME = File.realpath(File.join(File.dirname(__FILE__),
14
+ '..', '..', '..'))
14
15
 
15
16
  # Define a default name to file configuration
16
- DEFAULT_CONF = 'config/default.yml'
17
+ CONF_DEFAULT = 'config/default.yml'
17
18
 
18
19
  # Define a default override file configuration
19
- CUSTOMIZE_CONF = 'config/ruby-rabbitmq-janus.yml'
20
+ CONF_CUSTOM = 'config/ruby-rabbitmq-janus.yml'
21
+
22
+ # Define a default path to file configuration
23
+ PATH_DEFAULT = File.join(RRJ_HOME, CONF_DEFAULT)
20
24
 
21
25
  # Initialize configuration file default or customize if exist
22
26
  def initialize
@@ -40,13 +44,13 @@ module RubyRabbitmqJanus
40
44
 
41
45
  # Load customize configuration file if exist
42
46
  def conf_customize
43
- file = File.join(Dir.pwd, CUSTOMIZE_CONF)
47
+ file = File.join(Dir.pwd, CONF_CUSTOM)
44
48
  @options = load_configuration(file) if File.exist?(file)
45
49
  end
46
50
 
47
51
  # Load default configuration if customize configuration doesn't exist
48
52
  def conf_default
49
- file = File.join(DEFAULT_PATH, DEFAULT_CONF)
53
+ file = PATH_DEFAULT
50
54
  @options ||= load_configuration(file)
51
55
  end
52
56
 
data/lib/rrj/tools/log.rb CHANGED
@@ -40,31 +40,31 @@ module RubyRabbitmqJanus
40
40
  # Write a message in log with a FATAL level
41
41
  # @param message [String] Message writing in warning level in log
42
42
  def fatal(message)
43
- write_tag { @logs.fatal(message.red) } if test_level?(Logger::FATAL)
43
+ write_tag { @logs.fatal(message) } if test_level?(Logger::FATAL)
44
44
  end
45
45
 
46
46
  # Write a message in log with a ERROR level
47
47
  # @param message [String] Message writing in warning level in log
48
48
  def error(message)
49
- write_tag { @logs.error(message.orange) } if test_level?(Logger::ERROR)
49
+ write_tag { @logs.error(message) } if test_level?(Logger::ERROR)
50
50
  end
51
51
 
52
52
  # Write a message in log with a warn level
53
53
  # @param message [String] Message writing in warning level in log
54
54
  def warn(message)
55
- write_tag { @logs.warn(message.yellow) } if test_level?(Logger::WARN)
55
+ write_tag { @logs.warn(message) } if test_level?(Logger::WARN)
56
56
  end
57
57
 
58
58
  # Write a message in log with a info level
59
59
  # @param message [String] Message writing in info level in log
60
60
  def info(message)
61
- write_tag { @logs.info(message.green) } if test_level?(Logger::INFO)
61
+ write_tag { @logs.info(message) } if test_level?(Logger::INFO)
62
62
  end
63
63
 
64
64
  # Write a message in log with a debug level
65
65
  # @param message [String] Message writing in debug level in log
66
66
  def debug(message)
67
- write_tag { @logs.debug(message.light_blue) } if test_level?(Logger::DEBUG)
67
+ write_tag { @logs.debug(message) } if test_level?(Logger::DEBUG)
68
68
  end
69
69
 
70
70
  # Return instance logger
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'RubyRabbitmqJanus::RRJ -- message type handle_info' do
6
+ before(:example) { @type = 'admin::handle_info' }
7
+
8
+ describe '#message_admin', type: :request, level: :admin, name: :handle_info do
9
+ include_examples 'message_handle_admin should match json schema'
10
+ end
11
+
12
+ # after(:example) { @gateway.stop_handle }
13
+ end
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'RubyRabbitmqJanus::RRJ -- message type sessions' do
6
+ before(:example) { @type = 'admin::sessions' }
7
+
8
+ describe '#message_admin', type: :request, level: :admin, name: :sessions,
9
+ broken: true do
10
+ include_examples 'message_admin should match json schema'
11
+ end
12
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'RubyRabbitmqJanus::RRJ -- message type attach' do
6
+ before(:example) { @type = 'base::attach' }
7
+
8
+ describe '#message_handle', type: :request, level: :base, name: :attach do
9
+ context 'when queue is exclusive' do
10
+ it_behaves_like 'message_handle should match json schema' do
11
+ let(:replace) { {} }
12
+ let(:add) { {} }
13
+ end
14
+ end
15
+
16
+ context 'when queue is not exclusive' do
17
+ it_behaves_like 'message_handle should match json empty' do
18
+ let(:replace) { {} }
19
+ let(:add) { {} }
20
+ end
21
+ end
22
+ end
23
+
24
+ after(:example) { @gateway.stop_handle }
25
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'RubyRabbitmqJanus::RRJ -- message type create' do
6
+ before(:example) { @type = 'base::create' }
7
+
8
+ describe '#message_simple', type: :request, level: :base, name: :create do
9
+ context 'when queue is exclusive' do
10
+ include_examples 'message_simple should match json schema'
11
+ end
12
+
13
+ context 'when queue is not exclusive' do
14
+ include_examples 'message_simple should match json empty'
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'RubyRabbitmqJanus::RRJ -- message type destroy' do
6
+ before(:example) { @type = 'base::destroy' }
7
+
8
+ describe '#message_session', type: :request, level: :base, name: :destroy do
9
+ context 'when queue is exclusive' do
10
+ include_examples 'message_session should match json schema'
11
+ end
12
+
13
+ context 'when queue is not exclusive' do
14
+ include_examples 'message_session should match json empty'
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'RubyRabbitmqJanus::RRJ -- mesage type detach' do
6
+ before(:example) { @type = 'base::detach' }
7
+
8
+ describe '#message_handle', type: :request, level: :base, name: :detach do
9
+ context 'when queue is exclusive' do
10
+ it_behaves_like 'message_handle should match json schema' do
11
+ let(:replace) { {} }
12
+ let(:add) { {} }
13
+ end
14
+ end
15
+
16
+ context 'when queue is not exclusive' do
17
+ it_behaves_like 'message_handle should match json empty' do
18
+ let(:replace) { {} }
19
+ let(:add) { {} }
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'RubyRabbitmqJanus::RRJ -- message type info' do
6
+ before(:example) { @type = 'base::info' }
7
+
8
+ describe '#message_simple', type: :request, level: :base, name: :info do
9
+ context 'when queue is exclusive' do
10
+ include_examples 'message_simple should match json schema'
11
+ end
12
+
13
+ context 'when queue is not exclusive' do
14
+ include_examples 'message_simple should match json empty'
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'RubyRabbitmqJanus::RRJ -- message type keepalive' do
6
+ before(:example) { @type = 'base::keepalive' }
7
+
8
+ describe '#message_session', type: :request, level: :base, name: :keepalive do
9
+ context 'when queue is exclusive' do
10
+ include_examples 'message_session should match json schema'
11
+ end
12
+
13
+ context 'when queue is not exclusive' do
14
+ include_examples 'message_session should match json empty'
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ # describe 'RubyRabbitmqJanus::RRJ -- message type trickle' do
6
+ describe 'RubyRabbitmqJanus::RRJ -- message type trickle', broken: true do
7
+ before(:example) { @type = 'peer::trickle' }
8
+
9
+ describe '#message_handle', type: :request, level: :peer, name: :trickle do
10
+ let(:cdd) { { 'sdpMid' => 'video', 'sdpMLineIndex' => 1, 'candidate' => '...' } }
11
+ let(:candidate) { { 'candidate' => cdd } }
12
+ let(:candidates) { { 'candidates' => [cdd, cdd] } }
13
+
14
+ context 'when queue is exclusive and send 1 candidate' do
15
+ it_behaves_like 'message_handle should match json schema' do
16
+ let(:replace) { candidate }
17
+ let(:add) { {} }
18
+ end
19
+ end
20
+
21
+ context 'when queue is not exclusive and send 1 candidate' do
22
+ it_behaves_like 'message_handle should match json empty' do
23
+ let(:replace) { candidate }
24
+ let(:add) { {} }
25
+ end
26
+ end
27
+
28
+ context 'when queue is exclusive and send 1 candidate' do
29
+ it_behaves_like 'message_handle should match json schema' do
30
+ let(:replace) { candidates }
31
+ let(:add) { {} }
32
+ end
33
+ end
34
+
35
+ context 'when queue is exclusive and send many candidates' do
36
+ it_behaves_like 'message_handle should match json empty' do
37
+ let(:replace) { candidates }
38
+ let(:add) { {} }
39
+ end
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'RubyRabbitmqJanus::Config', type: :config, name: :config do
6
+ it 'Configuration is corectly loading' do
7
+ expect(RubyRabbitmqJanus::Tools::Config.instance.options).to \
8
+ match_json_schema(:config)
9
+ end
10
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'RubyRabbitmqJanus::Log', type: :config, name: :log do
6
+ it 'Log instance is correctly loading' do
7
+ expect(RubyRabbitmqJanus::Tools::Log.instance).not_to be nil
8
+ end
9
+
10
+ it 'Default level log is DEBUG' do
11
+ # 0 = debug
12
+ # ...
13
+ # 5 = unknown
14
+ expect(RubyRabbitmqJanus::Tools::Log.instance.level).to eq 1
15
+ end
16
+
17
+ it 'Default progname is RubyRabbitmqJanus' do
18
+ expect(RubyRabbitmqJanus::Tools::Log.instance.progname).to \
19
+ eq RubyRabbitmqJanus.name
20
+ end
21
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'RubyRabbitmqJanus::RabitMQ', type: :config, name: :rabbit do
6
+ it 'Start connection with RabbitMQ server' do
7
+ expect(RubyRabbitmqJanus::Rabbit::Connect.new.start.class).to eq Bunny::Session
8
+ end
9
+
10
+ it 'Close connection with RabbitMQ Server' do
11
+ expect(RubyRabbitmqJanus::Rabbit::Connect.new.close).to eq :closed
12
+ end
13
+
14
+ it 'Propertie to message sending in rabbit' do
15
+ expect(RubyRabbitmqJanus::Rabbit::Propertie.new.options).to \
16
+ match_json_schema(:rabbit)
17
+ end
18
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'spec_helper'
4
+
5
+ describe 'RubyRabbitmqJanus::RRJ', type: :config, name: :describe do
6
+ it 'Has a version number' do
7
+ expect(RubyRabbitmqJanus::VERSION).not_to be nil
8
+ end
9
+
10
+ it 'Has a description' do
11
+ expect(RubyRabbitmqJanus::DESCRIPTION).not_to be nil
12
+ end
13
+
14
+ it 'Has a summary description' do
15
+ expect(RubyRabbitmqJanus::SUMMARY).not_to be nil
16
+ end
17
+
18
+ it 'Has a homepage' do
19
+ expect(RubyRabbitmqJanus::HOMEPAGE).not_to be nil
20
+ end
21
+
22
+ it 'Has a post install message' do
23
+ expect(RubyRabbitmqJanus::POST_INSTALL).not_to be nil
24
+ end
25
+ end
@@ -0,0 +1,53 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/setup'
4
+ require 'ruby_rabbitmq_janus'
5
+ require 'pry'
6
+ require 'json-schema-rspec'
7
+
8
+ $LOAD_PATH.unshift File.expand_path('../../lib', __FILE__)
9
+
10
+ Dir['spec/support/**/*.rb'].each do |f|
11
+ require File.expand_path(f)
12
+ end
13
+
14
+ ::Dir.glob(::File.expand_path('../support/**/*.rb', __FILE__)).each do |f|
15
+ require_relative f
16
+ end
17
+
18
+ RSpec.configure do |config|
19
+ config.expect_with :rspec do |c|
20
+ c.syntax = :expect
21
+ end
22
+ config.include Aruba::Api
23
+ config.include JSON::SchemaMatchers
24
+
25
+ # Add JSONs for gem configuration test
26
+ Dir[File.join('spec/support/schemas/config/', '*.json')].count do |file|
27
+ json_file = JSON.parse(File.read(file))
28
+ json_name = File.basename(file, '.json').to_sym
29
+ config.json_schemas[json_name] = json_file
30
+ end
31
+
32
+ # Add JSONs for request result test
33
+ Dir[File.join('spec/support/schemas/request/*/', '*.json')].count do |file|
34
+ json_file = JSON.parse(File.read(file))
35
+ json_type = File.dirname(file).split('/').last
36
+ json_name = File.basename(file, '.json').to_sym
37
+ json_index = "#{json_type}::#{json_name}"
38
+ config.json_schemas[json_index] = json_file
39
+ end
40
+
41
+ # Configure requests test before sending request
42
+ config.before(:example) do
43
+ Singleton.__init__(RubyRabbitmqJanus::Tools::Env)
44
+ Singleton.__init__(RubyRabbitmqJanus::Tools::Log)
45
+ Singleton.__init__(RubyRabbitmqJanus::Tools::Config)
46
+ Singleton.__init__(RubyRabbitmqJanus::Tools::Requests)
47
+ Singleton.__init__(RubyRabbitmqJanus::Janus::Concurrencies::Keepalive)
48
+ @gateway = RubyRabbitmqJanus::RRJ.new
49
+ end
50
+
51
+ # Exclude request with tag broken
52
+ config.filter_run_excluding broken: true
53
+ end
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'aruba/rspec'
@@ -0,0 +1,83 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Simple request
4
+ shared_examples 'message_simple should match json empty' do
5
+ let(:message) { @gateway.message_simple(@type) }
6
+
7
+ it 'should match JSON empty' do
8
+ expect(message.to_json).to eq('{}')
9
+ end
10
+ end
11
+
12
+ shared_examples 'message_simple should match json schema' do
13
+ let(:message) { @gateway.message_simple(@type, true) }
14
+
15
+ it do
16
+ expect(message.to_json).to match_json_schema(@type)
17
+ end
18
+ end
19
+
20
+ # Session request
21
+ shared_examples 'message_session should match json empty' do
22
+ let(:message) { @gateway.message_session(@type, {}, false) }
23
+
24
+ it 'should match JSON empty' do
25
+ expect(message.to_json).to eq('{}')
26
+ end
27
+ end
28
+
29
+ shared_examples 'message_session should match json schema' do
30
+ let(:message) { @gateway.message_session(@type) }
31
+
32
+ it do
33
+ expect(message.to_json).to match_json_schema(@type)
34
+ end
35
+ end
36
+
37
+ # Handle request
38
+ shared_examples 'message_handle should match json schema' do
39
+ let(:replace) { replace }
40
+ let(:add) { add }
41
+ let(:message) { @gateway.message_handle(@type, replace, add) }
42
+
43
+ it do
44
+ @gateway.start_handle(true) do
45
+ expect(message.to_json).to match_json_schema(@type)
46
+ end
47
+ end
48
+ end
49
+
50
+ shared_examples 'message_handle should match json empty' do
51
+ let(:replace) { replace }
52
+ let(:add) { add }
53
+ let(:message) { @gateway.message_handle(@type, replace, add) }
54
+
55
+ it do
56
+ @gateway.start_handle(false) do
57
+ expect(message.to_json).to eq('{}')
58
+ end
59
+ end
60
+ end
61
+
62
+ # Handle admin
63
+ shared_examples 'message_handle_admin should match json schema' do
64
+ let(:message) do
65
+ @gateway.start_handle_admin do
66
+ @gateway.message_handle(@type)
67
+ end
68
+ end
69
+
70
+ it do
71
+ expect(message.to_json).to match_json_schema(@type)
72
+ end
73
+ end
74
+
75
+ shared_examples 'message_admin should match json schema' do
76
+ let(:message) do
77
+ @gateway.message_admin(@type)
78
+ end
79
+
80
+ it do
81
+ expect(message.to_json).to match_json_schema(@type)
82
+ end
83
+ end