class GitBumper::CLI
This class receives a Hash of options parsed by CLIParser
and executes the requested action.
Attributes
error_msg[R]
Public Class Methods
new(options)
click to toggle source
@param [Hash]
# File lib/git_bumper/cli.rb, line 8 def initialize(options) @options = options @error = false @error_msg = '' end
Public Instance Methods
error?()
click to toggle source
# File lib/git_bumper/cli.rb, line 33 def error? @error end
run()
click to toggle source
# File lib/git_bumper/cli.rb, line 14 def run Git.fetch_tags old_tag = greatest_tag return error('No tags found.') unless old_tag new_tag = old_tag.clone new_tag.increment(@options.fetch(:increment)) puts "The old tag is #{old_tag}" puts "The new tag will be #{new_tag}" puts 'Push to origin? (Y/n)' return error('Aborted.') unless prompt_yes Git.create_tag(new_tag) Git.push_tag(new_tag) end
Private Instance Methods
error(msg)
click to toggle source
# File lib/git_bumper/cli.rb, line 39 def error(msg) @error = true @error_msg = msg end
greatest_tag()
click to toggle source
# File lib/git_bumper/cli.rb, line 49 def greatest_tag Git.greatest_tag(klass: @options.fetch(:klass), prefix: @options.fetch(:prefix)) end
prompt_yes()
click to toggle source
# File lib/git_bumper/cli.rb, line 44 def prompt_yes input = STDIN.gets.chomp.to_s input.empty? || input =~ /\Ay(es)?\z/i end