fb_graph 1.7.4 → 1.7.5

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fb_graph (1.7.3)
4
+ fb_graph (1.7.4)
5
5
  rack-oauth2 (>= 0.6.5)
6
6
 
7
7
  GEM
@@ -16,7 +16,7 @@ GEM
16
16
  json (1.5.1)
17
17
  mime-types (1.16)
18
18
  rack (1.2.2)
19
- rack-oauth2 (0.6.6)
19
+ rack-oauth2 (0.6.9)
20
20
  activesupport (>= 2.3)
21
21
  attr_required (>= 0.0.3)
22
22
  i18n
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.7.4
1
+ 1.7.5
@@ -3,6 +3,7 @@ module FbGraph
3
3
  include Connections::Photos
4
4
  include Connections::Comments
5
5
  include Connections::Likes
6
+ include Connections::Picture
6
7
 
7
8
  attr_accessor :from, :name, :description, :location, :link, :privacy, :count, :created_time, :updated_time, :type
8
9
 
@@ -38,5 +39,13 @@ module FbGraph
38
39
  # cached connection
39
40
  @_comments_ = Collection.new(attributes[:comments])
40
41
  end
42
+
43
+ def picture_with_access_token(size = nil)
44
+ raise Unauthorized.new('Album picture connection requires an access token') unless self.access_token
45
+ _endpoint_ = URI.parse picture_without_access_token(size)
46
+ _endpoint_.query = [_endpoint_.query, {:access_token => self.access_token.to_s}.to_query].compact.join('&')
47
+ _endpoint_.to_s
48
+ end
49
+ alias_method_chain :picture, :access_token
41
50
  end
42
51
  end
@@ -4,10 +4,9 @@ module FbGraph
4
4
  def picture(size = nil)
5
5
  _endpoint_ = "#{self.endpoint}/picture"
6
6
  if size
7
- "#{_endpoint_}?type=#{size}"
8
- else
9
- _endpoint_
7
+ _endpoint_ += "?type=#{size}"
10
8
  end
9
+ _endpoint_
11
10
  end
12
11
  end
13
12
  end
@@ -1,63 +1,84 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe FbGraph::Album, '.new' do
3
+ describe FbGraph::Album do
4
4
 
5
- it 'should setup all supported attributes' do
6
- attributes = {
7
- :id => '12345',
8
- :from => {
9
- :id => '23456',
10
- :name => 'nov matake'
11
- },
12
- :name => 'album 1',
13
- :description => 'an album for fb_graph test',
14
- :location => 'Tokyo, Japan',
15
- :link => 'http://www.facebook.com/album/12345',
16
- :count => 10,
17
- :type => 'normal',
18
- :created_time => '2009-12-29T15:24:50+0000',
19
- :updated_time => '2010-01-02T15:37:41+0000',
20
- :comments => {
21
- :data => [{
22
- :id => '909694472945_418735',
23
- :from => {
24
- :id => '520739622',
25
- :name => 'Alison Marie Weber',
26
- },
27
- :message => 'Love all the pix!',
28
- :created_time => '2009-08-15T14:57:36+0000'
29
- }]
5
+ describe '.new' do
6
+ it 'should setup all supported attributes' do
7
+ attributes = {
8
+ :id => '12345',
9
+ :from => {
10
+ :id => '23456',
11
+ :name => 'nov matake'
12
+ },
13
+ :name => 'album 1',
14
+ :description => 'an album for fb_graph test',
15
+ :location => 'Tokyo, Japan',
16
+ :link => 'http://www.facebook.com/album/12345',
17
+ :count => 10,
18
+ :type => 'normal',
19
+ :created_time => '2009-12-29T15:24:50+0000',
20
+ :updated_time => '2010-01-02T15:37:41+0000',
21
+ :comments => {
22
+ :data => [{
23
+ :id => '909694472945_418735',
24
+ :from => {
25
+ :id => '520739622',
26
+ :name => 'Alison Marie Weber',
27
+ },
28
+ :message => 'Love all the pix!',
29
+ :created_time => '2009-08-15T14:57:36+0000'
30
+ }]
31
+ }
30
32
  }
31
- }
32
- album = FbGraph::Album.new(attributes.delete(:id), attributes)
33
- album.identifier.should == '12345'
34
- album.from.should == FbGraph::User.new('23456', :name => 'nov matake')
35
- album.name.should == 'album 1'
36
- album.description.should == 'an album for fb_graph test'
37
- album.location.should == 'Tokyo, Japan'
38
- album.link.should == 'http://www.facebook.com/album/12345'
39
- album.count.should == 10
40
- album.type.should == 'normal'
41
- album.created_time.should == Time.parse('2009-12-29T15:24:50+0000')
42
- album.updated_time.should == Time.parse('2010-01-02T15:37:41+0000')
43
- album.comments.should == [FbGraph::Comment.new(
44
- '909694472945_418735',
45
- :from => {
46
- :id => '520739622',
47
- :name => 'Alison Marie Weber',
48
- },
49
- :message => 'Love all the pix!',
50
- :created_time => '2009-08-15T14:57:36+0000'
51
- )]
33
+ album = FbGraph::Album.new(attributes.delete(:id), attributes)
34
+ album.identifier.should == '12345'
35
+ album.from.should == FbGraph::User.new('23456', :name => 'nov matake')
36
+ album.name.should == 'album 1'
37
+ album.description.should == 'an album for fb_graph test'
38
+ album.location.should == 'Tokyo, Japan'
39
+ album.link.should == 'http://www.facebook.com/album/12345'
40
+ album.count.should == 10
41
+ album.type.should == 'normal'
42
+ album.created_time.should == Time.parse('2009-12-29T15:24:50+0000')
43
+ album.updated_time.should == Time.parse('2010-01-02T15:37:41+0000')
44
+ album.comments.should == [FbGraph::Comment.new(
45
+ '909694472945_418735',
46
+ :from => {
47
+ :id => '520739622',
48
+ :name => 'Alison Marie Weber',
49
+ },
50
+ :message => 'Love all the pix!',
51
+ :created_time => '2009-08-15T14:57:36+0000'
52
+ )]
53
+ end
54
+
55
+ it 'should support page as from' do
56
+ page_album = FbGraph::Album.new('12345', :from => {
57
+ :id => '23456',
58
+ :name => 'Smart.fm',
59
+ :category => 'Web Site'
60
+ })
61
+ page_album.from.should == FbGraph::Page.new('23456', :name => 'Smart.fm', :category => 'Web Site')
62
+ end
52
63
  end
53
64
 
54
- it 'should support page as from' do
55
- page_album = FbGraph::Album.new('12345', :from => {
56
- :id => '23456',
57
- :name => 'Smart.fm',
58
- :category => 'Web Site'
59
- })
60
- page_album.from.should == FbGraph::Page.new('23456', :name => 'Smart.fm', :category => 'Web Site')
65
+ describe '#picture' do
66
+ let(:album) { FbGraph::Album.new('12345') }
67
+ subject { album }
68
+
69
+ context 'when access token is given' do
70
+ before { album.access_token = 'access_token' }
71
+ its(:picture) { should == File.join(FbGraph::ROOT_URL, '12345/picture?access_token=access_token') }
72
+ it 'should support size' do
73
+ album.picture(:small).should == File.join(FbGraph::ROOT_URL, '12345/picture?type=small&access_token=access_token')
74
+ end
75
+ end
76
+
77
+ context 'otherwise' do
78
+ it do
79
+ expect { album.picture }.should raise_error(FbGraph::Unauthorized)
80
+ end
81
+ end
61
82
  end
62
83
 
63
84
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: fb_graph
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.7.4
5
+ version: 1.7.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - nov matake
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-09 00:00:00 Z
13
+ date: 2011-05-11 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rack-oauth2