ehbrs-tools 0.16.3 → 0.19.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/ehbrs/cooking_book.rb +9 -0
- data/lib/ehbrs/cooking_book/build.rb +45 -0
- data/lib/ehbrs/cooking_book/build/base_page.rb +43 -0
- data/lib/ehbrs/cooking_book/build/index_page.rb +26 -0
- data/lib/ehbrs/cooking_book/build/recipe_page.rb +27 -0
- data/lib/ehbrs/cooking_book/project.rb +25 -0
- data/lib/ehbrs/cooking_book/recipe.rb +37 -0
- data/lib/ehbrs/cooking_book/recipe/ingredient.rb +21 -0
- data/lib/ehbrs/cooking_book/recipe/measure.rb +60 -0
- data/lib/ehbrs/cooking_book/recipe/part.rb +32 -0
- data/lib/ehbrs/patches/module/erb_template.rb +11 -0
- data/lib/ehbrs/patches/object/erb_template.rb +9 -0
- data/lib/ehbrs/patches/object/template.rb +7 -0
- data/lib/ehbrs/runner.rb +6 -13
- data/lib/ehbrs/runner/cooking_book.rb +30 -0
- data/lib/ehbrs/runner/cooking_book/build.rb +32 -0
- data/lib/ehbrs/runner/telegram.rb +26 -0
- data/lib/ehbrs/runner/telegram/send_message.rb +29 -0
- data/lib/ehbrs/runner/videos/unsupported.rb +1 -1
- data/lib/ehbrs/telegram.rb +9 -0
- data/lib/ehbrs/telegram/message_sending.rb +32 -0
- data/lib/ehbrs/tools/application.rb +13 -0
- data/lib/ehbrs/tools/instance.rb +16 -0
- data/lib/ehbrs/tools/version.rb +1 -1
- data/lib/ehbrs/videos/track.rb +1 -19
- data/lib/ehbrs/videos/unsupported/check_support.rb +1 -1
- data/lib/ehbrs/videos/unsupported/checks/codec_extra_unlisted.rb +1 -1
- data/lib/ehbrs/videos/unsupported/checks/codec_extra_unsupported.rb +1 -1
- data/lib/ehbrs/videos/unsupported/checks/codec_unlisted.rb +2 -2
- data/lib/ehbrs/videos/unsupported/checks/codec_unsupported.rb +1 -1
- data/lib/ehbrs/videos/unsupported/fix_profile.rb +0 -13
- data/lib/ehbrs/videos/unsupported/fixes/supported_codec.rb +10 -10
- data/lib/ehbrs/videos/unsupported/profiles/aoc.rb +27 -0
- data/template/ehbrs/cooking_book/build/base_page/layout.html.erb +20 -0
- data/template/ehbrs/cooking_book/build/index_page/inner.html.erb +6 -0
- data/template/ehbrs/cooking_book/build/recipe_page/inner.html.erb +6 -0
- data/template/ehbrs/cooking_book/build/recipe_page/part.html.erb +27 -0
- data/vendor/eac_cli/lib/eac_cli/docopt/runner_context_replacement.rb +15 -0
- data/vendor/eac_cli/lib/eac_cli/docopt/runner_extension.rb +5 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative.rb +4 -4
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/long_options.rb +37 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/option_argument.rb +29 -0
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/options.rb +7 -36
- data/vendor/eac_cli/lib/eac_cli/parser/alternative/short_options.rb +45 -0
- data/vendor/eac_cli/lib/eac_cli/runner_with/help.rb +3 -1
- data/vendor/eac_cli/lib/eac_cli/runner_with/subcommands.rb +19 -2
- data/vendor/eac_cli/lib/eac_cli/version.rb +1 -1
- data/vendor/eac_cli/spec/lib/eac_cli/runner_spec.rb +22 -1
- data/vendor/eac_cli/spec/lib/eac_cli/runner_with/subcommands_spec.rb +29 -0
- data/vendor/eac_ruby_base0/Gemfile +5 -0
- data/vendor/eac_ruby_base0/eac_ruby_base0.gemspec +20 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0.rb +7 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/application.rb +69 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner.rb +54 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/runner/test_all.rb +22 -0
- data/vendor/eac_ruby_base0/lib/eac_ruby_base0/version.rb +5 -0
- data/vendor/eac_ruby_base0/spec/rubocop_spec.rb +7 -0
- data/vendor/eac_ruby_base0/spec/spec_helper.rb +100 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_concern/module_setup.rb +16 -6
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor.rb +2 -99
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/class_initialize.rb +29 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/instance_initialize.rb +53 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/common_constructor/super_args.rb +54 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/console/docopt_runner/_subcommands.rb +10 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/fs/traverser.rb +0 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/inflector.rb +4 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/local_time_zone.rb +38 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel.rb +4 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/kernel/nyi.rb +8 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/module/template.rb +10 -0
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/template.rb +1 -8
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname/basename_sub.rb +2 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/default_time_zone_set.rb +3 -2
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/version.rb +1 -1
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/yaml.rb +8 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_concern_spec.rb +14 -4
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/common_constructor_spec.rb +30 -0
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/inflector_spec.rb +2 -1
- data/vendor/eac_ruby_utils/spec/lib/eac_ruby_utils/local_time_zone_spec.rb +17 -0
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/version.rb +1 -1
- data/vendor/ehbrs_ruby_utils/lib/ehbrs_ruby_utils/videos/stream.rb +1 -1
- metadata +89 -9
- data/vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/time/local_time_zone.rb +0 -25
@@ -35,11 +35,11 @@ module EacCli
|
|
35
35
|
attr_accessor :phase
|
36
36
|
|
37
37
|
def any_collect_argv_value
|
38
|
-
|
39
|
-
|
40
|
-
else
|
41
|
-
positional_collect_argv_value
|
38
|
+
%w[double_dash long_option short_option].each do |arg_type|
|
39
|
+
return send("#{arg_type}_collect_argv_value") if send("argv_current_#{arg_type}?")
|
42
40
|
end
|
41
|
+
|
42
|
+
positional_collect_argv_value
|
43
43
|
end
|
44
44
|
|
45
45
|
def collector
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EacCli
|
4
|
+
class Parser
|
5
|
+
class Alternative
|
6
|
+
module LongOptions
|
7
|
+
LONG_OPTION_PREFIX = '--'
|
8
|
+
OPTION_WITH_ARGUMENT_PATTERN = /\A([^=]+)(?:=(.*))\z/.freeze
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def argv_current_long_option?
|
13
|
+
phase == PHASE_ANY && argv_enum.peek.start_with?(LONG_OPTION_PREFIX) &&
|
14
|
+
!argv_current_double_dash?
|
15
|
+
end
|
16
|
+
|
17
|
+
def long_option_collect_argv_value
|
18
|
+
option_long, value = parse_option_current_argv
|
19
|
+
alternative.options.any? do |option|
|
20
|
+
next false unless option.long == option_long
|
21
|
+
|
22
|
+
if value.nil?
|
23
|
+
option_collect_option(option)
|
24
|
+
else
|
25
|
+
option_argument_collect(option, value)
|
26
|
+
end
|
27
|
+
end || raise_argv_current_invalid_option
|
28
|
+
end
|
29
|
+
|
30
|
+
def parse_option_current_argv
|
31
|
+
m = OPTION_WITH_ARGUMENT_PATTERN.match(argv_enum.peek)
|
32
|
+
m ? [m[1], m[2].if_present('')] : [argv_enum.peek, nil]
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EacCli
|
4
|
+
class Parser
|
5
|
+
class Alternative
|
6
|
+
module OptionArgument
|
7
|
+
private
|
8
|
+
|
9
|
+
attr_accessor :argument_option
|
10
|
+
|
11
|
+
def argument_option_collect_argv(option)
|
12
|
+
self.argument_option = option
|
13
|
+
self.phase = PHASE_OPTION_ARGUMENT
|
14
|
+
end
|
15
|
+
|
16
|
+
def option_argument_collect(option, value)
|
17
|
+
collector.collect(option, value)
|
18
|
+
self.argument_option = nil
|
19
|
+
self.phase = PHASE_ANY
|
20
|
+
option
|
21
|
+
end
|
22
|
+
|
23
|
+
def option_argument_collect_argv_value
|
24
|
+
option_argument_collect(argument_option, argv_enum.peek)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -4,49 +4,20 @@ module EacCli
|
|
4
4
|
class Parser
|
5
5
|
class Alternative
|
6
6
|
module Options
|
7
|
-
DOUBLE_DASH = '--'
|
8
|
-
|
9
7
|
private
|
10
8
|
|
11
|
-
attr_accessor :argument_option, :double_dash
|
12
|
-
|
13
|
-
def argument_option_collect_argv(option)
|
14
|
-
self.argument_option = option
|
15
|
-
self.phase = PHASE_OPTION_ARGUMENT
|
16
|
-
end
|
17
|
-
|
18
|
-
def argv_current_option?
|
19
|
-
phase == PHASE_ANY && argv_enum.peek.start_with?('-')
|
20
|
-
end
|
21
|
-
|
22
|
-
def argv_current_double_dash?
|
23
|
-
argv_enum.peek == DOUBLE_DASH && !double_dash
|
24
|
-
end
|
25
|
-
|
26
9
|
def boolean_option_collect_argv(option)
|
27
10
|
collector.collect(option, true)
|
28
11
|
end
|
29
12
|
|
30
|
-
def
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
def option_collect_argv_value
|
37
|
-
return double_dash_collect_argv_value if argv_current_double_dash?
|
38
|
-
|
39
|
-
alternative.options.any? do |option|
|
40
|
-
next false unless [option.short, option.long].include?(argv_enum.peek)
|
41
|
-
|
42
|
-
if option.argument?
|
43
|
-
argument_option_collect_argv(option)
|
44
|
-
else
|
45
|
-
boolean_option_collect_argv(option)
|
46
|
-
end
|
13
|
+
def option_collect_option(option)
|
14
|
+
if option.argument?
|
15
|
+
argument_option_collect_argv(option)
|
16
|
+
else
|
17
|
+
boolean_option_collect_argv(option)
|
18
|
+
end
|
47
19
|
|
48
|
-
|
49
|
-
end || raise_argv_current_invalid_option
|
20
|
+
option
|
50
21
|
end
|
51
22
|
|
52
23
|
def raise_argv_current_invalid_option
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module EacCli
|
4
|
+
class Parser
|
5
|
+
class Alternative
|
6
|
+
module ShortOptions
|
7
|
+
SHORT_OPTION_PREFIX = '-'
|
8
|
+
|
9
|
+
private
|
10
|
+
|
11
|
+
def argv_current_short_option?
|
12
|
+
phase == PHASE_ANY && argv_enum.peek.start_with?(SHORT_OPTION_PREFIX) &&
|
13
|
+
!argv_current_long_option?
|
14
|
+
end
|
15
|
+
|
16
|
+
def find_short_option(char)
|
17
|
+
alternative.options.find { |option| short_without_prefix(option.short) == char }
|
18
|
+
end
|
19
|
+
|
20
|
+
def short_option_collect_argv_value
|
21
|
+
last_option = nil
|
22
|
+
short_without_prefix(argv_enum.peek).each_char do |char|
|
23
|
+
raise_error "Option \"#{last_option}\" requires a argument not provided" if
|
24
|
+
last_option.present?
|
25
|
+
|
26
|
+
collected_option = short_option_collect_char(char)
|
27
|
+
last_option = collected_option if collected_option.argument?
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# @return [EacCli::Definition::BaseOption] The option collected.
|
32
|
+
def short_option_collect_char(char)
|
33
|
+
option = find_short_option(char)
|
34
|
+
raise_error "Invalid short option \"#{char}\"" unless option
|
35
|
+
|
36
|
+
option_collect_option(option)
|
37
|
+
end
|
38
|
+
|
39
|
+
def short_without_prefix(short)
|
40
|
+
short.gsub(/\A#{::Regexp.quote(SHORT_OPTION_PREFIX)}/, '')
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -27,7 +27,9 @@ module EacCli
|
|
27
27
|
end
|
28
28
|
|
29
29
|
def help_text
|
30
|
-
::EacCli::Docopt::DocBuilder.new(self.class.runner_definition).to_s
|
30
|
+
r = ::EacCli::Docopt::DocBuilder.new(self.class.runner_definition).to_s
|
31
|
+
r += help_extra_text if respond_to?(:help_extra_text)
|
32
|
+
r
|
31
33
|
end
|
32
34
|
end
|
33
35
|
end
|
@@ -6,6 +6,14 @@ require 'eac_ruby_utils/core_ext'
|
|
6
6
|
module EacCli
|
7
7
|
module RunnerWith
|
8
8
|
module Subcommands
|
9
|
+
class << self
|
10
|
+
def runner?(object)
|
11
|
+
::EacCli::Runner.runner?(object) || (
|
12
|
+
object.is_a?(::Class) && object < ::EacRubyUtils::Console::DocoptRunner
|
13
|
+
)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
9
17
|
common_concern do
|
10
18
|
include ::EacCli::Runner
|
11
19
|
end
|
@@ -19,7 +27,7 @@ module EacCli
|
|
19
27
|
def available_subcommands_auto
|
20
28
|
self.class.constants
|
21
29
|
.map { |name| [name.to_s.underscore.gsub('_', '-'), self.class.const_get(name)] }
|
22
|
-
.select { |c| ::EacCli::
|
30
|
+
.select { |c| ::EacCli::RunnerWith::Subcommands.runner?(c[1]) }
|
23
31
|
.to_h.with_indifferent_access
|
24
32
|
end
|
25
33
|
|
@@ -31,6 +39,11 @@ module EacCli
|
|
31
39
|
end
|
32
40
|
end
|
33
41
|
|
42
|
+
def help_extra_text
|
43
|
+
(['Subcommands:'] + available_subcommands.keys.map { |s| " #{s}" })
|
44
|
+
.map { |v| "#{v}\n" }.join
|
45
|
+
end
|
46
|
+
|
34
47
|
def method_missing(method_name, *arguments, &block)
|
35
48
|
return run_with_subcommand(*arguments, &block) if
|
36
49
|
run_with_subcommand_alias_run?(method_name)
|
@@ -44,7 +57,11 @@ module EacCli
|
|
44
57
|
|
45
58
|
def run_with_subcommand
|
46
59
|
if subcommand_name
|
47
|
-
subcommand_runner.run_run
|
60
|
+
if subcommand_runner.respond_to?(:run_run)
|
61
|
+
subcommand_runner.run_run
|
62
|
+
else
|
63
|
+
subcommand_runner.run
|
64
|
+
end
|
48
65
|
else
|
49
66
|
run_without_subcommand
|
50
67
|
end
|
@@ -11,7 +11,7 @@ RSpec.describe ::EacCli::Runner do
|
|
11
11
|
|
12
12
|
runner_definition do
|
13
13
|
arg_opt '-o', '--opt1', 'A arg option.'
|
14
|
-
bool_opt '-
|
14
|
+
bool_opt '-p', '--opt2', 'A boolean option'
|
15
15
|
pos_arg :pos1
|
16
16
|
pos_arg :pos2, repeat: true, optional: true
|
17
17
|
alt do
|
@@ -40,6 +40,27 @@ RSpec.describe ::EacCli::Runner do
|
|
40
40
|
it { expect(instance.parsed.pos2).to eq(%w[ccc ddd]) }
|
41
41
|
end
|
42
42
|
|
43
|
+
context 'with long option and argument in same position' do
|
44
|
+
let(:argv) { %w[--opt1=aaa pos1] }
|
45
|
+
|
46
|
+
it { expect(instance.parsed.opt1).to eq('aaa') }
|
47
|
+
end
|
48
|
+
|
49
|
+
context 'with valid grouped short options' do
|
50
|
+
let(:argv) { %w[-po aaa pos1] }
|
51
|
+
|
52
|
+
it { expect(instance.parsed.opt1).to eq('aaa') }
|
53
|
+
it { expect(instance.parsed.opt2?).to eq(true) }
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'with invalid grouped short options' do
|
57
|
+
let(:argv) { %w[-op aaa pos1] }
|
58
|
+
|
59
|
+
it do
|
60
|
+
expect { instance.parsed }.to raise_error(::EacCli::Parser::Error)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
43
64
|
context 'when only required args are supplied' do
|
44
65
|
let(:argv) { %w[bbb] }
|
45
66
|
let(:parsed_expected) { { opt1: nil, opt2: false, opt3: false, pos1: 'bbb', pos2: [] } }
|
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'eac_cli/runner'
|
4
|
+
require 'eac_cli/runner_with/help'
|
4
5
|
require 'eac_cli/runner_with/subcommands'
|
5
6
|
|
6
7
|
RSpec.describe ::EacCli::RunnerWith::Subcommands do
|
@@ -53,4 +54,32 @@ RSpec.describe ::EacCli::RunnerWith::Subcommands do
|
|
53
54
|
expect { instance.run }.to raise_error(::EacCli::Parser::Error)
|
54
55
|
end
|
55
56
|
end
|
57
|
+
|
58
|
+
context 'with help' do
|
59
|
+
let(:instance) { parent_runner.create(%w[--help]) }
|
60
|
+
let(:expected_output) do
|
61
|
+
<<~OUTPUT
|
62
|
+
A stub root runner.
|
63
|
+
|
64
|
+
Usage:
|
65
|
+
__PROGRAM__ [options] __SUBCOMMANDS__ [<subcommand_args>...]
|
66
|
+
__PROGRAM__ --help
|
67
|
+
|
68
|
+
Options:
|
69
|
+
-r --root-var=<value> A root variable.
|
70
|
+
-h --help Show help.
|
71
|
+
|
72
|
+
Subcommands:
|
73
|
+
child-cmd
|
74
|
+
OUTPUT
|
75
|
+
end
|
76
|
+
|
77
|
+
before do
|
78
|
+
parent_runner.include(::EacCli::RunnerWith::Help)
|
79
|
+
end
|
80
|
+
|
81
|
+
it 'show help text' do
|
82
|
+
expect { instance.run_run }.to output(expected_output).to_stdout_from_any_process
|
83
|
+
end
|
84
|
+
end
|
56
85
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
$LOAD_PATH.push File.expand_path('lib', __dir__)
|
4
|
+
|
5
|
+
require 'eac_ruby_base0/version'
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = 'eac_ruby_base0'
|
9
|
+
s.version = EacRubyBase0::VERSION
|
10
|
+
s.authors = ['Put here the authors']
|
11
|
+
s.summary = 'Put here de description.'
|
12
|
+
|
13
|
+
s.files = Dir['{lib}/**/*']
|
14
|
+
|
15
|
+
s.add_dependency 'eac_cli', '~> 0.7'
|
16
|
+
s.add_dependency 'eac_ruby_gems_utils', '~> 0.7', '>= 0.7.2'
|
17
|
+
s.add_dependency 'eac_ruby_utils', '~> 0.46'
|
18
|
+
|
19
|
+
s.add_development_dependency 'eac_ruby_gem_support', '~> 0.1', '>= 0.1.2'
|
20
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_ruby_gems_utils/gem'
|
4
|
+
require 'eac_ruby_utils/core_ext'
|
5
|
+
require 'eac_ruby_utils/filesystem_cache'
|
6
|
+
|
7
|
+
module EacRubyBase0
|
8
|
+
class Application
|
9
|
+
enable_simple_cache
|
10
|
+
enable_listable
|
11
|
+
lists.add_symbol :option, :name, :home_dir
|
12
|
+
|
13
|
+
common_constructor :gemspec_dir, :options, default: [{}] do
|
14
|
+
self.gemspec_dir = gemspec_dir.to_pathname
|
15
|
+
self.options = options.symbolize_keys.assert_valid_keys(self.class.lists.option.values).freeze
|
16
|
+
end
|
17
|
+
|
18
|
+
delegate :version, to: :self_gem
|
19
|
+
|
20
|
+
def all_gems
|
21
|
+
vendor_gems + [self_gem]
|
22
|
+
end
|
23
|
+
|
24
|
+
{ cache: '.cache', config: '.config', data: '.local/share' }.each do |item, subpath|
|
25
|
+
xdg_env_method_name = "#{item}_xdg_env"
|
26
|
+
|
27
|
+
define_method xdg_env_method_name do
|
28
|
+
ENV["XDG_#{item.upcase}_HOME"].if_present(&:to_pathname)
|
29
|
+
end
|
30
|
+
|
31
|
+
define_method "#{item}_dir" do
|
32
|
+
(send(xdg_env_method_name) || home_dir.join(subpath)).join(name)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def fs_cache
|
37
|
+
@fs_cache ||= ::EacRubyUtils::FilesystemCache.new(
|
38
|
+
cache_dir.join(::EacRubyUtils::FilesystemCache.name.parameterize)
|
39
|
+
)
|
40
|
+
end
|
41
|
+
|
42
|
+
def home_dir
|
43
|
+
@home_dir ||= (options[OPTION_HOME_DIR] || ENV.fetch('HOME')).to_pathname
|
44
|
+
end
|
45
|
+
|
46
|
+
def name
|
47
|
+
options[OPTION_NAME] || self_gem.name
|
48
|
+
end
|
49
|
+
|
50
|
+
def vendor_dir
|
51
|
+
gemspec_dir.join('vendor')
|
52
|
+
end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def self_gem_uncached
|
57
|
+
::EacRubyGemsUtils::Gem.new(gemspec_dir)
|
58
|
+
end
|
59
|
+
|
60
|
+
def vendor_gems_uncached
|
61
|
+
r = []
|
62
|
+
vendor_dir.children.each do |c|
|
63
|
+
vgem = ::EacRubyGemsUtils::Gem.new(c)
|
64
|
+
r << vgem if vgem.gemfile_path.exist?
|
65
|
+
end
|
66
|
+
r
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'eac_cli/runner_with/help'
|
4
|
+
require 'eac_cli/runner_with/subcommands'
|
5
|
+
require 'eac_ruby_utils/core_ext'
|
6
|
+
|
7
|
+
module EacRubyBase0
|
8
|
+
module Runner
|
9
|
+
require_sub __FILE__
|
10
|
+
enable_console_speaker
|
11
|
+
common_concern do
|
12
|
+
include ::EacCli::RunnerWith::Help
|
13
|
+
include ::EacCli::RunnerWith::Subcommands
|
14
|
+
runner_definition do
|
15
|
+
bool_opt '-q', '--quiet', 'Quiet mode.'
|
16
|
+
bool_opt '-I', '--no-input', 'Fail if a input is requested.'
|
17
|
+
subcommands
|
18
|
+
alt do
|
19
|
+
bool_opt '-V', '--version', 'Show version.', usage: true, required: true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
def run
|
25
|
+
on_speaker_node do |node|
|
26
|
+
node.stderr = ::StringIO.new if parsed.quiet?
|
27
|
+
node.stdin = FailIfRequestInput.new if parsed.no_input?
|
28
|
+
if parsed.version?
|
29
|
+
show_version
|
30
|
+
else
|
31
|
+
run_with_subcommand
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def application_version
|
37
|
+
runner_context.call(:application).version.to_s
|
38
|
+
end
|
39
|
+
|
40
|
+
def show_version
|
41
|
+
out("#{application_version}\n")
|
42
|
+
end
|
43
|
+
|
44
|
+
class FailIfRequestInput
|
45
|
+
enable_console_speaker
|
46
|
+
|
47
|
+
%w[gets noecho].each do |method|
|
48
|
+
define_method(method) do
|
49
|
+
raise "Input method requested (\"#{method}\") and option --no-input is set"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|