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

#faillogObject

Returns the value of attribute faillog

Returns:

  • (Object)

    the current value of faillog



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

def faillog
  @faillog
end

#failsObject

Returns the value of attribute fails

Returns:

  • (Object)

    the current value of fails



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

def fails
  @fails
end

#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

#passesObject

Returns the value of attribute passes

Returns:

  • (Object)

    the current value of passes



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

def passes
  @passes
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

#totalObject

Returns the value of attribute total

Returns:

  • (Object)

    the current value of total



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

def total
  @total
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



46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/cijoe/build.rb', line 46

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

    if config[8].to_s == "" or config[9].to_s == "" or config[10].to_s == ""
      config[8] = $1 if config[6] =~ /Total: ([0-9]+)/
      config[9] = $1 if config[6] =~ /Passed: ([0-9]+)/
      config[10] = $1 if config[6] =~ /Failed: ([0-9]+)/
    end
    
    new *config
  end
end

Instance Method Details

#clean_outputObject



31
32
33
# File 'lib/cijoe/build.rb', line 31

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

#commitObject



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

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

#dump(file) ⇒ Object



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

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

#failed?Boolean

Returns:

  • (Boolean)


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

def failed?
  status == :failed
end

#short_shaObject



23
24
25
26
27
28
29
# File 'lib/cijoe/build.rb', line 23

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