ehbrs-tools 0.9.0 → 0.13.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (147) hide show
  1. checksums.yaml +4 -4
  2. data/lib/ehbrs/gems.rb +37 -0
  3. data/lib/ehbrs/google.rb +9 -0
  4. data/lib/ehbrs/google/translate.rb +11 -0
  5. data/lib/ehbrs/google/translate/session.rb +61 -0
  6. data/lib/ehbrs/runner.rb +9 -13
  7. data/lib/ehbrs/runner/finances.rb +19 -0
  8. data/lib/ehbrs/runner/finances/bb_browser.rb +40 -0
  9. data/lib/ehbrs/runner/fs/used_space.rb +4 -4
  10. data/lib/ehbrs/runner/google.rb +19 -0
  11. data/lib/ehbrs/runner/google/translate.rb +92 -0
  12. data/lib/ehbrs/runner/self.rb +19 -0
  13. data/lib/ehbrs/runner/self/test.rb +30 -0
  14. data/lib/ehbrs/runner/videos/series.rb +21 -0
  15. data/lib/ehbrs/runner/videos/series/rename.rb +75 -0
  16. data/lib/ehbrs/tools/version.rb +1 -1
  17. data/lib/ehbrs/videos/series.rb +11 -0
  18. data/lib/ehbrs/videos/series/rename.rb +13 -0
  19. data/lib/ehbrs/videos/series/rename/directory_group.rb +28 -0
  20. data/lib/ehbrs/videos/series/rename/file.rb +114 -0
  21. data/lib/ehbrs/videos/series/rename/file/basename_parser.rb +44 -0
  22. data/lib/ehbrs/videos/series/rename/file/options.rb +30 -0
  23. data/lib/ehbrs/videos/series/rename/line_result.rb +26 -0
  24. data/lib/ehbrs/videos/series/rename/line_result_group.rb +39 -0
  25. data/lib/ehbrs/videos/series/rename/results_builder.rb +32 -0
  26. data/lib/ehbrs/videos/series/rename/season_group.rb +39 -0
  27. data/vendor/aranha-selenium/Gemfile +5 -0
  28. data/vendor/aranha-selenium/aranha-selenium.gemspec +19 -0
  29. data/vendor/aranha-selenium/lib/aranha/selenium.rb +8 -0
  30. data/vendor/aranha-selenium/lib/aranha/selenium/driver_factory.rb +47 -0
  31. data/vendor/aranha-selenium/lib/aranha/selenium/driver_factory/base.rb +76 -0
  32. data/vendor/aranha-selenium/lib/aranha/selenium/driver_factory/chrome.rb +28 -0
  33. data/vendor/aranha-selenium/lib/aranha/selenium/driver_factory/firefox.rb +54 -0
  34. data/vendor/aranha-selenium/lib/aranha/selenium/driver_factory/firefox_auto_download_mime_types +685 -0
  35. data/vendor/aranha-selenium/lib/aranha/selenium/session.rb +78 -0
  36. data/vendor/aranha-selenium/lib/aranha/selenium/version.rb +7 -0
  37. data/vendor/aranha-selenium/spec/rubocop_check_spec.rb +7 -0
  38. data/vendor/aranha-selenium/spec/spec_helper.rb +100 -0
  39. data/vendor/eac_cli/eac_cli.gemspec +3 -3
  40. data/vendor/eac_cli/lib/eac_cli/definition.rb +72 -0
  41. data/vendor/eac_cli/lib/eac_cli/definition/argument_option.rb +13 -0
  42. data/vendor/eac_cli/lib/eac_cli/{runner → definition}/base_option.rb +5 -1
  43. data/vendor/eac_cli/lib/eac_cli/definition/boolean_option.rb +13 -0
  44. data/vendor/eac_cli/lib/eac_cli/{runner → definition}/positional_argument.rb +5 -1
  45. data/vendor/eac_cli/lib/eac_cli/{runner/docopt_doc.rb → docopt/doc_builder.rb} +15 -8
  46. data/vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb +51 -0
  47. data/vendor/eac_cli/lib/eac_cli/parser.rb +14 -0
  48. data/vendor/eac_cli/lib/eac_cli/parser/collector.rb +56 -0
  49. data/vendor/eac_cli/lib/eac_cli/parser/error.rb +15 -0
  50. data/vendor/eac_cli/lib/eac_cli/parser/options_collection.rb +105 -0
  51. data/vendor/eac_cli/lib/eac_cli/parser/parse_result.rb +21 -0
  52. data/vendor/eac_cli/lib/eac_cli/parser/positional_collection.rb +49 -0
  53. data/vendor/eac_cli/lib/eac_cli/runner.rb +25 -5
  54. data/vendor/eac_cli/lib/eac_cli/runner/context.rb +18 -0
  55. data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
  56. data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +70 -0
  57. data/vendor/eac_docker/Gemfile +5 -0
  58. data/vendor/eac_docker/eac_docker.gemspec +18 -0
  59. data/vendor/eac_docker/lib/eac_docker.rb +7 -0
  60. data/vendor/eac_docker/lib/eac_docker/container.rb +50 -0
  61. data/vendor/eac_docker/lib/eac_docker/executables.rb +18 -0
  62. data/vendor/eac_docker/lib/eac_docker/images.rb +9 -0
  63. data/vendor/eac_docker/lib/eac_docker/images/base.rb +14 -0
  64. data/vendor/eac_docker/lib/eac_docker/images/named.rb +30 -0
  65. data/vendor/eac_docker/lib/eac_docker/rspec.rb +17 -0
  66. data/vendor/eac_docker/lib/eac_docker/version.rb +5 -0
  67. data/vendor/eac_docker/spec/lib/eac_docker/executables_spec.rb +9 -0
  68. data/vendor/eac_docker/spec/rubocop_spec.rb +7 -0
  69. data/vendor/eac_docker/spec/spec_helper.rb +103 -0
  70. data/vendor/eac_ruby_utils/eac_ruby_utils.gemspec +1 -1
  71. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/boolean.rb +31 -0
  72. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern.rb +68 -0
  73. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/configs.rb +4 -12
  74. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/configs.rb +1 -1
  75. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner.rb +6 -0
  76. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_class_methods.rb +3 -3
  77. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_subcommands.rb +8 -2
  78. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/speaker.rb +1 -1
  79. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command.rb +1 -0
  80. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/command/extra_options.rb +8 -0
  81. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env.rb +12 -9
  82. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/dasho_options.rb +53 -0
  83. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/identity_file.rb +25 -0
  84. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/quiet.rb +24 -0
  85. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/envs/ssh_env/terminal.rb +34 -0
  86. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/extname.rb +30 -0
  87. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs_cache.rb +1 -0
  88. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable.rb +15 -0
  89. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable/array_accessor.rb +32 -0
  90. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable/base_accessor.rb +23 -0
  91. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable/boolean_accessor.rb +16 -0
  92. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable/class_methods.rb +20 -0
  93. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable/common_accessor.rb +30 -0
  94. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable/hash_accessor.rb +46 -0
  95. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/immutable/instance_methods.rb +21 -0
  96. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/inflector.rb +18 -0
  97. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/list.rb +9 -0
  98. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/lists.rb +10 -12
  99. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/listable/symbol_list.rb +19 -0
  100. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/common_concern.rb +10 -0
  101. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/immutable.rb +10 -0
  102. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/patch.rb +1 -1
  103. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/require_sub.rb +2 -2
  104. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/if_present.rb +1 -1
  105. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/if_respond.rb +22 -0
  106. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/string.rb +4 -0
  107. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/string/inflector.rb +9 -0
  108. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/paths_hash.rb +1 -3
  109. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/require_sub.rb +72 -2
  110. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/struct.rb +47 -0
  111. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/directory.rb +7 -1
  112. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/file.rb +8 -59
  113. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_not_found_error.rb +7 -0
  114. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_providers.rb +25 -0
  115. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_providers/base.rb +23 -0
  116. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_providers/entries_reader.rb +25 -0
  117. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_providers/generic.rb +25 -0
  118. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/templates/variable_providers/hash.rb +29 -0
  119. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
  120. data/vendor/eac_ruby_utils/lib/eac_ruby_utils/yaml.rb +85 -2
  121. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb +42 -0
  122. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_constructor_spec.rb +1 -0
  123. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/console/docopt_runner_spec.rb +5 -5
  124. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/console/speaker_spec.rb +1 -1
  125. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/envs/executable_spec.rb +4 -0
  126. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/fs/extname_spec.rb +18 -0
  127. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/fs/temp/temp_spec.rb +1 -1
  128. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/inflector_spec.rb +15 -0
  129. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/listable_spec.rb +32 -0
  130. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/options_consumer_spec.rb +1 -1
  131. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/hash/sym_keys_hash_spec.rb +1 -1
  132. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/object/if_present_spec.rb +1 -1
  133. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/object/template_spec.rb +1 -1
  134. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/patches/pathname/basename_sub_spec.rb +4 -4
  135. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/require_sub_spec.rb +19 -0
  136. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/require_sub_spec/stubbed_module_a.rb +6 -0
  137. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/require_sub_spec/stubbed_not_module.rb +6 -0
  138. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/ruby_spec.rb +22 -0
  139. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/struct_spec.rb +46 -0
  140. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/file_spec.rb +1 -0
  141. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/templates/searcher_spec.rb +1 -1
  142. data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/yaml_spec.rb +75 -0
  143. data/vendor/eac_ruby_utils/spec/locales/pt-BR.yml +17 -0
  144. metadata +103 -10
  145. data/vendor/eac_cli/lib/eac_cli/runner/argument_option.rb +0 -13
  146. data/vendor/eac_cli/lib/eac_cli/runner/boolean_option.rb +0 -13
  147. data/vendor/eac_cli/lib/eac_cli/runner/definition.rb +0 -64
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module EacRubyUtils
4
+ module Templates
5
+ class VariableNotFoundError < StandardError; end
6
+ end
7
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacRubyUtils
6
+ module Templates
7
+ module VariableProviders
8
+ require_sub __FILE__
9
+
10
+ PROVIDERS = %w[entries_reader hash generic].map do |name|
11
+ "eac_ruby_utils/templates/variable_providers/#{name}".camelize.constantize
12
+ end
13
+
14
+ class << self
15
+ def build(variables_source)
16
+ PROVIDERS.each do |provider|
17
+ return provider.new(variables_source) if provider.accept?(variables_source)
18
+ end
19
+
20
+ raise "Variables provider not found for #{variables_source}"
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/templates/variable_not_found_error'
4
+
5
+ module EacRubyUtils
6
+ module Templates
7
+ module VariableProviders
8
+ class Base
9
+ attr_reader :source
10
+
11
+ def initialize(source)
12
+ @source = source
13
+ end
14
+
15
+ def variable_value(name)
16
+ return variable_fetch(name) if variable_exist?(name)
17
+
18
+ raise VariableNotFoundError, "Variable \"#{name}\" not found in #{source}"
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/templates/variable_providers/base'
4
+
5
+ module EacRubyUtils
6
+ module Templates
7
+ module VariableProviders
8
+ class EntriesReader < ::EacRubyUtils::Templates::VariableProviders::Base
9
+ class << self
10
+ def accept?(variables_source)
11
+ variables_source.respond_to?(:read_entry)
12
+ end
13
+ end
14
+
15
+ def variable_exist?(_name)
16
+ true
17
+ end
18
+
19
+ def variable_fetch(name)
20
+ source.read_entry(name)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/templates/variable_providers/base'
4
+
5
+ module EacRubyUtils
6
+ module Templates
7
+ module VariableProviders
8
+ class Generic < ::EacRubyUtils::Templates::VariableProviders::Base
9
+ class << self
10
+ def accept?(variables_source)
11
+ variables_source.is_a?(::Object)
12
+ end
13
+ end
14
+
15
+ def variable_exist?(name)
16
+ source.respond_to?(name)
17
+ end
18
+
19
+ def variable_fetch(name)
20
+ source.send(name)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/templates/variable_providers/base'
4
+
5
+ module EacRubyUtils
6
+ module Templates
7
+ module VariableProviders
8
+ class Hash < ::EacRubyUtils::Templates::VariableProviders::Base
9
+ class << self
10
+ def accept?(variables_source)
11
+ variables_source.is_a?(::Hash)
12
+ end
13
+ end
14
+
15
+ def initialize(source)
16
+ super(source.with_indifferent_access)
17
+ end
18
+
19
+ def variable_exist?(name)
20
+ source.key?(name)
21
+ end
22
+
23
+ def variable_fetch(name)
24
+ source.fetch(name)
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.32.0'
4
+ VERSION = '0.45.0'
5
5
  end
@@ -3,10 +3,93 @@
3
3
  require 'yaml'
4
4
 
5
5
  module EacRubyUtils
6
+ # A safe YAML loader/dumper with common types included.
6
7
  class Yaml
7
8
  class << self
8
- def load_common(string)
9
- ::YAML.safe_load(string, [::Symbol, ::Date])
9
+ DEFAULT_PERMITTED_CLASSES = [::Array, ::Date, ::FalseClass, ::Hash, ::NilClass, ::Numeric,
10
+ ::String, ::Symbol, ::Time, ::TrueClass].freeze
11
+
12
+ def dump(object)
13
+ ::YAML.dump(sanitize(object))
14
+ end
15
+
16
+ def load(string)
17
+ ::YAML.safe_load(string, permitted_classes)
18
+ end
19
+
20
+ def permitted_classes
21
+ DEFAULT_PERMITTED_CLASSES
22
+ end
23
+
24
+ def sanitize(object)
25
+ Sanitizer.new(object).result
26
+ end
27
+
28
+ def yaml?(object)
29
+ return false unless object.is_a?(::String)
30
+ return false unless object.start_with?('---')
31
+
32
+ load(object)
33
+ true
34
+ rescue ::Psych::SyntaxError
35
+ false
36
+ end
37
+
38
+ class Sanitizer
39
+ attr_reader :source
40
+
41
+ RESULT_TYPES = %w[permitted enumerableable hashable].freeze
42
+
43
+ def initialize(source)
44
+ @source = source
45
+ end
46
+
47
+ def result
48
+ RESULT_TYPES.each do |type|
49
+ return send("result_#{type}") if send("result_#{type}?")
50
+ end
51
+
52
+ source.to_s
53
+ end
54
+
55
+ private
56
+
57
+ def result_enumerableable?
58
+ source.respond_to?(:to_a) && !source.is_a?(::Hash)
59
+ end
60
+
61
+ def result_enumerableable
62
+ source.to_a.map { |child| sanitize_value(child) }
63
+ end
64
+
65
+ def result_hashable?
66
+ source.respond_to?(:to_h)
67
+ end
68
+
69
+ def result_hashable
70
+ source.to_h.map { |k, v| [k.to_sym, sanitize_value(v)] }.to_h
71
+ end
72
+
73
+ def result_nil?
74
+ source.nil?
75
+ end
76
+
77
+ def result_nil
78
+ nil
79
+ end
80
+
81
+ def result_permitted?
82
+ (::EacRubyUtils::Yaml.permitted_classes - [::Array, ::Hash])
83
+ .any? { |klass| source.is_a?(klass) }
84
+ end
85
+
86
+ def result_permitted
87
+ source
88
+ end
89
+
90
+ def sanitize_value(value)
91
+ self.class.new(value).result
92
+ end
10
93
  end
11
94
  end
12
95
  end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/common_concern'
4
+
5
+ RSpec.describe ::EacRubyUtils::CommonConcern do
6
+ let(:instance) do
7
+ described_class.new do
8
+ self.valor = 'changed'
9
+ end
10
+ end
11
+
12
+ module MyModule
13
+ module ClassMethods
14
+ def my_class_method
15
+ 'class'
16
+ end
17
+ end
18
+
19
+ module InstanceMethods
20
+ def my_instance_method
21
+ 'instance'
22
+ end
23
+ end
24
+ end
25
+
26
+ class MyClass
27
+ class << self
28
+ attr_accessor :valor
29
+ end
30
+ end
31
+
32
+ let(:subject) { MyClass.new }
33
+
34
+ before do
35
+ instance.setup(MyModule)
36
+ MyClass.include MyModule
37
+ end
38
+
39
+ it { expect(subject.my_instance_method).to eq('instance') }
40
+ it { expect(subject.class.my_class_method).to eq('class') }
41
+ it { expect(subject.class.valor).to eq('changed') }
42
+ end
@@ -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
- context '#subcommands?' do
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
- context '#subcommand' do
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
- context '#context' do
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
- context '#run' do
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
- context '#run' do
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
- context '#request_input' do
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,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/fs/extname'
4
+
5
+ RSpec.describe ::EacRubyUtils::Fs do
6
+ describe '#extname' do
7
+ {
8
+ 'After.Life.S01E01.WEBRip.x264-ION10.mp4' => '.mp4',
9
+ 's01e01.en.srt' => '.en.srt',
10
+ 's01e01.srt' => '.srt',
11
+ '/path/to/file.tar.gz' => '.tar.gz'
12
+ }.each do |source, expected|
13
+ context "when source is \"#{source}\"" do
14
+ it { expect(described_class.extname(source)).to eq(expected) }
15
+ end
16
+ end
17
+ end
18
+ end
@@ -7,6 +7,6 @@ RSpec.describe ::EacRubyUtils::Fs::Temp::Directory do
7
7
  let(:instance) { described_class.new }
8
8
 
9
9
  it { expect(instance).to be_directory }
10
- it { expect { instance.remove! }.to_not raise_error }
10
+ it { expect { instance.remove! }.not_to raise_error }
11
11
  end
12
12
  end
@@ -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