framey 1.0.0
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/.gemtest +0 -0
- data/Manifest.txt +7 -0
- data/README.txt +53 -0
- data/Rakefile +15 -0
- data/lib/framey/api.rb +93 -0
- data/lib/framey/configuration.rb +43 -0
- data/lib/framey/view_helpers.rb +80 -0
- data/lib/framey.rb +9 -0
- data/test/test_framey.rb +8 -0
- metadata +90 -0
data/.gemtest
ADDED
File without changes
|
data/Manifest.txt
ADDED
data/README.txt
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
= framey
|
2
|
+
|
3
|
+
* http://framey.com
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
This ruby gem can be used for easy Rails integration with the Framey video recording service.
|
8
|
+
|
9
|
+
== FEATURES/PROBLEMS:
|
10
|
+
|
11
|
+
* Easily embed the framey recorders and players and make API calls to the framey web service.
|
12
|
+
|
13
|
+
== SYNOPSIS:
|
14
|
+
|
15
|
+
Framey::API.get_video([your video name])
|
16
|
+
Framey::API.delete_video([your video name])
|
17
|
+
<%= render_recorder %>
|
18
|
+
<%= render_player(:video_url => [your framey video url]) %>
|
19
|
+
|
20
|
+
== REQUIREMENTS:
|
21
|
+
|
22
|
+
* httparty
|
23
|
+
|
24
|
+
== INSTALL:
|
25
|
+
|
26
|
+
* sudo gem install framey
|
27
|
+
|
28
|
+
== DEVELOPERS:
|
29
|
+
|
30
|
+
== LICENSE:
|
31
|
+
|
32
|
+
(The MIT License)
|
33
|
+
|
34
|
+
Copyright (c) 2011 FIX
|
35
|
+
|
36
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
37
|
+
a copy of this software and associated documentation files (the
|
38
|
+
'Software'), to deal in the Software without restriction, including
|
39
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
40
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
41
|
+
permit persons to whom the Software is furnished to do so, subject to
|
42
|
+
the following conditions:
|
43
|
+
|
44
|
+
The above copyright notice and this permission notice shall be
|
45
|
+
included in all copies or substantial portions of the Software.
|
46
|
+
|
47
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
48
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
49
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
50
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
51
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
52
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
53
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'hoe'
|
3
|
+
$:.unshift(File.dirname(__FILE__) + "/lib")
|
4
|
+
require 'framey'
|
5
|
+
|
6
|
+
Hoe.new('framey', "1.0.0") do |p|
|
7
|
+
p.name = "framey"
|
8
|
+
p.author = "Shaun Salzberg"
|
9
|
+
p.description = "A gem for easy Rails integration with the Framey video recording service."
|
10
|
+
p.email = 'shaun@qlabs.com'
|
11
|
+
p.summary = "A gem for easy Rails integration with the Framey video recording service."
|
12
|
+
p.url = "http://framey.com"
|
13
|
+
p.changes = p.paragraphs_of('CHANGELOG', 0..1).join("\n\n")
|
14
|
+
p.remote_rdoc_dir = '' # Release to root
|
15
|
+
end
|
data/lib/framey/api.rb
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
require 'digest/md5'
|
2
|
+
require 'httparty'
|
3
|
+
|
4
|
+
module Framey
|
5
|
+
module Api
|
6
|
+
def self.get_video(video_name)
|
7
|
+
res = self.make_request("get","/api/videos/#{video_name}")
|
8
|
+
return Video.new(res["video"])
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.delete_video(video_name)
|
12
|
+
res = self.make_request("delete","/api/videos/#{video_name}")
|
13
|
+
return true
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.make_request(method,url,params={})
|
17
|
+
timestamp, signature = self.sign
|
18
|
+
|
19
|
+
params = params.merge({:time_stamp => timestamp, :signature => signature, :api_key => Framey.api_key})
|
20
|
+
res = begin
|
21
|
+
HTTParty.send(method,Framey.api_host + url,{:query => params})
|
22
|
+
rescue SocketError => e
|
23
|
+
nil
|
24
|
+
end
|
25
|
+
|
26
|
+
parsed_res = res ? res.parsed_response : nil
|
27
|
+
|
28
|
+
if !res || parsed_res["success"] == false
|
29
|
+
err = nil
|
30
|
+
msg = parsed_res ? parsed_res["message"] : "There was a problem connecting to framey. Please try again."
|
31
|
+
|
32
|
+
case res.code
|
33
|
+
when 400
|
34
|
+
err = BadRequest.new(msg,res.headers)
|
35
|
+
when 403
|
36
|
+
err = Forbidden.new(msg,res.headers)
|
37
|
+
when 404
|
38
|
+
err = NotFound.new(msg,res.headers)
|
39
|
+
when 500
|
40
|
+
err = InternalServerError.new(msg,res.headers)
|
41
|
+
else
|
42
|
+
err = SocketError.new(msg)
|
43
|
+
end
|
44
|
+
|
45
|
+
raise err
|
46
|
+
end
|
47
|
+
|
48
|
+
parsed_res
|
49
|
+
end
|
50
|
+
|
51
|
+
def self.sign
|
52
|
+
timestamp = Time.now.utc + Framey.api_timeout * 60
|
53
|
+
signature = Digest::MD5.hexdigest(Framey.api_secret + "&" + timestamp.strftime("%m%d%Y%H%M%S"))
|
54
|
+
return timestamp.to_s, signature
|
55
|
+
end
|
56
|
+
|
57
|
+
class Error < StandardError
|
58
|
+
attr_reader :http_headers
|
59
|
+
|
60
|
+
def initialize(message, http_headers={})
|
61
|
+
@http_headers = Hash[http_headers]
|
62
|
+
super message
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
# 400
|
67
|
+
class BadRequest < Error; end
|
68
|
+
|
69
|
+
# 403
|
70
|
+
class Forbidden < Error; end
|
71
|
+
|
72
|
+
# 404
|
73
|
+
class NotFound < Error; end
|
74
|
+
|
75
|
+
# 500
|
76
|
+
class InternalServerError < Error; end
|
77
|
+
end
|
78
|
+
|
79
|
+
class Video
|
80
|
+
attr_accessor :name, :url, :filesize, :duration, :state, :views, :data, :url, :thumbnail
|
81
|
+
|
82
|
+
def initialize(attrs={})
|
83
|
+
attrs.each do |k,v|
|
84
|
+
self.send("#{k.to_s}=",v)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def delete!
|
89
|
+
Framey::Api::delete_video(self.name)
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Framey
|
2
|
+
|
3
|
+
module Configuration
|
4
|
+
VERSION = '1.0.0'.freeze unless defined?(VERSION)
|
5
|
+
|
6
|
+
DEFAULT_API_HOST = "http://framey.com".freeze
|
7
|
+
DEFAULT_USER_AGENT = "Framey Ruby Gem #{VERSION}".freeze
|
8
|
+
DEFAULT_RUN_ENV = "production"
|
9
|
+
|
10
|
+
CONFIGURATION_OPTIONS = {
|
11
|
+
:api_key => nil,
|
12
|
+
:api_secret => nil,
|
13
|
+
:api_timeout => 15, # minutes
|
14
|
+
:max_recording_time => 30, # seconds
|
15
|
+
:api_host => DEFAULT_API_HOST,
|
16
|
+
:run_env => DEFAULT_RUN_ENV,
|
17
|
+
:user_agent => DEFAULT_USER_AGENT
|
18
|
+
}.freeze
|
19
|
+
|
20
|
+
attr_accessor *(CONFIGURATION_OPTIONS.map { |k,v| k })
|
21
|
+
|
22
|
+
def self.extended(base)
|
23
|
+
base.reset
|
24
|
+
end
|
25
|
+
|
26
|
+
def configure(&blk)
|
27
|
+
yield(self)
|
28
|
+
end
|
29
|
+
|
30
|
+
def options
|
31
|
+
options = {}
|
32
|
+
CONFIGURATION_OPTIONS.each{|k| options[k] = send(k) }
|
33
|
+
options
|
34
|
+
end
|
35
|
+
|
36
|
+
def reset
|
37
|
+
CONFIGURATION_OPTIONS.each do |k,v|
|
38
|
+
send("#{k}=",v)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
module Framey
|
2
|
+
|
3
|
+
module ViewHelpers
|
4
|
+
def render_recorder(opts={})
|
5
|
+
api_key = Framey.api_key
|
6
|
+
timestamp, signature = Framey::Api.sign
|
7
|
+
session_data = (opts[:session_data]||{}).map { |k,v| "#{k.to_s}=#{v.to_s}" }.join(",")
|
8
|
+
run_env = Framey.run_env
|
9
|
+
max_time = opts[:max_time] || 30
|
10
|
+
divid = "frameyRecorderContainer_#{(rand*999999999).to_i}"
|
11
|
+
objid = "the#{divid}"
|
12
|
+
|
13
|
+
raw <<END_RECORDER
|
14
|
+
<div id="#{divid}"></div>
|
15
|
+
<script type="text/javascript">
|
16
|
+
var flashvars = {
|
17
|
+
api_key: "#{api_key}",
|
18
|
+
signature: "#{signature}",
|
19
|
+
time_stamp: "#{timestamp}",
|
20
|
+
session_data: "#{session_data}",
|
21
|
+
run_env: "#{run_env}",
|
22
|
+
max_time: "#{max_time.to_s}"
|
23
|
+
};
|
24
|
+
var params = {
|
25
|
+
'allowscriptaccess': 'always',
|
26
|
+
"wmode": "transparent"
|
27
|
+
};
|
28
|
+
var attributes = {
|
29
|
+
'id': "#{objid}",
|
30
|
+
'name': "#{objid}"
|
31
|
+
};
|
32
|
+
swfobject.embedSWF("#{Framey.api_host}/recorder.swf", "#{divid}", "340", "340", "8", "", flashvars, params, attributes);
|
33
|
+
</script>
|
34
|
+
END_RECORDER
|
35
|
+
end
|
36
|
+
|
37
|
+
def render_player(opts={})
|
38
|
+
video_url = opts[:video_url] || "#{Framey.api_host}/videos/#{opts[:video_name]}/source.flv"
|
39
|
+
thumbnail_url = opts[:thumbnail_url] || "#{Framey.api_host}/videos/#{opts[:video_name]}/thumbnail.jpg"
|
40
|
+
|
41
|
+
divid = "frameyPlayerContainer_#{(rand*999999999).to_i}"
|
42
|
+
objid = "the#{divid}"
|
43
|
+
|
44
|
+
progress_bar_color = "#{opts[:progress_bar_color]}"
|
45
|
+
volume_bar_color = "#{opts[:volume_bar_color]}"
|
46
|
+
|
47
|
+
raw <<END_PLAYER
|
48
|
+
<div id="#{divid}"></div>
|
49
|
+
<script type="text/javascript">
|
50
|
+
var flashvars = {
|
51
|
+
'video_url': "#{video_url}",
|
52
|
+
'thumbnail_url': "#{thumbnail_url}",
|
53
|
+
"progress_bar_color": "#{progress_bar_color}",
|
54
|
+
"volume_bar_color": "#{volume_bar_color}"
|
55
|
+
};
|
56
|
+
|
57
|
+
var params = {
|
58
|
+
'allowfullscreen': 'true',
|
59
|
+
'allowscriptaccess': 'always',
|
60
|
+
"wmode": "transparent"
|
61
|
+
};
|
62
|
+
|
63
|
+
var attributes = {
|
64
|
+
'id': "#{objid}",
|
65
|
+
'name': "#{objid}"
|
66
|
+
};
|
67
|
+
|
68
|
+
swfobject.embedSWF("#{Framey.api_host}/player.swf", "#{divid}", '340', '290', '9', 'false', flashvars, params, attributes);
|
69
|
+
</script>
|
70
|
+
END_PLAYER
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
module ActionView
|
77
|
+
module Helpers
|
78
|
+
include Framey::ViewHelpers
|
79
|
+
end
|
80
|
+
end
|
data/lib/framey.rb
ADDED
data/test/test_framey.rb
ADDED
metadata
ADDED
@@ -0,0 +1,90 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: framey
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 1.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Shaun Salzberg
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-04-29 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: hoe
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 35
|
29
|
+
segments:
|
30
|
+
- 2
|
31
|
+
- 9
|
32
|
+
- 4
|
33
|
+
version: 2.9.4
|
34
|
+
type: :development
|
35
|
+
version_requirements: *id001
|
36
|
+
description: A gem for easy Rails integration with the Framey video recording service.
|
37
|
+
email: shaun@qlabs.com
|
38
|
+
executables: []
|
39
|
+
|
40
|
+
extensions: []
|
41
|
+
|
42
|
+
extra_rdoc_files:
|
43
|
+
- Manifest.txt
|
44
|
+
- README.txt
|
45
|
+
files:
|
46
|
+
- Manifest.txt
|
47
|
+
- Rakefile
|
48
|
+
- README.txt
|
49
|
+
- lib/framey.rb
|
50
|
+
- lib/framey/api.rb
|
51
|
+
- lib/framey/configuration.rb
|
52
|
+
- lib/framey/view_helpers.rb
|
53
|
+
- test/test_framey.rb
|
54
|
+
- .gemtest
|
55
|
+
homepage: http://framey.com
|
56
|
+
licenses: []
|
57
|
+
|
58
|
+
post_install_message:
|
59
|
+
rdoc_options:
|
60
|
+
- --main
|
61
|
+
- README.txt
|
62
|
+
require_paths:
|
63
|
+
- lib
|
64
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
+
none: false
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
hash: 3
|
70
|
+
segments:
|
71
|
+
- 0
|
72
|
+
version: "0"
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
hash: 3
|
79
|
+
segments:
|
80
|
+
- 0
|
81
|
+
version: "0"
|
82
|
+
requirements: []
|
83
|
+
|
84
|
+
rubyforge_project: framey
|
85
|
+
rubygems_version: 1.7.2
|
86
|
+
signing_key:
|
87
|
+
specification_version: 3
|
88
|
+
summary: A gem for easy Rails integration with the Framey video recording service.
|
89
|
+
test_files:
|
90
|
+
- test/test_framey.rb
|