Class: CIJoe::Build
- Inherits:
-
Struct
- Object
- Struct
- CIJoe::Build
- Defined in:
- lib/cijoe/build.rb
Instance Attribute Summary collapse
-
#finished_at ⇒ Object
Returns the value of attribute finished_at.
-
#output ⇒ Object
Returns the value of attribute output.
-
#pid ⇒ Object
Returns the value of attribute pid.
-
#project ⇒ Object
Returns the value of attribute project.
-
#sha ⇒ Object
Returns the value of attribute sha.
-
#started_at ⇒ Object
Returns the value of attribute started_at.
-
#status ⇒ Object
Returns the value of attribute status.
-
#user ⇒ Object
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
- #clean_output ⇒ Object
- #commit ⇒ Object
- #dump(file) ⇒ Object
- #failed? ⇒ Boolean
-
#initialize(*args) ⇒ Build
constructor
A new instance of Build.
- #short_sha ⇒ Object
- #worked? ⇒ Boolean
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_at ⇒ Object
Returns the value of attribute finished_at
4 5 6 |
# File 'lib/cijoe/build.rb', line 4 def finished_at @finished_at end |
#output ⇒ Object
Returns the value of attribute output
4 5 6 |
# File 'lib/cijoe/build.rb', line 4 def output @output end |
#pid ⇒ Object
Returns the value of attribute pid
4 5 6 |
# File 'lib/cijoe/build.rb', line 4 def pid @pid end |
#project ⇒ Object
Returns the value of attribute project
4 5 6 |
# File 'lib/cijoe/build.rb', line 4 def project @project end |
#sha ⇒ Object
Returns the value of attribute sha
4 5 6 |
# File 'lib/cijoe/build.rb', line 4 def sha @sha end |
#started_at ⇒ Object
Returns the value of attribute started_at
4 5 6 |
# File 'lib/cijoe/build.rb', line 4 def started_at @started_at end |
#status ⇒ Object
Returns the value of attribute status
4 5 6 |
# File 'lib/cijoe/build.rb', line 4 def status @status end |
#user ⇒ Object
Returns the value of attribute 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 |
# File 'lib/cijoe/build.rb', line 46 def self.load(file) if File.exist?(file) config = YAML.load(File.read(file)) new *config end end |
Instance Method Details
#clean_output ⇒ Object
31 32 33 |
# File 'lib/cijoe/build.rb', line 31 def clean_output output.gsub(/\e\[.+?m/, '').strip end |
#commit ⇒ Object
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] data = YAML.dump(config) File.open(file, 'wb') { |io| io.write(data) } end |
#failed? ⇒ Boolean
15 16 17 |
# File 'lib/cijoe/build.rb', line 15 def failed? status == :failed end |
#short_sha ⇒ Object
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
19 20 21 |
# File 'lib/cijoe/build.rb', line 19 def worked? status == :worked end |