avm-eac_ruby_base1 0.13.0 → 0.17.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: 660a216c70551ca1c3ba380e9c4b4ea6af5f9a348134bdc508357b3a0c6d63f2
4
- data.tar.gz: 5b9853c0ae6e667615cc0b8cb17ed4173b84de60de4b0dfa67c74e6ec4fc1d45
3
+ metadata.gz: bb02e86e1a33fd58cb9f1dab6aec51e849621043a839e387144f3a60ff956b5a
4
+ data.tar.gz: 54a32ef14c923d468a5a39fd26b90aab414041f165ddcc5bb7872c64f7a3fb60
5
5
  SHA512:
6
- metadata.gz: 4c1a82c5c0302ad6db97ce0916daa899353e46ee77913508f4abbbd1a550dab1c44fa18b14ee97a85d9b60a57ae8301ea7b1848ed8f6fb8d9031471210776cb7
7
- data.tar.gz: 3f4dc7a0f397db675196a9035aaa672442a4cecb70510053ba05fce2f6e53a018d4848e76269704037f77b69ac29332cd6779140eeec5e6f043cac20f3718f39
6
+ metadata.gz: c3ea2861d3e32700be93a8dd033eee4d5f0e52c57a664e3bf5fad24b06cf2ca4272c81f5b8faab6f11be8888b87ccd5c9806e6238ba73576611a9b30f2700f30
7
+ data.tar.gz: b7a25698006c2d4396dee4ea923c8a50e6587c93df0660e60aa9a5d7f6f6a64843de0396e45cb83e5ed21a10d5db51bd494899073e7f8fc34e24276987d87ae6
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/version_number'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module EacRubyBase1
8
+ class PreferredVersionRequirements
9
+ enable_simple_cache
10
+ common_constructor :version do
11
+ self.version = ::Avm::VersionNumber.new(version)
12
+ end
13
+
14
+ # @return [Avm::VersionNumber]
15
+ def prefix_version
16
+ ::Avm::VersionNumber.new(
17
+ normalized_version.segments[0..normalized_version.segments.count - 2]
18
+ )
19
+ end
20
+
21
+ # @return [Gem::Requirement]
22
+ def to_requirement
23
+ r = ["~> #{prefix_version}"]
24
+ r << ">= #{normalized_version}" unless normalized_version.segments[-1].zero?
25
+ ::Gem::Requirement.new(r)
26
+ end
27
+
28
+ # @return [Array<String>]
29
+ def to_requirements_list
30
+ to_requirement.requirements.map { |r| "#{r[0]} #{r[1]}" }
31
+ end
32
+
33
+ private
34
+
35
+ # @return [Avm::VersionNumber]
36
+ def normalized_version_uncached
37
+ r = version
38
+ r = ::Avm::VersionNumber.new(r.segments + [0]) while r.segments.count < 3
39
+ r
40
+ end
41
+ end
42
+ end
43
+ end
@@ -2,8 +2,8 @@
2
2
 
3
3
  require 'avm/eac_generic_base0/sources/base'
4
4
  require 'avm/eac_ruby_base1/rubygems/version_file'
5
+ require 'avm/eac_ruby_base1/sources/runners'
5
6
  require 'avm/eac_ruby_base1/sources/update'
6
- require 'avm/eac_ruby_base1/sources/runners/bundler'
7
7
  require 'avm/version_number'
8
8
  require 'eac_ruby_utils/core_ext'
9
9
 
@@ -0,0 +1,84 @@
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
+ class GemfileLocal
11
+ runner_with :help do
12
+ bool_opt '-w', '--write', 'Write the Gemfile.local file.'
13
+ end
14
+
15
+ def run
16
+ start_banner
17
+ run_bundle
18
+ siblings_banner
19
+ write_gemfile_local
20
+ end
21
+
22
+ private
23
+
24
+ def gemfile_local_path
25
+ the_source.path.join('Gemfile.local')
26
+ end
27
+
28
+ def gemfile_local_content
29
+ siblings.map { |s| sibling_gemfile_local_line(s) }.join
30
+ end
31
+
32
+ def run_bundle
33
+ the_source.bundle.execute!
34
+ rescue ::RuntimeError
35
+ the_source.bundle('update').execute!
36
+ end
37
+
38
+ def sibling_gemfile_local_line(sibling)
39
+ ["gem '#{sibling.gem_name}'",
40
+ "path: ::File.expand_path('" +
41
+ sibling.path.relative_path_from(the_source.path).to_path +
42
+ "', __dir__)"].join(', ') + "\n"
43
+ end
44
+
45
+ def start_banner
46
+ runner_context.call(:source_banner)
47
+ infov 'Parent', the_source.parent
48
+ end
49
+
50
+ def siblings_banner
51
+ infov 'Siblings', siblings.count
52
+ siblings.each do |sibling|
53
+ infov ' * ', sibling.relative_path
54
+ end
55
+ end
56
+
57
+ def write_gemfile_local
58
+ return unless parsed.write?
59
+
60
+ infom "Writing #{gemfile_local_path}..."
61
+ gemfile_local_path.write(gemfile_local_content)
62
+ end
63
+
64
+ def siblings_uncached
65
+ the_source.parent.if_present([]) do |v|
66
+ v.subs.select { |sub| dependency_sub?(sub) }
67
+ end
68
+ end
69
+
70
+ def the_source
71
+ runner_context.call(:source)
72
+ end
73
+
74
+ def dependency_sub?(sub)
75
+ sub.is_a?(::Avm::EacRubyBase1::Sources::Base) &&
76
+ sub.gem_name != the_source.gem_name &&
77
+ the_source.gemfile_lock_gem_version(sub.gem_name).present?
78
+ end
79
+ end
80
+ end
81
+ end
82
+ end
83
+ end
84
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_ruby_base1/rubygems/gemspec'
4
+ require 'avm/eac_ruby_base1/sources/update_dependency_requirements'
5
+ require 'eac_cli/core_ext'
6
+
7
+ module Avm
8
+ module EacRubyBase1
9
+ module Sources
10
+ module Runners
11
+ class UpdateDependenciesRequirements
12
+ runner_with :help, :subcommands do
13
+ bool_opt '-a', '--all'
14
+ pos_arg :gem_name, repeat: true, optional: true
15
+ end
16
+
17
+ def run
18
+ runner_context.call(:source_banner)
19
+ infov 'Gems to update', gem_names.count
20
+ gem_names.each do |gem_name|
21
+ infov 'Gem to update', gem_name
22
+ ::Avm::EacRubyBase1::Sources::UpdateDependencyRequirements
23
+ .new(runner_context.call(:source), gem_name).perform
24
+ end
25
+ end
26
+
27
+ def gemspec
28
+ ::Avm::EacRubyBase1::Rubygems::Gemspec.from_file(
29
+ runner_context.call(:source).gemspec_path
30
+ )
31
+ end
32
+
33
+ private
34
+
35
+ def gem_names_uncached
36
+ ::Set.new(parsed.gem_name + gem_names_from_all).sort
37
+ end
38
+
39
+ def gem_names_from_all
40
+ return [] unless parsed.all?
41
+
42
+ gemspec.dependencies.map(&:gem_name)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_ruby_base1/preferred_version_requirements'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module EacRubyBase1
8
+ module Sources
9
+ class UpdateDependencyRequirements
10
+ enable_simple_cache
11
+ common_constructor :source, :gem_name
12
+
13
+ def perform
14
+ source.scm.commit_if_change(commit_message) { update_code }
15
+ end
16
+
17
+ private
18
+
19
+ # @return [String]
20
+ def commit_message
21
+ i18n_translate(__method__,
22
+ name: gem_name,
23
+ requirements_list: requirements_list.join(', '),
24
+ __locale: source.locale)
25
+ end
26
+
27
+ # @return [Array<String>]
28
+ def requirements_list_uncached
29
+ ::Avm::EacRubyBase1::PreferredVersionRequirements.new(
30
+ source.gemfile_lock_gem_version(gem_name)
31
+ ).to_requirements_list
32
+ end
33
+
34
+ def gemspec_uncached
35
+ ::Avm::EacRubyBase1::Rubygems::Gemspec.from_file(source.gemspec_path)
36
+ end
37
+
38
+ def update_code
39
+ update_gemspec
40
+ source.bundle.system!
41
+ end
42
+
43
+ def update_gemspec
44
+ gemspec.dependency(gem_name).version_specs = requirements_list
45
+ gemspec.write(source.gemspec_path)
46
+ source.bundle('exec', 'rubocop', source.gemspec_path).system!
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module EacRubyBase1
5
- VERSION = '0.13.0'
5
+ VERSION = '0.17.0'
6
6
  end
7
7
  end
data/locale/en.yml CHANGED
@@ -6,3 +6,5 @@ en:
6
6
  no_scm_update_commit_message: "Gem \"%{name}\" (Local): update to '%{version}'."
7
7
  scm_update_commit_message: '**/.gitrepo: fix/update.'
8
8
  update_gemfile_lock_commit_message: 'All gems: update.'
9
+ update_dependency_requirements:
10
+ commit_message: "Gem \"%{name}\": update to '%{requirements_list}'."
data/locale/pt-BR.yml CHANGED
@@ -6,3 +6,5 @@ pt-BR:
6
6
  no_scm_update_commit_message: "Gem \"%{name}\" (Local): atualiza para '%{version}'."
7
7
  scm_update_commit_message: '**/.gitrepo: conserta/atualiza.'
8
8
  update_gemfile_lock_commit_message: 'Todas as gems: atualiza.'
9
+ update_dependency_requirements:
10
+ commit_message: "Gem \"%{name}\": atualiza para to '%{requirements_list}'."
@@ -3,3 +3,6 @@
3
3
  source 'https://rubygems.org'
4
4
 
5
5
  gemspec
6
+
7
+ local_gemfile = ::File.join(::File.dirname(__FILE__), 'Gemfile.local')
8
+ eval_gemfile local_gemfile if ::File.exist?(local_gemfile)
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.13.0
4
+ version: 0.17.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-08-05 00:00:00.000000000 Z
11
+ date: 2022-08-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avm
@@ -111,6 +111,7 @@ files:
111
111
  - lib/avm/eac_ruby_base1/bundler/incompatible_parser/line_factory.rb
112
112
  - lib/avm/eac_ruby_base1/bundler/incompatible_parser/line_parser_base.rb
113
113
  - lib/avm/eac_ruby_base1/bundler/incompatible_parser/version_requirement.rb
114
+ - lib/avm/eac_ruby_base1/preferred_version_requirements.rb
114
115
  - lib/avm/eac_ruby_base1/rubocop.rb
115
116
  - lib/avm/eac_ruby_base1/rubocop/configured.rb
116
117
  - lib/avm/eac_ruby_base1/rubocop/envvar.rb
@@ -131,7 +132,9 @@ files:
131
132
  - lib/avm/eac_ruby_base1/sources/base/version_bump.rb
132
133
  - lib/avm/eac_ruby_base1/sources/runners.rb
133
134
  - lib/avm/eac_ruby_base1/sources/runners/bundler.rb
135
+ - lib/avm/eac_ruby_base1/sources/runners/bundler/gemfile_local.rb
134
136
  - lib/avm/eac_ruby_base1/sources/runners/bundler/incompatible.rb
137
+ - lib/avm/eac_ruby_base1/sources/runners/update_dependencies_requirements.rb
135
138
  - lib/avm/eac_ruby_base1/sources/tests.rb
136
139
  - lib/avm/eac_ruby_base1/sources/tests/base.rb
137
140
  - lib/avm/eac_ruby_base1/sources/tests/minitest.rb
@@ -141,6 +144,7 @@ files:
141
144
  - lib/avm/eac_ruby_base1/sources/tests/rspec.rb
142
145
  - lib/avm/eac_ruby_base1/sources/update.rb
143
146
  - lib/avm/eac_ruby_base1/sources/update/sub_update.rb
147
+ - lib/avm/eac_ruby_base1/sources/update_dependency_requirements.rb
144
148
  - lib/avm/eac_ruby_base1/version.rb
145
149
  - locale/en.yml
146
150
  - locale/pt-BR.yml