twinge-panda 0.0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +4 -0
- data/License.txt +20 -0
- data/Manifest.txt +22 -0
- data/README.txt +48 -0
- data/Rakefile +4 -0
- data/config/hoe.rb +70 -0
- data/config/requirements.rb +17 -0
- data/lib/panda/version.rb +9 -0
- data/lib/panda/video.rb +144 -0
- data/lib/panda.rb +3 -0
- data/log/debug.log +0 -0
- data/setup.rb +1585 -0
- data/tasks/deployment.rake +34 -0
- data/tasks/environment.rake +7 -0
- data/tasks/website.rake +17 -0
- data/test/test_helper.rb +2 -0
- data/test/test_panda.rb +11 -0
- data/website/index.html +93 -0
- data/website/index.txt +39 -0
- data/website/javascripts/rounded_corners_lite.inc.js +285 -0
- data/website/stylesheets/screen.css +138 -0
- data/website/template.rhtml +48 -0
- metadata +90 -0
data/History.txt
ADDED
data/License.txt
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright (c) 2008 FIXME full name
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Manifest.txt
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
config/hoe.rb
|
|
2
|
+
config/requirements.rb
|
|
3
|
+
History.txt
|
|
4
|
+
lib/panda/version.rb
|
|
5
|
+
lib/panda/video.rb
|
|
6
|
+
lib/panda.rb
|
|
7
|
+
License.txt
|
|
8
|
+
log/debug.log
|
|
9
|
+
Manifest.txt
|
|
10
|
+
Rakefile
|
|
11
|
+
README.txt
|
|
12
|
+
setup.rb
|
|
13
|
+
tasks/deployment.rake
|
|
14
|
+
tasks/environment.rake
|
|
15
|
+
tasks/website.rake
|
|
16
|
+
test/test_helper.rb
|
|
17
|
+
test/test_panda.rb
|
|
18
|
+
website/index.html
|
|
19
|
+
website/index.txt
|
|
20
|
+
website/javascripts/rounded_corners_lite.inc.js
|
|
21
|
+
website/stylesheets/screen.css
|
|
22
|
+
website/template.rhtml
|
data/README.txt
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
= Panda Gem
|
|
2
|
+
|
|
3
|
+
* http://pandastream.com
|
|
4
|
+
|
|
5
|
+
== DESCRIPTION:
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
== FEATURES/PROBLEMS:
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
== SYNOPSIS:
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
== REQUIREMENTS:
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
== INSTALL:
|
|
21
|
+
|
|
22
|
+
gem sources -a http://gems.github.com (you only have to do this once)
|
|
23
|
+
sudo gem install dctanner-panda_gem
|
|
24
|
+
|
|
25
|
+
== LICENSE:
|
|
26
|
+
|
|
27
|
+
(The MIT License)
|
|
28
|
+
|
|
29
|
+
Copyright (c) 2009 FIX
|
|
30
|
+
|
|
31
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
32
|
+
a copy of this software and associated documentation files (the
|
|
33
|
+
'Software'), to deal in the Software without restriction, including
|
|
34
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
35
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
36
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
37
|
+
the following conditions:
|
|
38
|
+
|
|
39
|
+
The above copyright notice and this permission notice shall be
|
|
40
|
+
included in all copies or substantial portions of the Software.
|
|
41
|
+
|
|
42
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
43
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
44
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
45
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
46
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
47
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
48
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
data/config/hoe.rb
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
require 'panda/version'
|
|
2
|
+
|
|
3
|
+
AUTHOR = 'Damien Tanner' # can also be an array of Authors
|
|
4
|
+
EMAIL = "damien@new-bamboo.co.uk"
|
|
5
|
+
DESCRIPTION = "Ruby library for Panda (pandastream.com), a video uploading, encoding and streaming service."
|
|
6
|
+
GEM_NAME = 'panda' # what ppl will type to install your gem
|
|
7
|
+
RUBYFORGE_PROJECT = 'panda' # The unix name for your project
|
|
8
|
+
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
|
9
|
+
DOWNLOAD_PATH = "http://rubyforge.org/projects/#{RUBYFORGE_PROJECT}"
|
|
10
|
+
|
|
11
|
+
@config_file = "~/.rubyforge/user-config.yml"
|
|
12
|
+
@config = nil
|
|
13
|
+
RUBYFORGE_USERNAME = "unknown"
|
|
14
|
+
def rubyforge_username
|
|
15
|
+
unless @config
|
|
16
|
+
begin
|
|
17
|
+
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
|
18
|
+
rescue
|
|
19
|
+
puts <<-EOS
|
|
20
|
+
ERROR: No rubyforge config file found: #{@config_file}
|
|
21
|
+
Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
|
22
|
+
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
|
23
|
+
EOS
|
|
24
|
+
exit
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
RUBYFORGE_USERNAME.replace @config["username"]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
REV = nil
|
|
32
|
+
# UNCOMMENT IF REQUIRED:
|
|
33
|
+
# REV = `svn info`.each {|line| if line =~ /^Revision:/ then k,v = line.split(': '); break v.chomp; else next; end} rescue nil
|
|
34
|
+
VERS = Panda::VERSION::STRING + (REV ? ".#{REV}" : "")
|
|
35
|
+
RDOC_OPTS = ['--quiet', '--title', 'panda documentation',
|
|
36
|
+
"--opname", "index.html",
|
|
37
|
+
"--line-numbers",
|
|
38
|
+
"--main", "README",
|
|
39
|
+
"--inline-source"]
|
|
40
|
+
|
|
41
|
+
class Hoe
|
|
42
|
+
def extra_deps
|
|
43
|
+
@extra_deps.reject! { |x| Array(x).first == 'hoe' }
|
|
44
|
+
@extra_deps
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Generate all the Rake tasks
|
|
49
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
|
50
|
+
hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
|
51
|
+
p.developer(AUTHOR, EMAIL)
|
|
52
|
+
p.description = DESCRIPTION
|
|
53
|
+
p.summary = DESCRIPTION
|
|
54
|
+
p.url = HOMEPATH
|
|
55
|
+
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
|
56
|
+
p.test_globs = ["test/**/test_*.rb"]
|
|
57
|
+
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store'] #An array of file patterns to delete on clean.
|
|
58
|
+
|
|
59
|
+
# == Optional
|
|
60
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
|
61
|
+
#p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
|
|
62
|
+
|
|
63
|
+
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
|
64
|
+
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
CHANGES = hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
|
68
|
+
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
|
69
|
+
hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
|
|
70
|
+
hoe.rsync_args = '-av --delete --ignore-errors'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
require 'fileutils'
|
|
2
|
+
include FileUtils
|
|
3
|
+
|
|
4
|
+
require 'rubygems'
|
|
5
|
+
%w[rake hoe newgem rubigen].each do |req_gem|
|
|
6
|
+
begin
|
|
7
|
+
require req_gem
|
|
8
|
+
rescue LoadError
|
|
9
|
+
puts "This Rakefile requires the '#{req_gem}' RubyGem."
|
|
10
|
+
puts "Installation: gem install #{req_gem} -y"
|
|
11
|
+
exit
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
|
|
16
|
+
|
|
17
|
+
require 'panda'
|
data/lib/panda/video.rb
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
require 'net/http'
|
|
2
|
+
require 'uri'
|
|
3
|
+
require 'yaml'
|
|
4
|
+
|
|
5
|
+
module Panda
|
|
6
|
+
class << self
|
|
7
|
+
attr_accessor :account_key, :api_domain, :api_port, :default_encoding_profile
|
|
8
|
+
|
|
9
|
+
def api_port
|
|
10
|
+
@api_port ||= 80
|
|
11
|
+
@api_port
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class Video
|
|
16
|
+
attr_accessor :vals
|
|
17
|
+
|
|
18
|
+
# Deprecated. Use encoding_for_profile instead and check for status == 'success' manually.
|
|
19
|
+
def find_encoding(profile_title)
|
|
20
|
+
self.encodings.find { |e|
|
|
21
|
+
e.profile_title == profile_title and e.status == 'success'
|
|
22
|
+
}
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def encoding_for_profile(profile_title)
|
|
26
|
+
self.encodings.find { |e|
|
|
27
|
+
e.profile_title == profile_title
|
|
28
|
+
}
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def self.new_with_attrs(vals)
|
|
32
|
+
video = new
|
|
33
|
+
video.vals = {}
|
|
34
|
+
vals.each do |k,v|
|
|
35
|
+
video.vals[k] = v
|
|
36
|
+
class_eval "def video.#{k}; @vals[:#{k}]; end"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
# If this is a parent video, turn the encodings into Panda::Video objects
|
|
40
|
+
if vals[:status] == "original"
|
|
41
|
+
vals[:encodings].map! do |e|
|
|
42
|
+
self.new_with_attrs(e[:video])
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
return video
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def self.find(token)
|
|
50
|
+
response = request(:get, "/videos/#{token}")
|
|
51
|
+
p = self.new_with_attrs(response[:video])
|
|
52
|
+
return p
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def self.create
|
|
56
|
+
response = request(:post, "/videos")
|
|
57
|
+
p = self.new_with_attrs(response[:video])
|
|
58
|
+
return p
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def self.file_uploaded(token, filename, original_filename)
|
|
62
|
+
response = request(:get, "/videos/#{token}/file_uploaded", {'filename' => filename, 'original_filename' => original_filename})
|
|
63
|
+
p = self.new_with_attrs(response[:video])
|
|
64
|
+
return p
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
def self.delete(token)
|
|
68
|
+
response = request(:post, "/videos/#{token}",{'_method' => 'delete'})
|
|
69
|
+
return response[:videos].map {|v| self.new_with_attrs(v[:video]) }
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
def self.videos
|
|
73
|
+
response = request(:get, "/videos")
|
|
74
|
+
return response[:videos].map {|v| self.new_with_attrs(v[:video]) }
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Makes request to remote service.
|
|
78
|
+
def self.request(method, path, params={})
|
|
79
|
+
raise Panda::AccountKeyNotSet if Panda.account_key.nil?
|
|
80
|
+
params[:account_key] = Panda.account_key
|
|
81
|
+
path += ".yaml"
|
|
82
|
+
http = Net::HTTP.new(Panda.api_domain, Panda.api_port)
|
|
83
|
+
|
|
84
|
+
case method
|
|
85
|
+
when :get
|
|
86
|
+
response = http.request_get("#{path}?" + params.each {|k,v| "#{k}=#{v}"}.join('&'))
|
|
87
|
+
when :post
|
|
88
|
+
req = Net::HTTP::Post.new(path)
|
|
89
|
+
req.form_data = params
|
|
90
|
+
response = http.request(req)
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
puts "--> #{response.code} #{response.message} (#{response.body.length})"
|
|
94
|
+
puts response.body
|
|
95
|
+
handle_response(response)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Handles response and error codes from remote service.
|
|
99
|
+
|
|
100
|
+
def self.handle_response(response)
|
|
101
|
+
case response.code.to_i
|
|
102
|
+
when 200...400
|
|
103
|
+
YAML.load(response.body)
|
|
104
|
+
when 401
|
|
105
|
+
raise(Panda::UnauthorizedAccess.new(response))
|
|
106
|
+
when 404
|
|
107
|
+
raise(Panda::VideoNotFound.new(response))
|
|
108
|
+
when 500...600
|
|
109
|
+
raise(Panda::ServerError.new(response))
|
|
110
|
+
else
|
|
111
|
+
raise(Panda::PandaError.new(response, "Unknown response code: #{response.code}"))
|
|
112
|
+
end
|
|
113
|
+
end
|
|
114
|
+
end
|
|
115
|
+
|
|
116
|
+
class PandaError < StandardError; end
|
|
117
|
+
|
|
118
|
+
class ConnectionError < PandaError # :nodoc:
|
|
119
|
+
attr_reader :response
|
|
120
|
+
|
|
121
|
+
def initialize(response, message = nil)
|
|
122
|
+
@response = response
|
|
123
|
+
@message = message
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def to_s
|
|
127
|
+
"Failed with #{response.code} #{response.message if response.respond_to?(:message)}"
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
class AccountKeyNotSet < PandaError; end
|
|
132
|
+
|
|
133
|
+
# 4xx Client Error
|
|
134
|
+
class ClientError < ConnectionError; end # :nodoc:
|
|
135
|
+
|
|
136
|
+
# 401 Unauthorized
|
|
137
|
+
class UnauthorizedAccess < ClientError; end # :nodoc
|
|
138
|
+
|
|
139
|
+
# 404 Not Found
|
|
140
|
+
class VideoNotFound < ClientError; end # :nodoc:
|
|
141
|
+
|
|
142
|
+
# 5xx Server Error
|
|
143
|
+
class ServerError < ConnectionError; end # :nodoc:
|
|
144
|
+
end
|
data/lib/panda.rb
ADDED
data/log/debug.log
ADDED
|
File without changes
|