Class: IssueMonitor

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

Defined Under Namespace

Classes: Result

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(account, password, match_strategy) ⇒ IssueMonitor

Returns a new instance of IssueMonitor.



10
11
12
# File 'lib/ci_helper/issue_monitor.rb', line 10

def initialize(, password, match_strategy)
  @ci_procedure = CiProcedure.new(, password, match_strategy)
end

Instance Attribute Details

#ci_procedureObject (readonly)

Returns the value of attribute ci_procedure.



4
5
6
# File 'lib/ci_helper/issue_monitor.rb', line 4

def ci_procedure
  @ci_procedure
end

#fail_examplesObject (readonly)

Returns the value of attribute fail_examples.



4
5
6
# File 'lib/ci_helper/issue_monitor.rb', line 4

def fail_examples
  @fail_examples
end

#issue_statusObject

Returns the value of attribute issue_status.



3
4
5
# File 'lib/ci_helper/issue_monitor.rb', line 3

def issue_status
  @issue_status
end

#resultObject (readonly)

Returns the value of attribute result.



4
5
6
# File 'lib/ci_helper/issue_monitor.rb', line 4

def result
  @result
end

#statusObject (readonly)

Returns the value of attribute status.



4
5
6
# File 'lib/ci_helper/issue_monitor.rb', line 4

def status
  @status
end

Instance Method Details

#contentObject



46
47
48
49
50
51
52
# File 'lib/ci_helper/issue_monitor.rb', line 46

def content
  Result.new(success?, fail_examples,
             "#{ci_procedure.console_page.uri.host}/#{ci_procedure.console_page.uri.request_uri}",
             ci_procedure.issue_number,
             ci_procedure.branch_name,
             ci_procedure.commit_hash)
end

#failures_eachObject



42
43
44
# File 'lib/ci_helper/issue_monitor.rb', line 42

def failures_each
  fail_examples.each { |failed_example| yield(failed_example) }
end

#finish_test?Boolean

Returns:

  • (Boolean)


32
33
34
35
36
37
38
39
40
# File 'lib/ci_helper/issue_monitor.rb', line 32

def finish_test?
  begin
    output = ci_procedure.re_get_console_output
    output.empty? ? false : true
  rescue CiHelper::Exceptions::IssueNotFound => e
    puts "#{e.message} #{ci_procedure.matching_strategy}"
    false
  end
end

#goto_monitor_pageObject



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ci_helper/issue_monitor.rb', line 14

def goto_monitor_page
  begin
    ci_procedure.run
    if finish_test?
      parse_output(ci_procedure.get_console_output)
    end
    true
  rescue CiHelper::Exceptions::IssueNotFound => e
    puts "#{e.message} #{ci_procedure.matching_strategy}"
    false
  end
end

#success?Boolean

Returns:

  • (Boolean)


27
28
29
30
# File 'lib/ci_helper/issue_monitor.rb', line 27

def success?
  parse_output(ci_procedure.get_console_output)
  finish_test? ? status[0].match('success') : false
end