Class: CIJoe::Build

Inherits:
Struct
  • Object
show all
Defined in:
lib/cijoe/build.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ Build

Returns a new instance of Build.



5
6
7
8
# File 'lib/cijoe/build.rb', line 5

def initialize(*args)
  super
  self.started_at ||= Time.now
end

Instance Attribute Details

#finished_atObject

Returns the value of attribute finished_at

Returns:

  • (Object)

    the current value of finished_at



4
5
6
# File 'lib/cijoe/build.rb', line 4

def finished_at
  @finished_at
end

#outputObject

Returns the value of attribute output

Returns:

  • (Object)

    the current value of output



4
5
6
# File 'lib/cijoe/build.rb', line 4

def output
  @output
end

#pidObject

Returns the value of attribute pid

Returns:

  • (Object)

    the current value of pid



4
5
6
# File 'lib/cijoe/build.rb', line 4

def pid
  @pid
end

#projectObject

Returns the value of attribute project

Returns:

  • (Object)

    the current value of project



4
5
6
# File 'lib/cijoe/build.rb', line 4

def project
  @project
end

#shaObject

Returns the value of attribute sha

Returns:

  • (Object)

    the current value of sha



4
5
6
# File 'lib/cijoe/build.rb', line 4

def sha
  @sha
end

#started_atObject

Returns the value of attribute started_at

Returns:

  • (Object)

    the current value of started_at



4
5
6
# File 'lib/cijoe/build.rb', line 4

def started_at
  @started_at
end

#statusObject

Returns the value of attribute status

Returns:

  • (Object)

    the current value of status



4
5
6
# File 'lib/cijoe/build.rb', line 4

def status
  @status
end

#userObject

Returns the value of attribute user

Returns:

  • (Object)

    the current value of user



4
5
6
# File 'lib/cijoe/build.rb', line 4

def user
  @user
end

Class Method Details

.load(file) ⇒ Object



83
84
85
86
87
88
# File 'lib/cijoe/build.rb', line 83

def self.load(file)
  if File.exist?(file)
    config = YAML.load(File.read(file))
    new *config
  end
end

Instance Method Details

#building?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/cijoe/build.rb', line 23

def building?
  status == :building
end

#clean_outputObject



68
69
70
# File 'lib/cijoe/build.rb', line 68

def clean_output
  output.gsub(/\e\[.+?m/, '').strip
end

#commitObject



72
73
74
75
# File 'lib/cijoe/build.rb', line 72

def commit
  return if sha.nil?
  @commit ||= Commit.new(sha, user, project)
end

#coverage_dirObject



48
49
50
# File 'lib/cijoe/build.rb', line 48

def coverage_dir
  "#{Config.cijoe.coveragedir}/#{project}/#{full_id}"
end

#coverage_urlObject



60
61
62
# File 'lib/cijoe/build.rb', line 60

def coverage_url
  "/coverage/#{project}/#{full_id}/index.html"
end

#dump(file) ⇒ Object



77
78
79
80
81
# File 'lib/cijoe/build.rb', line 77

def dump(file)
  config = [user, project, started_at, finished_at, sha, status, output, pid]
  data = YAML.dump(config)
  File.open(file, 'wb') { |io| io.write(data) }
end

#durationObject



27
28
29
30
# File 'lib/cijoe/build.rb', line 27

def duration
  return if building?
  finished_at - started_at
end

#failed?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/cijoe/build.rb', line 15

def failed?
  status == :failed
end

#full_idObject



40
41
42
# File 'lib/cijoe/build.rb', line 40

def full_id
  "#{short_sha}.#{finished_at.to_i.to_s}"
end

#metrics_dirObject



44
45
46
# File 'lib/cijoe/build.rb', line 44

def metrics_dir
  "#{Config.cijoe.metricsdir}/#{project}/#{full_id}"
end

#metrics_urlObject



56
57
58
# File 'lib/cijoe/build.rb', line 56

def metrics_url
  "/metrics/#{project}/#{full_id}/index.html"
end

#screenshots_dirObject



52
53
54
# File 'lib/cijoe/build.rb', line 52

def screenshots_dir
  "#{Config.cijoe.screenshotsdir}/#{project}/#{full_id}"
end

#screenshots_urlObject



64
65
66
# File 'lib/cijoe/build.rb', line 64

def screenshots_url
  "/screenshots/#{project}/#{full_id}/"
end

#short_shaObject



32
33
34
35
36
37
38
# File 'lib/cijoe/build.rb', line 32

def short_sha
  if sha
    sha[0,7]
  else
    "<unknown>"
  end
end

#worked?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/cijoe/build.rb', line 19

def worked?
  status == :worked
end