class UserCommsHelper

Constants

ASK_USER_INCREMENT_TYPE
ERROR_COMMIT_HAS_DEV_TAG
ERROR_INCORRECT_ENVIRON
ERROR_INITIALISE_WITH_STRING_IO
ERROR_NEXT_TAG_NOT_ASSIGNED
ERROR_SELECT_ACCEPTED_INCREMENT_TYPE
ERROR_SELECT_Y_OR_N
TELL_USER_NO_DEVELOP_TAGS

Public Class Methods

new(stdout, stdin) click to toggle source
# File lib/build_promotion_tool/helper/user_comms_helper.rb, line 15
def initialize(stdout, stdin)
  @stdout = stdout if stdout.respond_to?(:puts)
  @stdin = stdin if stdin.respond_to?(:gets)
  raise ERROR_INITIALISE_WITH_STRING_IO if @stdout.nil? || @stdin.nil?
end

Public Instance Methods

ask_increment_type() click to toggle source
# File lib/build_promotion_tool/helper/user_comms_helper.rb, line 25
def ask_increment_type
  @stdout.puts ASK_USER_INCREMENT_TYPE
end
ask_permissison_to_apply(next_tag) click to toggle source
# File lib/build_promotion_tool/helper/user_comms_helper.rb, line 38
def ask_permissison_to_apply(next_tag)
  raise ERROR_NEXT_TAG_NOT_ASSIGNED if next_tag.nil?
  @stdout.puts "Do you want to apply tag: #{next_tag}? - y/n"
end
error_commit_has_dev_tag() click to toggle source
# File lib/build_promotion_tool/helper/user_comms_helper.rb, line 64
def error_commit_has_dev_tag
  @stdout.puts ERROR_COMMIT_HAS_DEV_TAG
end
error_incorrect_environ() click to toggle source
# File lib/build_promotion_tool/helper/user_comms_helper.rb, line 60
def error_incorrect_environ
  @stdout.puts ERROR_INCORRECT_ENVIRON
end
say_no_tag_applied() click to toggle source
# File lib/build_promotion_tool/helper/user_comms_helper.rb, line 56
def say_no_tag_applied
  @stdout.puts "No tag applied"
end
say_thank_you() click to toggle source
# File lib/build_promotion_tool/helper/user_comms_helper.rb, line 52
def say_thank_you
  @stdout.puts "Thank you!"
end
tell_user_already_a_tag(tag_type) click to toggle source
# File lib/build_promotion_tool/helper/user_comms_helper.rb, line 72
def tell_user_already_a_tag(tag_type)
  @stdout.puts "Error: There is already a #{tag_type} tag on this commit"
end
tell_user_no_develop_tags() click to toggle source
# File lib/build_promotion_tool/helper/user_comms_helper.rb, line 21
def tell_user_no_develop_tags
  @stdout.puts TELL_USER_NO_DEVELOP_TAGS
end
tell_user_no_tag(tag_type) click to toggle source
# File lib/build_promotion_tool/helper/user_comms_helper.rb, line 68
def tell_user_no_tag(tag_type)
  @stdout.puts "Error: there are no previous #{tag_type} tags on this commit"
end
user_increment_choice() click to toggle source
# File lib/build_promotion_tool/helper/user_comms_helper.rb, line 29
def user_increment_choice
  increment_choice = @stdin.gets.chomp().downcase
  if ['major', 'minor', 'patch', 'p', 'mi','ma'].include? increment_choice
    return increment_choice
  else
    @stdout.puts ERROR_SELECT_ACCEPTED_INCREMENT_TYPE
  end
end
user_reply_y_or_n() click to toggle source
# File lib/build_promotion_tool/helper/user_comms_helper.rb, line 43
def user_reply_y_or_n
  user_choice = @stdin.gets.chomp().downcase
  if user_choice == "y" || user_choice == "n"
    return user_choice
  else
    @stdout.puts ERROR_SELECT_Y_OR_N
  end
end