avm-tools 0.117.0 → 0.117.1

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: aae509f1d4971fd8a6d39a9f20cc4a3dab9fd28267c333ffe521cba9252f20bb
4
- data.tar.gz: f27d6bd59c10b9638f1f42b173d38a53a677b1d8de4b1a01c63e170ed1ed362f
3
+ metadata.gz: 3c5b9e1cd2e14d276b38a0efe3965a884143065eafbade65938f37f72f0857e9
4
+ data.tar.gz: 81d047244f7fa7478bffc26e23457da9da5cc7e33839b6108e7fe55cb78a4706
5
5
  SHA512:
6
- metadata.gz: ea73fcc793b05f0265396c36a592969b9f60c6ccb8a0e7526f7f5e12f5c7b58688489c11cda94b7e17ab8a0430029dccca11d3a0b799a49e6c65d11c5f200b8a
7
- data.tar.gz: bf13a36e7cdf500a7538c75531b108b7f09ef76dfd1b5a4ceb102cc32f2c2b76026df875c593de2fa6c240b3b5fccc43b9d7a989941dab6b15e61a8b142ee503
6
+ metadata.gz: 4c802171d7c42fde415e6674888a0d430c003107d87846e7159cfc5aebb7d04a604b7b7f6c034b9d0081206e111f373e13e7fada07e2130d92624409f4389b17
7
+ data.tar.gz: 30765546f1f0faab035133812dd4f0508ac5a63112e2aa1925758c1bf66e7a81d92e01ed61f298c9f05f12cd156d49940d333c89ce3f9971b40021ef9c566bfd
@@ -10,8 +10,6 @@ module Avm
10
10
  class InGemfile < ::Avm::Ruby::Bundler::IncompatibleParser::LineParserBase
11
11
  LINE_PARSER = /In Gemfile:/
12
12
  .to_parser { |_m| new }
13
-
14
- common_constructor
15
13
  end
16
14
  end
17
15
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.117.0'
5
+ VERSION = '0.117.1'
6
6
  end
7
7
  end
@@ -0,0 +1,56 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacRubyBase1
7
+ module Bundler
8
+ class Gemfile
9
+ class AddOrReplaceGemLine
10
+ enable_method_class
11
+ common_constructor :sender, :gem_name, :gem_specs
12
+ delegate :lines, to: :sender
13
+
14
+ def existing_gem_line_index
15
+ lines.index { |line| line.start_with?(gem_line_prefix) }
16
+ end
17
+
18
+ def result
19
+ if existing_gem_line_index.present?
20
+ replace_line
21
+ else
22
+ add_line
23
+ end
24
+ end
25
+
26
+ def add_line
27
+ lines.insert(add_line_index, new_gem_line)
28
+ end
29
+
30
+ def add_line_index
31
+ (gems_lines_start_index..(lines.count - 1)).each do |e|
32
+ return e if new_gem_line < lines[e]
33
+ end
34
+ lines.count
35
+ end
36
+
37
+ def gems_lines_start_index
38
+ lines.index { |line| line.start_with?('gem ') } || lines.count
39
+ end
40
+
41
+ def new_gem_line
42
+ ([gem_line_prefix] + gem_specs).join(', ')
43
+ end
44
+
45
+ def gem_line_prefix
46
+ "gem '#{gem_name}'"
47
+ end
48
+
49
+ def replace_line
50
+ lines[existing_gem_line_index] = new_gem_line
51
+ end
52
+ end
53
+ end
54
+ end
55
+ end
56
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacRubyBase1
7
+ module Bundler
8
+ class Gemfile
9
+ class Dependency
10
+ common_constructor :gemfile, :gem_name
11
+
12
+ def version_specs=(version_specs)
13
+ gemfile.add_or_replace_gem_line(gem_name, version_specs)
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacRubyBase1
7
+ module Bundler
8
+ class Gemfile
9
+ require_sub __FILE__, require_dependency: true
10
+
11
+ class << self
12
+ def from_file(path)
13
+ new(path.read.each_line.map(&:rstrip))
14
+ end
15
+ end
16
+
17
+ common_constructor :lines
18
+
19
+ # @return [Avm::EacRubyBase1::Bundler::Gemfile::Dependency]
20
+ def dependency(gem_name)
21
+ ::Avm::EacRubyBase1::Bundler::Gemfile::Dependency.new(self, gem_name)
22
+ end
23
+
24
+ def write(path)
25
+ path.to_pathname.write(to_text)
26
+ end
27
+
28
+ def to_text
29
+ lines.map { |line| "#{line}\n" }.join
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacRubyBase1
7
+ module Bundler
8
+ require_sub __FILE__
9
+ end
10
+ end
11
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module EacRubyBase1
5
- VERSION = '0.5.0'
5
+ VERSION = '0.6.0'
6
6
  end
7
7
  end
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
14
14
 
15
15
  s.add_dependency 'colorize', '~> 0.8.1'
16
16
  s.add_dependency 'eac_config', '~> 0.8'
17
- s.add_dependency 'eac_ruby_utils', '~> 0.83'
17
+ s.add_dependency 'eac_ruby_utils', '~> 0.95'
18
18
 
19
19
  s.add_development_dependency 'eac_ruby_gem_support', '~> 0.5.1'
20
20
  end
@@ -33,7 +33,7 @@ module EacCli
33
33
  # @return [EacCli::Definition::BaseOption] The option collected.
34
34
  def short_option_collect_char(char)
35
35
  option = find_short_option(char)
36
- raise_error "Invalid short option \"#{char}\"" unless option
36
+ raise_argv_current_invalid_option unless option
37
37
 
38
38
  option_collect_option(option)
39
39
  end
@@ -1,23 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'eac_cli/speaker'
4
- require 'eac_ruby_utils/speaker'
3
+ require 'eac_cli/definition'
4
+ require 'eac_cli/runner/class_runner'
5
5
 
6
6
  module EacCli
7
7
  module Runner
8
8
  module AfterClassMethods
9
+ # @return [EacCli::Runner::ClassRunner]
10
+ def class_runner(runner_context_args)
11
+ ::EacCli::Runner::ClassRunner.new(self, runner_context_args)
12
+ end
13
+
9
14
  def create(*runner_context_args)
10
- r = new
11
- r.runner_context = ::EacCli::Runner::Context.new(r, *runner_context_args)
12
- r
15
+ class_runner(runner_context_args).create
13
16
  end
14
17
 
15
18
  def run(*runner_context_args)
16
- on_asserted_speaker do
17
- r = create(*runner_context_args)
18
- r.run_run
19
- r
20
- end
19
+ class_runner(runner_context_args).run
21
20
  end
22
21
 
23
22
  def runner_definition(&block)
@@ -29,18 +28,6 @@ module EacCli
29
28
  def super_runner_definition
30
29
  superclass.try(:runner_definition).if_present(&:dup) || ::EacCli::Definition.new
31
30
  end
32
-
33
- private
34
-
35
- def on_asserted_speaker
36
- if ::EacRubyUtils::Speaker.context.optional_current
37
- yield
38
- else
39
- ::EacRubyUtils::Speaker.context.on(::EacCli::Speaker.new) do
40
- yield
41
- end
42
- end
43
- end
44
31
  end
45
32
  end
46
33
  end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/speaker'
4
+ require 'eac_ruby_utils/core_ext'
5
+ require 'eac_ruby_utils/speaker'
6
+
7
+ module EacCli
8
+ module Runner
9
+ class ClassRunner
10
+ PARSER_ERROR_EXIT_CODE = 1
11
+
12
+ common_constructor :klass, :context_args
13
+
14
+ def create
15
+ r = klass.new
16
+ r.runner_context = ::EacCli::Runner::Context.new(r, *context_args)
17
+ r
18
+ end
19
+
20
+ def run
21
+ on_asserted_speaker do
22
+ r = create
23
+ begin
24
+ r.run_run
25
+ rescue ::EacCli::Parser::Error => e
26
+ run_parser_error(r, e)
27
+ end
28
+ r
29
+ end
30
+ end
31
+
32
+ def run_parser_error(runner_instance, error)
33
+ $stderr.write("#{runner_instance.program_name}: #{error}\n")
34
+ ::Kernel.exit(PARSER_ERROR_EXIT_CODE)
35
+ end
36
+
37
+ private
38
+
39
+ def on_asserted_speaker
40
+ if ::EacRubyUtils::Speaker.context.optional_current
41
+ yield
42
+ else
43
+ ::EacRubyUtils::Speaker.context.on(::EacCli::Speaker.new) do
44
+ yield
45
+ end
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -3,22 +3,13 @@
3
3
  module EacCli
4
4
  module Runner
5
5
  module InstanceMethods
6
- PARSER_ERROR_EXIT_CODE = 1
7
-
8
6
  def run_run
9
7
  parsed
10
8
  run_callbacks(:run) { run }
11
- rescue ::EacCli::Parser::Error => e
12
- run_parser_error(e)
13
9
  rescue ::EacCli::Runner::Exit # rubocop:disable Lint/SuppressedException
14
10
  # Do nothing
15
11
  end
16
12
 
17
- def run_parser_error(error)
18
- $stderr.write("#{program_name}: #{error}\n")
19
- ::Kernel.exit(PARSER_ERROR_EXIT_CODE)
20
- end
21
-
22
13
  def runner_context
23
14
  return @runner_context if @runner_context
24
15
 
@@ -6,7 +6,7 @@ require 'eac_ruby_utils/core_ext'
6
6
  module EacCli
7
7
  module RunnerWith
8
8
  module Help
9
- require_sub __FILE__
9
+ require_sub __FILE__, require_dependency: true
10
10
  common_concern do
11
11
  include ::EacCli::Runner
12
12
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacCli
4
- VERSION = '0.27.3'
4
+ VERSION = '0.27.4'
5
5
  end
@@ -20,23 +20,29 @@ RSpec.describe ::EacCli::RunnerWith::Help do
20
20
  end
21
21
  end
22
22
 
23
- let(:runner_argv) { ['--help'] }
24
- let(:instance) { runner.create(argv: runner_argv) }
25
- let(:expected_output) do
26
- <<~OUTPUT
27
- A stub runner.
28
-
29
- Usage:
30
- __PROGRAM__ [options] <a_argument>
31
- __PROGRAM__ --help
32
-
33
- Options:
34
- -h --help Show help.
35
-
36
- OUTPUT
37
- end
23
+ [
24
+ ['--help'],
25
+ ['trash-pos-arg-before', '--help', 'trash-pos-arg-after']
26
+ ].each do |runner_argv|
27
+ context "when runner ARGV is #{runner_argv}" do
28
+ let(:instance) { runner.create(argv: runner_argv) }
29
+ let(:expected_output) do
30
+ <<~OUTPUT
31
+ A stub runner.
32
+
33
+ Usage:
34
+ __PROGRAM__ [options] <a_argument>
35
+ __PROGRAM__ --help
36
+
37
+ Options:
38
+ -h --help Show help.
39
+
40
+ OUTPUT
41
+ end
38
42
 
39
- it 'show help text' do
40
- expect { instance.run_run }.to output(expected_output).to_stdout_from_any_process
43
+ it 'show help text' do
44
+ expect { instance.run_run }.to output(expected_output).to_stdout_from_any_process
45
+ end
46
+ end
41
47
  end
42
48
  end
@@ -12,10 +12,10 @@ Gem::Specification.new do |s|
12
12
 
13
13
  s.files = Dir['{lib}/**/*']
14
14
 
15
- s.add_dependency 'eac_cli', '~> 0.26'
15
+ s.add_dependency 'eac_cli', '~> 0.27', '>= 0.27.4'
16
16
  s.add_dependency 'eac_fs', '~> 0.10'
17
17
  s.add_dependency 'eac_ruby_gems_utils', '~> 0.9', '~> 0.9.6'
18
- s.add_dependency 'eac_ruby_utils', '~> 0.70'
18
+ s.add_dependency 'eac_ruby_utils', '~> 0.95', '>= 0.95.1'
19
19
 
20
20
  s.add_development_dependency 'eac_ruby_gem_support', '~> 0.5.1'
21
21
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyBase0
4
- VERSION = '0.16.2'
4
+ VERSION = '0.16.3'
5
5
  end
@@ -68,12 +68,12 @@ module EacRubyUtils
68
68
 
69
69
  def setup_class_attr_readers(klass)
70
70
  klass.send(:attr_reader, *args)
71
- klass.send(:public, *args)
71
+ klass.send(:public, *args) if args.any?
72
72
  end
73
73
 
74
74
  def setup_class_attr_writers(klass)
75
75
  klass.send(:attr_writer, *args)
76
- klass.send(:private, *args.map { |a| "#{a}=" })
76
+ klass.send(:private, *args.map { |a| "#{a}=" }) if args.any?
77
77
  end
78
78
 
79
79
  def setup_class_initialize(klass)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.95.0'
4
+ VERSION = '0.95.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm-tools
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.117.0
4
+ version: 0.117.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Esquilo Azul Company
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-06-14 00:00:00.000000000 Z
11
+ date: 2022-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -194,14 +194,20 @@ dependencies:
194
194
  requirements:
195
195
  - - "~>"
196
196
  - !ruby/object:Gem::Version
197
- version: '0.14'
197
+ version: '0.16'
198
+ - - ">="
199
+ - !ruby/object:Gem::Version
200
+ version: 0.16.3
198
201
  type: :runtime
199
202
  prerelease: false
200
203
  version_requirements: !ruby/object:Gem::Requirement
201
204
  requirements:
202
205
  - - "~>"
203
206
  - !ruby/object:Gem::Version
204
- version: '0.14'
207
+ version: '0.16'
208
+ - - ">="
209
+ - !ruby/object:Gem::Version
210
+ version: 0.16.3
205
211
  - !ruby/object:Gem::Dependency
206
212
  name: eac_ruby_gems_utils
207
213
  requirement: !ruby/object:Gem::Requirement
@@ -542,6 +548,10 @@ files:
542
548
  - sub/avm-eac_ruby_base1/Gemfile
543
549
  - sub/avm-eac_ruby_base1/avm-eac_ruby_base1.gemspec
544
550
  - sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1.rb
551
+ - sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler.rb
552
+ - sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler/gemfile.rb
553
+ - sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler/gemfile/add_or_replace_gem_line.rb
554
+ - sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/bundler/gemfile/dependency.rb
545
555
  - sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/rubocop.rb
546
556
  - sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/rubocop/configured.rb
547
557
  - sub/avm-eac_ruby_base1/lib/avm/eac_ruby_base1/rubocop/envvar.rb
@@ -822,6 +832,7 @@ files:
822
832
  - sub/eac_cli/lib/eac_cli/rspec/setup.rb
823
833
  - sub/eac_cli/lib/eac_cli/runner.rb
824
834
  - sub/eac_cli/lib/eac_cli/runner/after_class_methods.rb
835
+ - sub/eac_cli/lib/eac_cli/runner/class_runner.rb
825
836
  - sub/eac_cli/lib/eac_cli/runner/context.rb
826
837
  - sub/eac_cli/lib/eac_cli/runner/exit.rb
827
838
  - sub/eac_cli/lib/eac_cli/runner/instance_methods.rb