acts_as_kaltura 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,47 +15,44 @@ module ActsAsKaltura
15
15
  end
16
16
  end
17
17
 
18
- module InstanceMethods
18
+ def create_kaltura_annotation
19
+ if self.cuepoint_key.nil?
20
+ @kaltura_annotation = self.class.kaltura_client.cuepoint_service.
21
+ add( self.as_annotation_cuepoint )
22
+ raise KalturaAnnotationAddFailure if @kaltura_annotation.nil?
19
23
 
20
- def create_kaltura_annotation
21
- if self.cuepoint_key.nil?
22
- @kaltura_annotation = self.class.kaltura_client.cuepoint_service.
23
- add( self.as_annotation_cuepoint )
24
- raise KalturaAnnotationAddFailure if @kaltura_annotation.nil?
25
-
26
- self.cuepoint_key = @kaltura_annotation.id.to_s
27
- end
24
+ self.cuepoint_key = @kaltura_annotation.id.to_s
28
25
  end
26
+ end
29
27
 
30
- def update_kaltura_annotation
31
- if self.cuepoint_key.present?
32
- @kaltura_annotation = self.class.kaltura_client.cuepoint_service.
33
- update(self.cuepoint_key, self.as_annotation_cuepoint )
34
- raise KalturaAnnotationUpdateFailure if @kaltura_annotation.nil?
35
- end
28
+ def update_kaltura_annotation
29
+ if self.cuepoint_key.present?
30
+ @kaltura_annotation = self.class.kaltura_client.cuepoint_service.
31
+ update(self.cuepoint_key, self.as_annotation_cuepoint )
32
+ raise KalturaAnnotationUpdateFailure if @kaltura_annotation.nil?
36
33
  end
34
+ end
37
35
 
38
- def delete_kaltura_annotation
39
- if self.cuepoint_key.present?
40
- self.class.kaltura_client.cuepoint_service.delete(self.cuepoint_key)
41
- @kaltura_annotation = nil
42
- end
36
+ def delete_kaltura_annotation
37
+ if self.cuepoint_key.present?
38
+ self.class.kaltura_client.cuepoint_service.delete(self.cuepoint_key)
39
+ @kaltura_annotation = nil
43
40
  end
41
+ end
44
42
 
45
- def kaltura_annotation
46
- @kaltura_annotation ||= find_kaltura_annotation
47
- end
43
+ def kaltura_annotation
44
+ @kaltura_annotation ||= find_kaltura_annotation
45
+ end
48
46
 
49
- def kaltura_annotation=(annotation)
50
- @kaltura_annotation = annotation
51
- end
47
+ def kaltura_annotation=(annotation)
48
+ @kaltura_annotation = annotation
49
+ end
52
50
 
53
- private
54
- def find_kaltura_annotation
55
- if self.cuepoint_key.present?
56
- self.class.kaltura_client.cuepoint_service.get(self.cuepoint_key)
57
- end
51
+ private
52
+ def find_kaltura_annotation
53
+ if self.cuepoint_key.present?
54
+ self.class.kaltura_client.cuepoint_service.get(self.cuepoint_key)
58
55
  end
59
- end
56
+ end
60
57
  end
61
58
  end
@@ -24,27 +24,25 @@ module ActsAsKaltura
24
24
  end
25
25
  end
26
26
 
27
- module InstanceMethods
28
- protected
29
- def reset_kaltura_delegated_attributes
30
- if self.class._kaltura_options.present?
31
- self.class._kaltura_options[:delegate].each do |attr|
32
- self.send(:"#{attr}=", nil)
33
- end
27
+ protected
28
+ def reset_kaltura_delegated_attributes
29
+ if self.class._kaltura_options.present?
30
+ self.class._kaltura_options[:delegate].each do |attr|
31
+ self.send(:"#{attr}=", nil)
34
32
  end
35
33
  end
34
+ end
36
35
 
37
- def _lookup_local_attribute(attr)
38
- self.read_attribute attr
39
- end
36
+ def _lookup_local_attribute(attr)
37
+ self.read_attribute attr
38
+ end
40
39
 
41
- def _lookup_kaltura_attribute(attr)
42
- if entry = self.kaltura_entry
43
- value = entry.send(attr)
44
- self.update_column(attr, value) if value
45
- value
46
- end
40
+ def _lookup_kaltura_attribute(attr)
41
+ if entry = self.kaltura_entry
42
+ value = entry.send(attr)
43
+ self.update_column(attr, value) if value
44
+ value
47
45
  end
48
- end
46
+ end
49
47
  end
50
48
  end
@@ -8,10 +8,8 @@ module ActsAsKaltura
8
8
  module Extension
9
9
  extend ActiveSupport::Concern
10
10
 
11
- module InstanceMethods
12
- def cuepoint_service
13
- @cuepoint_service ||= ActsAsKaltura::Extension::Service::CuePointService.new(self)
14
- end
11
+ def cuepoint_service
12
+ @cuepoint_service ||= ActsAsKaltura::Extension::Service::CuePointService.new(self)
15
13
  end
16
14
  end
17
15
  end
@@ -2,7 +2,7 @@ module ActsAsKaltura
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 0
5
- TINY = 3
5
+ TINY = 4
6
6
  PRE = nil
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
@@ -13,7 +13,7 @@ module ActsAsKaltura
13
13
  end
14
14
 
15
15
  module ClassMethods
16
- def acts_as_kaltura_video(options = {})
16
+ def acts_as_kaltura_video(options = { })
17
17
  # Set instance accessors
18
18
  attr_accessor :video_file, :uploaded_video_token
19
19
  self._kaltura_options = options
@@ -24,7 +24,7 @@ module ActsAsKaltura
24
24
  end
25
25
 
26
26
  # Set validators
27
- validates :video_file, :presence => {:on => :create}
27
+ validates :video_file, :presence => { :on => :create }
28
28
 
29
29
  # Set filters
30
30
  before_save :process_uploaded_video_file
@@ -34,118 +34,115 @@ module ActsAsKaltura
34
34
  end
35
35
  end
36
36
 
37
- module InstanceMethods
38
-
39
- #
40
- # Push user uploaded video file to kaltura server
41
- # If successful set upload token with the object
42
- #
43
- def process_uploaded_video_file
44
- if @video_file.present?
45
- video_file_stream = if @video_file.respond_to?(:path, true)
46
- File.open(@video_file.path)
47
- else
48
- @video_file
49
- end
50
- @uploaded_video_token = self.class.kaltura_client.
51
- media_service.upload( video_file_stream )
52
- raise ActsAsKaltura::Video::NoUploadedTokenFound if @uploaded_video_token.nil?
37
+ #
38
+ # Push user uploaded video file to kaltura server
39
+ # If successful set upload token with the object
40
+ #
41
+ def process_uploaded_video_file
42
+ if @video_file.present?
43
+ video_file_stream = if @video_file.respond_to?(:path, true)
44
+ File.open(@video_file.path)
45
+ else
46
+ @video_file
53
47
  end
48
+ @uploaded_video_token = self.class.kaltura_client.
49
+ media_service.upload(video_file_stream)
50
+ raise ActsAsKaltura::Video::NoUploadedTokenFound if @uploaded_video_token.nil?
54
51
  end
52
+ end
55
53
 
56
- #
57
- # Create kaltura video entry based on current video data
58
- # if successful set kaltura id
59
- #
60
- def create_kaltura_video_entry
61
- if @video_file.present?
62
- # There must have uploaded token otherwise this should be invoked
63
- raise NoUploadedTokenFound if @uploaded_video_token.nil?
54
+ #
55
+ # Create kaltura video entry based on current video data
56
+ # if successful set kaltura id
57
+ #
58
+ def create_kaltura_video_entry
59
+ if @video_file.present?
60
+ # There must have uploaded token otherwise this should be invoked
61
+ raise NoUploadedTokenFound if @uploaded_video_token.nil?
64
62
 
65
- # Covert host model as kaltura entry
66
- entry = as_kaltura_entry
63
+ # Covert host model as kaltura entry
64
+ entry = as_kaltura_entry
67
65
 
68
- # Request kaltura service to store video entry for the
69
- # uploaded video file
70
- stored_entry = add_kaltuar_video_file(entry)
66
+ # Request kaltura service to store video entry for the
67
+ # uploaded video file
68
+ stored_entry = add_kaltuar_video_file(entry)
71
69
 
72
- # Nil return should throw exception
73
- raise KalturaVideoAddFailure if stored_entry.nil?
70
+ # Nil return should throw exception
71
+ raise KalturaVideoAddFailure if stored_entry.nil?
74
72
 
75
- # Set kaltura_key from stored kaltura entry
76
- self.kaltura_key = stored_entry.id.to_s
77
- self.kaltura_syncd_at = Time.now
73
+ # Set kaltura_key from stored kaltura entry
74
+ self.kaltura_key = stored_entry.id.to_s
75
+ self.kaltura_syncd_at = Time.now
78
76
 
79
- self.class.run_kaltura_after_save_callbacks self
80
- end
77
+ self.class.run_kaltura_after_save_callbacks self
81
78
  end
79
+ end
82
80
 
83
- #
84
- # Update kaltura existing video entry
85
- # If successful update kaltura_syncd_at
86
- #
87
- def update_kaltura_video_entry
88
- if kaltura_key.present?
89
- entry = as_kaltura_entry
90
- update_kaltura_entry(entry)
91
-
92
- if @video_file.nil?
93
- entry.id = kaltura_key
94
- add_kaltuar_video_file(entry)
95
- end
96
-
97
- self.class.run_kaltura_after_save_callbacks self
81
+ #
82
+ # Update kaltura existing video entry
83
+ # If successful update kaltura_syncd_at
84
+ #
85
+ def update_kaltura_video_entry
86
+ if kaltura_key.present?
87
+ entry = as_kaltura_entry
88
+ update_kaltura_entry(entry)
89
+
90
+ if @video_file.nil?
91
+ entry.id = kaltura_key
92
+ add_kaltuar_video_file(entry)
98
93
  end
99
- end
100
94
 
101
- def kaltura_entry
102
- find_kaltura_entry if @kaltura_entry.nil?
103
- @kaltura_entry
95
+ self.class.run_kaltura_after_save_callbacks self
104
96
  end
97
+ end
105
98
 
106
- def kaltura_entry=(entry)
107
- @kaltura_entry = entry
99
+ def kaltura_entry
100
+ find_kaltura_entry if @kaltura_entry.nil?
101
+ @kaltura_entry
102
+ end
103
+
104
+ def kaltura_entry=(entry)
105
+ @kaltura_entry = entry
106
+ end
107
+
108
+ def destroy_kaltura_video_entry
109
+ if kaltura_key
110
+ destroy_kaltura_entry
108
111
  end
112
+ end
109
113
 
110
- def destroy_kaltura_video_entry
111
- if kaltura_key
112
- destroy_kaltura_entry
113
- end
114
+ private
115
+ def add_kaltuar_video_file(entry)
116
+ if @video_file && @uploaded_video_token
117
+ self.class.kaltura_client.media_service.
118
+ add_from_uploaded_file(entry, @uploaded_video_token)
114
119
  end
120
+ end
115
121
 
116
- private
117
- def add_kaltuar_video_file(entry)
118
- if @video_file && @uploaded_video_token
119
- self.class.kaltura_client.media_service.
120
- add_from_uploaded_file(entry, @uploaded_video_token)
121
- end
122
- end
122
+ def update_kaltura_entry(entry)
123
+ if kaltura_key.present?
124
+ self.class.kaltura_client.media_service.update(kaltura_key, entry)
125
+ self.kaltura_syncd_at = Time.now
126
+ end
127
+ end
123
128
 
124
- def update_kaltura_entry(entry)
125
- if kaltura_key.present?
126
- self.class.kaltura_client.media_service.update(kaltura_key, entry)
127
- self.kaltura_syncd_at = Time.now
128
- end
129
+ def find_kaltura_entry
130
+ if kaltura_key
131
+ if @kaltura_entry.nil?
132
+ @kaltura_entry = self.class.kaltura_client.media_service.get(kaltura_key)
129
133
  end
130
134
 
131
- def find_kaltura_entry
132
- if kaltura_key
133
- if @kaltura_entry.nil?
134
- @kaltura_entry = self.class.kaltura_client.media_service.get(kaltura_key)
135
- end
136
-
137
- @kaltura_entry
138
- end
139
- end
135
+ @kaltura_entry
136
+ end
137
+ end
140
138
 
141
- def destroy_kaltura_entry
142
- if kaltura_key
143
- self.class.kaltura_client.media_service.delete(kaltura_key)
144
- @kaltura_entry = nil
145
- end
146
- rescue
139
+ def destroy_kaltura_entry
140
+ if kaltura_key
141
+ self.class.kaltura_client.media_service.delete(kaltura_key)
142
+ @kaltura_entry = nil
143
+ end
144
+ rescue
147
145
 
148
- end
149
146
  end
150
147
  end
151
148
  end
@@ -1,3 +1,4 @@
1
+ require 'active_support/core_ext'
1
2
  require 'acts_as_kaltura/version'
2
3
  require 'acts_as_kaltura/two_way_attr_accessor'
3
4
  require 'acts_as_kaltura/config'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_kaltura
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.3
4
+ version: 1.0.4
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-05 00:00:00.000000000 Z
12
+ date: 2012-02-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: jeweler
16
- requirement: &2152705160 !ruby/object:Gem::Requirement
16
+ requirement: &2152318060 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,40 +21,40 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *2152705160
24
+ version_requirements: *2152318060
25
25
  - !ruby/object:Gem::Dependency
26
- name: rails
27
- requirement: &2152703160 !ruby/object:Gem::Requirement
26
+ name: velir_kaltura-ruby
27
+ requirement: &2152315520 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
31
31
  - !ruby/object:Gem::Version
32
- version: 3.1.3
32
+ version: '0'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *2152703160
35
+ version_requirements: *2152315520
36
36
  - !ruby/object:Gem::Dependency
37
- name: sqlite3
38
- requirement: &2152726500 !ruby/object:Gem::Requirement
37
+ name: activesupport
38
+ requirement: &2152312960 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
- - - ! '>='
41
+ - - ~>
42
42
  - !ruby/object:Gem::Version
43
- version: '0'
43
+ version: 3.1.3
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *2152726500
46
+ version_requirements: *2152312960
47
47
  - !ruby/object:Gem::Dependency
48
- name: velir_kaltura-ruby
49
- requirement: &2152724920 !ruby/object:Gem::Requirement
48
+ name: activerecord
49
+ requirement: &2152310640 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
- - - ! '>='
52
+ - - ~>
53
53
  - !ruby/object:Gem::Version
54
- version: '0'
54
+ version: 3.1.3
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *2152724920
57
+ version_requirements: *2152310640
58
58
  description: Acts as kaltura
59
59
  email: hasan@somewherein.net
60
60
  executables: []