Class: Avm::Tools::Runner::AppSrc::VersionBump

Inherits:
Object
  • Object
show all
Defined in:
lib/avm/tools/runner/app_src/version_bump.rb

Instance Method Summary collapse

Instance Method Details

#confirm?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/avm/tools/runner/app_src/version_bump.rb', line 46

def confirm?
  parsed.yes? || input('Confirm version bump?', bool: true)
end

#current_version_uncachedObject



50
51
52
# File 'lib/avm/tools/runner/app_src/version_bump.rb', line 50

def current_version_uncached
  runner_context.call(:instance).if_respond('version')
end

#runObject



21
22
23
24
# File 'lib/avm/tools/runner/app_src/version_bump.rb', line 21

def run
  start_banner
  version_changed? ? run_version_changed : run_version_unchanged
end

#run_version_changedObject



26
27
28
29
30
31
32
33
34
# File 'lib/avm/tools/runner/app_src/version_bump.rb', line 26

def run_version_changed
  infom 'Version changed'
  if confirm?
    runner_context.call(:instance).run_job(:version_bump, target_version)
    success 'Bumped'
  else
    fatal_error 'Bump unconfirmed'
  end
end

#run_version_unchangedObject



36
37
38
# File 'lib/avm/tools/runner/app_src/version_bump.rb', line 36

def run_version_unchanged
  success 'Version unchanged'
end

#start_bannerObject



40
41
42
43
44
# File 'lib/avm/tools/runner/app_src/version_bump.rb', line 40

def start_banner
  runner_context.call(:instance_banner)
  infov 'Current version', current_version.if_present('-')
  infov 'Target version', target_version.if_present('-')
end

#target_version_from_new(_current, option_value) ⇒ Object



65
66
67
# File 'lib/avm/tools/runner/app_src/version_bump.rb', line 65

def target_version_from_new(_current, option_value)
  ::Avm::VersionNumber.new(option_value)
end

#target_version_from_segment(current, option_value) ⇒ Object



69
70
71
# File 'lib/avm/tools/runner/app_src/version_bump.rb', line 69

def target_version_from_segment(current, option_value)
  current.increment_segment(option_value.to_i)
end

#target_version_uncachedObject



54
55
56
57
58
59
60
61
62
63
# File 'lib/avm/tools/runner/app_src/version_bump.rb', line 54

def target_version_uncached
  r = current_version
  %w[new segment major minor patch].each do |option|
    option_value = parsed[option]
    next if option_value.blank?

    r = send("target_version_from_#{option}", r, option_value)
  end
  r
end

#version_changed?Boolean

Returns:

  • (Boolean)


79
80
81
# File 'lib/avm/tools/runner/app_src/version_bump.rb', line 79

def version_changed?
  target_version != current_version
end