Class: BuildTool::History::ModuleLog

Inherits:
Object
  • Object
show all
Includes:
StateHelper
Defined in:
lib/build-tool/history.rb

Overview

Represents a module event.

A module event is updating, compiling etc. a module.

Constant Summary

Constants included from StateHelper

StateHelper::CANCELED_BY_USER, StateHelper::FINISHED_SUCCESSFUL, StateHelper::FINISHED_WITH_ERRORS, StateHelper::STARTED

Instance Method Summary collapse

Methods included from StateHelper

included, #state_str

Instance Method Details

#before_updateObject

Sequel Hook

Make sure a finished command has one of the accepted finished states.



166
167
168
169
170
171
# File 'lib/build-tool/history.rb', line 166

def before_update
    super
    if !self.finished_at.nil?
        raise StandardError, "Wrong state for finished Command" if ! [ FINISHED_SUCCESSFUL, FINISHED_WITH_ERRORS, CANCELED_BY_USER ].include? self.state
    end
end

#durationObject



139
140
141
142
143
144
145
146
# File 'lib/build-tool/history.rb', line 139

def duration
    if self.finished_at
        dur = self.finished_at - self.started_at
        "%02d:%02d" % [ dur.to_i / 60, (dur% 60 ).to_i ]
    else
        "-----"
    end
end

#finished(state) ⇒ Object

Call this if the command is finished. [:finished] will be set to Time.now,

:state

to the given value and the object is saved.



150
151
152
153
154
# File 'lib/build-tool/history.rb', line 150

def finished( state )
    self.finished_at = Time.now
    self.state = state
    save
end

#startedObject

Call this when the command is started. [:started] will be set to Time.now and the object is saved.



158
159
160
161
# File 'lib/build-tool/history.rb', line 158

def started
    self.started_at = Time.now
    save
end