Rename stdout to stdout_data, stdin to stdin_data

This commit is contained in:
Marcin Kulik 2013-08-04 22:39:55 +02:00
parent 55fe325ec4
commit caa6c52759
11 changed files with 43 additions and 69 deletions

View File

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

View File

@ -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

View File

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

View File

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

View File

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

View File

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

View File

@ -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

View File

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

View File

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

BIN
spec/fixtures/stdout vendored

Binary file not shown.

BIN
spec/fixtures/stdout.time vendored Normal file

Binary file not shown.