class CiHelper::MainProcess

Constants

USER_CONFIG

This class is responsible for asking the function user want to use TODO: maybe this class in the future we can extract to command line use Thor to implement it

Attributes

config[RW]
user_cli[RW]

Public Class Methods

new(target) click to toggle source
# File lib/ci_helper/main_process.rb, line 15
def initialize(target)
  @config   = YAML.load_file("#{target}/#{CiHelper::CONFIG_FILE_NAME}")
  @user_cli = UserCommandLineInterface.new
  fail CiHelper::ConfigError, 'Please install to set your account first ' unless config

  structlize_config
end

Public Instance Methods

ci_monitor?() click to toggle source
# File lib/ci_helper/main_process.rb, line 55
def ci_monitor?
  @option == '1'
end
create_pull_request?() click to toggle source
# File lib/ci_helper/main_process.rb, line 63
def create_pull_request?
  @option == '2'
end
run() click to toggle source
# File lib/ci_helper/main_process.rb, line 23
def run

  while true
    # begin
    @option = user_cli.get_user_choose

    if ci_monitor?
      CiHelper::Functions::Jenkin.new(config).run
    elsif update_issue?
      CiHelper::Functions::Redmine.new(config).run
    elsif create_pull_request?
      CiHelper::Functions::PullRequest.new(config).run
    else
      puts 'Please dont act like a monkey'
    end
    # rescue => e
    #   puts 'You may enter wrong ticket, branch name or face a internet problem'
    #   puts e.message
    #   puts "If you think is a bug please go to create a issue for me #{CiHelper::BUG_REPORT_URL}"
    # end
  end
end
structlize_config() click to toggle source
# File lib/ci_helper/main_process.rb, line 46
def structlize_config
  self.config = USER_CONFIG.new(config[:ci][:account],
                                config[:ci][:password],
                                config[:bitbucket][:account],
                                config[:bitbucket][:password],
                                config[:redmine][:account],
                                config[:redmine][:password])
end
update_issue?() click to toggle source
# File lib/ci_helper/main_process.rb, line 59
def update_issue?
  @option == '3'
end