panda.rb used to be actual config but now its the config class
This commit is contained in:
Родитель
fa7359114f
Коммит
9b9fe88107
|
@ -5,5 +5,4 @@ uuid.state
|
|||
database.yml
|
||||
schema.rb
|
||||
aws.rb
|
||||
panda.rb
|
||||
videos/*
|
1
README
1
README
|
@ -15,6 +15,7 @@ Installation and setup
|
|||
Gems
|
||||
----
|
||||
|
||||
Merb 0.9.2
|
||||
SQS (http://sqs.rubyforge.org/)
|
||||
S3 (http://amazon.rubyforge.org/)
|
||||
SimpleDB (http://nytimes.rubyforge.org/amazon_sdb/)
|
||||
|
|
13
README_EC2
13
README_EC2
|
@ -8,18 +8,14 @@ ec2-run-instances ami-5538dd3c -k pv-keypair
|
|||
DO THIS: Install stuff which will be in the next AMI
|
||||
-------------------------------------------
|
||||
|
||||
# libjpeg
|
||||
http://www.ijg.org/
|
||||
http://www.libgd.org/FAQ#gd_keeps_saying_it_can.27t_find_png_or_jpeg_support._I_did_install_libpng_and_libjpeg._What_am_I_missing.3F
|
||||
|
||||
# libgd
|
||||
http://www.libgd.org/Main_Page
|
||||
See README
|
||||
|
||||
Grab Panda
|
||||
----------
|
||||
|
||||
cd /usr/local/panda
|
||||
git clone git@github.com:newbamboo/panda.git
|
||||
mkdir /usr/local/panda/videos # Place for temp videos
|
||||
|
||||
Create buckets, domains and queues
|
||||
----------------------------------
|
||||
|
@ -55,3 +51,8 @@ Login to the console with `merb -i`:
|
|||
u.email = 'email@mydomain'
|
||||
u.set_password('SECRETPASS')
|
||||
u.save
|
||||
|
||||
Create an encoding profile
|
||||
--------------------------
|
||||
|
||||
Profile.create!(:title => "Flash video HI", :container => "flv", :video_bitrate => 400, :audio_bitrate => 48, :width => 480, :height => 360, :fps => 24, :position => 1, :player => "flash")
|
|
@ -1,20 +1,39 @@
|
|||
ACCESS_KEY_ID = ''
|
||||
SECRET_ACCESS_KEY = ''
|
||||
|
||||
# SQS
|
||||
|
||||
SQS.access_key_id = ACCESS_KEY_ID
|
||||
SQS.secret_access_key = SECRET_ACCESS_KEY
|
||||
SQS.retry_attempts = 10
|
||||
|
||||
class Queue
|
||||
@@enc = SQS.get_queue :name => 'panda_encoding'
|
||||
def self.enc
|
||||
@@enc
|
||||
end
|
||||
@@encodings = SQS.get_queue :name => 'panda_encoding'
|
||||
def self.encodings; @@encodings; end
|
||||
end
|
||||
|
||||
# SimpleDB
|
||||
# ========
|
||||
# http://nytimes.rubyforge.org/amazon_sdb/
|
||||
# SimpleDB::Base.connection.create_domain('panda_videos')
|
||||
|
||||
SimpleDB::Base.establish_connection!(
|
||||
:access_key_id => ACCESS_KEY_ID,
|
||||
:secret_access_key => SECRET_ACCESS_KEY
|
||||
)
|
||||
|
||||
# S3
|
||||
# ==
|
||||
# AWS::S3::Bucket.create("my_bucket")
|
||||
|
||||
AWS::S3::Base.establish_connection!(
|
||||
:access_key_id => ACCESS_KEY_ID,
|
||||
:secret_access_key => SECRET_ACCESS_KEY
|
||||
)
|
||||
|
||||
# Encoded videos
|
||||
class S3VideoObject < AWS::S3::S3Object
|
||||
set_current_bucket_to 'videos.pandastream.com' # allows nice urls like http://videos.pandastream.com/video.flv
|
||||
set_current_bucket_to 'videos.pandastream.com'
|
||||
end
|
||||
|
||||
# Video access logs
|
||||
|
|
|
@ -0,0 +1,76 @@
|
|||
module Panda
|
||||
|
||||
class Setup
|
||||
class << self
|
||||
def create_s3_bucket(name)
|
||||
AWS::S3::Bucket.create(name)
|
||||
end
|
||||
|
||||
def create_sqs_queue(name)
|
||||
SQS.create_queue(name)
|
||||
end
|
||||
|
||||
def create_sdb_domain(name)
|
||||
SimpleDB::Base.connection.create_domain(name)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Config
|
||||
|
||||
class << self
|
||||
|
||||
# ==== Returns
|
||||
# Hash:: The defaults for the config.
|
||||
def defaults
|
||||
@defaults ||= {
|
||||
:account_name => "My Panda Account",
|
||||
:api_key => nil,
|
||||
:upload_redirect_url => "http://127.0.0.1:3000/videos/$1/done",
|
||||
:state_update_url => "http://127.0.0.1:3000/videos/$1/status",
|
||||
:videos_domain => nil,
|
||||
:storage => :filesystem # or :s3 TODO: implement
|
||||
}
|
||||
end
|
||||
|
||||
# Yields the configuration.
|
||||
#
|
||||
# ==== Block parameters
|
||||
# c<Hash>:: The configuration parameters.
|
||||
#
|
||||
# ==== Examples
|
||||
# Merb::Config.use do |config|
|
||||
# config[:exception_details] = false
|
||||
# end
|
||||
def use
|
||||
@configuration ||= {}
|
||||
yield @configuration
|
||||
end
|
||||
|
||||
# ==== Parameters
|
||||
# key<Object>:: The key to check.
|
||||
#
|
||||
# ==== Returns
|
||||
# Boolean:: True if the key exists in the config.
|
||||
def key?(key)
|
||||
@configuration.key?(key)
|
||||
end
|
||||
|
||||
# ==== Parameters
|
||||
# key<Object>:: The key to retrieve the parameter for.
|
||||
#
|
||||
# ==== Returns
|
||||
# Object:: The value of the configuration parameter.
|
||||
def [](key)
|
||||
(@configuration||={})[key]
|
||||
end
|
||||
|
||||
# ==== Parameters
|
||||
# key<Object>:: The key to set the parameter for.
|
||||
# val<Object>:: The value of the parameter.
|
||||
def []=(key,val)
|
||||
@configuration[key] = val
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Загрузка…
Ссылка в новой задаче