-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
199 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
module BrowseEverything | ||
module Driver | ||
class Kaltura < Base | ||
require 'kaltura' | ||
|
||
def icon | ||
'kaltura' | ||
end | ||
|
||
def validate_config | ||
unless [:partner_id,:administrator_secret,:service_url].all? { |key| config[key].present? } | ||
raise BrowseEverything::InitializationError, "Kaltura driver requires :partner_id, :administrator_secret, and :service_url" | ||
end | ||
end | ||
|
||
def contents(path='') | ||
result = [] | ||
|
||
@options = { :filter => { :creatorIdEqual => $current_user } } | ||
@session = ::Kaltura::Session.start | ||
@@entries = ::Kaltura::MediaEntry.list(@options) | ||
@@entries.each do |item| | ||
item.location = item.downloadUrl.sub('https:', 'kaltura:') | ||
item.mtime = Time.at(item.updatedAt.to_i) | ||
result.push(item) | ||
end | ||
result | ||
end | ||
|
||
def link_for(path) | ||
correct_path = path.sub('//', 'https://') | ||
file_list = @@entries | ||
extras = {file_name: ''} | ||
file_list.each do |file| | ||
if file.downloadUrl == correct_path | ||
extras[:file_name] = file.name | ||
end | ||
end | ||
ret = [correct_path, extras] | ||
end | ||
|
||
def details(path) | ||
byebug | ||
contents(path).first | ||
end | ||
|
||
def authorized? | ||
true | ||
end | ||
|
||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
require 'spec_helper' | ||
|
||
describe "Kaltura Driver", :vcr => { cassette_name: 'Kaltura_Session', record: :none } do | ||
|
||
context "starting a session", :vcr => { cassette_name: 'Kaltura_Session', record: :none } do | ||
|
||
describe "should properly set and read config values" do | ||
before do | ||
Kaltura.configure do |config| | ||
config.partner_id = 1 | ||
config.administrator_secret = 'superdupersecret' | ||
config.service_url = 'http://www.kaltura.com' | ||
end | ||
end | ||
|
||
it { Kaltura.config.partner_id.should == 1 } | ||
it { Kaltura.config.administrator_secret.should == 'superdupersecret' } | ||
it { Kaltura.config.service_url.should == 'http://www.kaltura.com' } | ||
end | ||
|
||
describe "should begin a session with proper credentials." do | ||
before do | ||
Kaltura.configure do |config| | ||
config.partner_id = 1 | ||
config.administrator_secret = 'superdupersecret' | ||
config.service_url = 'http://www.kaltura.com' | ||
end | ||
@session = Kaltura::Session.start | ||
end | ||
|
||
it { @session.result.should be_an_instance_of String } | ||
it { Kaltura::Session.kaltura_session.should eq(@session.result) } | ||
end | ||
|
||
describe "should not begin a session with invalid credentials." do | ||
before do | ||
Kaltura.configure { |config| config.partner_id = 2 } | ||
end | ||
|
||
it { lambda {Kaltura::Session.start}.should raise_error Kaltura::KalturaError } | ||
end | ||
end | ||
end |