kaltura_fu 0.1.3.prel → 0.1.3
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/Rakefile +17 -7
- data/VERSION.yml +1 -1
- data/kaltura_fu.gemspec +20 -10
- data/lib/kaltura_fu.rb +15 -92
- data/lib/kaltura_fu/configuration.rb +92 -0
- data/lib/kaltura_fu/entry.rb +16 -0
- data/lib/kaltura_fu/entry/class_methods.rb +61 -0
- data/lib/kaltura_fu/entry/instance_methods.rb +25 -0
- data/lib/kaltura_fu/entry/metadata.rb +147 -0
- data/lib/kaltura_fu/entry/metadata/class_and_instance_methods.rb +39 -0
- data/lib/kaltura_fu/flavor.rb +89 -0
- data/lib/kaltura_fu/railtie.rb +2 -2
- data/rails/init.rb +1 -1
- data/spec/entry_spec.rb +73 -0
- data/spec/kaltura_fu_spec.rb +53 -156
- data/spec/metadata_spec.rb +271 -0
- data/spec/spec.opts +1 -0
- data/spec/spec_helper.rb +26 -8
- metadata +38 -18
- data/lib/kaltura_fu/category.rb +0 -112
- data/test/kaltura_fu_test.rb +0 -8
- data/test/test_helper.rb +0 -3
data/.gitignore
CHANGED
data/Rakefile
CHANGED
@@ -10,6 +10,7 @@ begin
|
|
10
10
|
gem.email = "patrick.robertson@velir.com"
|
11
11
|
gem.homepage = "http://github.com/Velir/kaltura_fu"
|
12
12
|
gem.authors = ["Patrick Robertson"]
|
13
|
+
gem.add_development_dependency "rspec", ">= 1.2.9"
|
13
14
|
gem.add_dependency('velir_kaltura-ruby', '>=0.4.3')
|
14
15
|
# gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
16
|
end
|
@@ -18,18 +19,27 @@ rescue LoadError
|
|
18
19
|
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
19
20
|
end
|
20
21
|
|
21
|
-
require 'rake/
|
22
|
-
Rake::
|
23
|
-
|
24
|
-
|
25
|
-
test.verbose = true
|
22
|
+
require 'spec/rake/spectask'
|
23
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
24
|
+
spec.libs << 'lib' << 'spec'
|
25
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
26
26
|
end
|
27
27
|
|
28
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
29
|
+
spec.libs << 'lib' << 'spec'
|
30
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
31
|
+
spec.rcov = true
|
32
|
+
end
|
33
|
+
|
34
|
+
task :spec => :check_dependencies
|
35
|
+
|
36
|
+
task :default => :spec
|
37
|
+
|
28
38
|
begin
|
29
39
|
require 'rcov/rcovtask'
|
30
40
|
Rcov::RcovTask.new do |test|
|
31
|
-
test.libs << '
|
32
|
-
test.pattern = '
|
41
|
+
test.libs << 'spec'
|
42
|
+
test.pattern = 'spec/**/*_spec.rb'
|
33
43
|
test.verbose = true
|
34
44
|
end
|
35
45
|
rescue LoadError
|
data/VERSION.yml
CHANGED
data/kaltura_fu.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{kaltura_fu}
|
8
|
-
s.version = "0.1.3
|
8
|
+
s.version = "0.1.3"
|
9
9
|
|
10
|
-
s.required_rubygems_version = Gem::Requirement.new("
|
10
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Patrick Robertson"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-11-01}
|
13
13
|
s.email = %q{patrick.robertson@velir.com}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"README.markdown"
|
@@ -26,16 +26,23 @@ Gem::Specification.new do |s|
|
|
26
26
|
"install.rb",
|
27
27
|
"kaltura_fu.gemspec",
|
28
28
|
"lib/kaltura_fu.rb",
|
29
|
-
"lib/kaltura_fu/
|
29
|
+
"lib/kaltura_fu/configuration.rb",
|
30
|
+
"lib/kaltura_fu/entry.rb",
|
31
|
+
"lib/kaltura_fu/entry/class_methods.rb",
|
32
|
+
"lib/kaltura_fu/entry/instance_methods.rb",
|
33
|
+
"lib/kaltura_fu/entry/metadata.rb",
|
34
|
+
"lib/kaltura_fu/entry/metadata/class_and_instance_methods.rb",
|
35
|
+
"lib/kaltura_fu/flavor.rb",
|
30
36
|
"lib/kaltura_fu/railtie.rb",
|
31
37
|
"lib/kaltura_fu/report.rb",
|
32
38
|
"lib/kaltura_fu/video.rb",
|
33
39
|
"lib/kaltura_fu/view_helpers.rb",
|
34
40
|
"rails/init.rb",
|
41
|
+
"spec/entry_spec.rb",
|
35
42
|
"spec/kaltura_fu_spec.rb",
|
43
|
+
"spec/metadata_spec.rb",
|
44
|
+
"spec/spec.opts",
|
36
45
|
"spec/spec_helper.rb",
|
37
|
-
"test/kaltura_fu_test.rb",
|
38
|
-
"test/test_helper.rb",
|
39
46
|
"uninstall.rb"
|
40
47
|
]
|
41
48
|
s.homepage = %q{http://github.com/Velir/kaltura_fu}
|
@@ -44,10 +51,10 @@ Gem::Specification.new do |s|
|
|
44
51
|
s.rubygems_version = %q{1.3.7}
|
45
52
|
s.summary = %q{Rails gem for making Kaltura integrations easier.}
|
46
53
|
s.test_files = [
|
47
|
-
"spec/
|
48
|
-
"spec/
|
49
|
-
"
|
50
|
-
"
|
54
|
+
"spec/entry_spec.rb",
|
55
|
+
"spec/kaltura_fu_spec.rb",
|
56
|
+
"spec/metadata_spec.rb",
|
57
|
+
"spec/spec_helper.rb"
|
51
58
|
]
|
52
59
|
|
53
60
|
if s.respond_to? :specification_version then
|
@@ -55,11 +62,14 @@ Gem::Specification.new do |s|
|
|
55
62
|
s.specification_version = 3
|
56
63
|
|
57
64
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
65
|
+
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
58
66
|
s.add_runtime_dependency(%q<velir_kaltura-ruby>, [">= 0.4.3"])
|
59
67
|
else
|
68
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
60
69
|
s.add_dependency(%q<velir_kaltura-ruby>, [">= 0.4.3"])
|
61
70
|
end
|
62
71
|
else
|
72
|
+
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
63
73
|
s.add_dependency(%q<velir_kaltura-ruby>, [">= 0.4.3"])
|
64
74
|
end
|
65
75
|
end
|
data/lib/kaltura_fu.rb
CHANGED
@@ -1,24 +1,3 @@
|
|
1
|
-
##
|
2
|
-
# @private
|
3
|
-
##
|
4
|
-
class Hash
|
5
|
-
|
6
|
-
##
|
7
|
-
# @private
|
8
|
-
##
|
9
|
-
def recursively_symbolize_keys
|
10
|
-
tmp = {}
|
11
|
-
for k, v in self
|
12
|
-
tmp[k] = if v.respond_to? :recursively_symbolize_keys
|
13
|
-
v.recursively_symbolize_keys
|
14
|
-
else
|
15
|
-
v
|
16
|
-
end
|
17
|
-
end
|
18
|
-
tmp.symbolize_keys
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
1
|
##
|
23
2
|
# The KalturaFu module provides a singleton implementation for Kaltura API interaction. It stores session and API client information so that they do not need to be reset.
|
24
3
|
# @author Patrick Robertson
|
@@ -30,85 +9,29 @@ end
|
|
30
9
|
# @example Clear a session:
|
31
10
|
# KalturaFu.clear_session_key! #=> nil
|
32
11
|
##
|
12
|
+
require 'rubygems'
|
13
|
+
require 'kaltura'
|
14
|
+
|
33
15
|
module KalturaFu
|
34
16
|
|
17
|
+
#Initilize the configuration and send the ViewHelpers into ActionView::Base when it's a Rails 3 app.
|
35
18
|
require 'kaltura_fu/railtie' if defined?(Rails) && Rails.version.split(".").first == "3"
|
19
|
+
|
36
20
|
autoload :Video, 'kaltura_fu/video'
|
37
21
|
autoload :Category, 'kaltura_fu/category'
|
38
22
|
autoload :Report, 'kaltura_fu/report'
|
23
|
+
autoload :Configuration, 'kaltura_fu/configuration'
|
24
|
+
autoload :Entry, 'kaltura_fu/entry'
|
39
25
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
@@config = {}
|
45
|
-
@@client = nil
|
46
|
-
@@client_configuration = nil
|
47
|
-
@@session_key = nil
|
48
|
-
mattr_reader :config
|
49
|
-
mattr_reader :client
|
50
|
-
mattr_reader :session_key
|
51
|
-
|
52
|
-
class << self
|
53
|
-
##
|
54
|
-
# @private
|
55
|
-
##
|
56
|
-
def config=(options)
|
57
|
-
@@config = options
|
58
|
-
end
|
59
|
-
|
60
|
-
##
|
61
|
-
# @private
|
62
|
-
#
|
63
|
-
def create_client_config
|
64
|
-
@@client_configuration = Kaltura::Configuration.new(@@config[:partner_id])
|
65
|
-
unless @@config[:service_url].blank?
|
66
|
-
@@client_configuration.service_url = @@config[:service_url]
|
67
|
-
end
|
68
|
-
@@client_configuration
|
69
|
-
end
|
70
|
-
|
71
|
-
##
|
72
|
-
# @private
|
73
|
-
##
|
74
|
-
def create_client
|
75
|
-
if @@client_configuration.nil?
|
76
|
-
self.create_client_config
|
77
|
-
end
|
78
|
-
@@client = Kaltura::Client.new(@@client_configuration)
|
79
|
-
@@client
|
80
|
-
end
|
26
|
+
module Entry
|
27
|
+
autoload :Metadata, 'kaltura_fu/entry/metadata'
|
28
|
+
autoload :ClassMethods, 'kaltura_fu/entry/class_methods'
|
29
|
+
autoload :InstanceMethods, 'kaltura_fu/entry/instance_methods'
|
81
30
|
|
82
|
-
|
83
|
-
|
84
|
-
#
|
85
|
-
# @return [String] a Kaltura KS.
|
86
|
-
##
|
87
|
-
def generate_session_key
|
88
|
-
self.check_for_client_session
|
89
|
-
|
90
|
-
@@session_key = @@client.session_service.start(@@config[:administrator_secret],'',Kaltura::Constants::SessionType::ADMIN)
|
91
|
-
@@client.ks = @@session_key
|
92
|
-
end
|
93
|
-
##
|
94
|
-
# Clears the current Kaltura ks.
|
95
|
-
##
|
96
|
-
def clear_session_key!
|
97
|
-
@@session_key = nil
|
31
|
+
module Metadata
|
32
|
+
autoload :ClassAndInstanceMethods, 'kaltura_fu/entry/metadata/class_and_instance_methods'
|
98
33
|
end
|
99
|
-
|
100
|
-
##
|
101
|
-
# @private
|
102
|
-
##
|
103
|
-
def check_for_client_session
|
104
|
-
if @@client.nil?
|
105
|
-
self.create_client
|
106
|
-
self.generate_session_key
|
107
|
-
true
|
108
|
-
else
|
109
|
-
true
|
110
|
-
end
|
111
|
-
end
|
112
|
-
|
113
34
|
end
|
35
|
+
|
36
|
+
extend Configuration
|
114
37
|
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
module KalturaFu
|
2
|
+
module Configuration
|
3
|
+
|
4
|
+
@@config = {}
|
5
|
+
@@client = nil
|
6
|
+
@@client_configuration = nil
|
7
|
+
@@session_key = nil
|
8
|
+
|
9
|
+
def config
|
10
|
+
@@config ||= {}
|
11
|
+
end
|
12
|
+
|
13
|
+
def config=(value)
|
14
|
+
@@config = value
|
15
|
+
end
|
16
|
+
|
17
|
+
def client
|
18
|
+
@@client ||= nil
|
19
|
+
end
|
20
|
+
|
21
|
+
def client=(value)
|
22
|
+
@@client = value
|
23
|
+
end
|
24
|
+
|
25
|
+
def client_configuration
|
26
|
+
@@client_configuration ||= nil
|
27
|
+
end
|
28
|
+
def client_configuration=(value)
|
29
|
+
@@client_configuration = value
|
30
|
+
end
|
31
|
+
def session_key
|
32
|
+
@@session_key ||=nil
|
33
|
+
end
|
34
|
+
|
35
|
+
|
36
|
+
##
|
37
|
+
# @private
|
38
|
+
##
|
39
|
+
def create_client_config
|
40
|
+
raise "Missing Partner Identifier" unless @@config[:partner_id]
|
41
|
+
@@client_configuration = Kaltura::Configuration.new(@@config[:partner_id])
|
42
|
+
unless @@config[:service_url].nil?
|
43
|
+
@@client_configuration.service_url = @@config[:service_url]
|
44
|
+
end
|
45
|
+
@@client_configuration
|
46
|
+
end
|
47
|
+
|
48
|
+
##
|
49
|
+
# @private
|
50
|
+
##
|
51
|
+
def create_client
|
52
|
+
if @@client_configuration.nil?
|
53
|
+
self.create_client_config
|
54
|
+
end
|
55
|
+
@@client = Kaltura::Client.new(@@client_configuration)
|
56
|
+
@@client
|
57
|
+
end
|
58
|
+
|
59
|
+
##
|
60
|
+
# Generates a Kaltura ks and adds it to the KalturaFu client object.
|
61
|
+
#
|
62
|
+
# @return [String] a Kaltura KS.
|
63
|
+
##
|
64
|
+
def generate_session_key
|
65
|
+
self.check_for_client_session
|
66
|
+
|
67
|
+
raise "Missing Administrator Secret" unless @@config[:administrator_secret]
|
68
|
+
@@session_key = @@client.session_service.start(@@config[:administrator_secret],'',Kaltura::Constants::SessionType::ADMIN)
|
69
|
+
@@client.ks = @@session_key
|
70
|
+
end
|
71
|
+
##
|
72
|
+
# Clears the current Kaltura ks.
|
73
|
+
##
|
74
|
+
def clear_session_key!
|
75
|
+
@@session_key = nil
|
76
|
+
end
|
77
|
+
|
78
|
+
##
|
79
|
+
# @private
|
80
|
+
##
|
81
|
+
def check_for_client_session
|
82
|
+
if @@client.nil?
|
83
|
+
self.create_client
|
84
|
+
self.generate_session_key
|
85
|
+
true
|
86
|
+
else
|
87
|
+
true
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
module KalturaFu
|
2
|
+
module Entry
|
3
|
+
|
4
|
+
##
|
5
|
+
# Class level methods for the Entry module.
|
6
|
+
##
|
7
|
+
module ClassMethods
|
8
|
+
#extend KalturaFu::Entry::Metadata
|
9
|
+
##
|
10
|
+
# Allows you to upload some variety of media into Kaltura.
|
11
|
+
# This isn't going to be as great to use as one of their flash widgets, and
|
12
|
+
# should likely be used "off" the web process to not slow the application down.
|
13
|
+
#
|
14
|
+
# @param upload_object The object to upload. Currently, it only works with a File.
|
15
|
+
# @param [Hash] options An options hash of Kaltura Media Entry attributes to add & the
|
16
|
+
# upload_object source.
|
17
|
+
# @option options [Symbol] :source(nil) Currently only accepts :file
|
18
|
+
#
|
19
|
+
# @return [String] Returns the Kaltura Media Entry's ID that was created.
|
20
|
+
# @raise [Kaltura::APIError] It will force a Kaltura::APIError if something went terribly wrong.
|
21
|
+
#
|
22
|
+
# @todo Add the other upload types.
|
23
|
+
##
|
24
|
+
def upload(upload_object,options={})
|
25
|
+
KalturaFu.check_for_client_session
|
26
|
+
|
27
|
+
#options_for_media_entry = options.delete(:source)
|
28
|
+
media_entry = construct_entry_from_options(options)
|
29
|
+
upload_from_file(upload_object,media_entry) if options[:source] == :file
|
30
|
+
end
|
31
|
+
|
32
|
+
##
|
33
|
+
# @todo Build find.
|
34
|
+
##
|
35
|
+
def find
|
36
|
+
#pending
|
37
|
+
end
|
38
|
+
|
39
|
+
##
|
40
|
+
# @private
|
41
|
+
##
|
42
|
+
def upload_from_file(upload_object,media_entry)
|
43
|
+
upload_token = KalturaFu.client.media_service.upload(upload_object)
|
44
|
+
KalturaFu.client.media_service.add_from_uploaded_file(media_entry,upload_token).id
|
45
|
+
end
|
46
|
+
|
47
|
+
##
|
48
|
+
# @private
|
49
|
+
##
|
50
|
+
def construct_entry_from_options(options={})
|
51
|
+
media_entry = Kaltura::MediaEntry.new
|
52
|
+
options.each do |key,value|
|
53
|
+
media_entry.send("#{key}=",value) if valid_entry_attribute?(key)
|
54
|
+
end
|
55
|
+
media_entry.media_type = Kaltura::Constants::Media::Type::VIDEO if options[:media_type].nil?
|
56
|
+
return media_entry
|
57
|
+
end
|
58
|
+
|
59
|
+
end #ClassMethods
|
60
|
+
end
|
61
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module KalturaFu
|
2
|
+
module Entry
|
3
|
+
module InstanceMethods
|
4
|
+
##
|
5
|
+
# Deletes a Kaltura entry. Unlike the base API delete method, this returns true/false based on success.
|
6
|
+
#
|
7
|
+
# @param [String] entry_id Kaltura entry ID to delete.
|
8
|
+
#
|
9
|
+
# @return [Boolean] returns true if the delete was successful or false otherwise.
|
10
|
+
#
|
11
|
+
##
|
12
|
+
def delete_entry(entry_id)
|
13
|
+
KalturaFu.check_for_client_session
|
14
|
+
|
15
|
+
begin
|
16
|
+
KalturaFu.client.media_service.delete(entry_id)
|
17
|
+
true
|
18
|
+
rescue Kaltura::APIError => e
|
19
|
+
false
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|