fb_graph 1.0.2 → 1.0.3

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 CHANGED
@@ -1 +1 @@
1
- 1.0.2
1
+ 1.0.3
data/fb_graph.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{fb_graph}
8
- s.version = "1.0.2"
8
+ s.version = "1.0.3"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["nov matake"]
12
- s.date = %q{2010-09-13}
12
+ s.date = %q{2010-09-14}
13
13
  s.description = %q{A full-stack Facebook Graph API wrapper in Ruby.}
14
14
  s.email = %q{nov@matake.jp}
15
15
  s.extra_rdoc_files = [
@@ -1,10 +1,12 @@
1
1
  module FbGraph
2
2
  class Collection < Array
3
- attr_reader :previous, :next
3
+ attr_reader :previous, :next, :total_count
4
4
 
5
5
  def initialize(collection = nil)
6
- collection ||= {:data => []}
6
+ collection ||= {}
7
+ collection[:data] ||= []
7
8
  result = replace(collection[:data])
9
+ @total_count = collection[:count]
8
10
  @previous, @next = {}, {}
9
11
  if (paging = collection[:paging])
10
12
  if paging[:previous]
@@ -6,9 +6,31 @@ describe FbGraph::Collection, '.new' do
6
6
  end
7
7
 
8
8
  it 'should return an array with pagination info' do
9
- statuses = FbGraph::Page.new('platform', :access_token => 'access_token').statuses.collection
10
- statuses.should be_kind_of(Array)
11
- statuses.previous.should be_kind_of(Hash)
12
- statuses.next.should be_kind_of(Hash)
9
+ collection = FbGraph::Page.new('platform', :access_token => 'access_token').statuses.collection
10
+ collection.should be_kind_of(Array)
11
+ collection.previous.should be_kind_of(Hash)
12
+ collection.next.should be_kind_of(Hash)
13
+ end
14
+
15
+ it 'should allow blank data' do
16
+ patterns = [
17
+ FbGraph::Collection.new,
18
+ FbGraph::Collection.new({}),
19
+ FbGraph::Collection.new({:count => 5}),
20
+ FbGraph::Collection.new(nil)
21
+ ]
22
+ patterns.each do |collection|
23
+ collection.should be_kind_of(Array)
24
+ collection.previous.should be_kind_of(Hash)
25
+ collection.next.should be_kind_of(Hash)
26
+ collection.should be_blank
27
+ collection.previous.should be_blank
28
+ collection.next.should be_blank
29
+ end
30
+ end
31
+
32
+ it 'should fetch count as total_count' do
33
+ collection = FbGraph::Collection.new({:count => 5})
34
+ collection.total_count.should == 5
13
35
  end
14
36
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fb_graph
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 2
10
- version: 1.0.2
9
+ - 3
10
+ version: 1.0.3
11
11
  platform: ruby
12
12
  authors:
13
13
  - nov matake
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-09-13 00:00:00 +09:00
18
+ date: 2010-09-14 00:00:00 +09:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency