avm-eac_ruby_base1 0.3.1 → 0.6.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: 8524f1df1ef3eb469e6a869d7cf04984e31cdb0e2df3359eeed3d2d8bd602913
4
- data.tar.gz: cd4310a87629dfb54f5b25129b23ac8706196aa01977d77c216c665c8ec91d02
3
+ metadata.gz: ae50465c6257b0c96caed1eeadc4d7879294952f52a3e8b4fc0cbfb3dbc9408b
4
+ data.tar.gz: 1d76ec909ab0216c8f5759eae08d3ea4e1ea49fe6cd708bb5796fd0b97768179
5
5
  SHA512:
6
- metadata.gz: b099275afd2080c1746b877e91086d7bbce66f80446a59b46c58c1508ff80295386ba8a82f8a724f78aaa35a9032366d409f48068e1f0ab4c77e027294f3a0de
7
- data.tar.gz: 145f51546454ca8885ee837efd058ca5d7caa1fca76d71ad08c9716761525b82d5162750cbcdca58e89b1a3d4c3cb65e3294557df055413eca747d420eb9d4ad
6
+ metadata.gz: 81dba51b5ab1af1c389933de54316315c7af93a2b473a977a9f9f2b1c9522aeb6cbbf7ad6214b3873e0137c5534f0760e20a23d3a854abd19a376e332ab1805d
7
+ data.tar.gz: 0d3fea5b073cf33e07c76427d76112754832bd3c89cb1328e71bb8f09502cbdcffbf40f313fe5dadd13fd24a60c0f32bfe2897e52d6c016a302d927ed0ff2c8b
@@ -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
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/sources/configuration'
4
+
5
+ module Avm
6
+ module EacRubyBase1
7
+ class Rubocop
8
+ module Configured
9
+ def configured_rubocop_command_uncached
10
+ configured_rubocop_command_by_command || configured_rubocop_command_by_gemfile
11
+ end
12
+
13
+ def configured_rubocop_command_by_command
14
+ configuration.if_present(&:rubocop_command)
15
+ end
16
+
17
+ def configured_rubocop_command_by_gemfile
18
+ configuration.if_present(&:rubocop_gemfile).if_present do |v|
19
+ rubocop_command_by_gemfile_path(v.parent)
20
+ end
21
+ end
22
+
23
+ private
24
+
25
+ def configuration_uncached
26
+ ::Avm::Sources::Configuration.find_by_path(base_path)
27
+ end
28
+ end
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module Avm
6
+ module EacRubyBase1
7
+ class Rubocop
8
+ module Envvar
9
+ RUBOCOP_COMMAND_ENVVAR_NAME = 'RUBOCOP_COMMAND'
10
+
11
+ def env_rubocop_command
12
+ ENV[RUBOCOP_COMMAND_ENVVAR_NAME].present? ? cmd(ENV[RUBOCOP_COMMAND_ENVVAR_NAME]) : nil
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/patches/eac_ruby_gems_utils/gem'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module EacRubyBase1
8
+ class Rubocop
9
+ module Gemfile
10
+ def gemfile_rubocop_command
11
+ return nil unless rubocop_gemfile?
12
+
13
+ rubocop_command_by_gemfile_path(mygem.root)
14
+ end
15
+
16
+ def rubocop_command_by_gemfile_path(path)
17
+ ::EacRubyGemsUtils::Gem.new(path).bundle('exec', 'rubocop').chdir_root
18
+ end
19
+
20
+ def rubocop_gemfile?
21
+ return false if mygem.blank?
22
+
23
+ mygem.bundle('install').execute!
24
+ mygem.gemfile_lock_gem_version('rubocop').present?
25
+ end
26
+
27
+ private
28
+
29
+ def mygem_uncached
30
+ find_gem(::Pathname.new(base_path).expand_path)
31
+ end
32
+
33
+ def find_gem(path)
34
+ r = ::EacRubyGemsUtils::Gem.new(path)
35
+ return r if r.gemfile_path.exist?
36
+ return find_gem(path.dirname) unless path.root?
37
+ end
38
+ end
39
+ end
40
+ end
41
+ end
@@ -0,0 +1,55 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+ require 'eac_ruby_utils/ruby/on_clean_environment'
5
+
6
+ module Avm
7
+ module EacRubyBase1
8
+ class Rubocop
9
+ require_sub __FILE__, include_modules: true
10
+ enable_speaker
11
+ enable_simple_cache
12
+ common_constructor :base_path, :rubocop_args
13
+ set_callback :initialize, :after do
14
+ @base_path = ::Pathname.new(base_path.to_s) unless base_path.is_a?(::Pathname)
15
+ end
16
+
17
+ def run
18
+ start_banner
19
+ run_rubocop
20
+ end
21
+
22
+ private
23
+
24
+ def cmd(*args)
25
+ ::EacRubyUtils::Envs.local.command(*args)
26
+ end
27
+
28
+ def rubocop_command_uncached
29
+ %w[env configured gemfile].each do |s|
30
+ cmd = send("#{s}_rubocop_command")
31
+ return cmd if cmd.present?
32
+ end
33
+ cmd('rubocop')
34
+ end
35
+
36
+ def rubocop_command_with_args
37
+ rubocop_command.append(rubocop_args)
38
+ end
39
+
40
+ def rubocop_version_uncached
41
+ ::EacRubyUtils::Ruby.on_clean_environment do
42
+ rubocop_command.append(['--version']).execute!.strip
43
+ end
44
+ end
45
+
46
+ def run_rubocop
47
+ ::EacRubyUtils::Ruby.on_clean_environment { rubocop_command_with_args.system }
48
+ end
49
+
50
+ def start_banner
51
+ infov 'Rubocop version', rubocop_version
52
+ end
53
+ end
54
+ end
55
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/eac_generic_base0/sources/base'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module EacRubyBase1
8
+ module Sources
9
+ class Base < ::Avm::EacGenericBase0::Sources::Base
10
+ module VersionBump
11
+ def after_sub_version_bump_do_changes
12
+ the_gem.bundle('install').chdir_root.execute!
13
+ end
14
+
15
+ def version_bump_do_changes(target_version)
16
+ self.version = target_version
17
+ the_gem.bundle('install').chdir_root.execute!
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
23
+ 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/version_number'
6
7
  require 'eac_ruby_gems_utils/gem'
7
8
  require 'eac_ruby_utils/core_ext'
8
9
 
@@ -10,6 +11,7 @@ module Avm
10
11
  module EacRubyBase1
11
12
  module Sources
12
13
  class Base < ::Avm::EacGenericBase0::Sources::Base
14
+ require_sub __FILE__, include_modules: :prepend, require_dependency: true
13
15
  delegate :gemspec_path, to: :the_gem
14
16
 
15
17
  def gemfile_path
@@ -33,6 +35,15 @@ module Avm
33
35
  def update
34
36
  ::Avm::EacRubyBase1::Sources::Update.new(self)
35
37
  end
38
+
39
+ # @return [Avm::VersionNumber]
40
+ def version
41
+ the_gem.version.if_present { |v| ::Avm::VersionNumber.new(v) }
42
+ end
43
+
44
+ def version=(value)
45
+ the_gem.version_file.value = value
46
+ end
36
47
  end
37
48
  end
38
49
  end
@@ -19,7 +19,7 @@ module Avm
19
19
  # @return [EacRubyGemsUtils::Gem::Command, nil]
20
20
  def bundle_test_command
21
21
  source.read_configuration_as_shell_words(BUNDLE_TEST_COMMAND_CONFIGURATION_KEY)
22
- .if_present { |args| the_gem.bundle(*args).chdir_root }
22
+ .if_present { |args| the_gem.bundle(*args).chdir_root }
23
23
  end
24
24
 
25
25
  # @return [EacRubyGemsUtils::Gem::Command, nil]
@@ -18,7 +18,7 @@ module Avm
18
18
  if commit.no_scm_changed_files.any?
19
19
  commit = commit.reword(no_scm_update_commit_message)
20
20
  source.scm.commit_if_change { source_update.bundle_update }
21
- .if_present { |v| v.merge_with(commit) }
21
+ .if_present { |v| v.merge_with(commit) }
22
22
  else
23
23
  commit.reword(scm_update_commit_message)
24
24
  end
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avm/eac_ruby_base1/patches/i18n'
4
3
  require 'eac_ruby_utils/core_ext'
5
4
 
6
5
  module Avm
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module EacRubyBase1
5
- VERSION = '0.3.1'
5
+ VERSION = '0.6.0'
6
6
  end
7
7
  end
data/locale/en.yaml ADDED
@@ -0,0 +1,8 @@
1
+ en:
2
+ avm:
3
+ eac_ruby_base1:
4
+ sources:
5
+ update:
6
+ no_scm_update_commit_message: "Gem \"%{name}\" (Local): update to '%{version}'."
7
+ scm_update_commit_message: '**/.gitrepo: fix/update.'
8
+ update_gemfile_lock_commit_message: 'All gems: update.'
data/locale/pt-BR.yaml ADDED
@@ -0,0 +1,8 @@
1
+ pt-BR:
2
+ avm:
3
+ eac_ruby_base1:
4
+ sources:
5
+ update:
6
+ no_scm_update_commit_message: "Gem \"%{name}\" (Local): atualiza para '%{version}'."
7
+ scm_update_commit_message: '**/.gitrepo: conserta/atualiza.'
8
+ update_gemfile_lock_commit_message: 'Todas as gems: atualiza.'
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.3.1
4
+ version: 0.6.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: 2021-12-04 00:00:00.000000000 Z
11
+ date: 2022-06-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: avm
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.1'
33
+ version: '0.2'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.1'
40
+ version: '0.2'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: eac_ruby_gems_utils
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -78,14 +78,14 @@ dependencies:
78
78
  requirements:
79
79
  - - "~>"
80
80
  - !ruby/object:Gem::Version
81
- version: '0.4'
81
+ version: 0.5.1
82
82
  type: :development
83
83
  prerelease: false
84
84
  version_requirements: !ruby/object:Gem::Requirement
85
85
  requirements:
86
86
  - - "~>"
87
87
  - !ruby/object:Gem::Version
88
- version: '0.4'
88
+ version: 0.5.1
89
89
  description:
90
90
  email:
91
91
  executables: []
@@ -93,14 +93,23 @@ extensions: []
93
93
  extra_rdoc_files: []
94
94
  files:
95
95
  - lib/avm/eac_ruby_base1.rb
96
- - lib/avm/eac_ruby_base1/patches.rb
97
- - lib/avm/eac_ruby_base1/patches/i18n.rb
96
+ - lib/avm/eac_ruby_base1/bundler.rb
97
+ - lib/avm/eac_ruby_base1/bundler/gemfile.rb
98
+ - lib/avm/eac_ruby_base1/bundler/gemfile/add_or_replace_gem_line.rb
99
+ - lib/avm/eac_ruby_base1/bundler/gemfile/dependency.rb
100
+ - lib/avm/eac_ruby_base1/rubocop.rb
101
+ - lib/avm/eac_ruby_base1/rubocop/configured.rb
102
+ - lib/avm/eac_ruby_base1/rubocop/envvar.rb
103
+ - lib/avm/eac_ruby_base1/rubocop/gemfile.rb
98
104
  - lib/avm/eac_ruby_base1/sources.rb
99
105
  - lib/avm/eac_ruby_base1/sources/base.rb
106
+ - lib/avm/eac_ruby_base1/sources/base/version_bump.rb
100
107
  - lib/avm/eac_ruby_base1/sources/tester.rb
101
108
  - lib/avm/eac_ruby_base1/sources/update.rb
102
109
  - lib/avm/eac_ruby_base1/sources/update/sub_update.rb
103
110
  - lib/avm/eac_ruby_base1/version.rb
111
+ - locale/en.yaml
112
+ - locale/pt-BR.yaml
104
113
  homepage:
105
114
  licenses: []
106
115
  metadata: {}
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
- require 'i18n'
5
-
6
- ::I18n.load_path += __dir__.to_pathname.expand_path.parent_n(4).join('locale').glob('*.yaml')
7
- .map(&:to_path)
@@ -1,4 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/require_sub'
4
- ::EacRubyUtils.require_sub(__FILE__)