vj-sdk 0.5.6 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile CHANGED
@@ -2,7 +2,7 @@ source :gemcutter
2
2
 
3
3
  # http://github.com/carlhuda/bundler/issues/#issue/107
4
4
  # - do not change unless lib/bundler_runtime_patch tested / defunct
5
- gem "bundler", "0.9.10"
5
+ gem "bundler", "0.9.26"
6
6
 
7
7
  def gems(names, version)
8
8
  names.each { |n| gem(n, version) }
@@ -15,4 +15,5 @@ gem "rake", ">= 0.8.7"
15
15
  gem "rspec", ">= 1.3.0"
16
16
  gem "mash"
17
17
  gem "randexp"
18
- gem "ruby-hmac"
18
+ gem "ruby-hmac"
19
+ gem "liquid", "2.0.0"
data/Rakefile CHANGED
@@ -19,6 +19,7 @@ begin
19
19
  gem.add_dependency "json", ">= 1.0"
20
20
  gem.add_dependency "ruby-hmac", ">= 0.3.2"
21
21
  gem.add_dependency "mash", ">= 0.0.3"
22
+ gem.add_dependency "liquid", "2.0.0"
22
23
  end
23
24
  rescue LoadError
24
25
  puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- :patch: 6
3
- :build:
4
2
  :major: 0
5
- :minor: 5
3
+ :minor: 6
4
+ :patch: 0
5
+ :build:
data/lib/videojuicer.rb CHANGED
@@ -6,6 +6,7 @@ require 'cgi'
6
6
  require 'json'
7
7
  require 'hmac-sha1'
8
8
  require 'net/http'
9
+ require 'liquid'
9
10
 
10
11
  # Core ext
11
12
  require 'core_ext/hash'
@@ -15,6 +16,7 @@ require 'core_ext/cgi'
15
16
  # Core mixins
16
17
  require 'videojuicer/shared/exceptions'
17
18
  require 'videojuicer/shared/configurable'
19
+ require 'videojuicer/shared/liquid_helper'
18
20
  # Authentication and authorisation
19
21
  require 'videojuicer/oauth/request_proxy'
20
22
  require 'videojuicer/oauth/proxy_factory'
@@ -4,7 +4,6 @@ module Videojuicer
4
4
  include Videojuicer::Resource::Embeddable
5
5
  include Videojuicer::Exceptions
6
6
 
7
- property :slug, String
8
7
  property :title, String
9
8
  property :author, String
10
9
  property :author_url, String
@@ -30,10 +29,34 @@ module Videojuicer
30
29
 
31
30
  property :tag_list, String
32
31
 
32
+
33
+ @@asset_types = %w(video flash image document audio)
34
+
33
35
  def permalink
34
36
  proxy = proxy_for(config)
35
37
  "#{proxy.host_stub}/presentations/#{id}.html?seed_name=#{seed_name}".gsub(":80/","/")
36
38
  end
37
-
39
+
40
+ def asset_ids
41
+ Videojuicer::SDKLiquidHelper::Filters::AssetBlock.reset!
42
+ @@asset_types.each do |type|
43
+ Liquid::Template.register_tag type, Videojuicer::SDKLiquidHelper::Filters::AssetBlock
44
+ end
45
+ @template = Liquid::Template.parse(document_content)
46
+ @template.render
47
+ return Videojuicer::SDKLiquidHelper::Filters::AssetBlock.asset_ids
48
+ end
49
+
50
+ @@asset_types.each do |type|
51
+ sym_type = type.to_sym
52
+ define_method "#{type}_asset_ids" do
53
+ asset_ids[sym_type]
54
+ end
55
+ define_method "#{type}_assets" do
56
+ @assets ||= {}
57
+ @assets[sym_type] ||= Videojuicer::Asset.const_get(type.capitalize.to_sym).all :id => asset_ids[sym_type].join(',')
58
+ end
59
+ end
60
+
38
61
  end
39
62
  end
@@ -131,6 +131,8 @@ module Videojuicer
131
131
  # > "id.lt" => "9" #=> Returns only records with ID less than 9
132
132
  # > "id.gte" => "9" #=> Returns only records with ID greater than or equal to 9
133
133
  # > "id.lte" => "9" #=> Returns only records with ID less than or equal to than 9
134
+ # Range operations are also supported e.g.
135
+ # > :id => '1,2,3'
134
136
  def all(options={})
135
137
  # Get a proxy
136
138
  options = (options.empty?)? {} : {parameter_name=>options} # FIXME this is a hacky workaround for singleton scope.
@@ -0,0 +1,30 @@
1
+ module Videojuicer
2
+ module SDKLiquidHelper
3
+ module Filters
4
+
5
+ class AssetBlock < ::Liquid::Block
6
+
7
+ @@asset_ids = {}
8
+
9
+ def self.reset!
10
+ @@asset_ids = {}
11
+ end
12
+
13
+ def self.asset_ids
14
+ @@asset_ids.deep_symbolize
15
+ end
16
+
17
+ def initialize tag_name, args, tokens
18
+ @@asset_ids[tag_name] ||= []
19
+ @@asset_ids[tag_name] << tokens.to_s.gsub(/\{% id ([0-9]+){1,10} %\}.*/, "\\1").strip
20
+ super
21
+ end
22
+
23
+ def render; nil; end;
24
+
25
+ def unknown_tag tag_name, args, tokens; nil; end;
26
+
27
+ end#end class
28
+ end
29
+ end
30
+ end
@@ -10,6 +10,7 @@ module Videojuicer
10
10
  property :password_confirmation, String
11
11
  property :created_at, DateTime
12
12
  property :updated_at, DateTime
13
+ property :roles, Array, :writer => :readonly
13
14
 
14
15
  # Authenticates the given login and password and returns
15
16
  # a user if the details are correct. Requires a Master token.
@@ -21,5 +21,48 @@ describe Videojuicer::Presentation do
21
21
  it_should_behave_like "an embeddable"
22
22
  end
23
23
 
24
+ describe "fetching asset ids" do
25
+
26
+ before :each do
27
+ @presentation = @klass.gen
28
+ Videojuicer::Asset::Video.create :file_name => 'foo.mp4'
29
+ end
30
+
31
+ it "should fetch asset ids" do
32
+ @presentation.document_content = "{% video %}{% id 1 %}{% endvideo %}"
33
+ @presentation.asset_ids.should_not == nil
34
+ @presentation.asset_ids[:video].first.should == '1'
35
+ end
36
+
37
+ it "should fetch longer asset ids" do
38
+ @presentation.document_content = "{% video %}{% id 8003 %}{% endvideo %}"
39
+ @presentation.asset_ids.should_not == nil
40
+ @presentation.asset_ids[:video].first.should == '8003'
41
+ end
42
+
43
+ it "should deal with non-standard document_content" do
44
+ @presentation.document_content = "{% video %} {% id 200 %} {% endvideo %} {% audio %} {% id 122 %} {% endaudio %}"
45
+ @presentation.asset_ids.should_not == nil
46
+ @presentation.asset_ids[:video].first.should == '200'
47
+ @presentation.asset_ids[:audio].first.should == '122'
48
+ end
49
+
50
+ it "should deal with xml too" do
51
+ @presentation.document_content = '<seq><par>{% video %} {% id 200 %} {% endvideo %}{% image %} {% id 200 %} {% endimage %}</par><par>{% video %} {% id 200 %} {% endvideo %}</par></seq>'
52
+ @presentation.asset_ids.should_not == nil
53
+ @presentation.asset_ids[:video].first.should == '200'
54
+ @presentation.asset_ids[:image].first.should == '200'
55
+ end
56
+
57
+ it "should fetch assets too" do
58
+ @presentation.document_content = "{% video %}{% id 1 %}{% endvideo %}"
59
+ @presentation.asset_ids
60
+ @presentation.video_assets.first.should_not == nil
61
+ @presentation.video_assets.first.id.should == 1
62
+ end
63
+
64
+ end
65
+
66
+
24
67
 
25
68
  end
@@ -119,6 +119,7 @@ shared_examples_for "a RESTFUL resource model" do
119
119
  describe "an existing record" do
120
120
  before(:all) do
121
121
  @record = @klass.gen
122
+ @record.valid?.should be_true
122
123
  @record.save.should be_true
123
124
  end
124
125
 
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.5.6"
8
+ s.version = "0.6.0"
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"]
12
- s.date = %q{2010-07-08}
12
+ s.date = %q{2010-07-27}
13
13
  s.email = %q{dan@videojuicer.com}
14
14
  s.extra_rdoc_files = [
15
15
  "LICENSE",
@@ -60,6 +60,7 @@ Gem::Specification.new do |s|
60
60
  "lib/videojuicer/session.rb",
61
61
  "lib/videojuicer/shared/configurable.rb",
62
62
  "lib/videojuicer/shared/exceptions.rb",
63
+ "lib/videojuicer/shared/liquid_helper.rb",
63
64
  "lib/videojuicer/user.rb",
64
65
  "spec/assets/audio_spec.rb",
65
66
  "spec/assets/document_spec.rb",
@@ -107,7 +108,7 @@ Gem::Specification.new do |s|
107
108
  s.homepage = %q{http://github.com/videojuicer/vj-sdk}
108
109
  s.rdoc_options = ["--charset=UTF-8"]
109
110
  s.require_paths = ["lib"]
110
- s.rubygems_version = %q{1.3.6}
111
+ s.rubygems_version = %q{1.3.7}
111
112
  s.summary = %q{Videojuicer core-sdk}
112
113
  s.test_files = [
113
114
  "spec/assets/audio_spec.rb",
@@ -149,19 +150,22 @@ Gem::Specification.new do |s|
149
150
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
150
151
  s.specification_version = 3
151
152
 
152
- if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
153
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
153
154
  s.add_runtime_dependency(%q<json>, [">= 1.0"])
154
155
  s.add_runtime_dependency(%q<ruby-hmac>, [">= 0.3.2"])
155
156
  s.add_runtime_dependency(%q<mash>, [">= 0.0.3"])
157
+ s.add_runtime_dependency(%q<liquid>, ["= 2.0.0"])
156
158
  else
157
159
  s.add_dependency(%q<json>, [">= 1.0"])
158
160
  s.add_dependency(%q<ruby-hmac>, [">= 0.3.2"])
159
161
  s.add_dependency(%q<mash>, [">= 0.0.3"])
162
+ s.add_dependency(%q<liquid>, ["= 2.0.0"])
160
163
  end
161
164
  else
162
165
  s.add_dependency(%q<json>, [">= 1.0"])
163
166
  s.add_dependency(%q<ruby-hmac>, [">= 0.3.2"])
164
167
  s.add_dependency(%q<mash>, [">= 0.0.3"])
168
+ s.add_dependency(%q<liquid>, ["= 2.0.0"])
165
169
  end
166
170
  end
167
171
 
metadata CHANGED
@@ -1,12 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vj-sdk
3
3
  version: !ruby/object:Gem::Version
4
+ hash: 7
4
5
  prerelease: false
5
6
  segments:
6
7
  - 0
7
- - 5
8
8
  - 6
9
- version: 0.5.6
9
+ - 0
10
+ version: 0.6.0
10
11
  platform: ruby
11
12
  authors:
12
13
  - danski
@@ -18,50 +19,72 @@ autorequire:
18
19
  bindir: bin
19
20
  cert_chain: []
20
21
 
21
- date: 2010-07-08 00:00:00 +01:00
22
+ date: 2010-07-27 00:00:00 +01:00
22
23
  default_executable:
23
24
  dependencies:
24
25
  - !ruby/object:Gem::Dependency
25
- name: json
26
26
  prerelease: false
27
- requirement: &id001 !ruby/object:Gem::Requirement
27
+ version_requirements: &id001 !ruby/object:Gem::Requirement
28
+ none: false
28
29
  requirements:
29
30
  - - ">="
30
31
  - !ruby/object:Gem::Version
32
+ hash: 15
31
33
  segments:
32
34
  - 1
33
35
  - 0
34
36
  version: "1.0"
37
+ name: json
38
+ requirement: *id001
35
39
  type: :runtime
36
- version_requirements: *id001
37
40
  - !ruby/object:Gem::Dependency
38
- name: ruby-hmac
39
41
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
42
+ version_requirements: &id002 !ruby/object:Gem::Requirement
43
+ none: false
41
44
  requirements:
42
45
  - - ">="
43
46
  - !ruby/object:Gem::Version
47
+ hash: 23
44
48
  segments:
45
49
  - 0
46
50
  - 3
47
51
  - 2
48
52
  version: 0.3.2
53
+ name: ruby-hmac
54
+ requirement: *id002
49
55
  type: :runtime
50
- version_requirements: *id002
51
56
  - !ruby/object:Gem::Dependency
52
- name: mash
53
57
  prerelease: false
54
- requirement: &id003 !ruby/object:Gem::Requirement
58
+ version_requirements: &id003 !ruby/object:Gem::Requirement
59
+ none: false
55
60
  requirements:
56
61
  - - ">="
57
62
  - !ruby/object:Gem::Version
63
+ hash: 25
58
64
  segments:
59
65
  - 0
60
66
  - 0
61
67
  - 3
62
68
  version: 0.0.3
69
+ name: mash
70
+ requirement: *id003
71
+ type: :runtime
72
+ - !ruby/object:Gem::Dependency
73
+ prerelease: false
74
+ version_requirements: &id004 !ruby/object:Gem::Requirement
75
+ none: false
76
+ requirements:
77
+ - - "="
78
+ - !ruby/object:Gem::Version
79
+ hash: 15
80
+ segments:
81
+ - 2
82
+ - 0
83
+ - 0
84
+ version: 2.0.0
85
+ name: liquid
86
+ requirement: *id004
63
87
  type: :runtime
64
- version_requirements: *id003
65
88
  description:
66
89
  email: dan@videojuicer.com
67
90
  executables: []
@@ -116,6 +139,7 @@ files:
116
139
  - lib/videojuicer/session.rb
117
140
  - lib/videojuicer/shared/configurable.rb
118
141
  - lib/videojuicer/shared/exceptions.rb
142
+ - lib/videojuicer/shared/liquid_helper.rb
119
143
  - lib/videojuicer/user.rb
120
144
  - spec/assets/audio_spec.rb
121
145
  - spec/assets/document_spec.rb
@@ -169,23 +193,27 @@ rdoc_options:
169
193
  require_paths:
170
194
  - lib
171
195
  required_ruby_version: !ruby/object:Gem::Requirement
196
+ none: false
172
197
  requirements:
173
198
  - - ">="
174
199
  - !ruby/object:Gem::Version
200
+ hash: 3
175
201
  segments:
176
202
  - 0
177
203
  version: "0"
178
204
  required_rubygems_version: !ruby/object:Gem::Requirement
205
+ none: false
179
206
  requirements:
180
207
  - - ">="
181
208
  - !ruby/object:Gem::Version
209
+ hash: 3
182
210
  segments:
183
211
  - 0
184
212
  version: "0"
185
213
  requirements: []
186
214
 
187
215
  rubyforge_project:
188
- rubygems_version: 1.3.6
216
+ rubygems_version: 1.3.7
189
217
  signing_key:
190
218
  specification_version: 3
191
219
  summary: Videojuicer core-sdk