vj-sdk 0.7.1 → 0.7.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION.yml +2 -2
- data/lib/videojuicer/asset.rb +5 -0
- data/lib/videojuicer/resource/collection.rb +5 -0
- data/spec/asset_spec.rb +1 -1
- data/spec/collection_spec.rb +11 -0
- data/vj-sdk.gemspec +2 -2
- metadata +4 -4
data/VERSION.yml
CHANGED
data/lib/videojuicer/asset.rb
CHANGED
@@ -2,6 +2,11 @@ module Videojuicer
|
|
2
2
|
module Asset
|
3
3
|
def self.all(options = {})
|
4
4
|
proxy = Videojuicer::OAuth::RequestProxy.new(Videojuicer.current_scope)
|
5
|
+
|
6
|
+
if options[:page]
|
7
|
+
options[:offset] = Videojuicer::Resource::Collection.limit_from_page_number options.delete(:page), options[:limit]
|
8
|
+
end
|
9
|
+
|
5
10
|
response = proxy.get("/assets", "asset" => options)
|
6
11
|
items, count, offset, limit = JSON.parse(response.body).values_at("items", "count", "offset", "limit")
|
7
12
|
assets = items.map { |i| const_get(i.delete("type").capitalize).new(i) }
|
@@ -21,6 +21,11 @@ module Videojuicer
|
|
21
21
|
self.limit = limit
|
22
22
|
end
|
23
23
|
|
24
|
+
def self.limit_from_page_number page, limit
|
25
|
+
return 0 if page == 1
|
26
|
+
(page - 1) * limit
|
27
|
+
end
|
28
|
+
|
24
29
|
def page_count
|
25
30
|
return 1 if limit.nil? or total.nil? or total < 1
|
26
31
|
(total.to_f/limit.to_f).ceil
|
data/spec/asset_spec.rb
CHANGED
@@ -27,7 +27,7 @@ describe Videojuicer::Asset do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
it "should paginate" do
|
30
|
-
@assets = @klass.all(:
|
30
|
+
@assets = @klass.all(:limit => 10, :page => 2)
|
31
31
|
@assets.page_count.should > 2
|
32
32
|
@assets.page_number.should == 2
|
33
33
|
@assets.length.should == 10
|
data/spec/collection_spec.rb
CHANGED
@@ -38,4 +38,15 @@ describe Videojuicer::Resource::Collection do
|
|
38
38
|
collection.page_number.should == 1
|
39
39
|
end
|
40
40
|
|
41
|
+
it "provides a correct offset for a page number and limit when the page is 1" do
|
42
|
+
offset = Videojuicer::Resource::Collection.limit_from_page_number 1, 20
|
43
|
+
offset.should == 0
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should provide a correct offset" do
|
47
|
+
offset = Videojuicer::Resource::Collection.limit_from_page_number 2, 20
|
48
|
+
offset.should == 20
|
49
|
+
end
|
50
|
+
|
51
|
+
|
41
52
|
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.2"
|
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{2011-01-
|
12
|
+
s.date = %q{2011-01-11}
|
13
13
|
s.email = %q{dan@videojuicer.com}
|
14
14
|
s.extra_rdoc_files = [
|
15
15
|
"LICENSE",
|
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: 7
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
version: 0.7.
|
9
|
+
- 2
|
10
|
+
version: 0.7.2
|
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: 2011-01-
|
23
|
+
date: 2011-01-11 00:00:00 +00:00
|
24
24
|
default_executable:
|
25
25
|
dependencies:
|
26
26
|
- !ruby/object:Gem::Dependency
|