Rename stdout to stdout_data, stdin to stdin_data

openid
Marcin Kulik 11 years ago
parent 55fe325ec4
commit caa6c52759

@ -1,14 +1,14 @@
class Asciicast < ActiveRecord::Base
MAX_DELAY = 5.0
mount_uploader :stdin, BasicUploader
mount_uploader :stdin_timing, BasicUploader
mount_uploader :stdout, BasicUploader
mount_uploader :stdout_timing, BasicUploader
mount_uploader :stdin_data, StdinDataUploader
mount_uploader :stdin_timing, StdinTimingUploader
mount_uploader :stdout_data, StdoutDataUploader
mount_uploader :stdout_timing, StdoutTimingUploader
serialize :snapshot, Snapshot
validates :stdout, :stdout_timing, :presence => true
validates :stdout_data, :stdout_timing, :presence => true
validates :terminal_columns, :terminal_lines, :duration, :presence => true
belongs_to :user

@ -1,49 +0,0 @@
# encoding: utf-8
class BasicUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
# include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader:
# storage :fog
# Override the directory where uploaded files will be stored.
# This is a sensible default for uploaders that are meant to be mounted:
def store_dir
prefix = Rails.env.test? ? '../tmp/' : ''
prefix + "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
end
# Provide a default URL as a default if there hasn't been a file uploaded:
# def default_url
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
# end
# Process files as they are uploaded:
# process :scale => [200, 300]
#
# def scale(width, height)
# # do something
# end
# Create different versions of your uploaded files:
# version :thumb do
# process :scale => [50, 50]
# end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
# def extension_white_list
# %w(jpg jpeg gif png)
# end
# Override the filename of the uploaded files:
# Avoid using model.id or version_name here,
# see uploader/store.rb for details.
# def filename
# "something.jpg" if original_filename
# end
end

@ -0,0 +1,7 @@
class StdinDataUploader < Bzip2Uploader
def store_dir
store_dir_prefix + "uploads/#{model.class.to_s.underscore}/stdin/#{model.id}"
end
end

@ -0,0 +1 @@
class StdinTimingUploader < Bzip2Uploader; end

@ -0,0 +1,7 @@
class StdoutDataUploader < Bzip2Uploader
def store_dir
store_dir_prefix + "uploads/#{model.class.to_s.underscore}/stdout/#{model.id}"
end
end

@ -0,0 +1 @@
class StdoutTimingUploader < Bzip2Uploader; end

@ -0,0 +1,11 @@
class RenameAsciicastsStdinAndStdout < ActiveRecord::Migration
def up
rename_column :asciicasts, :stdin, :stdin_data
rename_column :asciicasts, :stdout, :stdout_data
end
def down
rename_column :asciicasts, :stdin_data, :stdin
rename_column :asciicasts, :stdout_data, :stdout
end
end

@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord::Schema.define(:version => 20120724203244) do
ActiveRecord::Schema.define(:version => 20130725202344) do
create_table "asciicasts", :force => true do |t|
t.integer "user_id"
@ -26,9 +26,9 @@ ActiveRecord::Schema.define(:version => 20120724203244) do
t.string "uname"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.string "stdin"
t.string "stdin_data"
t.string "stdin_timing"
t.string "stdout"
t.string "stdout_data"
t.string "stdout_timing"
t.string "user_token"
t.text "description"

@ -5,19 +5,15 @@ FactoryGirl.define do
factory :asciicast do
association :user
title "bashing"
duration 100
duration 11.146430015563965
recorded_at "2011-11-23 22:06:07"
terminal_type "xterm"
terminal_columns 80
terminal_lines 25
shell "/bin/bash"
uname "uname"
terminal_type "screen-256color"
terminal_columns 96
terminal_lines 26
shell "/bin/zsh"
uname "Linux 3.9.9-302.fc19.x86_64 #1 SMP Sat Jul 6 13:41:07 UTC 2013 x86_64"
views_count 1
stdout do
fixture_file_upload("spec/fixtures/stdout", "application/octet-stream")
end
stdout_timing do
fixture_file_upload("spec/fixtures/stdout", "application/octet-stream")
end
stdout_data { fixture_file_upload("spec/fixtures/stdout", "application/octet-stream") }
stdout_timing { fixture_file_upload("spec/fixtures/stdout.time", "application/octet-stream") }
end
end

BIN
spec/fixtures/stdout vendored

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save