fb_graph 1.9.1 → 1.9.2

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,29 +1,51 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fb_graph (1.9.0)
4
+ fb_graph (1.9.1)
5
5
  httpclient (>= 2.2.0.2)
6
6
  rack-oauth2 (>= 0.8.0)
7
7
 
8
8
  GEM
9
9
  remote: http://rubygems.org/
10
10
  specs:
11
+ abstract (1.0.0)
12
+ actionpack (3.0.9)
13
+ activemodel (= 3.0.9)
14
+ activesupport (= 3.0.9)
15
+ builder (~> 2.1.2)
16
+ erubis (~> 2.6.6)
17
+ i18n (~> 0.5.0)
18
+ rack (~> 1.2.1)
19
+ rack-mount (~> 0.6.14)
20
+ rack-test (~> 0.5.7)
21
+ tzinfo (~> 0.3.23)
22
+ activemodel (3.0.9)
23
+ activesupport (= 3.0.9)
24
+ builder (~> 2.1.2)
25
+ i18n (~> 0.5.0)
11
26
  activesupport (3.0.9)
12
27
  addressable (2.2.6)
13
28
  attr_required (0.0.3)
29
+ builder (2.1.2)
14
30
  crack (0.1.8)
15
31
  diff-lcs (1.1.2)
32
+ erubis (2.6.6)
33
+ abstract (>= 1.0.0)
16
34
  httpclient (2.2.1)
17
- i18n (0.6.0)
35
+ i18n (0.5.0)
18
36
  json (1.5.3)
19
- rack (1.3.0)
20
- rack-oauth2 (0.8.2)
37
+ rack (1.2.3)
38
+ rack-mount (0.6.14)
39
+ rack (>= 1.0.0)
40
+ rack-oauth2 (0.8.3)
21
41
  activesupport (>= 2.3)
22
42
  attr_required (>= 0.0.3)
23
43
  httpclient (>= 2.2.0.2)
24
44
  i18n
25
45
  json (>= 1.4.3)
26
46
  rack (>= 1.1)
47
+ rack-test (0.5.7)
48
+ rack (>= 1.0)
27
49
  rake (0.9.2)
28
50
  rcov (0.9.9)
29
51
  rspec (2.6.0)
@@ -34,6 +56,7 @@ GEM
34
56
  rspec-expectations (2.6.0)
35
57
  diff-lcs (~> 1.1.2)
36
58
  rspec-mocks (2.6.0)
59
+ tzinfo (0.3.29)
37
60
  webmock (1.6.4)
38
61
  addressable (> 2.2.5, ~> 2.2)
39
62
  crack (>= 0.1.7)
@@ -42,6 +65,7 @@ PLATFORMS
42
65
  ruby
43
66
 
44
67
  DEPENDENCIES
68
+ actionpack (>= 3.0.6)
45
69
  fb_graph!
46
70
  rake (>= 0.8)
47
71
  rcov (>= 0.9)
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.9.1
1
+ 1.9.2
data/fb_graph.gemspec CHANGED
@@ -18,4 +18,5 @@ Gem::Specification.new do |s|
18
18
  s.add_development_dependency "rcov", ">= 0.9"
19
19
  s.add_development_dependency "rspec", ">= 2"
20
20
  s.add_development_dependency "webmock", ">= 1.6.2"
21
+ s.add_development_dependency "actionpack", ">= 3.0.6"
21
22
  end
data/lib/fb_graph/node.rb CHANGED
@@ -70,10 +70,18 @@ module FbGraph
70
70
  v != false
71
71
  end
72
72
  _params_.each do |key, value|
73
- if value.present? && ![Symbol, String, Numeric, Rack::OAuth2::AccessToken::Legacy, IO].any? { |klass| value.is_a? klass }
74
- _params_[key] = value.to_json
75
- elsif [Symbol, Numeric, Rack::OAuth2::AccessToken::Legacy].any? { |klass| value.is_a? klass }
76
- _params_[key] = value.to_s
73
+ next if value.blank?
74
+ _params_[key] = case value
75
+ when Symbol, Numeric, Rack::OAuth2::AccessToken::Legacy
76
+ value.to_s
77
+ when String, IO
78
+ value
79
+ when defined?(ActionDispatch::Http::UploadedFile) && ActionDispatch::Http::UploadedFile
80
+ # NOTE: for Rails 3.0.6+
81
+ # ref) http://blog.livedoor.jp/idea_and_players/archives/5184702.html
82
+ value.tempfile
83
+ else
84
+ value.to_json
77
85
  end
78
86
  end
79
87
  _params_.blank? ? nil : _params_
@@ -13,9 +13,10 @@ describe FbGraph::Node do
13
13
  end
14
14
 
15
15
  describe '#build_params' do
16
+ let(:node) { node = FbGraph::Node.new('identifier') }
17
+
16
18
  it 'should make all values to JSON or String' do
17
19
  client = Rack::OAuth2::Client.new(:identifier => 'client_id', :secret => 'client_secret')
18
- node = FbGraph::Node.new('identifier')
19
20
  params = node.send :build_params, {:hash => {:a => :b}, :array => [:a, :b], :integer => 123}
20
21
  params[:hash].should == '{"a":"b"}'
21
22
  params[:array].should == '["a","b"]'
@@ -31,28 +32,36 @@ describe FbGraph::Node do
31
32
 
32
33
  it 'should support OAuth2::AccessToken as options[:access_token]' do
33
34
  client = Rack::OAuth2::Client.new(:identifier => 'client_id', :secret => 'client_secret')
34
- node = FbGraph::Node.new('identifier')
35
35
  params = node.send :build_params, {:access_token => Rack::OAuth2::AccessToken::Legacy.new(:access_token => 'token')}
36
36
  params[:access_token].should == 'token'
37
37
  end
38
- end
39
-
40
- end
41
38
 
42
- describe FbGraph::Node, '#handle_response' do
43
- it 'should handle null/false response' do
44
- node = FbGraph::Node.new('identifier')
45
- null_response = node.send :handle_response do
46
- HTTP::Message.new_response 'null'
39
+ require 'action_dispatch/http/upload'
40
+ it 'should support ActionDispatch::Http::UploadedFile' do
41
+ upload = ActionDispatch::Http::UploadedFile.new(
42
+ :tempfile => Tempfile.new('tmp')
43
+ )
44
+ params = node.send :build_params, :upload => upload
45
+ params[:upload].should be_a Tempfile
47
46
  end
48
- null_response.should be_nil
49
- lambda do
50
- node.send :handle_response do
51
- HTTP::Message.new_response 'false'
47
+ end
48
+
49
+ describe '#handle_response' do
50
+ it 'should handle null/false response' do
51
+ node = FbGraph::Node.new('identifier')
52
+ null_response = node.send :handle_response do
53
+ HTTP::Message.new_response 'null'
52
54
  end
53
- end.should raise_error(
54
- FbGraph::NotFound,
55
- 'Graph API returned false, so probably it means your requested object is not found.'
56
- )
55
+ null_response.should be_nil
56
+ lambda do
57
+ node.send :handle_response do
58
+ HTTP::Message.new_response 'false'
59
+ end
60
+ end.should raise_error(
61
+ FbGraph::NotFound,
62
+ 'Graph API returned false, so probably it means your requested object is not found.'
63
+ )
64
+ end
57
65
  end
66
+
58
67
  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: 49
4
+ hash: 55
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
8
  - 9
9
- - 1
10
- version: 1.9.1
9
+ - 2
10
+ version: 1.9.2
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: 2011-06-24 00:00:00 Z
18
+ date: 2011-07-04 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: httpclient
@@ -110,6 +110,22 @@ dependencies:
110
110
  version: 1.6.2
111
111
  type: :development
112
112
  version_requirements: *id006
113
+ - !ruby/object:Gem::Dependency
114
+ name: actionpack
115
+ prerelease: false
116
+ requirement: &id007 !ruby/object:Gem::Requirement
117
+ none: false
118
+ requirements:
119
+ - - ">="
120
+ - !ruby/object:Gem::Version
121
+ hash: 11
122
+ segments:
123
+ - 3
124
+ - 0
125
+ - 6
126
+ version: 3.0.6
127
+ type: :development
128
+ version_requirements: *id007
113
129
  description: A full-stack Facebook Graph API wrapper in Ruby.
114
130
  email: nov@matake.jp
115
131
  executables: []