evostream-event 1.0.0.pre.65 → 1.0.0.pre.69
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/evostream/cli/option/argument.rb +1 -0
- data/lib/evostream/cli/option/config.rb +4 -2
- data/lib/evostream/cli/option/help +2 -0
- data/lib/evostream/cli/option/host.rb +4 -1
- data/lib/evostream/cli/option/port.rb +4 -1
- data/lib/evostream/cli/option/version.rb +27 -0
- data/lib/evostream/cli/runner.rb +5 -8
- data/lib/evostream/cli/search.rb +2 -4
- data/spec/cli/argument/command_spec.rb +14 -5
- data/spec/cli/argument/config_spec.rb +29 -0
- data/spec/cli/argument/help_spec.rb +28 -0
- data/spec/cli/argument/host_spec.rb +29 -0
- data/spec/cli/argument/port_spec.rb +29 -0
- data/spec/cli/argument/search_spec.rb +31 -0
- data/spec/cli/argument/version_spec.rb +25 -0
- data/spec/matchers/exit_code_matchers.rb +37 -0
- data/spec/spec_helper.rb +8 -0
- data/spec/support/examples_arguments.rb +9 -0
- 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: 60e46c9ea0c67c3da0450eb970aa741c7d558f9f
|
4
|
+
data.tar.gz: 8f424511782e8ac44863578ad8c4bf83e9e8d298
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b9f4afe200f71ebf54ec5c2b3e28977ffdc99172cb2ada20d986262c23888e3ff1c2e8f3761cb196028b3e77ba0b5af41b2ac402fefd73881b6e978aa5e102c6
|
7
|
+
data.tar.gz: dea577d1d11357b5b83207f63aef17e836a506378d3a10d198c009df56b152dafb9b465c835ca1c66de85cafaf2ea6b3b891ef917cb526a12d6dd0481ca5b1e9
|
@@ -12,8 +12,10 @@ module Evostream
|
|
12
12
|
private
|
13
13
|
|
14
14
|
def action
|
15
|
-
|
16
|
-
CLI::Config.instance.load_custom_file(
|
15
|
+
path = parameter('--config')
|
16
|
+
CLI::Config.instance.load_custom_file(File.join(path))
|
17
|
+
rescue
|
18
|
+
raise CodeError::Syntax::OptionInvalid
|
17
19
|
end
|
18
20
|
end
|
19
21
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Evostream
|
4
|
+
module CLI
|
5
|
+
module Argument
|
6
|
+
# Argument for display version
|
7
|
+
class Version < Arg
|
8
|
+
include Singleton
|
9
|
+
|
10
|
+
KEY = ['-v', '--version'].freeze
|
11
|
+
|
12
|
+
private
|
13
|
+
|
14
|
+
def action
|
15
|
+
txt = <<~INFO
|
16
|
+
##################################
|
17
|
+
# Ruby -- #{RUBY_VERSION}
|
18
|
+
# Evostream::Event -- #{Evostream::VERSION}
|
19
|
+
##################################
|
20
|
+
INFO
|
21
|
+
$stdout.puts txt
|
22
|
+
super
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/evostream/cli/runner.rb
CHANGED
@@ -27,13 +27,6 @@ module Evostream
|
|
27
27
|
attr_reader :options
|
28
28
|
|
29
29
|
def initialize
|
30
|
-
txt = <<~INFO
|
31
|
-
##################################
|
32
|
-
# Start Evostream CLI \t\t #
|
33
|
-
# Version #{Evostream::VERSION} \t\t #
|
34
|
-
##################################
|
35
|
-
INFO
|
36
|
-
$stdout.puts txt.red
|
37
30
|
CLI::Config.instance
|
38
31
|
@options = CLI::Options.new
|
39
32
|
end
|
@@ -123,7 +116,11 @@ module Evostream
|
|
123
116
|
end
|
124
117
|
|
125
118
|
def two_last_arg(args)
|
126
|
-
|
119
|
+
if CLI::Argument::Search.instance.search.nil?
|
120
|
+
[args.first, args.last]
|
121
|
+
else
|
122
|
+
[args.last, args.last]
|
123
|
+
end
|
127
124
|
end
|
128
125
|
end
|
129
126
|
end
|
data/lib/evostream/cli/search.rb
CHANGED
@@ -6,11 +6,9 @@ module Evostream
|
|
6
6
|
module CLI
|
7
7
|
# Search data in evostream result
|
8
8
|
class Search
|
9
|
-
def initialize
|
9
|
+
def initialize
|
10
10
|
@response = nil
|
11
|
-
|
12
|
-
@search = [key.to_sym, value]
|
13
|
-
end
|
11
|
+
@search = CLI::Argument::Search.instance.search.split(': ')
|
14
12
|
end
|
15
13
|
|
16
14
|
def search_node(result)
|
@@ -4,13 +4,22 @@ require 'spec_helper'
|
|
4
4
|
|
5
5
|
describe Evostream::CLI::Argument::Command do
|
6
6
|
let(:runner) { Evostream::Runner.new }
|
7
|
+
let(:out) { /Commands :\n^ - .*/ }
|
8
|
+
let(:code) { 0 }
|
7
9
|
|
8
|
-
|
9
|
-
|
10
|
-
|
10
|
+
context 'when short argument' do
|
11
|
+
before { ARGV.push('-c') }
|
12
|
+
after { ARGV.pop }
|
13
|
+
|
14
|
+
include_examples 'argument exit'
|
15
|
+
include_examples 'argument output'
|
11
16
|
end
|
12
17
|
|
13
|
-
|
14
|
-
|
18
|
+
context 'when long argument' do
|
19
|
+
before { ARGV.push('--commands') }
|
20
|
+
after { ARGV.pop }
|
21
|
+
|
22
|
+
include_examples 'argument exit'
|
23
|
+
include_examples 'argument output'
|
15
24
|
end
|
16
25
|
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Evostream::CLI::Argument::Config do
|
6
|
+
before { ARGV.push('--config') }
|
7
|
+
after { ARGV.pop }
|
8
|
+
|
9
|
+
let(:runner) { Evostream::Runner.new }
|
10
|
+
|
11
|
+
context 'when argument with file dont exit' do
|
12
|
+
let(:out) { /No command executed !! No command precise\./ }
|
13
|
+
let(:code) { 100 }
|
14
|
+
|
15
|
+
include_examples 'argument exit'
|
16
|
+
include_examples 'argument output'
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'when argument with exit file', broken: true do
|
20
|
+
before { ARGV.push('.travis/evostream-configuration.yml') }
|
21
|
+
after { ARGV.pop }
|
22
|
+
|
23
|
+
let(:out) { /Connection to Evostream REFUSED !!/ }
|
24
|
+
let(:code) { 201 }
|
25
|
+
|
26
|
+
include_examples 'argument exit'
|
27
|
+
include_examples 'argument output'
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Evostream::CLI::Argument::Help do
|
6
|
+
let(:runner) { Evostream::Runner.new }
|
7
|
+
let(:out) do
|
8
|
+
file = File.join(__dir__, '..', '..', '..', 'lib', 'evostream', 'cli', 'option', 'help')
|
9
|
+
File.read(file)
|
10
|
+
end
|
11
|
+
let(:code) { 0 }
|
12
|
+
|
13
|
+
context 'when short argument' do
|
14
|
+
before { ARGV.push('-h') }
|
15
|
+
after { ARGV.pop }
|
16
|
+
|
17
|
+
include_examples 'argument exit'
|
18
|
+
include_examples 'argument output'
|
19
|
+
end
|
20
|
+
|
21
|
+
context 'when long argument' do
|
22
|
+
before { ARGV.push('-h') }
|
23
|
+
after { ARGV.pop }
|
24
|
+
|
25
|
+
include_examples 'argument exit'
|
26
|
+
include_examples 'argument output'
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Evostream::CLI::Argument::Host, type: :cli do
|
6
|
+
before { ARGV.push('--server') }
|
7
|
+
after { ARGV.pop }
|
8
|
+
|
9
|
+
let(:runner) { Evostream::Runner.new }
|
10
|
+
|
11
|
+
context 'when argument with host dont given' do
|
12
|
+
let(:out) { /Command is invalid !!/ }
|
13
|
+
let(:code) { 101 }
|
14
|
+
|
15
|
+
include_examples 'argument exit'
|
16
|
+
include_examples 'argument output'
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'when argument with host given', broken: true do
|
20
|
+
before { ARGV.push('127.0.0.1') }
|
21
|
+
after { ARGV.pop }
|
22
|
+
|
23
|
+
let(:out) { /Connection to Evostream REFUSED !!/ }
|
24
|
+
let(:code) { 201 }
|
25
|
+
|
26
|
+
include_examples 'argument exit'
|
27
|
+
include_examples 'argument output'
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Evostream::CLI::Argument::Port, type: :cli do
|
6
|
+
before { ARGV.push('--port') }
|
7
|
+
after { ARGV.pop }
|
8
|
+
|
9
|
+
let(:runner) { Evostream::Runner.new }
|
10
|
+
|
11
|
+
context 'when argument with port dont given' do
|
12
|
+
let(:out) { /Command is invalid !!/ }
|
13
|
+
let(:code) { 101 }
|
14
|
+
|
15
|
+
include_examples 'argument exit'
|
16
|
+
include_examples 'argument output'
|
17
|
+
end
|
18
|
+
|
19
|
+
context 'when argumentw with port given', broken: true do
|
20
|
+
before { ARGV.push(5489) }
|
21
|
+
after { ARGV.pop }
|
22
|
+
|
23
|
+
let(:out) { /No command executed !! No command precise\./ }
|
24
|
+
let(:code) { 100 }
|
25
|
+
|
26
|
+
include_examples 'argument exit'
|
27
|
+
include_examples 'argument output'
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Evostream::CLI::Argument::Search, broken: true do
|
6
|
+
let(:runner) { Evostream::Runner.new }
|
7
|
+
|
8
|
+
context 'when short argument' do
|
9
|
+
before { ARGV.push('--search') }
|
10
|
+
after { ARGV.pop }
|
11
|
+
|
12
|
+
context 'when argument with no search data' do
|
13
|
+
let(:out) { /Connection to Evostream REFUSED !!/ }
|
14
|
+
let(:code) { 201 }
|
15
|
+
|
16
|
+
include_examples 'argument exit'
|
17
|
+
include_examples 'argument output'
|
18
|
+
end
|
19
|
+
|
20
|
+
context 'when argument with search data', broken: true do
|
21
|
+
before { ARGV.push('id: 4') }
|
22
|
+
after { ARGV.pop }
|
23
|
+
|
24
|
+
let(:out) { /Connection to Evostream REFUSED !!/ }
|
25
|
+
let(:code) { 201 }
|
26
|
+
|
27
|
+
include_examples 'argument exit'
|
28
|
+
include_examples 'argument output'
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe Evostream::CLI::Argument::Version do
|
6
|
+
let(:runner) { Evostream::Runner.new }
|
7
|
+
let(:out) { /##################################\n^# Ruby --.*\n^# Evostream::Event -- .*\n##################################/m }
|
8
|
+
let(:code) { 0 }
|
9
|
+
|
10
|
+
context 'when short argument' do
|
11
|
+
before { ARGV.push('-v') }
|
12
|
+
after { ARGV.pop }
|
13
|
+
|
14
|
+
include_examples 'argument exit'
|
15
|
+
include_examples 'argument output'
|
16
|
+
end
|
17
|
+
|
18
|
+
context 'when long argument' do
|
19
|
+
before { ARGV.push('--version') }
|
20
|
+
after { ARGV.pop }
|
21
|
+
|
22
|
+
include_examples 'argument exit'
|
23
|
+
include_examples 'argument output'
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
RSpec::Matchers.define :terminate do |_code|
|
4
|
+
actual = nil
|
5
|
+
|
6
|
+
def supports_block_expectations?
|
7
|
+
true
|
8
|
+
end
|
9
|
+
|
10
|
+
match do |block|
|
11
|
+
actual = block.call
|
12
|
+
# puts "Actual : #{actual.inspect} -- #{@status_code}"
|
13
|
+
actual && actual == status_code
|
14
|
+
end
|
15
|
+
|
16
|
+
chain :with_code do |status_code|
|
17
|
+
# puts "Status Code : #{status_code}"
|
18
|
+
@status_code = status_code
|
19
|
+
end
|
20
|
+
|
21
|
+
failure_message do |_block|
|
22
|
+
"expected block to call exit(#{status_code}) but exit" +
|
23
|
+
(actual.nil? ? ' not called' : "(#{actual}) was called")
|
24
|
+
end
|
25
|
+
|
26
|
+
failure_message_when_negated do |_block|
|
27
|
+
"expected block not to call exit(#{status_code})"
|
28
|
+
end
|
29
|
+
|
30
|
+
description do
|
31
|
+
"expect block to call exit(#{status_code})"
|
32
|
+
end
|
33
|
+
|
34
|
+
def status_code
|
35
|
+
@status_code ||= 0
|
36
|
+
end
|
37
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -16,6 +16,9 @@ Dir['spec/support/**/*.rb'].each do |f|
|
|
16
16
|
require File.expand_path(f)
|
17
17
|
end
|
18
18
|
|
19
|
+
# Load custom matchers
|
20
|
+
Dir['spec/matchers/*.rb'].each { |f| require File.expand_path(f) }
|
21
|
+
|
19
22
|
RSpec.configure do |config|
|
20
23
|
config.expect_with :rspec do |c|
|
21
24
|
c.syntax = :expect
|
@@ -49,6 +52,11 @@ RSpec.configure do |config|
|
|
49
52
|
config.before(:each, type: :response) do
|
50
53
|
stub_request(:any, /server_stream.local/).to_rack(FakeEvostream)
|
51
54
|
end
|
55
|
+
|
56
|
+
config.before(:each, type: :cli) do
|
57
|
+
server = double('server').as_null_object
|
58
|
+
TCPSocket.stub(:new).and_return(server)
|
59
|
+
end
|
52
60
|
end
|
53
61
|
|
54
62
|
# Class for testing
|
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.69
|
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-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -304,6 +304,7 @@ files:
|
|
304
304
|
- lib/evostream/cli/option/host.rb
|
305
305
|
- lib/evostream/cli/option/port.rb
|
306
306
|
- lib/evostream/cli/option/search.rb
|
307
|
+
- lib/evostream/cli/option/version.rb
|
307
308
|
- lib/evostream/cli/runner.rb
|
308
309
|
- lib/evostream/cli/search.rb
|
309
310
|
- lib/evostream/event.rb
|
@@ -329,6 +330,12 @@ files:
|
|
329
330
|
- lib/evostream/event/service.rb
|
330
331
|
- lib/generators/evostream/initializer_generator.rb
|
331
332
|
- spec/cli/argument/command_spec.rb
|
333
|
+
- spec/cli/argument/config_spec.rb
|
334
|
+
- spec/cli/argument/help_spec.rb
|
335
|
+
- spec/cli/argument/host_spec.rb
|
336
|
+
- spec/cli/argument/port_spec.rb
|
337
|
+
- spec/cli/argument/search_spec.rb
|
338
|
+
- spec/cli/argument/version_spec.rb
|
332
339
|
- spec/evostream/action/action_spec.rb
|
333
340
|
- spec/evostream/commands/create_dash_spec.rb
|
334
341
|
- spec/evostream/commands/create_hls_spec.rb
|
@@ -346,8 +353,10 @@ files:
|
|
346
353
|
- spec/evostream/evostream_event_spec.rb
|
347
354
|
- spec/features/push_stream_spec.rb
|
348
355
|
- spec/features/remove_config_spec.rb
|
356
|
+
- spec/matchers/exit_code_matchers.rb
|
349
357
|
- spec/spec_helper.rb
|
350
358
|
- spec/support/examples_actions.rb
|
359
|
+
- spec/support/examples_arguments.rb
|
351
360
|
- spec/support/examples_commands.rb
|
352
361
|
- spec/support/examples_events.rb
|
353
362
|
- spec/support/fake_evostream.rb
|
@@ -386,7 +395,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
386
395
|
requirements:
|
387
396
|
- - ">="
|
388
397
|
- !ruby/object:Gem::Version
|
389
|
-
version:
|
398
|
+
version: 2.4.0
|
390
399
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
391
400
|
requirements:
|
392
401
|
- - ">"
|