Class: MainProcess

Inherits:
Object
  • Object
show all
Defined in:
lib/ci_helper/main_process.rb

Overview

TODO: need to refactor this class

Defined Under Namespace

Classes: USER_CONFIG

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(target) ⇒ MainProcess

Returns a new instance of MainProcess.



10
11
12
13
14
# File 'lib/ci_helper/main_process.rb', line 10

def initialize(target)
  @config = YAML.load_file("#{target}/#{CiHelper::CONFIG_FILE_NAME}")
  fail CiHelper::ConfigError, 'Please install to set your account first ' unless config
  structulize_config
end

Instance Attribute Details

#configObject

Returns the value of attribute config.



8
9
10
# File 'lib/ci_helper/main_process.rb', line 8

def config
  @config
end

Instance Method Details

#runObject



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/ci_helper/main_process.rb', line 16

def run
  puts CiHelper::HELLO_MSG
  while true
    @issue_is_queued_in_ci = false
    puts 'Please Input your next ticked number or commit hash to specifiy the multi test result in the CI'
    match_strategy = gets.chop
    issue_monitor  = IssueMonitor.new(config.ci_ac, config.ci_pass, match_strategy)

    unless issue_monitor.goto_monitor_page # no issue pull request found
      # ask user to wait this issue or not
      puts 'Your issue is queue or enter wrong issue number, do you want to wait the queue?'
      puts 'y\n'
      user_input = gets.chop
      next if user_input == 'n' || user_input == 'N'
    end

    while !issue_monitor.finish_test?
      puts 'Your Issue is running the test now, I will check for you every 60seconds'
      sleep(CiHelper::WAITING_TIME)
    end

    if issue_monitor.success?
      result = issue_monitor.content
      puts " Console link:  #{result.console_link}"
      bit_bucket_client = BitBucketProcedure.new(config.bit_ac, config.bit_pass)
      bit_bucket_client.create_pull_request(issue_monitor.content)
    else

      puts 'issue failed here is failures '
      issue_monitor.failures_each do |fail|
        puts fail
      end

      result = issue_monitor.content
      puts " Console link:  #{result.console_link}"

      puts "Are You still wanna crete a pull request ? \n Please make sure all the values are all unstable or you will be killed by Gadii >W<"
      puts 'y/n'
      user_input = gets.chop
      if user_input == 'y' || user_input == 'Y'
        bit_bucket_client = BitBucketProcedure.new(config.bit_ac, config.bit_pass)
        puts 'Please Provide the destination'
        destination = gets.chop
        puts 'Please Provide the more description you want add in the text box'
        user_description =gets.chop
        bit_bucket_client.add_destination(destination)
        bit_bucket_client.add_user_description(user_description)
        bit_bucket_client.create_pull_request(issue_monitor.content)
        sleep(0.5)
        bit_bucket_client.go_to_pull_request_page
        sleep(0.5)
        puts "this is your pull request page : #{CiHelper::BITBUCKET_DOMAIN}#{bit_bucket_client.pull_request_page.link_with(class: 'execute').href}"
      end
    end
  end
end