kaltura_fu 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +2 -2
- data/kaltura_fu.gemspec +6 -2
- data/lib/kaltura_fu/entry/metadata/class_and_instance_methods.rb +15 -4
- data/lib/kaltura_fu/entry/metadata/class_methods.rb +71 -0
- data/lib/kaltura_fu/entry/metadata.rb +9 -7
- data/lib/kaltura_fu.rb +1 -0
- data/spec/config/kaltura.yml +10 -0
- data/spec/config/video.flv +0 -0
- data/spec/debug.log +1 -0
- data/spec/metadata_spec.rb +23 -23
- metadata +8 -4
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.
|
8
|
+
s.version = "0.1.4"
|
9
9
|
|
10
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-11-
|
12
|
+
s.date = %q{2010-11-04}
|
13
13
|
s.email = %q{patrick.robertson@velir.com}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"README.markdown"
|
@@ -32,12 +32,16 @@ Gem::Specification.new do |s|
|
|
32
32
|
"lib/kaltura_fu/entry/instance_methods.rb",
|
33
33
|
"lib/kaltura_fu/entry/metadata.rb",
|
34
34
|
"lib/kaltura_fu/entry/metadata/class_and_instance_methods.rb",
|
35
|
+
"lib/kaltura_fu/entry/metadata/class_methods.rb",
|
35
36
|
"lib/kaltura_fu/flavor.rb",
|
36
37
|
"lib/kaltura_fu/railtie.rb",
|
37
38
|
"lib/kaltura_fu/report.rb",
|
38
39
|
"lib/kaltura_fu/video.rb",
|
39
40
|
"lib/kaltura_fu/view_helpers.rb",
|
40
41
|
"rails/init.rb",
|
42
|
+
"spec/config/kaltura.yml",
|
43
|
+
"spec/config/video.flv",
|
44
|
+
"spec/debug.log",
|
41
45
|
"spec/entry_spec.rb",
|
42
46
|
"spec/kaltura_fu_spec.rb",
|
43
47
|
"spec/metadata_spec.rb",
|
@@ -14,18 +14,29 @@ module KalturaFu
|
|
14
14
|
valid_media_entry_methods = media_entry_methods.map{|m| m unless m =~/^(.*)=/}.compact!
|
15
15
|
|
16
16
|
valid_media_entry_methods -= object_methods
|
17
|
-
|
17
|
+
valid_entry_attributes.include?(request_attribute.to_sym)
|
18
|
+
end
|
19
|
+
|
20
|
+
##
|
21
|
+
# @private
|
22
|
+
##
|
23
|
+
def valid_entry_attributes
|
24
|
+
object_methods, media_entry_methods = Object.instance_methods , Kaltura::MediaEntry.instance_methods
|
25
|
+
|
26
|
+
#clean out all the setter methods from the media entry methods
|
27
|
+
valid_media_entry_methods = media_entry_methods.map{|m| m.to_sym unless m =~/^(.*)=/}.compact!
|
28
|
+
|
29
|
+
valid_media_entry_methods -= object_methods
|
18
30
|
end
|
19
|
-
|
20
31
|
##
|
21
32
|
# Determines if an attribute is valid in the sense of the add method making sense. Only
|
22
33
|
# categories and tags are currently considered valid.
|
23
34
|
##
|
24
35
|
def valid_add_attribute?(request_attribute)
|
25
36
|
case request_attribute.to_s
|
26
|
-
when /^(.*)_(
|
37
|
+
when /^(.*)_(categories|tags)/
|
27
38
|
return true
|
28
|
-
when /^(
|
39
|
+
when /^(categories|tags)/
|
29
40
|
return true
|
30
41
|
else
|
31
42
|
return false
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module KalturaFu
|
2
|
+
module Entry
|
3
|
+
module Metadata
|
4
|
+
module ClassMethods
|
5
|
+
|
6
|
+
# Contains the names of the generated attribute methods.
|
7
|
+
def generated_methods #:nodoc:
|
8
|
+
@generated_methods ||= Set.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def generated_methods?
|
12
|
+
!generated_methods.empty?
|
13
|
+
end
|
14
|
+
|
15
|
+
##
|
16
|
+
# This method is called from with method_missing. It generates
|
17
|
+
# actual methods for all the valid Kaltura::Media Entry methods
|
18
|
+
# the first time a dynamic getter/setter/adder is called.
|
19
|
+
##
|
20
|
+
def define_attribute_methods
|
21
|
+
return if generated_methods?
|
22
|
+
valid_entry_attributes.each do |name|
|
23
|
+
define_set_method(name)
|
24
|
+
define_get_method(name)
|
25
|
+
define_add_method(name) if valid_add_attribute?(name)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
##
|
30
|
+
# Defines the set method for a specific Media Entry attribute
|
31
|
+
##
|
32
|
+
def define_set_method(attr_name)
|
33
|
+
evaluate_attribute_method( attr_name,
|
34
|
+
"def set_#{attr_name}(entry,new_value);set_attribute('#{attr_name}',entry,new_value);end",
|
35
|
+
"set_#{attr_name}"
|
36
|
+
)
|
37
|
+
end
|
38
|
+
|
39
|
+
##
|
40
|
+
# defines a get methods
|
41
|
+
##
|
42
|
+
def define_get_method(attr_name)
|
43
|
+
evaluate_attribute_method( attr_name,
|
44
|
+
"def get_#{attr_name}(entry);get_entry(entry).send('#{attr_name}');end",
|
45
|
+
"get_#{attr_name}"
|
46
|
+
)
|
47
|
+
end
|
48
|
+
|
49
|
+
def define_add_method(attr_name)
|
50
|
+
evaluate_attribute_method( attr_name,
|
51
|
+
"def add_#{attr_name}(entry,new_value);add_attribute('#{attr_name}',entry,new_value);end",
|
52
|
+
"add_#{attr_name}"
|
53
|
+
)
|
54
|
+
end
|
55
|
+
|
56
|
+
def evaluate_attribute_method(attr_name, method_definition, method_name=attr_name)
|
57
|
+
generated_methods << method_name
|
58
|
+
|
59
|
+
begin
|
60
|
+
class_eval(method_definition, __FILE__, __LINE__)
|
61
|
+
rescue SyntaxError => err
|
62
|
+
generated_methods.delete(attr_name)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
|
@@ -9,6 +9,7 @@ module KalturaFu
|
|
9
9
|
##
|
10
10
|
def self.included(base)
|
11
11
|
base.extend ClassAndInstanceMethods
|
12
|
+
base.extend ClassMethods
|
12
13
|
base.class_eval do
|
13
14
|
include ClassAndInstanceMethods
|
14
15
|
end
|
@@ -19,13 +20,14 @@ module KalturaFu
|
|
19
20
|
# @private
|
20
21
|
##
|
21
22
|
def method_missing(name, *args)
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
23
|
+
method_name = name.to_s
|
24
|
+
unless self.class.generated_methods?
|
25
|
+
self.class.define_attribute_methods
|
26
|
+
if self.class.generated_methods.include?(method_name)
|
27
|
+
return self.send(name,*args)
|
28
|
+
else
|
29
|
+
super
|
30
|
+
end
|
29
31
|
else
|
30
32
|
super
|
31
33
|
end
|
data/lib/kaltura_fu.rb
CHANGED
@@ -29,6 +29,7 @@ module KalturaFu
|
|
29
29
|
autoload :InstanceMethods, 'kaltura_fu/entry/instance_methods'
|
30
30
|
|
31
31
|
module Metadata
|
32
|
+
autoload :ClassMethods, 'kaltura_fu/entry/metadata/class_methods'
|
32
33
|
autoload :ClassAndInstanceMethods, 'kaltura_fu/entry/metadata/class_and_instance_methods'
|
33
34
|
end
|
34
35
|
end
|
@@ -0,0 +1,10 @@
|
|
1
|
+
login_email: 'USER_EMAIL'
|
2
|
+
login_password: 'THE_PASSWORD'
|
3
|
+
partner_id: '101'
|
4
|
+
subpartner_id: '10100'
|
5
|
+
administrator_secret: '92fb84b76a249049427ce7f993a96a33'
|
6
|
+
user_secret: 'dd614d5bec07835e231083009e1582d7'
|
7
|
+
thumb_width: '300'
|
8
|
+
thumb_height: '300'
|
9
|
+
service_url: 'http://kaltura.dev.velir.com'
|
10
|
+
player_conf_id: '1000010'
|
Binary file
|
data/spec/debug.log
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
# Logfile created on Mon Jun 14 10:07:52 -0400 2010 by /
|
data/spec/metadata_spec.rb
CHANGED
@@ -50,32 +50,17 @@ describe "Actions on an entries metadata" do
|
|
50
50
|
test = MetadataSpecTester.new
|
51
51
|
test.should respond_to :set_categories
|
52
52
|
end
|
53
|
-
|
54
|
-
it "should respond to adding valid entry attributes" do
|
55
|
-
test = MetadataSpecTester.new
|
56
|
-
test.should respond_to :add_category
|
57
|
-
end
|
58
|
-
|
53
|
+
|
59
54
|
it "should respond to adding valid entry attributes" do
|
60
55
|
test = MetadataSpecTester.new
|
61
56
|
test.should respond_to :add_categories
|
62
57
|
end
|
63
58
|
|
64
|
-
it "should respond to adding valid entry attributes" do
|
65
|
-
test = MetadataSpecTester.new
|
66
|
-
test.should respond_to :add_tag
|
67
|
-
end
|
68
|
-
|
69
59
|
it "should respond to adding valid entry attributes" do
|
70
60
|
test = MetadataSpecTester.new
|
71
61
|
test.should respond_to :add_tags
|
72
62
|
end
|
73
|
-
|
74
|
-
it "should respond to adding valid entry attributes" do
|
75
|
-
test = MetadataSpecTester.new
|
76
|
-
test.should respond_to :add_admin_tag
|
77
|
-
end
|
78
|
-
|
63
|
+
|
79
64
|
it "should respond to adding valid entry attributes" do
|
80
65
|
test = MetadataSpecTester.new
|
81
66
|
test.should respond_to :add_admin_tags
|
@@ -96,6 +81,21 @@ describe "Actions on an entries metadata" do
|
|
96
81
|
test.should_not respond_to :add_waffles
|
97
82
|
end
|
98
83
|
|
84
|
+
it "should not respond to adding invalid entry attributes" do
|
85
|
+
test = MetadataSpecTester.new
|
86
|
+
test.should_not respond_to :add_category
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should not respond to adding invalid entry attributes" do
|
90
|
+
test = MetadataSpecTester.new
|
91
|
+
test.should_not respond_to :add_tag
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should not respond to adding invalid entry attributes" do
|
95
|
+
test = MetadataSpecTester.new
|
96
|
+
test.should_not respond_to :add_admin_tag
|
97
|
+
end
|
98
|
+
|
99
99
|
it "should not respond to adding valid entry attributes, but improperly typed" do
|
100
100
|
test = MetadataSpecTester.new
|
101
101
|
test.should_not respond_to :add_name
|
@@ -189,12 +189,12 @@ describe "Actions on an entries metadata" do
|
|
189
189
|
test.add_tags(@entry_id,"mos,def").should == original_tags + ", mos, def"
|
190
190
|
end
|
191
191
|
|
192
|
-
it "
|
192
|
+
it "no longer responds to adding a single tag. dynamic dispatches are cooler than syntax sugar." do
|
193
193
|
test = MetadataSpecTester.new
|
194
194
|
|
195
195
|
original_tags = test.set_tags(@entry_id,"gorillaz, pop, damon, albarn")
|
196
196
|
|
197
|
-
test.add_tag(@entry_id,"mos").should
|
197
|
+
lambda {test.add_tag(@entry_id,"mos")}.should raise_error
|
198
198
|
end
|
199
199
|
|
200
200
|
it "should allow you to add admin tags onto an existing tag string without knowing the original tags" do
|
@@ -205,12 +205,12 @@ describe "Actions on an entries metadata" do
|
|
205
205
|
test.add_admin_tags(@entry_id,"mos,def").should == original_tags + ",mos,def"
|
206
206
|
end
|
207
207
|
|
208
|
-
it "
|
208
|
+
it "no longer responds to adding a single admin tag" do
|
209
209
|
test = MetadataSpecTester.new
|
210
210
|
|
211
211
|
original_tags = test.set_admin_tags(@entry_id,"gorillaz, pop, damon, albarn")
|
212
212
|
|
213
|
-
test.add_admin_tag(@entry_id,"mos").should
|
213
|
+
lambda {test.add_admin_tag(@entry_id,"mos")}.should raise_error
|
214
214
|
end
|
215
215
|
|
216
216
|
it "should let you add categories onto an existing category string as well." do
|
@@ -253,13 +253,13 @@ describe "Actions on an entries metadata" do
|
|
253
253
|
end
|
254
254
|
end
|
255
255
|
|
256
|
-
it "should
|
256
|
+
it "should no longer respond to adding a single category" do
|
257
257
|
test = MetadataSpecTester.new
|
258
258
|
|
259
259
|
original_categories = test.set_categories(@entry_id,"peanuts#{rand(10)},pirates#{rand(10)}")
|
260
260
|
|
261
261
|
new_cat = "waffles#{rand(10)}"
|
262
|
-
test.add_category(@entry_id,new_cat).should
|
262
|
+
lambda{test.add_category(@entry_id,new_cat)}.should raise_error
|
263
263
|
|
264
264
|
bob = KalturaFu.client.category_service.list.objects
|
265
265
|
bob.each do |cat|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kaltura_fu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 1
|
9
|
-
-
|
10
|
-
version: 0.1.
|
9
|
+
- 4
|
10
|
+
version: 0.1.4
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Patrick Robertson
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-11-
|
18
|
+
date: 2010-11-04 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -76,12 +76,16 @@ files:
|
|
76
76
|
- lib/kaltura_fu/entry/instance_methods.rb
|
77
77
|
- lib/kaltura_fu/entry/metadata.rb
|
78
78
|
- lib/kaltura_fu/entry/metadata/class_and_instance_methods.rb
|
79
|
+
- lib/kaltura_fu/entry/metadata/class_methods.rb
|
79
80
|
- lib/kaltura_fu/flavor.rb
|
80
81
|
- lib/kaltura_fu/railtie.rb
|
81
82
|
- lib/kaltura_fu/report.rb
|
82
83
|
- lib/kaltura_fu/video.rb
|
83
84
|
- lib/kaltura_fu/view_helpers.rb
|
84
85
|
- rails/init.rb
|
86
|
+
- spec/config/kaltura.yml
|
87
|
+
- spec/config/video.flv
|
88
|
+
- spec/debug.log
|
85
89
|
- spec/entry_spec.rb
|
86
90
|
- spec/kaltura_fu_spec.rb
|
87
91
|
- spec/metadata_spec.rb
|