vj-sdk 0.7.0 → 0.7.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +2 -1
- data/VERSION.yml +2 -2
- data/lib/videojuicer.rb +1 -1
- data/lib/videojuicer/asset.rb +21 -0
- data/spec/asset_spec.rb +40 -0
- data/vj-sdk.gemspec +5 -5
- metadata +7 -7
- data/lib/videojuicer/asset/all.rb +0 -45
- data/spec/assets/all.rb +0 -41
data/Gemfile
CHANGED
data/VERSION.yml
CHANGED
data/lib/videojuicer.rb
CHANGED
@@ -37,7 +37,7 @@ require 'videojuicer/user'
|
|
37
37
|
require 'videojuicer/campaign'
|
38
38
|
require 'videojuicer/insert'
|
39
39
|
require 'videojuicer/presentation'
|
40
|
-
require 'videojuicer/asset
|
40
|
+
require 'videojuicer/asset'
|
41
41
|
require 'videojuicer/asset/audio'
|
42
42
|
require 'videojuicer/asset/document'
|
43
43
|
require 'videojuicer/asset/flash'
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Videojuicer
|
2
|
+
module Asset
|
3
|
+
def self.all(options = {})
|
4
|
+
proxy = Videojuicer::OAuth::RequestProxy.new(Videojuicer.current_scope)
|
5
|
+
response = proxy.get("/assets", "asset" => options)
|
6
|
+
items, count, offset, limit = JSON.parse(response.body).values_at("items", "count", "offset", "limit")
|
7
|
+
assets = items.map { |i| const_get(i.delete("type").capitalize).new(i) }
|
8
|
+
|
9
|
+
# TODO: this should really be taken care of in VJ:Resource::initialize
|
10
|
+
# then VJ::Resource::CMs.all can also omit this step
|
11
|
+
assets.each { |a| a.clean_dirty_attributes! }
|
12
|
+
|
13
|
+
Videojuicer::Resource::Collection.new(assets, count, offset, limit)
|
14
|
+
end
|
15
|
+
|
16
|
+
TYPES = %w(Audio Document Image Flash Text Video)
|
17
|
+
def self.types
|
18
|
+
TYPES.map { |t| const_get(t) }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/spec/asset_spec.rb
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "helpers", "spec_helper")
|
2
|
+
|
3
|
+
describe Videojuicer::Asset do
|
4
|
+
before :all do
|
5
|
+
configure_test_settings
|
6
|
+
|
7
|
+
@klass = Videojuicer::Asset
|
8
|
+
@assets = @klass.types.map do |t|
|
9
|
+
4.of { t.gen } << t.gen(:friendly_name => "to_filter")
|
10
|
+
end.flatten
|
11
|
+
end
|
12
|
+
|
13
|
+
after :all do
|
14
|
+
@assets.each { |a| a.destroy }
|
15
|
+
end
|
16
|
+
|
17
|
+
describe "listing assets of all types" do
|
18
|
+
it "should list all assets" do
|
19
|
+
@assets = @klass.all
|
20
|
+
@assets.class.should == Videojuicer::Resource::Collection
|
21
|
+
@assets.total.should >= @assets.size
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should limit results" do
|
25
|
+
@assets = @klass.all(:limit => 5)
|
26
|
+
@assets.length.should == 5
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should paginate" do
|
30
|
+
@assets = @klass.all(:offset => 19, :limit => 10)
|
31
|
+
@assets.page_count.should > 2
|
32
|
+
@assets.page_number.should == 2
|
33
|
+
@assets.length.should == 10
|
34
|
+
end
|
35
|
+
|
36
|
+
it "should filter by friendly_name" do
|
37
|
+
@klass.all("friendly_name.like" => "to_filter").total.should == @klass.types.size
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
data/vj-sdk.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{vj-sdk}
|
8
|
-
s.version = "0.7.
|
8
|
+
s.version = "0.7.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["danski", "thejohnny", "knowtheory", "sixones", "btab", "lamp"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-01-10}
|
13
13
|
s.email = %q{dan@videojuicer.com}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE",
|
@@ -28,7 +28,7 @@ Gem::Specification.new do |s|
|
|
28
28
|
"lib/core_ext/object.rb",
|
29
29
|
"lib/core_ext/string.rb",
|
30
30
|
"lib/videojuicer.rb",
|
31
|
-
"lib/videojuicer/asset
|
31
|
+
"lib/videojuicer/asset.rb",
|
32
32
|
"lib/videojuicer/asset/audio.rb",
|
33
33
|
"lib/videojuicer/asset/base.rb",
|
34
34
|
"lib/videojuicer/asset/document.rb",
|
@@ -62,7 +62,7 @@ Gem::Specification.new do |s|
|
|
62
62
|
"lib/videojuicer/shared/exceptions.rb",
|
63
63
|
"lib/videojuicer/shared/liquid_helper.rb",
|
64
64
|
"lib/videojuicer/user.rb",
|
65
|
-
"spec/
|
65
|
+
"spec/asset_spec.rb",
|
66
66
|
"spec/assets/audio_spec.rb",
|
67
67
|
"spec/assets/document_spec.rb",
|
68
68
|
"spec/assets/flash_spec.rb",
|
@@ -111,7 +111,7 @@ Gem::Specification.new do |s|
|
|
111
111
|
s.rubygems_version = %q{1.3.7}
|
112
112
|
s.summary = %q{Videojuicer core-sdk}
|
113
113
|
s.test_files = [
|
114
|
-
"spec/
|
114
|
+
"spec/asset_spec.rb",
|
115
115
|
"spec/assets/audio_spec.rb",
|
116
116
|
"spec/assets/document_spec.rb",
|
117
117
|
"spec/assets/flash_spec.rb",
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vj-sdk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 1
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 1
|
10
|
+
version: 0.7.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- danski
|
@@ -20,7 +20,7 @@ autorequire:
|
|
20
20
|
bindir: bin
|
21
21
|
cert_chain: []
|
22
22
|
|
23
|
-
date:
|
23
|
+
date: 2011-01-10 00:00:00 +00:00
|
24
24
|
default_executable:
|
25
25
|
dependencies:
|
26
26
|
- !ruby/object:Gem::Dependency
|
@@ -108,7 +108,7 @@ files:
|
|
108
108
|
- lib/core_ext/object.rb
|
109
109
|
- lib/core_ext/string.rb
|
110
110
|
- lib/videojuicer.rb
|
111
|
-
- lib/videojuicer/asset
|
111
|
+
- lib/videojuicer/asset.rb
|
112
112
|
- lib/videojuicer/asset/audio.rb
|
113
113
|
- lib/videojuicer/asset/base.rb
|
114
114
|
- lib/videojuicer/asset/document.rb
|
@@ -142,7 +142,7 @@ files:
|
|
142
142
|
- lib/videojuicer/shared/exceptions.rb
|
143
143
|
- lib/videojuicer/shared/liquid_helper.rb
|
144
144
|
- lib/videojuicer/user.rb
|
145
|
-
- spec/
|
145
|
+
- spec/asset_spec.rb
|
146
146
|
- spec/assets/audio_spec.rb
|
147
147
|
- spec/assets/document_spec.rb
|
148
148
|
- spec/assets/flash_spec.rb
|
@@ -219,7 +219,7 @@ signing_key:
|
|
219
219
|
specification_version: 3
|
220
220
|
summary: Videojuicer core-sdk
|
221
221
|
test_files:
|
222
|
-
- spec/
|
222
|
+
- spec/asset_spec.rb
|
223
223
|
- spec/assets/audio_spec.rb
|
224
224
|
- spec/assets/document_spec.rb
|
225
225
|
- spec/assets/flash_spec.rb
|
@@ -1,45 +0,0 @@
|
|
1
|
-
module Videojuicer
|
2
|
-
module Asset
|
3
|
-
class All
|
4
|
-
|
5
|
-
include Videojuicer::Resource
|
6
|
-
include Videojuicer::Exceptions
|
7
|
-
|
8
|
-
property :name, String
|
9
|
-
property :friendly_name, String
|
10
|
-
property :type, String
|
11
|
-
property :http_url, String
|
12
|
-
property :created_at, DateTime
|
13
|
-
property :updated_at, DateTime
|
14
|
-
|
15
|
-
def self.singular_name
|
16
|
-
"asset"
|
17
|
-
end
|
18
|
-
|
19
|
-
def self.base_path(options={})
|
20
|
-
"/assets"
|
21
|
-
end
|
22
|
-
|
23
|
-
def derive(preset)
|
24
|
-
response = proxy_for(config).post(resource_path, :preset_id => preset.id)
|
25
|
-
self.class.new(JSON.parse(response.body))
|
26
|
-
end
|
27
|
-
|
28
|
-
def returnable_attributes
|
29
|
-
attrs = super
|
30
|
-
attrs.delete(:file) unless new_record?
|
31
|
-
attrs
|
32
|
-
end
|
33
|
-
|
34
|
-
def set_derived(from_asset, preset)
|
35
|
-
params = {
|
36
|
-
:original_asset_type => from_asset.class.to_s.split("::").last,
|
37
|
-
:original_asset_id => from_asset.id,
|
38
|
-
:preset_id => preset.id
|
39
|
-
}
|
40
|
-
response = proxy_for(config).post(resource_path(:set_derived), params)
|
41
|
-
self.attributes = JSON.parse(response.body)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
data/spec/assets/all.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "..", "helpers", "spec_helper")
|
2
|
-
|
3
|
-
describe Videojuicer::Asset::All do
|
4
|
-
|
5
|
-
before :all do
|
6
|
-
configure_test_settings
|
7
|
-
5.of do
|
8
|
-
Videojuicer::Asset::Video.gen :friendly_name => "test"
|
9
|
-
end
|
10
|
-
@klass = Videojuicer::Asset::All
|
11
|
-
end
|
12
|
-
|
13
|
-
describe "instantiation" do
|
14
|
-
it_should_behave_like "a configurable"
|
15
|
-
end
|
16
|
-
|
17
|
-
describe "listing assets of all types" do
|
18
|
-
|
19
|
-
it "should list assets" do
|
20
|
-
@assets = @klass.all
|
21
|
-
@assets.should_not == nil
|
22
|
-
@assets.class.should == Videojuicer::Resource::Collection
|
23
|
-
end
|
24
|
-
|
25
|
-
it "should paginate" do
|
26
|
-
@assets = @klass.all :page => 1, :limit => 5
|
27
|
-
@assets.length.should == 5
|
28
|
-
end
|
29
|
-
|
30
|
-
end
|
31
|
-
|
32
|
-
describe "searching" do
|
33
|
-
it "should search" do
|
34
|
-
@assets = @klass.all({"friendly_name.like" => "test"})
|
35
|
-
@assets.should_not == nil
|
36
|
-
@assets.class.should == Videojuicer::Resource::Collection
|
37
|
-
@assets.first.friendly_name.should =~ /test/
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|