Module: KalturaFu::Configuration

Included in:
KalturaFu
Defined in:
lib/kaltura_fu/configuration.rb

Constant Summary

@@config =

A Has containing the Kaltura server information

{}
@@client =

An insantiated Kaltura::Client class

nil
@@client_configuration =

Configuration values for the @@client.

nil
@@session_key =

The Kaltura ks to use.

nil

Instance Method Summary collapse

Instance Method Details

#check_for_client_sessionObject



81
82
83
84
85
86
87
88
89
# File 'lib/kaltura_fu/configuration.rb', line 81

def check_for_client_session
  if @@client.nil?
    self.create_client
    self.generate_session_key
    true
  else
    true
  end
end

#clear_session_key!Object

Clears the current Kaltura ks.



74
75
76
# File 'lib/kaltura_fu/configuration.rb', line 74

def clear_session_key!
  @@session_key = nil
end

#clientObject



17
18
19
# File 'lib/kaltura_fu/configuration.rb', line 17

def client
  @@client ||= nil
end

#client=(value) ⇒ Object



21
22
23
# File 'lib/kaltura_fu/configuration.rb', line 21

def client=(value)
  @@client = value
end

#client_configurationObject



25
26
27
# File 'lib/kaltura_fu/configuration.rb', line 25

def client_configuration
  @@client_configuration ||= nil
end

#client_configuration=(value) ⇒ Object



28
29
30
# File 'lib/kaltura_fu/configuration.rb', line 28

def client_configuration=(value)
  @@client_configuration = value
end

#configObject



9
10
11
# File 'lib/kaltura_fu/configuration.rb', line 9

def config
  @@config ||= {}
end

#config=(value) ⇒ Object



13
14
15
# File 'lib/kaltura_fu/configuration.rb', line 13

def config=(value)
  @@config = value
end

#create_clientObject



51
52
53
54
55
56
57
# File 'lib/kaltura_fu/configuration.rb', line 51

def create_client
  if @@client_configuration.nil?
    self.create_client_config
  end
  @@client = Kaltura::Client.new(@@client_configuration)
  @@client
end

#create_client_configObject



39
40
41
42
43
44
45
46
# File 'lib/kaltura_fu/configuration.rb', line 39

def create_client_config
  raise "Missing Partner Identifier" unless @@config[:partner_id]
  @@client_configuration = Kaltura::Configuration.new(@@config[:partner_id])
  unless @@config[:service_url].nil?
    @@client_configuration.service_url = @@config[:service_url]
  end
  @@client_configuration
end

#generate_session_keyString

Generates a Kaltura ks and adds it to the KalturaFu client object.

Returns:

  • (String)

    a Kaltura KS.



64
65
66
67
68
69
70
# File 'lib/kaltura_fu/configuration.rb', line 64

def generate_session_key
  self.check_for_client_session
  
  raise "Missing Administrator Secret" unless @@config[:administrator_secret]
  @@session_key = @@client.session_service.start(@@config[:administrator_secret],'',Kaltura::Constants::SessionType::ADMIN)
  @@client.ks = @@session_key
end

#session_keyObject



31
32
33
# File 'lib/kaltura_fu/configuration.rb', line 31

def session_key
  @@session_key ||=nil
end