diff --git a/app/models/asciicast.rb b/app/models/asciicast.rb index f0d5b3c..9d8e2e1 100644 --- a/app/models/asciicast.rb +++ b/app/models/asciicast.rb @@ -6,4 +6,18 @@ class Asciicast < ActiveRecord::Base validates :stdout, :stdout_timing, :presence => true validates :terminal_columns, :terminal_lines, :duration, :presence => true + + def meta=(file) + data = JSON.parse(file.tempfile.read) + + self.duration = data['duration'] + self.recorded_at = data['recorded_at'] + self.title = data['title'] + self.command = data['command'] + self.shell = data['shell'] + self.uname = data['uname'] + self.terminal_lines = data['term']['lines'] + self.terminal_columns = data['term']['columns'] + self.terminal_type = data['term']['type'] + end end