ehbrs-tools 0.11.0 → 0.14.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ehbrs/executables.rb +1 -1
- data/lib/ehbrs/google.rb +9 -0
- data/lib/ehbrs/google/translate.rb +11 -0
- data/lib/ehbrs/google/translate/session.rb +61 -0
- data/lib/ehbrs/runner.rb +9 -13
- data/lib/ehbrs/runner/finances.rb +19 -0
- data/lib/ehbrs/runner/finances/bb_browser.rb +40 -0
- data/lib/ehbrs/runner/fs/used_space.rb +4 -4
- data/lib/ehbrs/runner/google.rb +19 -0
- data/lib/ehbrs/runner/google/translate.rb +92 -0
- data/lib/ehbrs/runner/videos.rb +6 -11
- data/lib/ehbrs/runner/videos/probe.rb +35 -0
- data/lib/ehbrs/tools/version.rb +1 -1
- data/lib/ehbrs/videos/file.rb +2 -1
- data/lib/ehbrs/videos/unsupported/fix_profile.rb +1 -0
- data/vendor/aranha-selenium/Gemfile +5 -0
- data/vendor/aranha-selenium/aranha-selenium.gemspec +19 -0
- data/vendor/aranha-selenium/lib/aranha/selenium.rb +8 -0
- data/vendor/aranha-selenium/lib/aranha/selenium/driver_factory.rb +47 -0
- data/vendor/aranha-selenium/lib/aranha/selenium/driver_factory/base.rb +76 -0
- data/vendor/aranha-selenium/lib/aranha/selenium/driver_factory/chrome.rb +28 -0
- data/vendor/aranha-selenium/lib/aranha/selenium/driver_factory/firefox.rb +54 -0
- data/vendor/aranha-selenium/lib/aranha/selenium/driver_factory/firefox_auto_download_mime_types +685 -0
- data/vendor/aranha-selenium/lib/aranha/selenium/session.rb +78 -0
- data/vendor/aranha-selenium/lib/aranha/selenium/version.rb +7 -0
- data/vendor/aranha-selenium/spec/rubocop_check_spec.rb +7 -0
- data/vendor/aranha-selenium/spec/spec_helper.rb +100 -0
- data/vendor/eac_cli/eac_cli.gemspec +3 -3
- data/vendor/eac_cli/lib/eac_cli/core_ext.rb +4 -0
- data/vendor/eac_cli/lib/eac_cli/default_runner.rb +6 -14
- data/vendor/eac_cli/lib/eac_cli/definition.rb +72 -0
- data/vendor/eac_cli/lib/eac_cli/definition/argument_option.rb +13 -0
- data/vendor/eac_cli/lib/eac_cli/{runner → definition}/base_option.rb +5 -1
- data/vendor/eac_cli/lib/eac_cli/definition/boolean_option.rb +13 -0
- data/vendor/eac_cli/lib/eac_cli/{runner → definition}/positional_argument.rb +5 -1
- data/vendor/eac_cli/lib/eac_cli/{runner/docopt_doc.rb → docopt/doc_builder.rb} +15 -8
- data/vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb +45 -0
- data/vendor/eac_cli/lib/eac_cli/parser.rb +14 -0
- data/vendor/eac_cli/lib/eac_cli/parser/collector.rb +56 -0
- data/vendor/eac_cli/lib/eac_cli/parser/error.rb +15 -0
- data/vendor/eac_cli/lib/eac_cli/parser/options_collection.rb +105 -0
- data/vendor/eac_cli/lib/eac_cli/parser/parse_result.rb +21 -0
- data/vendor/eac_cli/lib/eac_cli/parser/positional_collection.rb +49 -0
- data/vendor/eac_cli/lib/eac_cli/patches.rb +4 -0
- data/vendor/eac_cli/lib/eac_cli/patches/object.rb +5 -0
- data/vendor/eac_cli/lib/eac_cli/patches/object/runner_with.rb +24 -0
- data/vendor/eac_cli/lib/eac_cli/runner.rb +64 -7
- data/vendor/eac_cli/lib/eac_cli/runner/context.rb +18 -0
- data/vendor/eac_cli/lib/eac_cli/runner_with.rb +9 -0
- data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +19 -0
- data/vendor/eac_cli/lib/eac_cli/runner_with/output_file.rb +26 -0
- data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
- data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +70 -0
- data/vendor/eac_docker/Gemfile +5 -0
- data/vendor/eac_docker/eac_docker.gemspec +18 -0
- data/vendor/eac_docker/lib/eac_docker.rb +7 -0
- data/vendor/eac_docker/lib/eac_docker/container.rb +50 -0
- data/vendor/eac_docker/lib/eac_docker/executables.rb +18 -0
- data/vendor/eac_docker/lib/eac_docker/images.rb +9 -0
- data/vendor/eac_docker/lib/eac_docker/images/base.rb +14 -0
- data/vendor/eac_docker/lib/eac_docker/images/named.rb +30 -0
- data/vendor/eac_docker/lib/eac_docker/rspec.rb +17 -0
- data/vendor/eac_docker/lib/eac_docker/version.rb +5 -0
- data/vendor/eac_docker/spec/lib/eac_docker/executables_spec.rb +9 -0
- data/vendor/eac_docker/spec/rubocop_spec.rb +7 -0
- data/vendor/eac_docker/spec/spec_helper.rb +103 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/boolean.rb +31 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern.rb +68 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/configs.rb +4 -12
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs.rb +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner.rb +6 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_class_methods.rb +3 -3
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_subcommands.rb +8 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/speaker.rb +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command.rb +1 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/extra_options.rb +8 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env.rb +12 -9
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/dasho_options.rb +53 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/identity_file.rb +25 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/quiet.rb +24 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/terminal.rb +34 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs_cache.rb +1 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable.rb +15 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable/array_accessor.rb +32 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable/base_accessor.rb +23 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable/boolean_accessor.rb +16 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable/class_methods.rb +20 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable/common_accessor.rb +30 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable/hash_accessor.rb +46 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable/instance_methods.rb +21 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/inflector.rb +18 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/list.rb +9 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/lists.rb +10 -12
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/symbol_list.rb +19 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/value.rb +3 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/common_concern.rb +10 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/immutable.rb +10 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/patch.rb +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/require_sub.rb +2 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/if_present.rb +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/if_respond.rb +22 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/string.rb +4 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/string/inflector.rb +9 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash.rb +1 -3
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/require_sub.rb +72 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/simple_cache.rb +6 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/struct.rb +53 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/directory.rb +7 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/file.rb +8 -59
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_not_found_error.rb +7 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_providers.rb +25 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_providers/base.rb +23 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_providers/entries_reader.rb +25 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_providers/generic.rb +25 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_providers/hash.rb +29 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/yaml.rb +85 -2
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb +42 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_constructor_spec.rb +1 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/console/docopt_runner_spec.rb +5 -5
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/console/speaker_spec.rb +1 -1
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/envs/executable_spec.rb +4 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/fs/temp/temp_spec.rb +1 -1
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/inflector_spec.rb +15 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/listable_spec.rb +32 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb +1 -1
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/hash/sym_keys_hash_spec.rb +1 -1
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/object/if_present_spec.rb +1 -1
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/object/template_spec.rb +1 -1
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/pathname/basename_sub_spec.rb +4 -4
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/require_sub_spec.rb +19 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/require_sub_spec/stubbed_module_a.rb +6 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/require_sub_spec/stubbed_not_module.rb +6 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/ruby_spec.rb +22 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/struct_spec.rb +46 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb +1 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/searcher_spec.rb +1 -1
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/yaml_spec.rb +75 -0
- data/vendor/eac_ruby_utils/spec/locales/pt-BR.yml +17 -0
- data/vendor/ehbrs_ruby_utils/Gemfile +16 -0
- data/vendor/ehbrs_ruby_utils/ehbrs_ruby_utils.gemspec +20 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils.rb +7 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/executables.rb +28 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/version.rb +5 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos.rb +9 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container.rb +11 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container/file.rb +31 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/container/info.rb +21 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/quality.rb +68 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/resolution.rb +68 -0
- data/vendor/ehbrs_ruby_utils/spec/lib/ehbrs_ruby_utils/videos/resolution_spec.rb +18 -0
- data/vendor/ehbrs_ruby_utils/spec/rubocop_check_spec.rb +7 -0
- data/vendor/ehbrs_ruby_utils/spec/spec_helper.rb +100 -0
- metadata +108 -10
- data/vendor/eac_cli/lib/eac_cli/runner/argument_option.rb +0 -13
- data/vendor/eac_cli/lib/eac_cli/runner/boolean_option.rb +0 -13
- data/vendor/eac_cli/lib/eac_cli/runner/definition.rb +0 -64
@@ -27,6 +27,7 @@ RSpec.describe ::EacRubyUtils::CommonConstructor do
|
|
27
27
|
it "attribute \"#{attr}\" equal to \"#{expected_value}\"" do
|
28
28
|
expect(subject.send(attr)).to eq(expected_value)
|
29
29
|
end
|
30
|
+
|
30
31
|
[false, true].each do |include_all|
|
31
32
|
it "respond_to?('#{attr}', #{include_all}) == #{include_all}" do
|
32
33
|
expect(subject.respond_to?("#{attr}=", include_all)).to eq(include_all)
|
@@ -66,7 +66,7 @@ RSpec.describe ::EacRubyUtils::Console::DocoptRunner do
|
|
66
66
|
|
67
67
|
let(:instance) { RunnerWithSubcommands.new }
|
68
68
|
|
69
|
-
|
69
|
+
describe '#subcommands?' do
|
70
70
|
it 'returns true' do
|
71
71
|
expect(instance.subcommands?).to eq(true)
|
72
72
|
end
|
@@ -85,19 +85,19 @@ RSpec.describe ::EacRubyUtils::Console::DocoptRunner do
|
|
85
85
|
it { expect(instance.target_doc).to include('Subcommands:') }
|
86
86
|
end
|
87
87
|
|
88
|
-
|
88
|
+
describe '#subcommand' do
|
89
89
|
it 'is of subcommand class' do
|
90
90
|
expect(instance.subcommand).to be_a(RunnerWithSubcommands::MySubCommand)
|
91
91
|
end
|
92
92
|
end
|
93
93
|
|
94
|
-
|
94
|
+
describe '#context' do
|
95
95
|
it 'accesses instance methods by subcommand' do
|
96
96
|
expect(instance.subcommand.context(:parent_arg)).to eq('value0')
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
-
|
100
|
+
describe '#run' do
|
101
101
|
it 'calls subcommand' do
|
102
102
|
instance.run
|
103
103
|
expect(instance.subarg_value).to eq('value1')
|
@@ -109,7 +109,7 @@ RSpec.describe ::EacRubyUtils::Console::DocoptRunner do
|
|
109
109
|
context 'when subcommand is invalid' do
|
110
110
|
let(:instance) { RunnerWithSubcommands.new(argv: %w[value0 invalid-subcommand]) }
|
111
111
|
|
112
|
-
|
112
|
+
describe '#run' do
|
113
113
|
it 'raises Docopt::Exit' do
|
114
114
|
expect { instance.run }.to raise_error(::Docopt::Exit)
|
115
115
|
end
|
@@ -9,7 +9,7 @@ RSpec.describe ::EacRubyUtils::Console::Speaker do
|
|
9
9
|
r
|
10
10
|
end
|
11
11
|
|
12
|
-
|
12
|
+
describe '#request_input' do
|
13
13
|
it 'recover value from hash list' do
|
14
14
|
allow(instance).to receive(:request_string).and_return('opt1')
|
15
15
|
list = { opt1: 'value1', opt2: 'value2' }
|
@@ -5,6 +5,7 @@ require 'eac_ruby_utils/envs/local_env'
|
|
5
5
|
|
6
6
|
RSpec.describe ::EacRubyUtils::Envs::Executable do
|
7
7
|
let(:env) { ::EacRubyUtils::Envs::LocalEnv.new }
|
8
|
+
|
8
9
|
context 'when program exist' do
|
9
10
|
let(:instance) { described_class.new(env, 'cat', '--version') }
|
10
11
|
|
@@ -18,12 +19,15 @@ RSpec.describe ::EacRubyUtils::Envs::Executable do
|
|
18
19
|
let(:instance) { described_class.new(env, 'this_cannot_exist', '--version') }
|
19
20
|
|
20
21
|
it { expect(instance.exist?).to eq(false) }
|
22
|
+
|
21
23
|
it {
|
22
24
|
expect { instance.validate! }.to raise_error(
|
23
25
|
described_class.const_get('ProgramNotFoundError')
|
24
26
|
)
|
25
27
|
}
|
28
|
+
|
26
29
|
it { expect(instance.validate).to be_present }
|
30
|
+
|
27
31
|
it {
|
28
32
|
expect { instance.command }.to raise_error(
|
29
33
|
described_class.const_get('ProgramNotFoundError')
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/inflector'
|
4
|
+
|
5
|
+
RSpec.describe ::EacRubyUtils::Inflector do
|
6
|
+
describe '#variableize' do
|
7
|
+
{
|
8
|
+
'_A_variableName' => 'a_variablename'
|
9
|
+
}.each do |source, expected|
|
10
|
+
context "when source is \"#{source}\"" do
|
11
|
+
it { expect(described_class.variableize(source)).to eq(expected) }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -11,6 +11,8 @@ class Stub
|
|
11
11
|
lists.add_integer :code, 7 => :a, 13 => :b
|
12
12
|
lists.add_string :cadeia, :a, :b, :c
|
13
13
|
lists.add_string :type, 'Namespace::ClazzA' => :a, 'Namespace::ClazzB' => :b
|
14
|
+
lists.add_symbol :simbolo, :a, :b, :c
|
15
|
+
lists.add_symbol :tipado, :tipo_aaa => :a, 'tipo_bbb' => :b
|
14
16
|
end
|
15
17
|
|
16
18
|
RSpec.describe ::EacRubyUtils::Listable do
|
@@ -19,6 +21,8 @@ RSpec.describe ::EacRubyUtils::Listable do
|
|
19
21
|
it { expect(Stub.lists.code.values).to eq([7, 13]) }
|
20
22
|
it { expect(Stub.lists.cadeia.values).to eq(%w[a b c]) }
|
21
23
|
it { expect(Stub.lists.type.values).to eq(%w[Namespace::ClazzA Namespace::ClazzB]) }
|
24
|
+
it { expect(Stub.lists.simbolo.values).to eq(%i[a b c]) }
|
25
|
+
it { expect(Stub.lists.tipado.values).to eq(%i[tipo_aaa tipo_bbb]) }
|
22
26
|
end
|
23
27
|
|
24
28
|
context 'value instance options' do
|
@@ -26,18 +30,31 @@ RSpec.describe ::EacRubyUtils::Listable do
|
|
26
30
|
expect(Stub.lists.inteiro.options)
|
27
31
|
.to eq([['Inteiro A', 1], ['Inteiro BB', 2], ['Inteiro CCC', 3]])
|
28
32
|
}
|
33
|
+
|
29
34
|
it {
|
30
35
|
expect(Stub.lists.code.options)
|
31
36
|
.to eq([['Código A', 7], ['Código B', 13]])
|
32
37
|
}
|
38
|
+
|
33
39
|
it {
|
34
40
|
expect(Stub.lists.cadeia.options)
|
35
41
|
.to eq([['Cadeia AAA', 'a'], ['Cadeia BB', 'b'], ['Cadeia C', 'c']])
|
36
42
|
}
|
43
|
+
|
37
44
|
it {
|
38
45
|
expect(Stub.lists.type.options)
|
39
46
|
.to eq([['Tipo A', 'Namespace::ClazzA'], ['Tipo B', 'Namespace::ClazzB']])
|
40
47
|
}
|
48
|
+
|
49
|
+
it {
|
50
|
+
expect(Stub.lists.simbolo.options)
|
51
|
+
.to eq([['Simbolo A', :a], ['Simbolo B', :b], ['Simbolo C', :c]])
|
52
|
+
}
|
53
|
+
|
54
|
+
it {
|
55
|
+
expect(Stub.lists.tipado.options)
|
56
|
+
.to eq([['Tipado A', :tipo_aaa], ['Tipado B', :tipo_bbb]])
|
57
|
+
}
|
41
58
|
end
|
42
59
|
|
43
60
|
context 'constants' do
|
@@ -50,6 +67,11 @@ RSpec.describe ::EacRubyUtils::Listable do
|
|
50
67
|
it { expect(Stub::CADEIA_C).to eq('c') }
|
51
68
|
it { expect(Stub::TYPE_A).to eq('Namespace::ClazzA') }
|
52
69
|
it { expect(Stub::TYPE_B).to eq('Namespace::ClazzB') }
|
70
|
+
it { expect(Stub::SIMBOLO_A).to eq(:a) }
|
71
|
+
it { expect(Stub::SIMBOLO_B).to eq(:b) }
|
72
|
+
it { expect(Stub::SIMBOLO_C).to eq(:c) }
|
73
|
+
it { expect(Stub::TIPADO_A).to eq(:tipo_aaa) }
|
74
|
+
it { expect(Stub::TIPADO_B).to eq(:tipo_bbb) }
|
53
75
|
end
|
54
76
|
|
55
77
|
context 'values instances' do
|
@@ -110,60 +132,70 @@ RSpec.describe ::EacRubyUtils::Listable do
|
|
110
132
|
|
111
133
|
context 'when inteiro value is A' do
|
112
134
|
before { instance.inteiro = Stub::INTEIRO_A }
|
135
|
+
|
113
136
|
it { expect(instance.inteiro_label).to eq('Inteiro A') }
|
114
137
|
it { expect(instance.inteiro_description).to eq('Inteiro A Descr.') }
|
115
138
|
end
|
116
139
|
|
117
140
|
context 'when inteiro value is A' do
|
118
141
|
before { instance.inteiro = Stub::INTEIRO_B }
|
142
|
+
|
119
143
|
it { expect(instance.inteiro_label).to eq('Inteiro BB') }
|
120
144
|
it { expect(instance.inteiro_description).to eq('Inteiro BB Descr.') }
|
121
145
|
end
|
122
146
|
|
123
147
|
context 'when inteiro value is C' do
|
124
148
|
before { instance.inteiro = Stub::INTEIRO_C }
|
149
|
+
|
125
150
|
it { expect(instance.inteiro_label).to eq('Inteiro CCC') }
|
126
151
|
it { expect(instance.inteiro_description).to eq('Inteiro CCC Descr.') }
|
127
152
|
end
|
128
153
|
|
129
154
|
context 'when code value is A' do
|
130
155
|
before { instance.code = Stub::CODE_A }
|
156
|
+
|
131
157
|
it { expect(instance.code_label).to eq('Código A') }
|
132
158
|
it { expect(instance.code_description).to eq('Código A Descr.') }
|
133
159
|
end
|
134
160
|
|
135
161
|
context 'when code value is B' do
|
136
162
|
before { instance.code = Stub::CODE_B }
|
163
|
+
|
137
164
|
it { expect(instance.code_label).to eq('Código B') }
|
138
165
|
it { expect(instance.code_description).to eq('Código B Descr.') }
|
139
166
|
end
|
140
167
|
|
141
168
|
context 'when cadeia value is A' do
|
142
169
|
before { instance.cadeia = Stub::CADEIA_A }
|
170
|
+
|
143
171
|
it { expect(instance.cadeia_label).to eq('Cadeia AAA') }
|
144
172
|
it { expect(instance.cadeia_description).to eq('Cadeia AAA Descr.') }
|
145
173
|
end
|
146
174
|
|
147
175
|
context 'when cadeia value is B' do
|
148
176
|
before { instance.cadeia = Stub::CADEIA_B }
|
177
|
+
|
149
178
|
it { expect(instance.cadeia_label).to eq('Cadeia BB') }
|
150
179
|
it { expect(instance.cadeia_description).to eq('Cadeia BB Descr.') }
|
151
180
|
end
|
152
181
|
|
153
182
|
context 'when cadeia value is C' do
|
154
183
|
before { instance.cadeia = Stub::CADEIA_C }
|
184
|
+
|
155
185
|
it { expect(instance.cadeia_label).to eq('Cadeia C') }
|
156
186
|
it { expect(instance.cadeia_description).to eq('Cadeia C Descr.') }
|
157
187
|
end
|
158
188
|
|
159
189
|
context 'when type value is A' do
|
160
190
|
before { instance.type = Stub::TYPE_A }
|
191
|
+
|
161
192
|
it { expect(instance.type_label).to eq('Tipo A') }
|
162
193
|
it { expect(instance.type_description).to eq('Tipo A Descr.') }
|
163
194
|
end
|
164
195
|
|
165
196
|
context 'when type value is B' do
|
166
197
|
before { instance.type = Stub::TYPE_B }
|
198
|
+
|
167
199
|
it { expect(instance.type_label).to eq('Tipo B') }
|
168
200
|
it { expect(instance.type_description).to eq('Tipo B Descr.') }
|
169
201
|
end
|
@@ -5,7 +5,7 @@ require 'eac_ruby_utils/patches/hash/sym_keys_hash'
|
|
5
5
|
RSpec.describe ::Hash do
|
6
6
|
let(:a_hash) { { 'a' => 'a_value', 1 => '1_value', s: 's_value' } }
|
7
7
|
|
8
|
-
|
8
|
+
describe '#to_sym_keys_hash' do
|
9
9
|
it 'converts all keys to symbols' do
|
10
10
|
expect(a_hash.to_sym_keys_hash).to eq(a: 'a_value', '1': '1_value', s: 's_value')
|
11
11
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'eac_ruby_utils/patches/object/if_present'
|
4
4
|
|
5
5
|
RSpec.describe ::Object do
|
6
|
-
|
6
|
+
describe '#if_present' do
|
7
7
|
it { expect(nil.if_present).to eq(nil) }
|
8
8
|
it { expect(nil.if_present('default')) .to eq('default') }
|
9
9
|
it { expect(nil.if_present('default') { |_v| 'calculated' }).to eq('default') }
|
@@ -17,7 +17,7 @@ RSpec.describe ::Object do
|
|
17
17
|
::EacRubyUtils::Templates::Searcher.default.included_paths.delete(templates_path)
|
18
18
|
end
|
19
19
|
|
20
|
-
|
20
|
+
describe '#template' do
|
21
21
|
it { expect(instance.template).to be_a(::EacRubyUtils::Templates::File) }
|
22
22
|
end
|
23
23
|
end
|
@@ -4,14 +4,14 @@ require 'eac_ruby_utils/patches/pathname/basename_sub'
|
|
4
4
|
|
5
5
|
RSpec.describe ::Pathname do
|
6
6
|
it do
|
7
|
-
expect(
|
8
|
-
|
7
|
+
expect(described_class.new('/absolute/path/to/file').basename_sub { |_b| 'other_file' }).to eq(
|
8
|
+
described_class.new('/absolute/path/to/other_file')
|
9
9
|
)
|
10
10
|
end
|
11
11
|
|
12
12
|
it do
|
13
|
-
expect(
|
14
|
-
|
13
|
+
expect(described_class.new('file').basename_sub { |b| b.to_s + '_appended' }).to eq(
|
14
|
+
described_class.new('file_appended')
|
15
15
|
)
|
16
16
|
end
|
17
17
|
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/require_sub'
|
4
|
+
|
5
|
+
RSpec.describe ::EacRubyUtils::RequireSub do
|
6
|
+
class RequireSubStubClass
|
7
|
+
end
|
8
|
+
|
9
|
+
let(:instance) { described_class.new(__FILE__, base: RequireSubStubClass, include_modules: true) }
|
10
|
+
|
11
|
+
before do
|
12
|
+
instance.apply
|
13
|
+
end
|
14
|
+
|
15
|
+
it do
|
16
|
+
expect(RequireSubStubClass.included_modules)
|
17
|
+
.to include(RequireSubStubClass::StubbedModuleA)
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/ruby'
|
4
|
+
|
5
|
+
RSpec.describe ::EacRubyUtils::Ruby do
|
6
|
+
describe '#on_clean_environment' do
|
7
|
+
let(:envvar_name) { 'BUNDLE_NOT_EXISTENT_ENV_VAR' }
|
8
|
+
let(:envvar_value) { 'any value' }
|
9
|
+
|
10
|
+
before do
|
11
|
+
ENV[envvar_name] = envvar_value
|
12
|
+
end
|
13
|
+
|
14
|
+
it do # rubocop:disable RSpec/MultipleExpectations
|
15
|
+
expect(ENV[envvar_name]).to eq(envvar_value)
|
16
|
+
described_class.on_clean_environment do
|
17
|
+
expect(ENV[envvar_name]).to eq(nil)
|
18
|
+
end
|
19
|
+
expect(ENV[envvar_name]).to eq(envvar_value)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_utils/struct'
|
4
|
+
|
5
|
+
RSpec.describe ::EacRubyUtils::Struct do
|
6
|
+
let(:instance) { described_class.new(a: 1, b: '') }
|
7
|
+
|
8
|
+
describe '#[]' do
|
9
|
+
it { expect(instance[:a]).to eq(1) }
|
10
|
+
it { expect(instance['a']).to eq(1) }
|
11
|
+
it { expect(instance[:a?]).to eq(true) }
|
12
|
+
it { expect(instance['a?']).to eq(true) }
|
13
|
+
it { expect(instance[:b]).to eq('') }
|
14
|
+
it { expect(instance['b']).to eq('') }
|
15
|
+
it { expect(instance[:b?]).to eq(false) }
|
16
|
+
it { expect(instance['b?']).to eq(false) }
|
17
|
+
it { expect(instance[:c]).to eq(nil) }
|
18
|
+
it { expect(instance['c']).to eq(nil) }
|
19
|
+
it { expect(instance[:c?]).to eq(false) }
|
20
|
+
it { expect(instance['c?']).to eq(false) }
|
21
|
+
end
|
22
|
+
|
23
|
+
describe '#fetch' do
|
24
|
+
it { expect(instance.fetch(:a)).to eq(1) }
|
25
|
+
it { expect(instance.fetch('a')).to eq(1) }
|
26
|
+
it { expect(instance.fetch(:a?)).to eq(true) }
|
27
|
+
it { expect(instance.fetch('a?')).to eq(true) }
|
28
|
+
it { expect(instance.fetch(:b)).to eq('') }
|
29
|
+
it { expect(instance.fetch('b')).to eq('') }
|
30
|
+
it { expect(instance.fetch(:b?)).to eq(false) }
|
31
|
+
it { expect(instance.fetch('b?')).to eq(false) }
|
32
|
+
it { expect { instance.fetch(:c) }.to raise_error(::KeyError) }
|
33
|
+
it { expect { instance.fetch('c') }.to raise_error(::KeyError) }
|
34
|
+
it { expect { instance.fetch(:c?) }.to raise_error(::KeyError) }
|
35
|
+
it { expect { instance.fetch('c?') }.to raise_error(::KeyError) }
|
36
|
+
end
|
37
|
+
|
38
|
+
describe '#property_method' do
|
39
|
+
it { expect(instance.a).to eq(1) }
|
40
|
+
it { expect(instance.a?).to eq(true) }
|
41
|
+
it { expect(instance.b).to eq('') }
|
42
|
+
it { expect(instance.b?).to eq(false) }
|
43
|
+
it { expect { instance.c }.to raise_error(::NoMethodError) }
|
44
|
+
it { expect { instance.c? }.to raise_error(::NoMethodError) }
|
45
|
+
end
|
46
|
+
end
|
@@ -20,7 +20,7 @@ RSpec.describe ::EacRubyUtils::Templates::Searcher do
|
|
20
20
|
}.each do |klass, subpaths|
|
21
21
|
subpaths.each do |subpath|
|
22
22
|
context "when subpath is \"#{subpath}\"" do
|
23
|
-
it "
|
23
|
+
it "returns a #{klass}'s instance" do
|
24
24
|
expect(instance.template(subpath, false)).to be_a(klass)
|
25
25
|
end
|
26
26
|
end
|
@@ -0,0 +1,75 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'active_support/hash_with_indifferent_access'
|
4
|
+
require 'eac_ruby_utils/yaml'
|
5
|
+
|
6
|
+
RSpec.describe ::EacRubyUtils::Yaml do
|
7
|
+
let(:unpermitted_class) do
|
8
|
+
Class.new do
|
9
|
+
def initialize(value)
|
10
|
+
@value = value
|
11
|
+
end
|
12
|
+
|
13
|
+
def to_s
|
14
|
+
@value.to_s
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:arrayliable_class) do
|
20
|
+
Class.new do
|
21
|
+
def initialize(value)
|
22
|
+
@value = value
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_a
|
26
|
+
[@value]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
let(:source) do
|
32
|
+
{
|
33
|
+
a: 'a', b: :b, c: false, d: true, e: nil,
|
34
|
+
f: [
|
35
|
+
'f',
|
36
|
+
{
|
37
|
+
g: 'g',
|
38
|
+
h: ::ActiveSupport::HashWithIndifferentAccess.new(
|
39
|
+
'i' => ['i', unpermitted_class.new('j')],
|
40
|
+
k: arrayliable_class.new('k')
|
41
|
+
)
|
42
|
+
}
|
43
|
+
]
|
44
|
+
}
|
45
|
+
end
|
46
|
+
|
47
|
+
let(:target) do
|
48
|
+
{
|
49
|
+
a: 'a', b: :b, c: false, d: true, e: nil,
|
50
|
+
f: ['f', { g: 'g', h: { i: %w[i j], k: ['k'] } }]
|
51
|
+
}
|
52
|
+
end
|
53
|
+
|
54
|
+
describe '#dump' do
|
55
|
+
it { expect(described_class.load(described_class.dump(source))).to eq(target) }
|
56
|
+
end
|
57
|
+
|
58
|
+
describe '#sanitize' do
|
59
|
+
it { expect(described_class.sanitize(target)).to eq(target) }
|
60
|
+
end
|
61
|
+
|
62
|
+
describe '#yaml' do
|
63
|
+
{
|
64
|
+
['text'] => false,
|
65
|
+
'text' => false,
|
66
|
+
"--- Text\n\n" => true,
|
67
|
+
"---\n" + ":index: 0\n" + ":codec_name: h264\n" + ":codec_type: video\n" => true,
|
68
|
+
'--- - \n bla bla bla' => false
|
69
|
+
}.each do |source, result|
|
70
|
+
it "return #{result} to source \"#{source}\"" do
|
71
|
+
expect(described_class.yaml?(source)).to eq(result)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|