goncalossilva-kaltura_fu 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,5 @@
1
+ *.swp
2
+ doc/**
3
+ .svn
4
+ .DS_Store
5
+ spec/config/**
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2010 [name of plugin creator]
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/README.markdown ADDED
@@ -0,0 +1,50 @@
1
+ Kaltura_Fu
2
+ --------------
3
+ **Homepage**: [http://www.velir.com](http://www.velir.com)
4
+ **Author**: [Patrick Robertson](mailto:patrick.robertson@velir.com)
5
+ **Copyright**: 2010
6
+ **License**: [MIT License](file:MIT-LICENSE)
7
+
8
+ About Kaltura
9
+ ----------------
10
+ [Kaltura](http://kaltura.org/) is an open source video streaming service.
11
+
12
+ About Kaltura_Fu
13
+ ------------------
14
+
15
+ Kaltura_Fu is a gem that wraps the Kaltura-Ruby API wrapper and also adds some convenience methods for Rails'
16
+ ActionView. The intent of this library is to provide a far easier means to communicate with your Kaltura server.
17
+ It's just too much of a pain to update simple things like the metadata fields with the default kaltura-ruby client.
18
+
19
+ Installation:
20
+ -------------
21
+ Install the gem with the command:
22
+
23
+ gem install kaltura_fu
24
+ Run:
25
+
26
+ script/generate kaltura_fu_install
27
+
28
+ This will install the kaltura.yml file into your application's config directory and the kaltura_upload.js into the application's public/javascripts directory.
29
+
30
+ Testing:
31
+ --------
32
+
33
+ The Kaltura_Fu library is being tested against the following version of Ruby:
34
+
35
+ * 1.8.7(MRI)
36
+ * 1.8.7(EE)
37
+ * 1.9.2(YARV)
38
+ * Rubinius
39
+
40
+ In order to test this gem (for local development), you'll need to have access to a Kaltura server.
41
+ I use a local installation of KalturaCE. You'll have to add a config file under spec/config/kaltura.yml and
42
+ add in a small video file named video.flv in the same folder. Since Kaltura provides no testing in kaltura-ruby,
43
+ I tend to use this library as a test suite for fixes for that library as well.
44
+
45
+
46
+ Documentation:
47
+ ------
48
+ The full documentation is located [here](http://rdoc.info/github/Velir/kaltura_fu/).
49
+
50
+ Copyright (c) 2010 [Velir Studios](http://www.velir.com), released under the MIT license
data/Rakefile ADDED
@@ -0,0 +1,68 @@
1
+ require 'rubygems'
2
+ require 'rake'
3
+ require 'yaml'
4
+
5
+ begin
6
+ require 'jeweler'
7
+ Jeweler::Tasks.new do |gem|
8
+ gem.name = "kaltura_fu"
9
+ gem.summary = "Rails gem for making Kaltura integrations easier."
10
+ gem.email = "patrick.robertson@velir.com"
11
+ gem.homepage = "http://github.com/Velir/kaltura_fu"
12
+ gem.authors = ["Patrick Robertson"]
13
+ gem.add_development_dependency "rspec", "= 1.3.0"
14
+ gem.add_development_dependency "activesupport"
15
+ gem.add_dependency('velir_kaltura-ruby', '>=0.4.3')
16
+ # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
17
+ end
18
+
19
+ rescue LoadError
20
+ puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
21
+ end
22
+
23
+ require 'spec/rake/spectask'
24
+ Spec::Rake::SpecTask.new(:spec) do |spec|
25
+ spec.libs << 'lib' << 'spec'
26
+ spec.spec_files = FileList['spec/**/*_spec.rb']
27
+ end
28
+
29
+ Spec::Rake::SpecTask.new(:rcov) do |spec|
30
+ spec.libs << 'lib' << 'spec'
31
+ spec.pattern = 'spec/**/*_spec.rb'
32
+ spec.rcov = true
33
+ end
34
+
35
+ task :spec => :check_dependencies
36
+
37
+ task :default => :spec
38
+
39
+ begin
40
+ require 'rcov/rcovtask'
41
+ Rcov::RcovTask.new do |test|
42
+ test.libs << 'spec'
43
+ test.pattern = 'spec/**/*_spec.rb'
44
+ test.verbose = true
45
+ end
46
+ rescue LoadError
47
+ task :rcov do
48
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
49
+ end
50
+ end
51
+
52
+
53
+ task :default => :test
54
+
55
+ require 'rake/rdoctask'
56
+ Rake::RDocTask.new do |rdoc|
57
+ if File.exist?('VERSION.yml')
58
+ config = YAML.load(File.read('VERSION.yml'))
59
+ version = "#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
60
+ else
61
+ version = ""
62
+ end
63
+
64
+ rdoc.rdoc_dir = 'rdoc'
65
+ rdoc.title = "kaltura-ruby #{version}"
66
+ rdoc.rdoc_files.include('README*')
67
+ rdoc.rdoc_files.include('lib/**/*.rb')
68
+ end
data/VERSION.yml ADDED
@@ -0,0 +1,5 @@
1
+ ---
2
+ :major: 0
3
+ :build:
4
+ :minor: 2
5
+ :patch: 0
@@ -0,0 +1,11 @@
1
+ class KalturaFuInstallGenerator < Rails::Generator::Base
2
+ def manifest
3
+ record do |m|
4
+ m.directory "config"
5
+ m.file "kaltura.yml", "config/kaltura.yml"
6
+
7
+ m.directory "public/javascripts"
8
+ m.file "kaltura_upload.js" , "public/javascripts/kaltura_upload.js"
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,22 @@
1
+ # config/kaltura.yml
2
+ base: &base
3
+ login_email: 'USER_EMAIL'
4
+ login_password: 'THE_PASSWORD'
5
+ partner_id: 'PARTNER_ID'
6
+ subpartner_id: 'PARTNER_ID * 100'
7
+ administrator_secret: 'ADMINISTRATOR_SECRET'
8
+ user_secret: 'USER_SECRET'
9
+ thumb_width: '300'
10
+ thumb_height: '300'
11
+ player_conf_id: 'whatever'
12
+ service_url: 'http://www.kaltura.com'
13
+
14
+ development:
15
+ <<: *base
16
+
17
+ test:
18
+ <<: *base
19
+
20
+
21
+ production:
22
+ <<: *base
@@ -0,0 +1,67 @@
1
+ var flashObj;
2
+ var delegate = {};
3
+ var mediaTypeInput;
4
+
5
+ //KSU handlers
6
+ delegate.readyHandler = function()
7
+ {
8
+ flashObj = document.getElementById("uploader");
9
+ }
10
+
11
+ delegate.selectHandler = function()
12
+ {
13
+ //flashObj.upload();
14
+ console.log("selectHandler()");
15
+ console.log(flashObj.getTotalSize());
16
+ }
17
+
18
+ function setMediaType()
19
+ {
20
+ var mediaType = document.getElementById("mediaTypeInput").value;
21
+ //alert(mediaType);
22
+ console.log(mediaType);
23
+ flashObj.setMediaType(mediaType);
24
+ }
25
+
26
+ delegate.singleUploadCompleteHandler = function(args)
27
+ {
28
+
29
+ flashObj.addEntries();
30
+ console.log("singleUploadCompleteHandler", args[0].title);
31
+ document.getElementById('button_submit').disabled = false;
32
+
33
+ }
34
+
35
+ delegate.allUploadsCompleteHandler = function()
36
+ {
37
+ console.log("allUploadsCompleteHandler");
38
+ }
39
+
40
+ delegate.entriesAddedHandler = function(entries)
41
+ {
42
+ //alert(entries.length);
43
+ var entry = entries[0];
44
+ //alert(entry.entryId);
45
+ document.getElementById('video_entry_id').value = entry.entryId
46
+ console.log(entries);
47
+ }
48
+
49
+ delegate.progressHandler = function(args)
50
+ {
51
+ document.getElementById('video_title').value = args[2].title;
52
+ var bob = Math.round(args[0] / args[1] * 100);
53
+ document.getElementById('progress').value = bob;
54
+ console.log(args[2].title + ": " + args[0] + " / " + args[1]);
55
+ }
56
+
57
+ delegate.uiConfErrorHandler = function()
58
+ {
59
+ console.log("ui conf loading error");
60
+ }
61
+
62
+ <!--- JavaScript callback methods to activate Kaltura services via the KSU widget.-->
63
+ function upload()
64
+ {
65
+ flashObj.upload();
66
+ //flashObj.addEntries();
67
+ }
data/install.rb ADDED
@@ -0,0 +1 @@
1
+ # Install hook code here
@@ -0,0 +1,79 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run the gemspec command
4
+ # -*- encoding: utf-8 -*-
5
+
6
+ Gem::Specification.new do |s|
7
+ s.name = %q{goncalossilva-kaltura_fu}
8
+ s.version = "0.2.0"
9
+
10
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
+ s.authors = ["Patrick Robertson"]
12
+ s.date = %q{2010-11-06}
13
+ s.email = %q{patrick.robertson@velir.com}
14
+ s.extra_rdoc_files = [
15
+ "README.markdown"
16
+ ]
17
+ s.files = [
18
+ ".gitignore",
19
+ "MIT-LICENSE",
20
+ "README.markdown",
21
+ "Rakefile",
22
+ "VERSION.yml",
23
+ "generators/kaltura_fu_install/kaltura_fu_install_generator.rb",
24
+ "generators/kaltura_fu_install/templates/kaltura.yml",
25
+ "generators/kaltura_fu_install/templates/kaltura_upload.js",
26
+ "install.rb",
27
+ "kaltura_fu.gemspec",
28
+ "lib/kaltura_fu.rb",
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/flavor.rb",
33
+ "lib/kaltura_fu/entry/instance_methods.rb",
34
+ "lib/kaltura_fu/entry/metadata.rb",
35
+ "lib/kaltura_fu/entry/metadata/class_and_instance_methods.rb",
36
+ "lib/kaltura_fu/entry/metadata/class_methods.rb",
37
+ "lib/kaltura_fu/railtie.rb",
38
+ "lib/kaltura_fu/view_helpers.rb",
39
+ "rails/init.rb",
40
+ "spec/debug.log",
41
+ "spec/entry_spec.rb",
42
+ "spec/flavor_spec.rb",
43
+ "spec/kaltura_fu_spec.rb",
44
+ "spec/metadata_spec.rb",
45
+ "spec/spec.opts",
46
+ "spec/spec_helper.rb",
47
+ "uninstall.rb"
48
+ ]
49
+ s.homepage = %q{http://github.com/goncalossilva/kaltura_fu}
50
+ s.rdoc_options = ["--charset=UTF-8"]
51
+ s.require_paths = ["lib"]
52
+ s.rubygems_version = %q{1.3.7}
53
+ s.summary = %q{Rails gem for making Kaltura integrations easier.}
54
+ s.test_files = [
55
+ "spec/entry_spec.rb",
56
+ "spec/flavor_spec.rb",
57
+ "spec/kaltura_fu_spec.rb",
58
+ "spec/metadata_spec.rb",
59
+ "spec/spec_helper.rb"
60
+ ]
61
+
62
+ if s.respond_to? :specification_version then
63
+ current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
64
+ s.specification_version = 3
65
+
66
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
67
+ s.add_development_dependency(%q<rspec>, ["= 1.3.0"])
68
+ s.add_development_dependency(%q<activesupport>, ["~> 2.3.5"])
69
+ else
70
+ s.add_dependency(%q<rspec>, ["= 1.3.0"])
71
+ s.add_dependency(%q<activesupport>, ["~> 2.3.5"])
72
+ end
73
+ else
74
+ s.add_dependency(%q<rspec>, ["= 1.3.0"])
75
+ s.add_dependency(%q<activesupport>, ["~> 2.3.5"])
76
+ s.add_dependency(%q<velir_kaltura-ruby>, [">= 0.4.3"])
77
+ end
78
+ end
79
+
data/lib/kaltura_fu.rb ADDED
@@ -0,0 +1,57 @@
1
+ #--
2
+ # Copyright (c) 2010 Velir Studios
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining
5
+ # a copy of this software and associated documentation files (the
6
+ # "Software"), to deal in the Software without restriction, including
7
+ # without limitation the rights to use, copy, modify, merge, publish,
8
+ # distribute, sublicense, and/or sell copies of the Software, and to
9
+ # permit persons to whom the Software is furnished to do so, subject to
10
+ # the following conditions:
11
+ #
12
+ # The above copyright notice and this permission notice shall be
13
+ # included in all copies or substantial portions of the Software.
14
+ #
15
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ # EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17
+ # MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ # NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19
+ # LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20
+ # OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21
+ # WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
+ #++
23
+
24
+ ##
25
+ # The KalturaFu module provides a singleton implementation for Kaltura API interaction.
26
+ # It stores session and API client information so that they do not need to be reset.
27
+ #
28
+ # @author Patrick Robertson
29
+ #
30
+ ##
31
+ require 'rubygems'
32
+ require 'kaltura'
33
+ require 'active_support/all'
34
+
35
+ module KalturaFu
36
+
37
+ #Initilize the configuration and send the ViewHelpers into ActionView::Base when it's a Rails 3 app.
38
+ require 'kaltura_fu/railtie' if defined?(Rails) && Rails.version.split(".").first == "3"
39
+
40
+ autoload :Configuration, 'kaltura_fu/configuration'
41
+ autoload :Entry, 'kaltura_fu/entry'
42
+
43
+ module Entry
44
+
45
+ autoload :Metadata, 'kaltura_fu/entry/metadata'
46
+ autoload :ClassMethods, 'kaltura_fu/entry/class_methods'
47
+ autoload :InstanceMethods, 'kaltura_fu/entry/instance_methods'
48
+ autoload :Flavor, 'kaltura_fu/entry/flavor'
49
+
50
+ module Metadata
51
+ autoload :ClassMethods, 'kaltura_fu/entry/metadata/class_methods'
52
+ autoload :ClassAndInstanceMethods, 'kaltura_fu/entry/metadata/class_and_instance_methods'
53
+ end
54
+ end
55
+
56
+ extend Configuration
57
+ end
@@ -0,0 +1,92 @@
1
+ module KalturaFu
2
+ module Configuration
3
+
4
+ @@config = {} #A Has containing the Kaltura server information
5
+ @@client = nil #An insantiated Kaltura::Client class
6
+ @@client_configuration = nil #Configuration values for the @@client.
7
+ @@session_key = nil #The Kaltura ks to use.
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