eac_ruby_base0 0.17.3 → 0.19.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ec80e40f31bd5b55a358a87e4c743951e42aed2443dc841e7185d6c85caa92e
4
- data.tar.gz: 94f485a005bf57a967bf9571e49e84b5386ae9ae5a774f90ead91281740bb960
3
+ metadata.gz: bc3b395db26b74da71be9faa4253a680e50a351945dbfb03bd560b34f05a6a02
4
+ data.tar.gz: 171f9af1e9bd30048a39497654a3c16be6680682c7b990f37870318562607ef4
5
5
  SHA512:
6
- metadata.gz: 43e4bd9665b5c9d74a8cf60ecaee95268514d531fa0d57d1d2f7c72e4005902c2ff285f486672712d16fc0b47bb5ac408c9f6d5309d1ef030c6b3ec79312a426
7
- data.tar.gz: c518b21f971f0031d069e088b5a8e2fe80f7c6a4329d5f194e5562eccb4e19b202d98a7026e871e5f6bc1bbc0b9b864c0ca9ee5d83d859f64730893b8429250e
6
+ metadata.gz: e34d1a2177d776d223423305048c72ecc65b62f95576597f8e22f9926dc38f7d713f005a0a91dd5e253958fc17dac8c88e0f27c2670168fe396f02e41bae49a1
7
+ data.tar.gz: d786a7145937ee3e65625e6555d15c13375a44bd00c4866ae2721f7b66752d711423b69fee79771e27b3a365d5a37262f31bed24b9e3c7139247bcaf89070f2c
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_config/node'
4
+ require 'eac_fs/contexts'
5
+ require 'eac_ruby_utils/core_ext'
6
+ require 'eac_ruby_utils/speaker'
7
+
8
+ module EacRubyBase0
9
+ module Runner
10
+ module Contexts
11
+ def on_context(&block)
12
+ top_block = block
13
+ available_contexts.each do |context|
14
+ next if context.object.any?
15
+
16
+ last_block = top_block
17
+ top_block = ::Proc.new { context.object.on(context.builder.call, &last_block) }
18
+ end
19
+ top_block.call
20
+ end
21
+
22
+ private
23
+
24
+ # @return [Array<EacRubyUtils::Struct>]
25
+ def available_contexts
26
+ (filesystem_available_contexts + [
27
+ [:config, ::EacConfig::Node.context,
28
+ -> { runner_context.call(:application).build_config }],
29
+ [:speaker, ::EacRubyUtils::Speaker.context, -> { build_speaker }]
30
+ ]).map { |row| available_context_row_to_struct(row) }
31
+ end
32
+
33
+ def available_context_row_to_struct(row)
34
+ %i[type object builder].zip(row).to_h.to_struct
35
+ end
36
+
37
+ def build_speaker
38
+ options = {}
39
+ options[:err_out] = ::StringIO.new if parsed.quiet?
40
+ options[:in_in] = ::EacCli::Speaker::InputBlocked.new if parsed.no_input?
41
+ ::EacCli::Speaker.new(options)
42
+ end
43
+
44
+ def filesystem_available_contexts
45
+ ::EacFs::Contexts::TYPES.map do |type|
46
+ key = "fs_#{type}".to_sym
47
+ [key, ::EacFs::Contexts.send(type), -> { application.send("self_#{key}") }]
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -10,17 +10,30 @@ require 'eac_ruby_utils/speaker'
10
10
  module EacRubyBase0
11
11
  module Runner
12
12
  module Prepend
13
+ SYSTEM_STACK_ERROR_FILE = 'system_stack_error'
14
+
13
15
  def run
14
- if parsed.version?
15
- show_version
16
- else
17
- run_with_subcommand
16
+ on_rescue_stack_overflow do
17
+ if parsed.version?
18
+ show_version
19
+ else
20
+ run_with_subcommand
21
+ end
18
22
  end
19
23
  end
20
24
 
21
25
  def run_run
22
26
  on_context { super }
23
27
  end
28
+
29
+ private
30
+
31
+ def on_rescue_stack_overflow
32
+ yield
33
+ rescue ::SystemStackError => e
34
+ SYSTEM_STACK_ERROR_FILE.to_pathname.write(e.backtrace.map { |v| "#{v}\n" }.join)
35
+ raise e
36
+ end
24
37
  end
25
38
  end
26
39
  end
@@ -14,6 +14,7 @@ module EacRubyBase0
14
14
  common_concern do
15
15
  include ::EacCli::RunnerWith::Help
16
16
  include ::EacCli::RunnerWith::Subcommands
17
+ include ::EacRubyBase0::Runner::Contexts
17
18
  prepend ::EacRubyBase0::Runner::Prepend
18
19
  runner_definition do
19
20
  bool_opt '-q', '--quiet', 'Quiet mode.'
@@ -29,47 +30,8 @@ module EacRubyBase0
29
30
  runner_context.call(:application).version.to_s
30
31
  end
31
32
 
32
- def on_context(&block)
33
- top_block = block
34
- available_contexts.each do |context|
35
- next if context.object.any?
36
-
37
- last_block = top_block
38
- top_block = ::Proc.new { context.object.on(context.builder.call, &last_block) }
39
- end
40
- top_block.call
41
- end
42
-
43
33
  def show_version
44
34
  out("#{application_version}\n")
45
35
  end
46
-
47
- private
48
-
49
- # @return [Array<EacRubyUtils::Struct>]
50
- def available_contexts
51
- (filesystem_available_contexts + [
52
- [:config, ::EacConfig::Node.context, -> { runner_context.call(:application).build_config }],
53
- [:speaker, ::EacRubyUtils::Speaker.context, -> { build_speaker }]
54
- ]).map { |row| available_context_row_to_struct(row) }
55
- end
56
-
57
- def available_context_row_to_struct(row)
58
- %i[type object builder].zip(row).to_h.to_struct
59
- end
60
-
61
- def build_speaker
62
- options = {}
63
- options[:err_out] = ::StringIO.new if parsed.quiet?
64
- options[:in_in] = ::EacCli::Speaker::InputBlocked.new if parsed.no_input?
65
- ::EacCli::Speaker.new(options)
66
- end
67
-
68
- def filesystem_available_contexts
69
- ::EacFs::Contexts::TYPES.map do |type|
70
- key = "fs_#{type}".to_sym
71
- [key, ::EacFs::Contexts.send(type), -> { application.send("self_#{key}") }]
72
- end
73
- end
74
36
  end
75
37
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyBase0
4
- VERSION = '0.17.3'
4
+ VERSION = '0.19.0'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eac_ruby_base0
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.3
4
+ version: 0.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Put here the authors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-26 00:00:00.000000000 Z
11
+ date: 2023-05-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avm-eac_ruby_base1
@@ -16,34 +16,34 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.29'
19
+ version: '0.30'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.30.3
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
- version: '0.29'
29
+ version: '0.30'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.30.3
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: eac_cli
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - "~>"
32
38
  - !ruby/object:Gem::Version
33
- version: '0.30'
34
- - - ">="
35
- - !ruby/object:Gem::Version
36
- version: 0.30.1
39
+ version: '0.35'
37
40
  type: :runtime
38
41
  prerelease: false
39
42
  version_requirements: !ruby/object:Gem::Requirement
40
43
  requirements:
41
44
  - - "~>"
42
45
  - !ruby/object:Gem::Version
43
- version: '0.30'
44
- - - ">="
45
- - !ruby/object:Gem::Version
46
- version: 0.30.1
46
+ version: '0.35'
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: eac_fs
49
49
  requirement: !ruby/object:Gem::Requirement
@@ -64,14 +64,14 @@ dependencies:
64
64
  requirements:
65
65
  - - "~>"
66
66
  - !ruby/object:Gem::Version
67
- version: '0.112'
67
+ version: '0.117'
68
68
  type: :runtime
69
69
  prerelease: false
70
70
  version_requirements: !ruby/object:Gem::Requirement
71
71
  requirements:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
- version: '0.112'
74
+ version: '0.117'
75
75
  - !ruby/object:Gem::Dependency
76
76
  name: eac_ruby_gem_support
77
77
  requirement: !ruby/object:Gem::Requirement
@@ -103,11 +103,9 @@ files:
103
103
  - lib/eac_ruby_base0/rspec.rb
104
104
  - lib/eac_ruby_base0/rspec/setup.rb
105
105
  - lib/eac_ruby_base0/runner.rb
106
+ - lib/eac_ruby_base0/runner/contexts.rb
106
107
  - lib/eac_ruby_base0/runner/prepend.rb
107
108
  - lib/eac_ruby_base0/runner_with.rb
108
- - lib/eac_ruby_base0/runner_with/confirmation.rb
109
- - lib/eac_ruby_base0/runner_with/input.rb
110
- - lib/eac_ruby_base0/runner_with/output.rb
111
109
  - lib/eac_ruby_base0/version.rb
112
110
  homepage:
113
111
  licenses: []
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_cli/runner'
4
- require 'eac_ruby_utils/core_ext'
5
-
6
- module EacRubyBase0
7
- module RunnerWith
8
- module Confirmation
9
- DEFAULT_CONFIRM_QUESTION_TEXT = 'Confirm?'
10
-
11
- common_concern do
12
- include ::EacCli::Runner
13
- enable_settings_provider
14
- enable_simple_cache
15
- runner_definition do
16
- bool_opt '--no', 'Deny confirmation without question.'
17
- bool_opt '--yes', 'Accept confirmation without question.'
18
- end
19
- end
20
-
21
- def confirm?(message = nil)
22
- return false if parsed.no?
23
- return true if parsed.yes?
24
-
25
- input(
26
- message || setting_value(:confirm_question_text, default: DEFAULT_CONFIRM_QUESTION_TEXT),
27
- bool: true
28
- )
29
- end
30
-
31
- def run_confirm(message = nil)
32
- yield if confirm?(message)
33
- end
34
-
35
- private
36
-
37
- def cached_confirm_uncached?(message = nil)
38
- confirm?(message)
39
- end
40
- end
41
- end
42
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_cli/runner'
4
- require 'eac_ruby_utils/core_ext'
5
- require 'eac_ruby_utils/abstract_methods'
6
-
7
- module EacRubyBase0
8
- module RunnerWith
9
- module Input
10
- STDIN_OPTION = '-'
11
- BLANK_OPTION = '+'
12
- DEFAULT_DEFAULT_INPUT_OPTION = BLANK_OPTION
13
-
14
- common_concern do
15
- enable_settings_provider
16
- include ::EacCli::Runner
17
-
18
- runner_definition do
19
- arg_opt '-i', '--input', 'Input from file.'
20
- end
21
- end
22
-
23
- def input_content
24
- case input_option
25
- when STDIN_OPTION then $stdin.read
26
- when BLANK_OPTION then ''
27
- else input_option.to_pathname.read
28
- end
29
- end
30
-
31
- def input_option
32
- parsed.input || setting_value(:default_input_option, default: DEFAULT_DEFAULT_INPUT_OPTION)
33
- end
34
- end
35
- end
36
- end
@@ -1,58 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_cli/runner'
4
- require 'eac_ruby_utils/core_ext'
5
- require 'eac_ruby_utils/abstract_methods'
6
-
7
- module EacRubyBase0
8
- module RunnerWith
9
- module Output
10
- STDOUT_OPTION = '-'
11
- DEFAULT_FILE_OPTION = '+'
12
- DEFAULT_DEFAULT_OUTPUT_OPTION = STDOUT_OPTION
13
- DEFAULT_DEFAULT_FILE_TO_OUTPUT = 'output'
14
-
15
- common_concern do
16
- enable_abstract_methods
17
- enable_settings_provider
18
- include ::EacCli::Runner
19
-
20
- abstract_methods :output_content
21
-
22
- runner_definition do
23
- arg_opt '-o', '--output', 'Output to file.'
24
- end
25
- end
26
-
27
- def run_output
28
- file = file_to_output
29
- if file
30
- file.to_pathname.write(output_content)
31
- else
32
- $stdout.write(output_content)
33
- end
34
- end
35
-
36
- def output_option
37
- parsed.output || default_output_option_value
38
- end
39
-
40
- def file_to_output
41
- case output_option
42
- when STDOUT_OPTION then nil
43
- when DEFAULT_FILE_OPTION then default_file_to_output_value
44
- else output_option
45
- end
46
- end
47
-
48
- def default_output_option_value
49
- setting_value(:default_output_option,
50
- default: DEFAULT_DEFAULT_OUTPUT_OPTION)
51
- end
52
-
53
- def default_file_to_output_value
54
- setting_value(:default_file_to_output, default: DEFAULT_DEFAULT_FILE_TO_OUTPUT)
55
- end
56
- end
57
- end
58
- end