avm-eac_ruby_base1 0.6.1 → 0.7.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: 57e656d0b5fb33024c64dd35c473501431f7028a33807ad1d5e6f4552a05f667
4
- data.tar.gz: 70bb5bb4b97831868bf3fd517ffcc136fe1e986a1af5b30d95d96b8e150c5085
3
+ metadata.gz: c305f619c0ed8bc7660261832144b80ff2d2c4f4f2c36e2bf11c3c457565a4d3
4
+ data.tar.gz: 2d045f5de093cc946db258c9d7ddb8bf23f783a05ebb884ec0b3c35485712756
5
5
  SHA512:
6
- metadata.gz: 177ee8f268f7a561978082f381685da016a58cbe76cd13fa6e0593a9e052e19aca60def68475d30cb23675f73d215ed8e64bd2ec207551509ecd3fcc46eb138f
7
- data.tar.gz: e5cedc261ea19d80fd7cbba6d6a54f4cc92ce17be70f7a487f0ccc76379504404911378a750ff6b152c3d06725bcfd0fc2fa40eac95ac956ea94ca5123aa7f8e
6
+ metadata.gz: 76b37e673a2c8f2efc9af27c54bdc5873b6cca86e9eba7b09c986efdb4d7aa8ed92135f37f805abd476feb2a7aa59cd35f022df11a7abe983f9c82db4032d4e4
7
+ data.tar.gz: c24bb9ca1bf92936fce1b415a2beabd53f29b3c93353ea862d5021c817a9fcf2b80a0dea4f32b921093873b79700ec0142a6660a84a16e901b405837d9d31200
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'avm/eac_ruby_base1/bundler/incompatible_parser/line_parser_base'
5
+
6
+ module Avm
7
+ module EacRubyBase1
8
+ module Bundler
9
+ class IncompatibleParser
10
+ class DependsOn < ::Avm::EacRubyBase1::Bundler::IncompatibleParser::LineParserBase
11
+ LINE_PARSER = /(.+) was resolved to (.+), which depends on/
12
+ .to_parser { |m| new(m[1], m[2]) }
13
+
14
+ common_constructor :gem_name, :version do
15
+ self.version = ::Gem::Version.new(version)
16
+ end
17
+
18
+ def data
19
+ { gem_name: gem_name, version: version }
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,44 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'avm/eac_ruby_base1/bundler/incompatible_parser/line_parser_base'
5
+
6
+ module Avm
7
+ module EacRubyBase1
8
+ module Bundler
9
+ class IncompatibleParser
10
+ class GemConflict < ::Avm::EacRubyBase1::Bundler::IncompatibleParser::LineParserBase
11
+ LINE_PARSER = /Bundler could not find compatible versions for gem "(.+)":/
12
+ .to_parser { |m| new(m[1]) }
13
+
14
+ enable_simple_cache
15
+ common_constructor :gem_name
16
+
17
+ def add_depends_on(depends_on)
18
+ depends_on_stack << depends_on
19
+ end
20
+
21
+ def add_version_requirement(version_requirement)
22
+ version_requirement.stack = depends_on_stack
23
+ versions_requirements << version_requirement
24
+ @depends_on_stack = nil
25
+ end
26
+
27
+ def data
28
+ { gem_name: gem_name, versions_requirements: versions_requirements.map(&:data) }
29
+ end
30
+
31
+ def versions_requirements
32
+ @versions_requirements ||= []
33
+ end
34
+
35
+ private
36
+
37
+ def depends_on_stack
38
+ @depends_on_stack ||= []
39
+ end
40
+ end
41
+ end
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'avm/eac_ruby_base1/bundler/incompatible_parser/line_parser_base'
5
+
6
+ module Avm
7
+ module EacRubyBase1
8
+ module Bundler
9
+ class IncompatibleParser
10
+ class InGemfile < ::Avm::EacRubyBase1::Bundler::IncompatibleParser::LineParserBase
11
+ LINE_PARSER = /In Gemfile:/
12
+ .to_parser { |_m| new }
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,73 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'avm/eac_ruby_base1/bundler/incompatible_parser/gem_conflict'
5
+ require 'avm/eac_ruby_base1/bundler/incompatible_parser/line_factory'
6
+
7
+ module Avm
8
+ module EacRubyBase1
9
+ module Bundler
10
+ class IncompatibleParser
11
+ class LineBuffer
12
+ class << self
13
+ def from_file(path)
14
+ new(::File.read(path.to_s))
15
+ end
16
+ end
17
+
18
+ attr_reader :gems_in_conflict
19
+
20
+ def initialize(content)
21
+ self.gems_in_conflict = []
22
+ self.parsing_required = false
23
+ content.each_line { |string_line| add_line(LineFactory.new(string_line)) }
24
+ end
25
+
26
+ private
27
+
28
+ attr_accessor :parsing_required
29
+ attr_writer :gems_in_conflict
30
+
31
+ def add_line(line)
32
+ return if line.blank?
33
+
34
+ return if LineFactory::TYPES.any? do |type|
35
+ next false unless line.result.is_a?(type)
36
+
37
+ send("on_#{type.name.demodulize.underscore.variableize}_line", line.result)
38
+ true
39
+ end
40
+
41
+ return unless parsing_required
42
+
43
+ raise(::ArgumentError, "Unparsed line: \"#{line.content}\"")
44
+ end
45
+
46
+ def on_gem_conflict_line(result)
47
+ self.parsing_required = true
48
+ gems_in_conflict << result
49
+ end
50
+
51
+ def on_in_gemfile_line(result)
52
+ # Do nothing
53
+ end
54
+
55
+ def on_depends_on_line(result)
56
+ current_gem_conflict.add_depends_on(result)
57
+ end
58
+
59
+ def on_version_requirement_line(result)
60
+ current_gem_conflict.add_version_requirement(result)
61
+ end
62
+
63
+ def current_gem_conflict
64
+ raise 'No gems in conflict' if gems_in_conflict.none?
65
+ raise 'Last gem is blank' if gems_in_conflict.last.blank?
66
+
67
+ gems_in_conflict.last
68
+ end
69
+ end
70
+ end
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'avm/eac_ruby_base1/bundler/incompatible_parser/depends_on'
5
+ require 'avm/eac_ruby_base1/bundler/incompatible_parser/gem_conflict'
6
+ require 'avm/eac_ruby_base1/bundler/incompatible_parser/in_gemfile'
7
+
8
+ module Avm
9
+ module EacRubyBase1
10
+ module Bundler
11
+ class IncompatibleParser
12
+ class LineFactory
13
+ TYPES = [GemConflict, InGemfile, DependsOn, VersionRequirement].freeze
14
+
15
+ enable_simple_cache
16
+ common_constructor :content do
17
+ self.content = content.strip
18
+ end
19
+
20
+ delegate :blank?, to: :content
21
+
22
+ private
23
+
24
+ def result_uncached
25
+ TYPES.lazy.map { |type| type.parse(content) }.find(&:present?)
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
31
+ 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 IncompatibleParser
9
+ class LineParserBase
10
+ class << self
11
+ def parse(line_content)
12
+ const_get('LINE_PARSER').parse(line_content)
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'avm/eac_ruby_base1/bundler/incompatible_parser/line_parser_base'
5
+
6
+ module Avm
7
+ module EacRubyBase1
8
+ module Bundler
9
+ class IncompatibleParser
10
+ class VersionRequirement < ::Avm::EacRubyBase1::Bundler::IncompatibleParser::LineParserBase
11
+ LINE_PARSER = /\A([a-z][a-z\-_0-9]*)(?: \((.+)\))?\z/
12
+ .to_parser { |m| new(m[1], m[2]) }
13
+
14
+ enable_simple_cache
15
+ attr_accessor :stack
16
+
17
+ common_constructor :gem_name, :requirements_source
18
+
19
+ def data
20
+ { requirements_source: requirements_source, stack: stack.map(&:data) }
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,25 @@
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 IncompatibleParser
9
+ require_sub __FILE__
10
+
11
+ enable_simple_cache
12
+ attr_reader :gems_in_conflict
13
+
14
+ def initialize(path)
15
+ @gems_in_conflict = ::Avm::EacRubyBase1::Bundler::IncompatibleParser::LineBuffer
16
+ .from_file(path).gems_in_conflict.freeze
17
+ end
18
+
19
+ def data
20
+ gems_in_conflict.map(&:data)
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_generic_base0/sources/base'
4
+ require 'eac_ruby_utils/core_ext'
5
+ require 'eac_ruby_utils/ruby/command'
6
+
7
+ module Avm
8
+ module EacRubyBase1
9
+ module Sources
10
+ class Base < ::Avm::EacGenericBase0::Sources::Base
11
+ class BundleCommand < ::EacRubyUtils::Ruby::Command
12
+ GEMFILE_PATH_ENVVAR = 'BUNDLE_GEMFILE'
13
+
14
+ attr_reader :source
15
+
16
+ def initialize(source, command_args, extra_options = {})
17
+ @source = source
18
+ super(command_args, extra_options.merge(host_env: source.env))
19
+ end
20
+
21
+ # Changes current directory to the source's directory.
22
+ def chdir_root
23
+ chdir(source.path)
24
+ end
25
+
26
+ def envvar_gemfile
27
+ envvar(GEMFILE_PATH_ENVVAR, source.gemfile_path.to_path)
28
+ end
29
+
30
+ protected
31
+
32
+ def duplicate(command, extra_options)
33
+ self.class.new(source, command, extra_options)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_generic_base0/sources/base'
4
+ require 'avm/eac_ruby_base1/sources/base/bundle_command'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module Avm
8
+ module EacRubyBase1
9
+ module Sources
10
+ class Base < ::Avm::EacGenericBase0::Sources::Base
11
+ module Bundler
12
+ CONFIGURED_GEMFILE_PATH_ENTRY_KEY = 'ruby.gemfile_path'
13
+ DEFAULT_GEMFILE_PATH = 'Gemfile'
14
+
15
+ # @return [Avm::EacRubyBase1::Sources::Base::BundleCommand]
16
+ def bundle(*args)
17
+ ::Avm::EacRubyBase1::Sources::Base::BundleCommand.new(self, %w[bundle] + args)
18
+ .envvar_gemfile
19
+ end
20
+
21
+ # @return [String]
22
+ def configured_gemfile_path
23
+ configuration.entry(CONFIGURED_GEMFILE_PATH_ENTRY_KEY).value
24
+ end
25
+
26
+ # @return [String]
27
+ def default_gemfile_path
28
+ DEFAULT_GEMFILE_PATH
29
+ end
30
+
31
+ # @return [Pathname]
32
+ def gemfile_path
33
+ path.join(configured_gemfile_path || default_gemfile_path)
34
+ end
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
@@ -3,6 +3,7 @@
3
3
  require 'avm/eac_generic_base0/sources/base'
4
4
  require 'avm/eac_ruby_base1/sources/update'
5
5
  require 'avm/eac_ruby_base1/sources/tester'
6
+ require 'avm/eac_ruby_base1/sources/runners/bundler'
6
7
  require 'avm/version_number'
7
8
  require 'eac_ruby_gems_utils/gem'
8
9
  require 'eac_ruby_utils/core_ext'
@@ -14,8 +15,12 @@ module Avm
14
15
  require_sub __FILE__, include_modules: :prepend, require_dependency: true
15
16
  delegate :gemspec_path, to: :the_gem
16
17
 
17
- def gemfile_path
18
- path.join('Gemfile')
18
+ EXTRA_AVAILABLE_SUBCOMMANDS = {
19
+ 'bundler' => ::Avm::EacRubyBase1::Sources::Runners::Bundler
20
+ }.freeze
21
+
22
+ def extra_available_subcommands
23
+ EXTRA_AVAILABLE_SUBCOMMANDS
19
24
  end
20
25
 
21
26
  def valid?
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_ruby_base1/bundler/incompatible_parser'
4
+ require 'eac_cli/core_ext'
5
+
6
+ module Avm
7
+ module EacRubyBase1
8
+ module Sources
9
+ module Runners
10
+ class Bundler
11
+ class Incompatible
12
+ runner_with :help do
13
+ desc 'Identify incompatible gems in a "Gemfile.lock" file.'
14
+ bool_opt '-l', '--last', 'Process the last \"bundle update\" result.'
15
+ end
16
+
17
+ def run
18
+ infov 'Cache path', fs_cache.content_path
19
+ infov 'Cached?', fs_cache.stored?
20
+ parser.gems_in_conflict.each do |gem_in_conflict|
21
+ print_gem_in_conflict(gem_in_conflict)
22
+ end
23
+ end
24
+
25
+ private
26
+
27
+ def bundle_update
28
+ infom 'Running "bundle update"...'
29
+ runner_context.call(:subject).bundle('update').execute[:stdout]
30
+ end
31
+
32
+ def content_path
33
+ fs_cache.write(bundle_update) unless fs_cache.stored? && parsed.last?
34
+ fs_cache.content_path
35
+ end
36
+
37
+ def fs_object_id
38
+ runner_context.call(:subject).path.to_s.variableize
39
+ end
40
+
41
+ def gem_title(gem_in_conflict)
42
+ gem_in_conflict.gem_name
43
+ end
44
+
45
+ def parser_uncached
46
+ ::Avm::EacRubyBase1::Bundler::IncompatibleParser.new(content_path)
47
+ end
48
+
49
+ def print_gem_in_conflict(gem_in_conflict)
50
+ infov 'Gem', gem_title(gem_in_conflict)
51
+ gem_in_conflict.versions_requirements.each do |requirement|
52
+ print_requirement(requirement)
53
+ end
54
+ end
55
+
56
+ def print_requirement(req)
57
+ infov ' ' + requirement_title(req), requirement_value(req)
58
+ end
59
+
60
+ def requirement_stack(req)
61
+ req.stack.map { |d| "#{d.gem_name} (#{d.version})" }.join(' > '.green)
62
+ end
63
+
64
+ def requirement_title(req)
65
+ req.requirements_source.if_present('*')
66
+ end
67
+
68
+ def requirement_value(req)
69
+ requirement_stack(req)
70
+ end
71
+ end
72
+ end
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/core_ext'
4
+
5
+ module Avm
6
+ module EacRubyBase1
7
+ module Sources
8
+ module Runners
9
+ class Bundler
10
+ require_sub __FILE__
11
+ runner_with :help, :subcommands do
12
+ desc 'Ruby\'s bundler utitilies for local projects.'
13
+ subcommands
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacRubyBase1
7
+ module Sources
8
+ module Runners
9
+ require_sub __FILE__
10
+ end
11
+ end
12
+ end
13
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module EacRubyBase1
5
- VERSION = '0.6.1'
5
+ VERSION = '0.7.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: avm-eac_ruby_base1
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.7.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: 2022-06-24 00:00:00.000000000 Z
11
+ date: 2022-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avm
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.9'
19
+ version: '0.21'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.9'
26
+ version: '0.21'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: avm-eac_generic_base0
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -72,6 +72,26 @@ dependencies:
72
72
  - - "~>"
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0.80'
75
+ - !ruby/object:Gem::Dependency
76
+ name: aranha-parsers
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: '0.14'
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: 0.14.1
85
+ type: :development
86
+ prerelease: false
87
+ version_requirements: !ruby/object:Gem::Requirement
88
+ requirements:
89
+ - - "~>"
90
+ - !ruby/object:Gem::Version
91
+ version: '0.14'
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: 0.14.1
75
95
  - !ruby/object:Gem::Dependency
76
96
  name: eac_ruby_gem_support
77
97
  requirement: !ruby/object:Gem::Requirement
@@ -97,13 +117,26 @@ files:
97
117
  - lib/avm/eac_ruby_base1/bundler/gemfile.rb
98
118
  - lib/avm/eac_ruby_base1/bundler/gemfile/add_or_replace_gem_line.rb
99
119
  - lib/avm/eac_ruby_base1/bundler/gemfile/dependency.rb
120
+ - lib/avm/eac_ruby_base1/bundler/incompatible_parser.rb
121
+ - lib/avm/eac_ruby_base1/bundler/incompatible_parser/depends_on.rb
122
+ - lib/avm/eac_ruby_base1/bundler/incompatible_parser/gem_conflict.rb
123
+ - lib/avm/eac_ruby_base1/bundler/incompatible_parser/in_gemfile.rb
124
+ - lib/avm/eac_ruby_base1/bundler/incompatible_parser/line_buffer.rb
125
+ - lib/avm/eac_ruby_base1/bundler/incompatible_parser/line_factory.rb
126
+ - lib/avm/eac_ruby_base1/bundler/incompatible_parser/line_parser_base.rb
127
+ - lib/avm/eac_ruby_base1/bundler/incompatible_parser/version_requirement.rb
100
128
  - lib/avm/eac_ruby_base1/rubocop.rb
101
129
  - lib/avm/eac_ruby_base1/rubocop/configured.rb
102
130
  - lib/avm/eac_ruby_base1/rubocop/envvar.rb
103
131
  - lib/avm/eac_ruby_base1/rubocop/gemfile.rb
104
132
  - lib/avm/eac_ruby_base1/sources.rb
105
133
  - lib/avm/eac_ruby_base1/sources/base.rb
134
+ - lib/avm/eac_ruby_base1/sources/base/bundle_command.rb
135
+ - lib/avm/eac_ruby_base1/sources/base/bundler.rb
106
136
  - lib/avm/eac_ruby_base1/sources/base/version_bump.rb
137
+ - lib/avm/eac_ruby_base1/sources/runners.rb
138
+ - lib/avm/eac_ruby_base1/sources/runners/bundler.rb
139
+ - lib/avm/eac_ruby_base1/sources/runners/bundler/incompatible.rb
107
140
  - lib/avm/eac_ruby_base1/sources/tester.rb
108
141
  - lib/avm/eac_ruby_base1/sources/update.rb
109
142
  - lib/avm/eac_ruby_base1/sources/update/sub_update.rb