eac_ruby_base0 0.3.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5193818f92e1b8682d957066eeea509bbab7c5b3d57efaaffa86d4ef3e484a9c
4
- data.tar.gz: '058c8ef7b5ab0a202a66853eb56c4f78764a738eccf75452f425d5d6a444df27'
3
+ metadata.gz: 884925b5545fdce598cc740b36d02803ec9d1caf08d9962be132d41ccf4c01ec
4
+ data.tar.gz: b8d0b62cce06851ed131f0c0d1f4c6a2cb37c21676d02c20fd9ff5ad408fefa8
5
5
  SHA512:
6
- metadata.gz: 0f99e58f564fabfa9ff33d722d180c2c4811da27f3f728a0e975d7394472d329c4c0eaecf08bd556a2c148a0ccc4d2673054a836ddefd2734fa18e646a7a001b
7
- data.tar.gz: 75b9fe14d67c575c1ff5d58e9e9380339897731addf0bb6d230e31cb528633a2c9c99ce262c36773ce7e6859c8305c0aac885e4696310da79ddd54948882491c
6
+ metadata.gz: e75700fec5d167a0e89b186b79ea01440816ba498cdfa29aff6aa8e880586d3ad42ddef656062e1f09bac23d1fc377d8b571bdb6d754dbf985bb9e54e412a40d
7
+ data.tar.gz: cb6e05b4007d44e8489e9d9e0dbc473ac99a89cbb0becaa7981f3dc4e78a964d69526288bf83b1ce3497b28af27a930e59fe2bb774916cfd1b141cc6ca2f8cb1
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'eac_ruby_gems_utils/gem'
3
4
  require 'eac_ruby_utils/core_ext'
4
5
  require 'eac_ruby_utils/filesystem_cache'
5
6
 
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/core_ext'
4
+ require 'eac_ruby_base0/patches'
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/console/speaker'
4
+ require 'eac_ruby_utils/settings_provider'
5
+
6
+ module EacRubyBase0
7
+ module JobsRunner
8
+ common_concern do
9
+ include ::EacRubyUtils::Console::Speaker
10
+ include ::EacRubyUtils::SettingsProvider
11
+ end
12
+
13
+ def run_job(job)
14
+ return unless run_job?(job)
15
+
16
+ infom "Running job \"#{job}\"..."
17
+ send(job)
18
+ end
19
+
20
+ def run_job?(job)
21
+ the_method = "run_#{job}?"
22
+ respond_to?(the_method, true) ? send(the_method) : true
23
+ end
24
+
25
+ def run_jobs(*jobs)
26
+ jobs = setting_value(:jobs) if jobs.empty?
27
+ jobs.each { |job| run_job(job) }
28
+ success 'Done'
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/require_sub'
4
+ ::EacRubyUtils.require_sub(__FILE__)
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/require_sub'
4
+ ::EacRubyUtils.require_sub(__FILE__)
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_base0/jobs_runner'
4
+ require 'eac_ruby_utils/patch'
5
+
6
+ class Class
7
+ def enable_jobs_runner
8
+ ::EacRubyUtils.patch(self, ::EacRubyBase0::JobsRunner)
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ Dir["#{File.dirname(__FILE__)}/#{::File.basename(__FILE__, '.*')}/*.rb"].sort.each do |path|
4
+ require path
5
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/core_ext'
4
+ require 'eac_ruby_base0/runner_with'
5
+ ::EacCli::RunnerWithSet.default.add_namespace(::EacRubyBase0::RunnerWith)
@@ -1,28 +1,31 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_cli/default_runner'
3
+ require 'eac_cli/runner_with/help'
4
+ require 'eac_cli/runner_with/subcommands'
4
5
  require 'eac_ruby_utils/core_ext'
5
6
 
6
7
  module EacRubyBase0
7
8
  module Runner
8
9
  require_sub __FILE__
10
+ enable_console_speaker
9
11
  common_concern do
10
- include ::EacCli::DefaultRunner
12
+ include ::EacCli::RunnerWith::Help
13
+ include ::EacCli::RunnerWith::Subcommands
11
14
  runner_definition do
12
15
  bool_opt '-q', '--quiet', 'Quiet mode.'
13
16
  bool_opt '-I', '--no-input', 'Fail if a input is requested.'
14
17
  subcommands
15
18
  alt do
16
- bool_opt '-V', '--version', 'Show version.'
19
+ bool_opt '-V', '--version', 'Show version.', usage: true, required: true
17
20
  end
18
21
  end
19
22
  end
20
23
 
21
24
  def run
22
25
  on_speaker_node do |node|
23
- node.stderr = ::StringIO.new if options.fetch('--quiet')
24
- node.stdin = FailIfRequestInput.new if options.fetch('--no-input')
25
- if options.fetch('--version')
26
+ node.stderr = ::StringIO.new if parsed.quiet?
27
+ node.stdin = FailIfRequestInput.new if parsed.no_input?
28
+ if parsed.version?
26
29
  show_version
27
30
  else
28
31
  run_with_subcommand
@@ -31,7 +34,7 @@ module EacRubyBase0
31
34
  end
32
35
 
33
36
  def application_version
34
- context(:application).version.to_s
37
+ runner_context.call(:application).version.to_s
35
38
  end
36
39
 
37
40
  def show_version
@@ -1,17 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_cli/default_runner'
4
- require 'eac_ruby_utils/console/docopt_runner'
5
- require 'eac_ruby_utils/core_ext'
3
+ require 'eac_cli/core_ext'
6
4
  require 'eac_ruby_gems_utils/tests/multiple'
7
5
 
8
6
  module EacRubyBase0
9
7
  module Runner
10
- class TestAll < ::EacRubyUtils::Console::DocoptRunner
11
- require_sub __FILE__
12
- include ::EacCli::DefaultRunner
13
-
14
- runner_definition do
8
+ class TestAll
9
+ runner_with :help do
15
10
  desc 'Test core and local gems.'
16
11
  end
17
12
 
@@ -20,7 +15,7 @@ module EacRubyBase0
20
15
  end
21
16
 
22
17
  def tests_uncached
23
- ::EacRubyGemsUtils::Tests::Multiple.new(context(:application).all_gems)
18
+ ::EacRubyGemsUtils::Tests::Multiple.new(runner_context.call(:application).all_gems)
24
19
  end
25
20
  end
26
21
  end
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacRubyBase0
6
+ module RunnerWith
7
+ require_sub __FILE__
8
+ end
9
+ end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/runner'
4
+ require 'eac_ruby_utils/core_ext'
5
+ require 'eac_ruby_utils/fs/traversable'
6
+
7
+ module EacRubyBase0
8
+ module RunnerWith
9
+ module Confirmation
10
+ DEFAULT_CONFIRM_QUESTION_TEXT = 'Confirm?'
11
+
12
+ common_concern do
13
+ include ::EacCli::Runner
14
+ enable_settings_provider
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
+ request_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
+ end
35
+ end
36
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/runner'
4
+ require 'eac_ruby_utils/core_ext'
5
+ require 'eac_ruby_utils/fs/traversable'
6
+ require 'eac_ruby_utils/settings_provider'
7
+
8
+ module EacRubyBase0
9
+ module RunnerWith
10
+ module FilesystemTraverser
11
+ DEFAULT_DEFAULT_TRAVERSER_RECURSIVE = false
12
+
13
+ common_concern do
14
+ include ::EacCli::Runner
15
+ include ::EacRubyUtils::Fs::Traversable
16
+ enable_settings_provider
17
+ include TopMethods
18
+ runner_definition do
19
+ bool_opt '-R', '--recursive', 'Recursive.'
20
+ bool_opt '--no-recursive', 'No recursive.'
21
+ pos_arg :paths, optional: true, repeat: true
22
+ end
23
+ end
24
+
25
+ module TopMethods
26
+ def on_none_path_informed
27
+ infom 'Warning: none path informed'
28
+ end
29
+
30
+ def paths
31
+ parsed.paths.map(&:to_pathname)
32
+ end
33
+
34
+ def run_filesystem_traverser
35
+ if parsed.paths.any?
36
+ parsed.paths.each { |path| traverser_check_path(path) }
37
+ else
38
+ on_none_path_informed
39
+ end
40
+ end
41
+
42
+ def traverser_recursive
43
+ return false if parsed.no_recursive?
44
+ return true if parsed.recursive?
45
+
46
+ setting_value(:default_traverser_recursive, required: false)
47
+ .if_not_nil(DEFAULT_DEFAULT_TRAVERSER_RECURSIVE)
48
+ end
49
+ end
50
+ end
51
+ end
52
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyBase0
4
- VERSION = '0.3.0'
4
+ VERSION = '0.5.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.3.0
4
+ version: 0.5.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: 2020-11-28 00:00:00.000000000 Z
11
+ date: 2021-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eac_cli
@@ -86,8 +86,18 @@ extra_rdoc_files: []
86
86
  files:
87
87
  - lib/eac_ruby_base0.rb
88
88
  - lib/eac_ruby_base0/application.rb
89
+ - lib/eac_ruby_base0/core_ext.rb
90
+ - lib/eac_ruby_base0/jobs_runner.rb
91
+ - lib/eac_ruby_base0/patches.rb
92
+ - lib/eac_ruby_base0/patches/class.rb
93
+ - lib/eac_ruby_base0/patches/class/jobs_runner.rb
94
+ - lib/eac_ruby_base0/patches/object.rb
95
+ - lib/eac_ruby_base0/patches/object/runner_with.rb
89
96
  - lib/eac_ruby_base0/runner.rb
90
97
  - lib/eac_ruby_base0/runner/test_all.rb
98
+ - lib/eac_ruby_base0/runner_with.rb
99
+ - lib/eac_ruby_base0/runner_with/confirmation.rb
100
+ - lib/eac_ruby_base0/runner_with/filesystem_traverser.rb
91
101
  - lib/eac_ruby_base0/version.rb
92
102
  homepage:
93
103
  licenses: []