Class: Bard::CLI::CI

Inherits:
Struct
  • Object
show all
Defined in:
lib/bard/ci.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#last_responseObject

Returns the value of attribute last_response.



27
28
29
# File 'lib/bard/ci.rb', line 27

def last_response
  @last_response
end

#project_nameObject

Returns the value of attribute project_name

Returns:

  • (Object)

    the current value of project_name



2
3
4
# File 'lib/bard/ci.rb', line 2

def project_name
  @project_name
end

#shaObject

Returns the value of attribute sha

Returns:

  • (Object)

    the current value of sha



2
3
4
# File 'lib/bard/ci.rb', line 2

def sha
  @sha
end

Instance Method Details

#consoleObject



22
23
24
25
# File 'lib/bard/ci.rb', line 22

def console
  raw = `curl -s #{ci_host}/lastBuild/console?token=botandrose`
  raw[%r{<pre.*?>(.+)</pre>}m, 1]
end

#exists?Boolean

Returns:

  • (Boolean)


18
19
20
# File 'lib/bard/ci.rb', line 18

def exists?
  `curl -s -I #{ci_host}/?token=botandrose` =~ /\b200 OK\b/
end

#runObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/bard/ci.rb', line 3

def run
  last_time_elapsed = get_last_time_elapsed
  start
  sleep(2) until started?

  start_time = Time.new.to_i
  while building?
    elapsed_time = Time.new.to_i - start_time
    yield elapsed_time, last_time_elapsed
    sleep(2)
  end

  success?
end