avm-tools 0.64.0 → 0.67.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: 1565797abcceccaa3a466abb16694b514ae9773b151142ad27628a0d344a6c2b
4
- data.tar.gz: a2756806ed389c2d141a9d038cdb6a55aaa28c9747768cac97bb32ca27b49962
3
+ metadata.gz: 916ea6c3a654cc81c07739fffab5013f51cf9e83a7cf8b1163abef48c6fa7ea8
4
+ data.tar.gz: 7393ff7addec4974fccb0b95b1b6bc5e625e05decc8e695696a1511f4d40c472
5
5
  SHA512:
6
- metadata.gz: 5d895b6ceef334e3b439291f2c2eed9477cc738864fede0f4426d0f7040768febf4759b3cc2267fa0ee34eb18301e8c0066e29b5c1a02b952fcacd7f711c91bd
7
- data.tar.gz: 812e64910a913c855562bcea3f61aabf441cfafbd7a0af8e356dc217f66451f12361d30507343dbab2b56898313d319880d51bf59893ca11cab6c1d29ed90682
6
+ metadata.gz: 70c1fa8e342208bfd2af99796da13e6cad4d86bb1e28f15b92212c5255fbb5de56dbd88a70ac89c84106a82dac44c1429c3bbf1524932034ef797bc690e4c7b3
7
+ data.tar.gz: 2b20f95259f5603547d3484d5771babb52eeaa43be785b0afe16460ac0bac584d8143ec70df2f53e6e567fdd99ad19498375a78eccb7f876c7ad445b44496f83
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/files/rotate'
3
4
  require 'eac_ruby_utils/core_ext'
4
5
  require 'minitar'
5
6
 
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/patches/eac_ruby_gems_utils/gem'
4
+ require 'i18n'
5
+
6
+ module Avm
7
+ module Instances
8
+ class Configuration < ::EacRubyUtils::Configs
9
+ LOCALE_KEY = :locale
10
+
11
+ def locale
12
+ read_entry(LOCALE_KEY) || ::I18n.default_locale
13
+ end
14
+ end
15
+ end
16
+ end
@@ -1,8 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/instances/configuration'
3
4
  require 'eac_launcher/paths/real'
4
5
  require 'eac_ruby_utils/core_ext'
5
6
  require 'avm/projects/stereotypes'
7
+ require 'i18n'
6
8
 
7
9
  module Avm
8
10
  module LocalProjects
@@ -13,14 +15,39 @@ module Avm
13
15
  source_stereotypes_mixins
14
16
  end
15
17
 
18
+ delegate :to_s, to: :path
19
+
20
+ def locale
21
+ configuration.if_present(&:locale) || ::I18n.default_locale
22
+ end
23
+
16
24
  # Backward compatibility with [EacLauncher::Paths::Logical].
17
25
  # @return [EacLauncher::Paths::Real].
18
26
  def real
19
27
  ::EacLauncher::Paths::Real.new(path.to_path)
20
28
  end
21
29
 
30
+ def run_job(job, job_args = [])
31
+ stereotypes.each { |stereotype| run_stereotype_job(stereotype, job, job_args) }
32
+ end
33
+
22
34
  private
23
35
 
36
+ # @return [Avm::Instances::Configuration]
37
+ def configuration_uncached
38
+ ::Avm::Instances::Configuration.find_in_path(path)
39
+ end
40
+
41
+ def run_stereotype_job(stereotype, job, job_args)
42
+ job_class_method = "#{job}_class"
43
+ if stereotype.send(job_class_method).present?
44
+ puts stereotype.label + ": #{job} class found. Running..."
45
+ stereotype.send(job_class_method).new(self, *job_args).run
46
+ else
47
+ puts stereotype.label + ": #{job} class not found"
48
+ end
49
+ end
50
+
24
51
  def stereotypes_uncached
25
52
  ::Avm::Projects::Stereotypes.list.select { |s| s.match?(self) }
26
53
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/self'
4
+ require 'i18n'
5
+
6
+ module Avm
7
+ module Patches
8
+ module I18n
9
+ class << self
10
+ def setup_i18n
11
+ ::I18n.load_path += locale_files_paths.map(&:to_path)
12
+ end
13
+
14
+ def locale_files_paths
15
+ ::Avm::Self.root.join('locale').glob('*.yml')
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
21
+
22
+ ::Avm::Patches::I18n.setup_i18n
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/patches/i18n'
4
+
5
+ class Object
6
+ def translate(entry_suffix, values = {})
7
+ ::I18n.translate(translate_entry_full(entry_suffix), values)
8
+ end
9
+
10
+ def translate_entry_full(entry_suffix)
11
+ "#{translate_entry_self_prefix}.#{entry_suffix}"
12
+ end
13
+
14
+ def translate_entry_self_prefix
15
+ self.class.name.underscore.gsub('/', '.')
16
+ end
17
+ end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'avm/self'
3
4
  require 'eac_ruby_utils/patches/object/template'
4
5
 
5
- ::EacRubyUtils::Templates::Searcher.default.included_paths << ::File.expand_path(
6
- ('../' * 4) + 'template', __dir__
7
- )
6
+ ::EacRubyUtils::Templates::Searcher.default.included_paths <<
7
+ ::Avm::Self.root.join('template').to_path
@@ -37,6 +37,7 @@ module Avm
37
37
  local_project_mixin: ::Module,
38
38
  publish: ::Class,
39
39
  update: ::Class,
40
+ version_bump: ::Class,
40
41
  warp: ::Class
41
42
  }.each do |name, is_a|
42
43
  define_method "#{name}_#{is_a.name.underscore}" do
@@ -47,14 +48,14 @@ module Avm
47
48
  private
48
49
 
49
50
  def sub_constant(constant_name, is_a)
51
+ return nil unless const_defined?(constant_name)
52
+
50
53
  constant = const_get(constant_name)
51
54
  unless is_a.if_present(true) { |v| constant.is_a?(v) }
52
55
  raise("#{constant} is not a #{is_a}")
53
56
  end
54
57
 
55
58
  constant
56
- rescue NameError
57
- nil
58
59
  end
59
60
  end
60
61
  end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'avm/patches/eac_ruby_gems_utils/gem'
4
+ require 'avm/version'
4
5
  require 'eac_ruby_utils/core_ext'
5
6
 
6
7
  module Avm
@@ -12,6 +13,14 @@ module Avm
12
13
  def ruby_gem
13
14
  @ruby_gem ||= ::EacRubyGemsUtils::Gem.new(path)
14
15
  end
16
+
17
+ def version
18
+ ruby_gem.version.if_present { |v| ::Avm::Version.new(v) }
19
+ end
20
+
21
+ def version=(value)
22
+ ruby_gem.version_file.value = value
23
+ end
15
24
  end
16
25
  end
17
26
  end
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/patches/object/i18n'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Projects
8
+ module Stereotypes
9
+ class RubyGem
10
+ class VersionBump
11
+ enable_console_speaker
12
+ common_constructor :instance, :target_version
13
+
14
+ def run
15
+ git_checkout
16
+ change_version
17
+ bundle_run
18
+ git_commit
19
+ end
20
+
21
+ private
22
+
23
+ def bundle_run
24
+ infom 'Running "bundle install"...'
25
+ instance.ruby_gem.bundle('install').execute!
26
+ end
27
+
28
+ def change_version
29
+ infom 'Setting project version...'
30
+ instance.version = target_version
31
+ end
32
+
33
+ def git_checkout
34
+ return unless instance.respond_to?(:git_repo)
35
+
36
+ infom "Checkouting #{changing_files.map(&:to_path).join(', ')}..."
37
+ instance.git_repo.command('checkout', '--',
38
+ *changing_files.map(&:to_path)).execute!
39
+ end
40
+
41
+ def git_commit
42
+ return unless instance.respond_to?(:git_repo)
43
+
44
+ infom "Commiting #{changing_files.map(&:to_path).join(', ')}..."
45
+ instance.git_repo.command('commit', '-m', git_commit_message, '--',
46
+ *changing_files.map(&:to_path)).execute!
47
+ end
48
+
49
+ def git_commit_message
50
+ ::I18n.default_locale = instance.locale
51
+ translate(__method__, version: target_version)
52
+ end
53
+
54
+ def changing_files
55
+ [instance.ruby_gem.gemfile_lock_path, instance.ruby_gem.version_file_path]
56
+ end
57
+ end
58
+ end
59
+ end
60
+ end
61
+ end
@@ -10,12 +10,16 @@ module Avm
10
10
 
11
11
  class << self
12
12
  def application
13
- @application ||= ::EacRubyBase0::Application.new(::File.expand_path('../..', __dir__))
13
+ @application ||= ::EacRubyBase0::Application.new(root.to_path)
14
14
  end
15
15
 
16
16
  def instance
17
17
  @instance ||= ::Avm::Self::Instance.by_id('avm-tools_self')
18
18
  end
19
+
20
+ def root
21
+ ::Pathname.new('../..').expand_path(__dir__)
22
+ end
19
23
  end
20
24
  end
21
25
  end
@@ -17,6 +17,11 @@ module Avm
17
17
  subcommands
18
18
  end
19
19
 
20
+ def instance_banner
21
+ infov 'Instance', instance
22
+ infov 'Stereotypes', instance.stereotypes.map(&:label).join(', ')
23
+ end
24
+
20
25
  private
21
26
 
22
27
  def instance_uncached
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/patches/eac_ruby_gems_utils/gem'
4
+ require 'eac_cli/default_runner'
5
+ require 'eac_ruby_utils/console/docopt_runner'
6
+ require 'eac_ruby_utils/core_ext'
7
+
8
+ module Avm
9
+ module Tools
10
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
11
+ class LocalProject < ::EacRubyUtils::Console::DocoptRunner
12
+ class Ruby < ::EacRubyUtils::Console::DocoptRunner
13
+ require_sub __FILE__
14
+ include ::EacCli::DefaultRunner
15
+
16
+ runner_definition do
17
+ desc 'Ruby utitilies for local projects.'
18
+ subcommands
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/default_runner'
4
+ require 'eac_ruby_utils/console/docopt_runner'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module Avm
8
+ module Tools
9
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
10
+ class LocalProject < ::EacRubyUtils::Console::DocoptRunner
11
+ class Ruby < ::EacRubyUtils::Console::DocoptRunner
12
+ class Bundler < ::EacRubyUtils::Console::DocoptRunner
13
+ require_sub __FILE__
14
+ include ::EacCli::DefaultRunner
15
+
16
+ runner_definition do
17
+ desc 'Ruby\'s bundler utitilies for local projects.'
18
+ subcommands
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,138 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_cli/default_runner'
4
+ require 'eac_ruby_utils/console/docopt_runner'
5
+
6
+ module Avm
7
+ module Tools
8
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
9
+ class LocalProject < ::EacRubyUtils::Console::DocoptRunner
10
+ class Ruby < ::EacRubyUtils::Console::DocoptRunner
11
+ class Bundler < ::EacRubyUtils::Console::DocoptRunner
12
+ class GemfileLock < ::EacRubyUtils::Console::DocoptRunner
13
+ include ::EacCli::DefaultRunner
14
+
15
+ runner_definition do
16
+ desc 'Manipulage a "Gemfile.lock" file.'
17
+ bool_opt '-c', '--continue', 'Continue Git rebase/cherry-pick.'
18
+ bool_opt '-i', '--install', 'Run "bundle install".'
19
+ bool_opt '-u', '--update', 'Run "bundle update".'
20
+ bool_opt '-r', '--recursive', 'Run until Git rebase/cherry-pick is finished.'
21
+ bool_opt '-a', '--all', 'Same as "-ciru".'
22
+ end
23
+
24
+ def run
25
+ loop do
26
+ git_reset_checkout
27
+ bundle_update
28
+ bundle_install
29
+ git_continue
30
+ break if complete?
31
+ end
32
+ end
33
+
34
+ private
35
+
36
+ def complete?
37
+ !option_or_all?('--recursive') || !conflict?
38
+ end
39
+
40
+ def rebasing?
41
+ instance.git_repo.root_path.join('.git', 'rebase-merge').exist?
42
+ end
43
+
44
+ def git_reset_checkout
45
+ return unless check_capability(__method__, :git_repo, nil)
46
+
47
+ infom 'Reseting...'
48
+ instance.git_repo.command('reset', gemfile_lock).system!
49
+ infom 'Checkouting...'
50
+ instance.git_repo.command('checkout', '--', gemfile_lock).system!
51
+ end
52
+
53
+ def bundle_install
54
+ return unless check_capability(__method__, :ruby_gem, '--install')
55
+
56
+ infom '"bundle install"...'
57
+ bundle_run('install')
58
+ end
59
+
60
+ def bundle_update
61
+ return unless check_capability(__method__, :ruby_gem, '--update')
62
+
63
+ infom '"bundle update"...'
64
+ bundle_run('update')
65
+ end
66
+
67
+ def git_continue
68
+ return unless check_capability(__method__, :git_repo, '--continue')
69
+
70
+ infom "Adding \"#{gemfile_lock}\"..."
71
+ instance.git_repo.command('add', gemfile_lock).execute!
72
+ if rebase_conflict?
73
+ git_continue_run('rebase')
74
+ elsif cherry_conflict?
75
+ git_continue_run('cherry-pick')
76
+ else
77
+ raise 'Unknown how to continue'
78
+ end
79
+ end
80
+
81
+ def git_continue_run(command)
82
+ infom "\"#{command}\" --continue..."
83
+ cmd = instance.git_repo.command(command, '--continue').envvar('GIT_EDITOR', 'true')
84
+ return unless !cmd.system && !conflict?
85
+
86
+ fatal_error "\"#{cmd}\" failed and there is no conflict"
87
+ end
88
+
89
+ def gemfile_lock
90
+ 'Gemfile.lock'
91
+ end
92
+
93
+ def git_uncached
94
+ ::EacGit::Local.new(git_path)
95
+ end
96
+
97
+ def bundle_run(*args)
98
+ instance.ruby_gem.bundle(*args).system!
99
+ end
100
+
101
+ def git_path
102
+ '.'
103
+ end
104
+
105
+ def conflict?
106
+ rebase_conflict? || cherry_conflict?
107
+ end
108
+
109
+ def rebase_conflict?
110
+ instance.git_repo.root_path.join('.git', 'REBASE_HEAD').exist?
111
+ end
112
+
113
+ def cherry_conflict?
114
+ instance.git_repo.root_path.join('.git', 'CHERRY_PICK_HEAD').exist?
115
+ end
116
+
117
+ def option_or_all?(option)
118
+ options.fetch(option) || options.fetch('--all')
119
+ end
120
+
121
+ def instance
122
+ context(:instance)
123
+ end
124
+
125
+ def check_capability(caller, capability, option)
126
+ return false unless option.blank? || option_or_all?(option)
127
+ return true if instance.respond_to?(capability)
128
+
129
+ warn "Cannot run #{caller}: instance has no capability \"#{capability}\""
130
+ false
131
+ end
132
+ end
133
+ end
134
+ end
135
+ end
136
+ end
137
+ end
138
+ end
@@ -0,0 +1,34 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/console/docopt_runner'
4
+ require 'eac_ruby_utils/core_ext'
5
+
6
+ module Avm
7
+ module Tools
8
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
9
+ class LocalProject < ::EacRubyUtils::Console::DocoptRunner
10
+ class Test < ::EacRubyUtils::Console::DocoptRunner
11
+ include ::EacCli::DefaultRunner
12
+
13
+ runner_definition do
14
+ desc 'Test local project.'
15
+ end
16
+
17
+ def run
18
+ context(:instance_banner)
19
+ infov 'Test command', test_command
20
+ if test_command.present?
21
+ test_command.system!
22
+ else
23
+ fatal_error 'No test command found'
24
+ end
25
+ end
26
+
27
+ def test_command
28
+ context(:instance).configuration.if_present(&:any_test_command)
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'avm/local_projects/jobs/update'
4
3
  require 'eac_ruby_utils/console/docopt_runner'
5
4
  require 'eac_ruby_utils/core_ext'
6
5
 
@@ -17,7 +16,7 @@ module Avm
17
16
 
18
17
  def run
19
18
  infov 'Path', context(:instance).path
20
- ::Avm::LocalProjects::Jobs::Update.new(context(:instance)).run
19
+ context(:instance).run_job(:update)
21
20
  end
22
21
  end
23
22
  end
@@ -0,0 +1,89 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'avm/version'
4
+ require 'eac_ruby_utils/console/docopt_runner'
5
+ require 'eac_ruby_utils/core_ext'
6
+
7
+ module Avm
8
+ module Tools
9
+ class Runner < ::EacRubyUtils::Console::DocoptRunner
10
+ class LocalProject < ::EacRubyUtils::Console::DocoptRunner
11
+ class VersionBump < ::EacRubyUtils::Console::DocoptRunner
12
+ include ::EacCli::DefaultRunner
13
+
14
+ runner_definition do
15
+ desc 'Bump version of a local project.'
16
+ arg_opt '-n', '--new', 'Set new version.'
17
+ arg_opt '-s', '--segment', 'Increment de <segment>-th segment (Left-most is 0)'
18
+ bool_opt '-M', '--major', 'Same as --segment=0.'
19
+ bool_opt '-m', '--minor', 'Same as --segment=1.'
20
+ bool_opt '-p', '--patch', 'Same as --segment=2.'
21
+ bool_opt '-y', '--yes', 'Bump without confirmation.'
22
+ end
23
+
24
+ def run
25
+ start_banner
26
+ version_changed? ? run_version_changed : run_version_unchanged
27
+ end
28
+
29
+ def run_version_changed
30
+ infom 'Version changed'
31
+ if confirm?
32
+ context(:instance).run_job(:version_bump, target_version)
33
+ success 'Bumped'
34
+ else
35
+ fatal_error 'Bump unconfirmed'
36
+ end
37
+ end
38
+
39
+ def run_version_unchanged
40
+ success 'Version unchanged'
41
+ end
42
+
43
+ def start_banner
44
+ context(:instance_banner)
45
+ infov 'Current version', current_version.if_present('-')
46
+ infov 'Target version', target_version.if_present('-')
47
+ end
48
+
49
+ def confirm?
50
+ options.fetch('--yes') || request_input('Confirm version bump?', bool: true)
51
+ end
52
+
53
+ def current_version_uncached
54
+ context(:instance).if_respond('version')
55
+ end
56
+
57
+ def target_version_uncached
58
+ r = current_version
59
+ %w[new segment major minor patch].each do |option|
60
+ option_value = options.fetch("--#{option}")
61
+ next if option_value.blank?
62
+
63
+ r = send("target_version_from_#{option}", r, option_value)
64
+ end
65
+ r
66
+ end
67
+
68
+ def target_version_from_new(_current, option_value)
69
+ ::Avm::Version.new(option_value)
70
+ end
71
+
72
+ def target_version_from_segment(current, option_value)
73
+ current.increment_segment(option_value.to_i)
74
+ end
75
+
76
+ %w[major minor patch].each_with_index do |segment, segment_index|
77
+ define_method "target_version_from_#{segment}" do |current, _option_value|
78
+ target_version_from_segment(current, segment_index)
79
+ end
80
+ end
81
+
82
+ def version_changed?
83
+ target_version != current_version
84
+ end
85
+ end
86
+ end
87
+ end
88
+ end
89
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Avm
4
4
  module Tools
5
- VERSION = '0.64.0'
5
+ VERSION = '0.67.0'
6
6
  end
7
7
  end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Avm
4
+ # A sequence of segments of integer versions (Ex.: 2, 1.0.1, 3.0.0.0.0).
5
+ class Version
6
+ include ::Comparable
7
+
8
+ SEGMENT_SEPARATOR = '.'
9
+
10
+ class << self
11
+ def segments_from_mixed(segments)
12
+ (segments.is_a?(::Enumerable) ? segments.to_a : segments.to_s.split(SEGMENT_SEPARATOR))
13
+ .map(&:to_i)
14
+ end
15
+ end
16
+
17
+ attr_reader :segments
18
+
19
+ def initialize(segments)
20
+ @segments = self.class.segments_from_mixed(segments).freeze
21
+ end
22
+
23
+ delegate :[], to: :segments
24
+
25
+ def <=>(other)
26
+ segments <=> other.segments
27
+ end
28
+
29
+ def to_s
30
+ segments.join(SEGMENT_SEPARATOR)
31
+ end
32
+
33
+ # @return [Avm::Version]
34
+ def increment_segment(segment_index)
35
+ x = [segments.count, segment_index + 1].max.times.map do |index|
36
+ value = index < segments.count ? segments[index] : 0
37
+ next value if index < segment_index
38
+ next value + 1 if index == segment_index
39
+
40
+ 0
41
+ end
42
+ self.class.new x
43
+ end
44
+ end
45
+ end
@@ -54,7 +54,7 @@ module EacRubyGemsUtils
54
54
  end
55
55
 
56
56
  def version
57
- /VERSION\s*=\s*[\'\"]([^\'\"]+)[\'\"]/.if_match(version_file.read) { |m| m[1] }
57
+ version_file.value
58
58
  end
59
59
 
60
60
  private
@@ -76,6 +76,10 @@ module EacRubyGemsUtils
76
76
  end
77
77
 
78
78
  def version_file_uncached
79
+ ::EacRubyGemsUtils::Gem::VersionFile.new(version_file_path)
80
+ end
81
+
82
+ def version_file_path_uncached
79
83
  root.join('lib', *namespace_parts, 'version.rb')
80
84
  end
81
85
  end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'eac_ruby_utils/core_ext'
4
+
5
+ module EacRubyGemsUtils
6
+ class Gem
7
+ class VersionFile
8
+ common_constructor :path
9
+
10
+ VERSION_LINE_PATTERN = /\A(\s*)VERSION\s*=\s*[\'\"]([^\'\"]+)[\'\"](\s*)\z/.freeze
11
+
12
+ def value
13
+ path.read.each_line do |line|
14
+ VERSION_LINE_PATTERN.if_match(line.rstrip, false) do |m|
15
+ ::Gem::Version.new(m[2])
16
+ end
17
+ end
18
+ end
19
+
20
+ def value=(new_value)
21
+ path.write(new_value_content(new_value))
22
+ end
23
+
24
+ private
25
+
26
+ def new_value_content(new_value)
27
+ path.read.each_line
28
+ .map { |line| new_value_line(line, new_value) }
29
+ .join
30
+ end
31
+
32
+ def new_value_line(line, new_value)
33
+ m = VERSION_LINE_PATTERN.match(line)
34
+ return line unless m
35
+
36
+ "#{m[1]}VERSION = '#{new_value}'#{m[3]}"
37
+ end
38
+ end
39
+ end
40
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyGemsUtils
4
- VERSION = '0.6.2'
4
+ VERSION = '0.7.0'
5
5
  end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'active_support/core_ext/object/blank'
4
+
5
+ class Object
6
+ # @return +block.call(self.method_name)+ if +self+ responds to +method_name+, +default_value+
7
+ # otherwise.
8
+ def if_respond(method_name, default_value = nil)
9
+ return default_value unless respond_to?(method_name)
10
+
11
+ value = send(method_name)
12
+
13
+ block_given? ? yield(value) : value
14
+ end
15
+
16
+ # @return +yield+ if +self+ is blank.
17
+ def if_blank
18
+ return yield if blank? && block_given?
19
+
20
+ self
21
+ end
22
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module EacRubyUtils
4
- VERSION = '0.43.0'
4
+ VERSION = '0.44.0'
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.64.0
4
+ version: 0.67.0
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: 2020-08-19 00:00:00.000000000 Z
11
+ date: 2020-09-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aranha-parsers
@@ -361,6 +361,7 @@ files:
361
361
  - lib/avm/instances/base/auto_values/web.rb
362
362
  - lib/avm/instances/base/dockerizable.rb
363
363
  - lib/avm/instances/configuration.rb
364
+ - lib/avm/instances/configuration/_locale.rb
364
365
  - lib/avm/instances/configuration/_rubocop.rb
365
366
  - lib/avm/instances/configuration/_tests.rb
366
367
  - lib/avm/instances/entries.rb
@@ -376,9 +377,10 @@ files:
376
377
  - lib/avm/launcher/instances/settings.rb
377
378
  - lib/avm/local_projects.rb
378
379
  - lib/avm/local_projects/instance.rb
379
- - lib/avm/local_projects/jobs/update.rb
380
380
  - lib/avm/patches.rb
381
381
  - lib/avm/patches/eac_ruby_gems_utils/gem.rb
382
+ - lib/avm/patches/i18n.rb
383
+ - lib/avm/patches/object/i18n.rb
382
384
  - lib/avm/patches/object/template.rb
383
385
  - lib/avm/path_string.rb
384
386
  - lib/avm/projects.rb
@@ -400,6 +402,7 @@ files:
400
402
  - lib/avm/projects/stereotypes/ruby_gem/local_project_mixin.rb
401
403
  - lib/avm/projects/stereotypes/ruby_gem/publish.rb
402
404
  - lib/avm/projects/stereotypes/ruby_gem/update.rb
405
+ - lib/avm/projects/stereotypes/ruby_gem/version_bump.rb
403
406
  - lib/avm/rails.rb
404
407
  - lib/avm/rails/runners.rb
405
408
  - lib/avm/rails/runners/bundle.rb
@@ -489,7 +492,12 @@ files:
489
492
  - lib/avm/tools/runner/launcher/publish.rb
490
493
  - lib/avm/tools/runner/local_project.rb
491
494
  - lib/avm/tools/runner/local_project/info.rb
495
+ - lib/avm/tools/runner/local_project/ruby.rb
496
+ - lib/avm/tools/runner/local_project/ruby/bundler.rb
497
+ - lib/avm/tools/runner/local_project/ruby/bundler/gemfile_lock.rb
498
+ - lib/avm/tools/runner/local_project/test.rb
492
499
  - lib/avm/tools/runner/local_project/update.rb
500
+ - lib/avm/tools/runner/local_project/version_bump.rb
493
501
  - lib/avm/tools/runner/ruby.rb
494
502
  - lib/avm/tools/runner/ruby/gems.rb
495
503
  - lib/avm/tools/runner/ruby/gems/generate.rb
@@ -497,6 +505,7 @@ files:
497
505
  - lib/avm/tools/runner/self.rb
498
506
  - lib/avm/tools/runner/self/docker.rb
499
507
  - lib/avm/tools/version.rb
508
+ - lib/avm/version.rb
500
509
  - lib/eac_launcher.rb
501
510
  - lib/eac_launcher/context.rb
502
511
  - lib/eac_launcher/context/instance_discovery.rb
@@ -781,6 +790,7 @@ files:
781
790
  - vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils.rb
782
791
  - vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem.rb
783
792
  - vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem/command.rb
793
+ - vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/gem/version_file.rb
784
794
  - vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests.rb
785
795
  - vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/base.rb
786
796
  - vendor/eac_ruby_gems_utils/lib/eac_ruby_gems_utils/tests/minitest.rb
@@ -886,6 +896,7 @@ files:
886
896
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object.rb
887
897
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/asserts.rb
888
898
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/if_present.rb
899
+ - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/if_respond.rb
889
900
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/template.rb
890
901
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/object/to_pathname.rb
891
902
  - vendor/eac_ruby_utils/lib/eac_ruby_utils/patches/pathname.rb
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'eac_ruby_utils/core_ext'
4
-
5
- module Avm
6
- module LocalProjects
7
- module Jobs
8
- class Update
9
- enable_console_speaker
10
- common_constructor :instance
11
-
12
- def run
13
- instance.stereotypes.each { |stereotype| run_stereotype(stereotype) }
14
- end
15
-
16
- private
17
-
18
- def run_stereotype(stereotype)
19
- if stereotype.update_class.present?
20
- puts stereotype.label + ': update class found. Running...'
21
- stereotype.update_class.new(instance).run
22
- else
23
- puts stereotype.label + ': update class not found'
24
- end
25
- end
26
- end
27
- end
28
- end
29
- end