2013-09-10 19:29:17 +00:00
|
|
|
class AsciicastSnapshotUpdater
|
|
|
|
|
2014-11-27 11:48:41 +00:00
|
|
|
def update(asciicast, at_seconds = nil)
|
|
|
|
at_seconds ||= asciicast.snapshot_at || asciicast.duration / 2
|
2013-09-10 19:29:17 +00:00
|
|
|
snapshot = generate_snapshot(asciicast, at_seconds)
|
|
|
|
asciicast.update_attribute(:snapshot, snapshot)
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def generate_snapshot(asciicast, at_seconds)
|
|
|
|
asciicast.with_terminal do |terminal|
|
|
|
|
Film.new(asciicast.stdout, terminal).snapshot_at(at_seconds)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|