evostream-event 1.0.0.pre.59 → 1.0.0.pre.65
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +21 -0
- data/lib/evostream/cli/config.rb +2 -0
- data/lib/evostream/cli/option.rb +5 -84
- data/lib/evostream/cli/option/argument.rb +40 -0
- data/lib/evostream/cli/option/command.rb +24 -0
- data/lib/evostream/cli/option/config.rb +21 -0
- data/lib/evostream/cli/{help → option/help} +0 -0
- data/lib/evostream/cli/option/help.rb +25 -0
- data/lib/evostream/cli/option/host.rb +20 -0
- data/lib/evostream/cli/option/port.rb +20 -0
- data/lib/evostream/cli/option/search.rb +32 -0
- data/lib/evostream/cli/runner.rb +45 -17
- data/lib/evostream/cli/search.rb +12 -3
- data/lib/evostream/event/commands.rb +20 -0
- data/lib/evostream/event/commands/create.rb +2 -0
- data/lib/evostream/event/commands/create/dash.rb +2 -0
- data/lib/evostream/event/commands/create/hls.rb +2 -0
- data/lib/evostream/event/commands/destroy.rb +4 -2
- data/lib/evostream/event/commands/error.rb +14 -0
- data/lib/evostream/event/commands/get_stream_info.rb +2 -0
- data/lib/evostream/event/commands/list_config.rb +2 -0
- data/lib/evostream/event/commands/list_streams.rb +2 -0
- data/lib/evostream/event/commands/push_stream.rb +2 -0
- data/lib/evostream/event/commands/set_log_level.rb +2 -0
- data/spec/cli/argument/command_spec.rb +16 -0
- data/spec/evostream/commands/create_dash_spec.rb +12 -1
- data/spec/evostream/commands/create_hls_spec.rb +25 -14
- data/spec/evostream/commands/create_spec.rb +22 -25
- data/spec/evostream/commands/destroy_spec.rb +4 -5
- data/spec/evostream/commands/get_stream_info_spec.rb +3 -4
- data/spec/evostream/commands/list_stream_spec.rb +2 -3
- data/spec/evostream/commands/push_stream_spec.rb +4 -5
- data/spec/evostream/commands/set_log_level_spec.rb +2 -3
- data/spec/spec_helper.rb +2 -0
- data/spec/support/examples_commands.rb +20 -2
- metadata +12 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 53872935638141a25ff53658fab7e36c55ce7b09
|
4
|
+
data.tar.gz: 181e0a17fb95652167cd7c4300163b807ffbc045
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f0ebb8baa0572b75f1e0f72bdb9c293f01023e259a1fb9ddfea9f5aff348c134079ba9d47891b0b17e9faaef394ac26b8cfa2745950f827bf49e9c53080ef745
|
7
|
+
data.tar.gz: 5228b5e83a3f222ebde719ee709d0668da3939ba0b11a36c54d0f27c13b5be6a585c25bd5385a1794395103a8bb7fa0ab4d03a7fb60c67ec2789a08e896ad5a9
|
data/README.md
CHANGED
@@ -79,6 +79,27 @@ event.execute_action
|
|
79
79
|
|
80
80
|
### Usage in cli
|
81
81
|
|
82
|
+
Use this gem in CLI. For more explain use helper :
|
83
|
+
|
84
|
+
```linux
|
85
|
+
evostream -h
|
86
|
+
```
|
87
|
+
|
88
|
+
Example for delete a configuration :
|
89
|
+
|
90
|
+
```linux
|
91
|
+
evostream removeConfig 'id: 565'
|
92
|
+
```
|
93
|
+
|
94
|
+
Example for list configuration :
|
95
|
+
|
96
|
+
```linux
|
97
|
+
# All configuration
|
98
|
+
evostream listConfig
|
99
|
+
|
100
|
+
# Just configuration number 42
|
101
|
+
evostream -s 'configId: 42' listConfig
|
102
|
+
```
|
82
103
|
|
83
104
|
## Development
|
84
105
|
|
data/lib/evostream/cli/config.rb
CHANGED
data/lib/evostream/cli/option.rb
CHANGED
@@ -1,101 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
# :reek:TooManyConstants
|
5
|
-
# :reek:TooManyStatements
|
3
|
+
require 'option/argument'
|
6
4
|
|
7
5
|
module Evostream
|
8
6
|
module CLI
|
9
7
|
# Class for parsing option used in CLI software
|
10
8
|
class Options
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
CASE_PORT = ['--port'].freeze
|
15
|
-
CASE_SEARCH = ['-s', '--search'].freeze
|
16
|
-
CASE_CONFIG = ['--config'].freeze
|
17
|
-
|
18
|
-
attr_reader :search
|
19
|
-
|
20
|
-
def initialize(configuration)
|
21
|
-
@search = nil
|
22
|
-
@file = File.read(File.join(__dir__, 'help'))
|
23
|
-
@config = configuration
|
24
|
-
end
|
25
|
-
|
26
|
-
# Parse options and execute action if necessary
|
27
|
-
# rubocop:disable Style/EmptyCaseCondition
|
28
|
-
# rubocop:disable Metrics/PerceivedComplexity
|
29
|
-
# rubocop:disable Metrics/CyclomaticComplexity
|
30
|
-
# rubocop:disable Metrics/AbcSize
|
31
|
-
def parse(argv)
|
32
|
-
@command_line_args = argv
|
33
|
-
case
|
34
|
-
when include(CASE_HELP) then display_help
|
35
|
-
when include(CASE_CMD) then display_command
|
36
|
-
when include(CASE_HOST) then use_host
|
37
|
-
when include(CASE_PORT) then use_port
|
38
|
-
when include(CASE_SEARCH) then search_in_response
|
39
|
-
when include(CASE_CONFIG) then use_config_file
|
40
|
-
when @command_line_args.empty? then display_no_command
|
41
|
-
end
|
9
|
+
def parse
|
10
|
+
Argument::Arg.descendants.each { |klass| klass.instance.used? }
|
11
|
+
display_no_command if ARGV.empty?
|
42
12
|
end
|
43
|
-
# rubocop:enable Style/EmptyCaseCondition
|
44
|
-
# rubocop:enable Metrics/AbcSize
|
45
|
-
# rubocop:enable Metrics/CyclomaticComplexity
|
46
|
-
# rubocop:enable Metrics/PerceivedComplexity
|
47
13
|
|
48
14
|
private
|
49
15
|
|
50
|
-
def include(case_parse)
|
51
|
-
case_parse.any? { |value| @command_line_args.include?(value) }
|
52
|
-
end
|
53
|
-
|
54
|
-
def display_help
|
55
|
-
puts @file
|
56
|
-
raise CodeError::Finished
|
57
|
-
end
|
58
|
-
|
59
|
-
def display_command
|
60
|
-
puts 'Commands :'
|
61
|
-
Evostream::Commands::Command.descendants.each do |cmd|
|
62
|
-
puts " - #{cmd.to_s.split('::').last}"
|
63
|
-
end
|
64
|
-
raise CodeError::Finished
|
65
|
-
end
|
66
|
-
|
67
|
-
def use_host
|
68
|
-
@config.change_host(parameter('--server'))
|
69
|
-
end
|
70
|
-
|
71
|
-
def use_port
|
72
|
-
@config.change_port(parameter('--port'))
|
73
|
-
end
|
74
|
-
|
75
|
-
def search_in_response
|
76
|
-
CASE_SEARCH.each do |search|
|
77
|
-
@search = parameter(search) if args_has_present?(search)
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
def use_config_file
|
82
|
-
file = File.join(parameter('--config'))
|
83
|
-
@config.load_custom_file(file)
|
84
|
-
end
|
85
|
-
|
86
16
|
def display_no_command
|
87
|
-
|
17
|
+
Argument::Help.instance.send(:action)
|
88
18
|
raise CodeError::Syntax::OptionInvalid
|
89
19
|
end
|
90
|
-
|
91
|
-
def parameter(search_case)
|
92
|
-
param = @command_line_args.find_index(search_case)
|
93
|
-
@command_line_args[param + 1]
|
94
|
-
end
|
95
|
-
|
96
|
-
def args_has_present?(ind)
|
97
|
-
@command_line_args.find_index(ind)
|
98
|
-
end
|
99
20
|
end
|
100
21
|
end
|
101
22
|
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Evostream
|
4
|
+
module CLI
|
5
|
+
module Argument
|
6
|
+
# Abstract class for all argument used with CLI command
|
7
|
+
class Arg
|
8
|
+
def self.descendants
|
9
|
+
ObjectSpace.each_object(Class).select { |klass| klass < self }
|
10
|
+
end
|
11
|
+
|
12
|
+
def used?
|
13
|
+
action if use(self.class::KEY)
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def use(argument_parsed)
|
19
|
+
argument_parsed.any? { |value| ARGV.include?(value) }
|
20
|
+
end
|
21
|
+
|
22
|
+
def action
|
23
|
+
raise CodeError::Finished
|
24
|
+
end
|
25
|
+
|
26
|
+
def parameter(search_case)
|
27
|
+
param = ARGV.find_index(search_case)
|
28
|
+
ARGV[param + 1]
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
require 'option/help'
|
36
|
+
require 'option/command'
|
37
|
+
require 'option/host'
|
38
|
+
require 'option/port'
|
39
|
+
require 'option/search'
|
40
|
+
require 'option/config'
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Evostream
|
4
|
+
module CLI
|
5
|
+
module Argument
|
6
|
+
# Argument for listing command available in this software
|
7
|
+
class Command < Arg
|
8
|
+
include Singleton
|
9
|
+
|
10
|
+
KEY = ['-c', '--commands'].freeze
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def action
|
15
|
+
$stdout.puts 'Commands :'
|
16
|
+
Evostream::Commands::Command.descendants.each do |cmd|
|
17
|
+
$stdout.puts " - #{cmd.to_s.split('::').last}"
|
18
|
+
end
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Evostream
|
4
|
+
module CLI
|
5
|
+
module Argument
|
6
|
+
# Argument for precise configuration file used
|
7
|
+
class Config < Arg
|
8
|
+
include Singleton
|
9
|
+
|
10
|
+
KEY = ['--config'].freeze
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def action
|
15
|
+
file = File.join(parameter('--config'))
|
16
|
+
CLI::Config.instance.load_custom_file(file)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
File without changes
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Evostream
|
4
|
+
module CLI
|
5
|
+
module Argument
|
6
|
+
# Argument for display help
|
7
|
+
class Help < Arg
|
8
|
+
include Singleton
|
9
|
+
|
10
|
+
KEY = ['-h', '--help'].freeze
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@file = File.read(File.join(__dir__, 'help'))
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def action
|
19
|
+
puts @file
|
20
|
+
super
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Evostream
|
4
|
+
module CLI
|
5
|
+
module Argument
|
6
|
+
# Argument for change host used with command calling
|
7
|
+
class Host < Arg
|
8
|
+
include Singleton
|
9
|
+
|
10
|
+
KEY = ['--server'].freeze
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def action
|
15
|
+
CLI::Config.instance.change_host(parameter('--server'))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Evostream
|
4
|
+
module CLI
|
5
|
+
module Argument
|
6
|
+
# Argument for change port used with command
|
7
|
+
class Port < Arg
|
8
|
+
include Singleton
|
9
|
+
|
10
|
+
KEY = ['--port'].freeze
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def action
|
15
|
+
CLI::Config.instance.change_host(parameter('--port'))
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Evostream
|
4
|
+
module CLI
|
5
|
+
module Argument
|
6
|
+
# Argument for searching in response to command
|
7
|
+
class Search < Arg
|
8
|
+
include Singleton
|
9
|
+
|
10
|
+
KEY = ['-s', '--search'].freeze
|
11
|
+
|
12
|
+
attr_reader :search
|
13
|
+
|
14
|
+
def initialize
|
15
|
+
@search = nil
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def action
|
21
|
+
KEY.each do |search|
|
22
|
+
@search = parameter(search) if args_has_present?(search)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
def args_has_present?(ind)
|
27
|
+
ARGV.find_index(ind)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
data/lib/evostream/cli/runner.rb
CHANGED
@@ -1,19 +1,25 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'singleton'
|
3
4
|
require 'colorize'
|
4
|
-
require 'option'
|
5
|
-
require 'config'
|
6
|
-
require 'search'
|
7
5
|
require 'timeout'
|
8
6
|
require 'socket'
|
9
|
-
require 'code_error'
|
10
7
|
require 'yaml'
|
11
8
|
require 'yaml/dbm'
|
12
9
|
|
10
|
+
$LOAD_PATH.unshift(__dir__)
|
11
|
+
require 'option'
|
12
|
+
require 'config'
|
13
|
+
require 'search'
|
14
|
+
require 'code_error'
|
15
|
+
|
13
16
|
$LOAD_PATH.unshift("#{__dir__}/../")
|
14
17
|
require 'event'
|
15
18
|
|
19
|
+
# :reek:FeatureEnvy
|
16
20
|
# :reek:TooManyStatements
|
21
|
+
# :reek:DuplicateMethodCall
|
22
|
+
# :reek:NilCheck
|
17
23
|
|
18
24
|
module Evostream
|
19
25
|
# Execute CLI with this gem
|
@@ -27,17 +33,17 @@ module Evostream
|
|
27
33
|
# Version #{Evostream::VERSION} \t\t #
|
28
34
|
##################################
|
29
35
|
INFO
|
30
|
-
puts txt.red
|
31
|
-
|
32
|
-
@options = CLI::Options.new
|
36
|
+
$stdout.puts txt.red
|
37
|
+
CLI::Config.instance
|
38
|
+
@options = CLI::Options.new
|
33
39
|
end
|
34
40
|
|
35
41
|
# rubocop:disable Metrics/MethodLength
|
36
42
|
def run(args = ARGV)
|
37
|
-
@options.parse
|
43
|
+
@options.parse
|
38
44
|
|
39
45
|
access_evostream?
|
40
|
-
execute_runner(args
|
46
|
+
execute_runner(two_last_arg(args)) if args.count >= 1
|
41
47
|
rescue CodeError::Evostream::ConnectionFailed
|
42
48
|
return 201
|
43
49
|
rescue CodeError::Evostream::NoResult
|
@@ -46,6 +52,9 @@ module Evostream
|
|
46
52
|
return 101
|
47
53
|
rescue CodeError::Syntax::OptionInvalid
|
48
54
|
return 100
|
55
|
+
rescue Evostream::Commands::Errors::MissingMandatory => error
|
56
|
+
$stdout.puts error.message.red
|
57
|
+
return 50
|
49
58
|
rescue CodeError::Finished
|
50
59
|
return 0
|
51
60
|
end
|
@@ -61,7 +70,6 @@ module Evostream
|
|
61
70
|
raise CodeError::Evostream::ConnectionFailed
|
62
71
|
end
|
63
72
|
|
64
|
-
# :reek:FeatureEnvy
|
65
73
|
def test_server_started
|
66
74
|
uri = URI.parse(Evostream::Service.uri_in.to_s)
|
67
75
|
socket = TCPSocket.new(uri.host, uri.port)
|
@@ -72,23 +80,27 @@ module Evostream
|
|
72
80
|
|
73
81
|
def execute_runner(cmd)
|
74
82
|
test_command(cmd) do
|
75
|
-
|
76
|
-
|
83
|
+
payload = cmd.last == cmd.first ? {} : create_an_hash(cmd.last)
|
84
|
+
act = Evostream::Action.new(payload)
|
85
|
+
interpret_response(act.execute_action(cmd.first)[:data])
|
77
86
|
end
|
78
87
|
end
|
79
88
|
|
80
89
|
def interpret_response(result)
|
81
|
-
if
|
82
|
-
puts result.to_yaml
|
90
|
+
if CLI::Argument::Search.instance.search.nil?
|
91
|
+
$stdout.puts result.to_yaml
|
83
92
|
else
|
84
|
-
CLI::Search.new
|
93
|
+
CLI::Search.new.search_node(result)
|
85
94
|
end
|
86
95
|
raise CodeError::Finished
|
87
96
|
end
|
88
97
|
|
89
98
|
def test_command(cmd)
|
90
|
-
|
91
|
-
|
99
|
+
cmd.each_with_index do |one_arg, index|
|
100
|
+
raise CodeError::Syntax::CommandInvalid \
|
101
|
+
if one_arg.start_with?('-', '--') ||
|
102
|
+
(cmd_exist?(one_arg) if index.zero?)
|
103
|
+
end
|
92
104
|
yield
|
93
105
|
end
|
94
106
|
|
@@ -97,5 +109,21 @@ module Evostream
|
|
97
109
|
command.to_s.split('::').last.casecmp(cmd).zero?
|
98
110
|
end
|
99
111
|
end
|
112
|
+
|
113
|
+
def create_an_hash(arguments)
|
114
|
+
super_hash = {}
|
115
|
+
arguments.split(': ').each_with_index do |value, index|
|
116
|
+
if (index % 2).zero?
|
117
|
+
super_hash[value] = nil
|
118
|
+
else
|
119
|
+
super_hash[super_hash.keys[index - 1]] = value
|
120
|
+
end
|
121
|
+
end
|
122
|
+
super_hash
|
123
|
+
end
|
124
|
+
|
125
|
+
def two_last_arg(args)
|
126
|
+
[args.first, args.last]
|
127
|
+
end
|
100
128
|
end
|
101
129
|
end
|
data/lib/evostream/cli/search.rb
CHANGED
@@ -1,10 +1,13 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# :reek:NilCheck
|
4
|
+
|
3
5
|
module Evostream
|
4
6
|
module CLI
|
5
7
|
# Search data in evostream result
|
6
8
|
class Search
|
7
9
|
def initialize(yaml_search)
|
10
|
+
@response = nil
|
8
11
|
YAML.load(yaml_search).each do |key, value|
|
9
12
|
@search = [key.to_sym, value]
|
10
13
|
end
|
@@ -14,15 +17,21 @@ module Evostream
|
|
14
17
|
YAML.load(result.to_yaml).each do |_key, value|
|
15
18
|
inspect_array(value) if value.is_a?(Array) && !value.empty?
|
16
19
|
end
|
20
|
+
|
21
|
+
puts @response.nil? ? "No node equal to #{@search}" : @response
|
17
22
|
end
|
18
23
|
|
19
24
|
private
|
20
25
|
|
21
26
|
def inspect_array(evostream_response)
|
22
27
|
evostream_response.each do |value|
|
23
|
-
value
|
24
|
-
|
25
|
-
|
28
|
+
inspect_hash(value)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def inspect_hash(evostream_response)
|
33
|
+
evostream_response.each do |hash_value|
|
34
|
+
puts value.to_yaml if hash_value == @search
|
26
35
|
end
|
27
36
|
end
|
28
37
|
end
|
@@ -1,6 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'base64'
|
4
|
+
|
3
5
|
# :reek:UncommunicativeMethodName
|
6
|
+
# :reek:NestedIterators
|
7
|
+
# :reek:DuplicateMethodCall
|
4
8
|
|
5
9
|
module Evostream
|
6
10
|
# Manage command
|
@@ -12,6 +16,7 @@ module Evostream
|
|
12
16
|
commands.each do |command_name, command_param|
|
13
17
|
@command.push send(command_name, command_param)
|
14
18
|
end
|
19
|
+
test_missing_parameter
|
15
20
|
end
|
16
21
|
|
17
22
|
def cmd
|
@@ -28,10 +33,25 @@ module Evostream
|
|
28
33
|
def encode_64
|
29
34
|
Base64.strict_encode64(@command.join(' '))
|
30
35
|
end
|
36
|
+
|
37
|
+
def test_missing_parameter
|
38
|
+
missing = self.class::MANDATORY.empty? ? false : missing_parameter
|
39
|
+
raise Errors::MissingMandatory.new(self.class::MANDATORY, self.class) \
|
40
|
+
if missing
|
41
|
+
end
|
42
|
+
|
43
|
+
def missing_parameter
|
44
|
+
self.class::MANDATORY.none? do |method|
|
45
|
+
@command.any? do |part_payload|
|
46
|
+
part_payload.match?(/#{method}/)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
31
50
|
end
|
32
51
|
end
|
33
52
|
end
|
34
53
|
|
54
|
+
require 'evostream/event/commands/error'
|
35
55
|
require 'evostream/event/commands/create'
|
36
56
|
require 'evostream/event/commands/destroy'
|
37
57
|
require 'evostream/event/commands/get_stream_info'
|
@@ -4,6 +4,8 @@ module Evostream
|
|
4
4
|
module Commands
|
5
5
|
# Create flux DASH
|
6
6
|
class CreateDASH < Create
|
7
|
+
MANDATORY = %w[localStreamNames targetFolder].freeze
|
8
|
+
|
7
9
|
# Call default command for create DASH Stream
|
8
10
|
def initialize(commands = {
|
9
11
|
local_stream_names: 'null', target_folder: 'null'
|
@@ -6,6 +6,8 @@ module Evostream
|
|
6
6
|
module Commands
|
7
7
|
# Create flux HLS
|
8
8
|
class CreateHLS < Create
|
9
|
+
MANDATORY = %w[localStreamNames targetFolder].freeze
|
10
|
+
|
9
11
|
# Call default command for create DASH Stream
|
10
12
|
def initialize(commands = {
|
11
13
|
local_stream_names: 'null', target_folder: 'null'
|
@@ -4,7 +4,9 @@ module Evostream
|
|
4
4
|
# Concern all command sending to evoStream
|
5
5
|
module Commands
|
6
6
|
# Abstract class for create element
|
7
|
-
class
|
7
|
+
class RemoveConfig < Command
|
8
|
+
MANDATORY = %w[id].freeze
|
9
|
+
|
8
10
|
def initialize(commands = { group_name: 'null', remove_hls_hds_files: 1 })
|
9
11
|
super(commands)
|
10
12
|
end
|
@@ -40,6 +42,6 @@ module Evostream
|
|
40
42
|
end
|
41
43
|
|
42
44
|
# Alias to Destroy class
|
43
|
-
|
45
|
+
Destroy = RemoveConfig
|
44
46
|
end
|
45
47
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Evostream
|
4
|
+
module Commands
|
5
|
+
module Errors
|
6
|
+
# Exception if command have no mandatory parameter
|
7
|
+
class MissingMandatory < StandardError
|
8
|
+
def initialize(arg_mandatory, klass)
|
9
|
+
super "Parameter missing(s) #{arg_mandatory} in #{klass}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Evostream::CLI::Argument::Command do
|
6
|
+
let(:runner) { Evostream::Runner.new }
|
7
|
+
|
8
|
+
it do
|
9
|
+
ARGV << '-c'
|
10
|
+
expect(runner.run).to eql(0)
|
11
|
+
end
|
12
|
+
|
13
|
+
it do
|
14
|
+
expect { runner.run }.to output(/.*Commands :.*/).to_stdout
|
15
|
+
end
|
16
|
+
end
|
@@ -3,12 +3,23 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Evostream::Commands::CreateDASH do
|
6
|
-
let(:command) { Evostream::Commands::CreateDASH
|
6
|
+
let(:command) { Evostream::Commands::CreateDASH }
|
7
7
|
|
8
8
|
context 'manifest_name' do
|
9
9
|
let(:arg_value) { Faker::Pokemon.name }
|
10
10
|
let(:argument) { 'manifest_name' }
|
11
11
|
|
12
|
+
include_examples 'command raise'
|
13
|
+
end
|
14
|
+
|
15
|
+
context 'with mandatory argument(s)' do
|
16
|
+
let(:cmd) do
|
17
|
+
{
|
18
|
+
local_stream_names: Faker::Pokemon.name,
|
19
|
+
target_folder: Faker::File.file_name('/path/to')
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
12
23
|
include_examples 'command'
|
13
24
|
end
|
14
25
|
end
|
@@ -3,103 +3,114 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Evostream::Commands::CreateHLS do
|
6
|
-
let(:command) { Evostream::Commands::CreateHLS
|
6
|
+
let(:command) { Evostream::Commands::CreateHLS }
|
7
7
|
|
8
8
|
context 'create_master_playlist' do
|
9
9
|
let(:arg_value) { Faker::Number.between(0, 1) }
|
10
10
|
let(:argument) { 'create_master_playlist' }
|
11
11
|
|
12
|
-
include_examples 'command'
|
12
|
+
include_examples 'command raise'
|
13
13
|
end
|
14
14
|
|
15
15
|
context 'playlist_name' do
|
16
16
|
let(:arg_value) { Faker::Pokemon.name }
|
17
17
|
let(:argument) { 'playlist_name' }
|
18
18
|
|
19
|
-
include_examples 'command'
|
19
|
+
include_examples 'command raise'
|
20
20
|
end
|
21
21
|
|
22
22
|
context 'max_chunk_length' do
|
23
23
|
let(:arg_value) { Faker::Number.between(0, 1) }
|
24
24
|
let(:argument) { 'max_chunk_length' }
|
25
25
|
|
26
|
-
include_examples 'command'
|
26
|
+
include_examples 'command raise'
|
27
27
|
end
|
28
28
|
|
29
29
|
context 'chunk_base_name' do
|
30
30
|
let(:arg_value) { Faker::Pokemon.name }
|
31
31
|
let(:argument) { 'chunk_base_name' }
|
32
32
|
|
33
|
-
include_examples 'command'
|
33
|
+
include_examples 'command raise'
|
34
34
|
end
|
35
35
|
|
36
36
|
context 'drm_type' do
|
37
37
|
let(:arg_value) { Faker::Pokemon.name }
|
38
38
|
let(:argument) { 'drm_type' }
|
39
39
|
|
40
|
-
include_examples 'command'
|
40
|
+
include_examples 'command raise'
|
41
41
|
end
|
42
42
|
|
43
43
|
context 'aes_key_count', broken: true do
|
44
44
|
let(:arg_value) { Faker::Number.between(1, 99) }
|
45
45
|
let(:argument) { 'aes_key_count' }
|
46
46
|
|
47
|
-
include_examples 'command'
|
47
|
+
include_examples 'command raise'
|
48
48
|
end
|
49
49
|
|
50
50
|
context 'audio_only' do
|
51
51
|
let(:arg_value) { Faker::Number.between(0, 1) }
|
52
52
|
let(:argument) { 'audio_only' }
|
53
53
|
|
54
|
-
include_examples 'command'
|
54
|
+
include_examples 'command raise'
|
55
55
|
end
|
56
56
|
|
57
57
|
context 'hls_resume' do
|
58
58
|
let(:arg_value) { Faker::Number.between(0, 1) }
|
59
59
|
let(:argument) { 'hls_resume' }
|
60
60
|
|
61
|
-
include_examples 'command'
|
61
|
+
include_examples 'command raise'
|
62
62
|
end
|
63
63
|
|
64
64
|
context 'cleanup_on_close' do
|
65
65
|
let(:arg_value) { Faker::Number.between(0, 1) }
|
66
66
|
let(:argument) { 'cleanup_on_close' }
|
67
67
|
|
68
|
-
include_examples 'command'
|
68
|
+
include_examples 'command raise'
|
69
69
|
end
|
70
70
|
|
71
71
|
context 'use_byte_range' do
|
72
72
|
let(:arg_value) { Faker::Number.between(0, 1) }
|
73
73
|
let(:argument) { 'use_byte_range' }
|
74
74
|
|
75
|
-
include_examples 'command'
|
75
|
+
include_examples 'command raise'
|
76
76
|
end
|
77
77
|
|
78
78
|
context 'file_length' do
|
79
79
|
let(:arg_value) { Faker::Number.between(0, 1) }
|
80
80
|
let(:argument) { 'file_length' }
|
81
81
|
|
82
|
-
include_examples 'command'
|
82
|
+
include_examples 'command raise'
|
83
83
|
end
|
84
84
|
|
85
85
|
context 'use_system_time' do
|
86
86
|
let(:arg_value) { Faker::Number.between(0, 1) }
|
87
87
|
let(:argument) { 'use_system_time' }
|
88
88
|
|
89
|
-
include_examples 'command'
|
89
|
+
include_examples 'command raise'
|
90
90
|
end
|
91
91
|
|
92
92
|
context 'offset_time' do
|
93
93
|
let(:arg_value) { Faker::Number.between(0, 1) }
|
94
94
|
let(:argument) { 'offset_time' }
|
95
95
|
|
96
|
-
include_examples 'command'
|
96
|
+
include_examples 'command raise'
|
97
97
|
end
|
98
98
|
|
99
99
|
context 'start_offset' do
|
100
100
|
let(:arg_value) { Faker::Number.between(0, 1) }
|
101
101
|
let(:argument) { 'start_offset' }
|
102
102
|
|
103
|
+
include_examples 'command raise'
|
104
|
+
end
|
105
|
+
|
106
|
+
context 'with mandatory argument(s)' do
|
107
|
+
let(:cmd) do
|
108
|
+
{
|
109
|
+
local_stream_names: Faker::Pokemon.name,
|
110
|
+
target_folder: Faker::File.file_name('/path/to')
|
111
|
+
}
|
112
|
+
end
|
113
|
+
|
103
114
|
include_examples 'command'
|
104
115
|
end
|
105
116
|
end
|
@@ -3,96 +3,93 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Evostream::Commands::Create do
|
6
|
-
let(:command) { Evostream::Commands::Create
|
7
|
-
|
8
|
-
context 'local_stream_names' do
|
9
|
-
let(:arg_value) { Faker::Pokemon.name }
|
10
|
-
let(:argument) { 'local_stream_names' }
|
11
|
-
|
12
|
-
include_examples 'command'
|
13
|
-
end
|
14
|
-
|
15
|
-
context 'target_folder' do
|
16
|
-
let(:arg_value) { Faker::Pokemon.name }
|
17
|
-
let(:argument) { 'target_folder' }
|
18
|
-
|
19
|
-
include_examples 'command'
|
20
|
-
end
|
6
|
+
let(:command) { Evostream::Commands::Create }
|
21
7
|
|
22
8
|
context 'bandwidths' do
|
23
9
|
let(:arg_value) { Faker::Number.between(1, 99) }
|
24
10
|
let(:argument) { 'bandwidths' }
|
25
11
|
|
26
|
-
include_examples 'command'
|
12
|
+
include_examples 'command raise'
|
27
13
|
end
|
28
14
|
|
29
15
|
context 'group_name' do
|
30
16
|
let(:arg_value) { Faker::Pokemon.name }
|
31
17
|
let(:argument) { 'group_name' }
|
32
18
|
|
33
|
-
include_examples 'command'
|
19
|
+
include_examples 'command raise'
|
34
20
|
end
|
35
21
|
|
36
22
|
context 'playlist_type' do
|
37
23
|
let(:arg_value) { %w[appending rolling].sample }
|
38
24
|
let(:argument) { 'playlist_type' }
|
39
25
|
|
40
|
-
include_examples 'command'
|
26
|
+
include_examples 'command raise'
|
41
27
|
end
|
42
28
|
|
43
29
|
context 'playlist_length' do
|
44
30
|
let(:arg_value) { Faker::Number.between(1, 99) }
|
45
31
|
let(:argument) { 'playlist_length' }
|
46
32
|
|
47
|
-
include_examples 'command'
|
33
|
+
include_examples 'command raise'
|
48
34
|
end
|
49
35
|
|
50
36
|
context 'chunk_length' do
|
51
37
|
let(:arg_value) { Faker::Number.between(1, 99) }
|
52
38
|
let(:argument) { 'chunk_length' }
|
53
39
|
|
54
|
-
include_examples 'command'
|
40
|
+
include_examples 'command raise'
|
55
41
|
end
|
56
42
|
|
57
43
|
context 'chunk_on_idr', broken: true do
|
58
44
|
let(:arg_value) { Faker::Number.between(0, 1) }
|
59
45
|
let(:argument) { 'chunk_on_idr' }
|
60
46
|
|
61
|
-
include_examples 'command'
|
47
|
+
include_examples 'command raise'
|
62
48
|
end
|
63
49
|
|
64
50
|
context 'keep_alive' do
|
65
51
|
let(:arg_value) { Faker::Number.between(0, 1) }
|
66
52
|
let(:argument) { 'keep_alive' }
|
67
53
|
|
68
|
-
include_examples 'command'
|
54
|
+
include_examples 'command raise'
|
69
55
|
end
|
70
56
|
|
71
57
|
context 'overwrite_destination' do
|
72
58
|
let(:arg_value) { Faker::Number.between(0, 1) }
|
73
59
|
let(:argument) { 'overwrite_destination' }
|
74
60
|
|
75
|
-
include_examples 'command'
|
61
|
+
include_examples 'command raise'
|
76
62
|
end
|
77
63
|
|
78
64
|
context 'stale_retention_count' do
|
79
65
|
let(:arg_value) { Faker::Number.between(1, 99) }
|
80
66
|
let(:argument) { 'stale_retention_count' }
|
81
67
|
|
82
|
-
include_examples 'command'
|
68
|
+
include_examples 'command raise'
|
83
69
|
end
|
84
70
|
|
85
71
|
context 'cleanup_destination' do
|
86
72
|
let(:arg_value) { Faker::Number.between(0, 1) }
|
87
73
|
let(:argument) { 'cleanup_destination' }
|
88
74
|
|
89
|
-
include_examples 'command'
|
75
|
+
include_examples 'command raise'
|
90
76
|
end
|
91
77
|
|
92
78
|
context 'dynamic_profile' do
|
93
79
|
let(:arg_value) { Faker::Number.between(0, 1) }
|
94
80
|
let(:argument) { 'dynamic_profile' }
|
95
81
|
|
82
|
+
include_examples 'command raise'
|
83
|
+
end
|
84
|
+
|
85
|
+
context 'with mandatory argument(s)' do
|
86
|
+
let(:cmd) do
|
87
|
+
{
|
88
|
+
local_stream_names: Faker::Pokemon.name,
|
89
|
+
target_folder: Faker::File.file_name('/path/to')
|
90
|
+
}
|
91
|
+
end
|
92
|
+
|
96
93
|
include_examples 'command'
|
97
94
|
end
|
98
95
|
end
|
@@ -3,11 +3,10 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Evostream::Commands::Destroy do
|
6
|
-
let(:command) { Evostream::Commands::Destroy
|
6
|
+
let(:command) { Evostream::Commands::Destroy }
|
7
7
|
|
8
8
|
context 'id' do
|
9
|
-
let(:
|
10
|
-
let(:argument) { 'id' }
|
9
|
+
let(:cmd) { { id: Faker::Number.between(1, 99).to_s } }
|
11
10
|
|
12
11
|
include_examples 'command'
|
13
12
|
end
|
@@ -16,13 +15,13 @@ describe Evostream::Commands::Destroy do
|
|
16
15
|
let(:arg_value) { Faker::Number.between(0, 1) }
|
17
16
|
let(:argument) { 'remove_hls_hds_files' }
|
18
17
|
|
19
|
-
include_examples 'command'
|
18
|
+
include_examples 'command raise'
|
20
19
|
end
|
21
20
|
|
22
21
|
context 'group_name' do
|
23
22
|
let(:arg_value) { Faker::Pokemon.name }
|
24
23
|
let(:argument) { 'group_name' }
|
25
24
|
|
26
|
-
include_examples 'command'
|
25
|
+
include_examples 'command raise'
|
27
26
|
end
|
28
27
|
end
|
@@ -3,11 +3,10 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Evostream::Commands::GetStreamInfo do
|
6
|
-
let(:command) { Evostream::Commands::GetStreamInfo
|
6
|
+
let(:command) { Evostream::Commands::GetStreamInfo }
|
7
7
|
|
8
8
|
context 'id' do
|
9
|
-
let(:
|
10
|
-
let(:argument) { 'id' }
|
9
|
+
let(:cmd) { { id: Faker::Number.between(1, 999).to_s } }
|
11
10
|
|
12
11
|
include_examples 'command'
|
13
12
|
end
|
@@ -16,6 +15,6 @@ describe Evostream::Commands::GetStreamInfo do
|
|
16
15
|
let(:arg_value) { Faker::Pokemon.name }
|
17
16
|
let(:argument) { 'local_stream_name' }
|
18
17
|
|
19
|
-
include_examples 'command'
|
18
|
+
include_examples 'command raise'
|
20
19
|
end
|
21
20
|
end
|
@@ -3,11 +3,10 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Evostream::Commands::ListStreams do
|
6
|
-
let(:command) { Evostream::Commands::ListStreams
|
6
|
+
let(:command) { Evostream::Commands::ListStreams }
|
7
7
|
|
8
8
|
context 'disable_internal_streams' do
|
9
|
-
let(:
|
10
|
-
let(:argument) { 'disable_internal_streams' }
|
9
|
+
let(:cmd) { { disable_internal_streams: Faker::Boolean.boolean.to_s } }
|
11
10
|
|
12
11
|
include_examples 'command'
|
13
12
|
end
|
@@ -3,11 +3,10 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Evostream::Commands::Destroy do
|
6
|
-
let(:command) { Evostream::Commands::PushStream
|
6
|
+
let(:command) { Evostream::Commands::PushStream }
|
7
7
|
|
8
8
|
context 'uri' do
|
9
|
-
let(:
|
10
|
-
let(:argument) { 'uri' }
|
9
|
+
let(:cmd) { { uri: 'rtmp://de.pscp.tv:80/x/31' } }
|
11
10
|
|
12
11
|
include_examples 'command'
|
13
12
|
end
|
@@ -16,13 +15,13 @@ describe Evostream::Commands::Destroy do
|
|
16
15
|
let(:arg_value) { Faker::Pokemon.name }
|
17
16
|
let(:argument) { 'local_stream_name' }
|
18
17
|
|
19
|
-
include_examples 'command'
|
18
|
+
include_examples 'command raise'
|
20
19
|
end
|
21
20
|
|
22
21
|
context 'target_stream_name' do
|
23
22
|
let(:arg_value) { Faker::Pokemon.name }
|
24
23
|
let(:argument) { 'target_stream_name' }
|
25
24
|
|
26
|
-
include_examples 'command'
|
25
|
+
include_examples 'command raise'
|
27
26
|
end
|
28
27
|
end
|
@@ -3,11 +3,10 @@
|
|
3
3
|
require 'spec_helper'
|
4
4
|
|
5
5
|
describe Evostream::Commands::SetLogLevel do
|
6
|
-
let(:command) { Evostream::Commands::SetLogLevel
|
6
|
+
let(:command) { Evostream::Commands::SetLogLevel }
|
7
7
|
|
8
8
|
context 'level' do
|
9
|
-
let(:
|
10
|
-
let(:argument) { 'level' }
|
9
|
+
let(:cmd) { { level: Faker::Number.between(0, 6).to_s } }
|
11
10
|
|
12
11
|
include_examples 'command'
|
13
12
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -3,10 +3,28 @@
|
|
3
3
|
require 'active_support/core_ext/string'
|
4
4
|
|
5
5
|
RSpec.shared_examples 'command' do
|
6
|
+
let(:test) do
|
7
|
+
test = []
|
8
|
+
var = command.new(cmd).instance_variable_get(:@command)
|
9
|
+
cmd.each_with_index do |_value, index|
|
10
|
+
test << var[index].split('=').last
|
11
|
+
end
|
12
|
+
test
|
13
|
+
end
|
14
|
+
let(:to) do
|
15
|
+
to = []
|
16
|
+
cmd.each { |value| to << value.last }
|
17
|
+
to
|
18
|
+
end
|
19
|
+
|
20
|
+
it { expect(test).to eql(to) }
|
21
|
+
end
|
22
|
+
|
23
|
+
RSpec.shared_examples 'command raise' do
|
6
24
|
let(:cmd) { { argument => arg_value } }
|
7
|
-
let(:result) { "#{argument.camelize(:lower)}=#{arg_value} " }
|
8
25
|
|
9
26
|
it do
|
10
|
-
expect
|
27
|
+
expect { command.new(cmd) }.to \
|
28
|
+
raise_error(Evostream::Commands::Errors::MissingMandatory)
|
11
29
|
end
|
12
30
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: evostream-event
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.pre.
|
4
|
+
version: 1.0.0.pre.65
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- VAILLANT Jeremy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -295,8 +295,15 @@ files:
|
|
295
295
|
- lib/evostream/action/action.rb
|
296
296
|
- lib/evostream/cli/code_error.rb
|
297
297
|
- lib/evostream/cli/config.rb
|
298
|
-
- lib/evostream/cli/help
|
299
298
|
- lib/evostream/cli/option.rb
|
299
|
+
- lib/evostream/cli/option/argument.rb
|
300
|
+
- lib/evostream/cli/option/command.rb
|
301
|
+
- lib/evostream/cli/option/config.rb
|
302
|
+
- lib/evostream/cli/option/help
|
303
|
+
- lib/evostream/cli/option/help.rb
|
304
|
+
- lib/evostream/cli/option/host.rb
|
305
|
+
- lib/evostream/cli/option/port.rb
|
306
|
+
- lib/evostream/cli/option/search.rb
|
300
307
|
- lib/evostream/cli/runner.rb
|
301
308
|
- lib/evostream/cli/search.rb
|
302
309
|
- lib/evostream/event.rb
|
@@ -305,6 +312,7 @@ files:
|
|
305
312
|
- lib/evostream/event/commands/create/dash.rb
|
306
313
|
- lib/evostream/event/commands/create/hls.rb
|
307
314
|
- lib/evostream/event/commands/destroy.rb
|
315
|
+
- lib/evostream/event/commands/error.rb
|
308
316
|
- lib/evostream/event/commands/get_stream_info.rb
|
309
317
|
- lib/evostream/event/commands/list_config.rb
|
310
318
|
- lib/evostream/event/commands/list_streams.rb
|
@@ -320,6 +328,7 @@ files:
|
|
320
328
|
- lib/evostream/event/response/response.rb
|
321
329
|
- lib/evostream/event/service.rb
|
322
330
|
- lib/generators/evostream/initializer_generator.rb
|
331
|
+
- spec/cli/argument/command_spec.rb
|
323
332
|
- spec/evostream/action/action_spec.rb
|
324
333
|
- spec/evostream/commands/create_dash_spec.rb
|
325
334
|
- spec/evostream/commands/create_hls_spec.rb
|