rest-graph 1.8.0 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitmodules +3 -0
- data/CHANGES +31 -0
- data/CONTRIBUTORS +4 -3
- data/README +24 -20
- data/README.md +24 -20
- data/TODO +0 -1
- data/doc/heroku-facebook.md +186 -0
- data/doc/tutorial.md +4 -0
- data/example/rails3/Gemfile +1 -1
- data/example/sinatra/config.ru +16 -0
- data/lib/rest-graph/core.rb +71 -57
- data/lib/rest-graph/rails_util.rb +4 -2
- data/lib/rest-graph/test_util.rb +13 -7
- data/lib/rest-graph/version.rb +1 -1
- data/rest-graph.gemspec +122 -11
- data/task/gemgem.rb +13 -2
- data/test/test_api.rb +13 -1
- data/test/test_cache.rb +3 -2
- data/test/test_misc.rb +5 -18
- data/test/test_old.rb +32 -0
- data/test/test_serialize.rb +5 -0
- data/test/test_test_util.rb +12 -0
- data/test/test_timeout.rb +5 -0
- metadata +27 -30
- data/lib/rest-graph/auto_load.rb +0 -4
- data/lib/rest-graph/autoload.rb +0 -4
data/task/gemgem.rb
CHANGED
@@ -11,7 +11,7 @@ module Gemgem
|
|
11
11
|
yield(spec = Gem::Specification.new{ |s|
|
12
12
|
s.authors = ['Lin Jen-Shin (godfat)']
|
13
13
|
s.email = ['godfat (XD) godfat.org']
|
14
|
-
s.homepage = "
|
14
|
+
s.homepage = "https://github.com/godfat/#{s.name}"
|
15
15
|
|
16
16
|
s.summary = File.read("#{Gemgem.dir}/README").
|
17
17
|
match(/DESCRIPTION:\n\n(.+?)\n\n/m)[1]
|
@@ -33,7 +33,18 @@ module Gemgem
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def write
|
36
|
-
File.open("#{dir}/#{spec.name}.gemspec", 'w'){ |f|
|
36
|
+
File.open("#{dir}/#{spec.name}.gemspec", 'w'){ |f|
|
37
|
+
f << split_lines(spec.to_ruby) }
|
38
|
+
end
|
39
|
+
|
40
|
+
def split_lines ruby
|
41
|
+
ruby.gsub(/(.+?)\[(.+?)\]/){ |s|
|
42
|
+
if $2.index(',')
|
43
|
+
"#{$1}[\n #{$2.split(',').map(&:strip).join(",\n ")}]"
|
44
|
+
else
|
45
|
+
s
|
46
|
+
end
|
47
|
+
}
|
37
48
|
end
|
38
49
|
|
39
50
|
def all_files
|
data/test/test_api.rb
CHANGED
@@ -47,6 +47,18 @@ describe RestGraph do
|
|
47
47
|
RestGraph.new.request({:headers => {'X-Forwarded-For' => '127.0.0.1'}},
|
48
48
|
[:get, 'http://example.com']).
|
49
49
|
should == {'data' => []}
|
50
|
+
|
51
|
+
EM.run{
|
52
|
+
RestGraph.new.request({:headers => {'X-Forwarded-For' => '127.0.0.1',
|
53
|
+
'User-Agent' => 'Ruby',
|
54
|
+
'Accept-Encoding' =>
|
55
|
+
'gzip, deflate'},
|
56
|
+
:async => true},
|
57
|
+
[:get, 'http://example.com']){ |result|
|
58
|
+
result.should == {'data' => []}
|
59
|
+
EM.stop
|
60
|
+
}
|
61
|
+
}
|
50
62
|
end
|
51
63
|
|
52
64
|
should 'post right' do
|
@@ -83,7 +95,7 @@ describe RestGraph do
|
|
83
95
|
stub_request(:put, url).
|
84
96
|
with(:body => 'message=hi%20there').to_return(:body => '[]')
|
85
97
|
|
86
|
-
mock.proxy(rg = RestGraph.new).post_request(
|
98
|
+
mock.proxy(rg = RestGraph.new).post_request({}, url, '[]')
|
87
99
|
rg.put('feed/me', :message => 'hi there').
|
88
100
|
should == []
|
89
101
|
end
|
data/test/test_cache.rb
CHANGED
@@ -21,12 +21,13 @@ describe RestGraph do
|
|
21
21
|
|
22
22
|
should 'enable cache if passing cache' do
|
23
23
|
3.times{ @rg.get('cache').should == @body }
|
24
|
-
@cache.should == {@rg.send(:cache_key, @url) => @body}
|
24
|
+
@cache.should == {@rg.send(:cache_key, {}, @url) => @body}
|
25
25
|
end
|
26
26
|
|
27
27
|
should 'respect expires_in' do
|
28
28
|
mock(@cache).method(:store){ mock!.arity{ -3 } }
|
29
|
-
mock(@cache).store(@rg.send(:cache_key, @url), @body,
|
29
|
+
mock(@cache).store(@rg.send(:cache_key, {}, @url), @body,
|
30
|
+
:expires_in => 3)
|
30
31
|
@rg.get('cache', {}, :expires_in => 3).should == @body
|
31
32
|
end
|
32
33
|
|
data/test/test_misc.rb
CHANGED
@@ -54,29 +54,16 @@ describe RestGraph do
|
|
54
54
|
|
55
55
|
should 'auto decode json' do
|
56
56
|
RestGraph.new(:auto_decode => true).
|
57
|
-
send(:post_request, '
|
57
|
+
send(:post_request, {}, '', '[]').should == []
|
58
58
|
end
|
59
59
|
|
60
60
|
should 'not auto decode json' do
|
61
61
|
RestGraph.new(:auto_decode => false).
|
62
|
-
send(:post_request, '
|
62
|
+
send(:post_request, {}, '', '[]').should == '[]'
|
63
63
|
end
|
64
64
|
|
65
|
-
should 'give
|
66
|
-
RestGraph.new(:auto_decode => false).
|
67
|
-
|
68
|
-
' strict=false,' \
|
69
|
-
' timeout=10,' \
|
70
|
-
' graph_server="https://graph.facebook.com/",' \
|
71
|
-
' old_server="https://api.facebook.com/",' \
|
72
|
-
' accept="text/javascript",' \
|
73
|
-
' lang="en-us",' \
|
74
|
-
' app_id=nil,' \
|
75
|
-
' secret=nil,' \
|
76
|
-
' data=\{\},' \
|
77
|
-
' cache=nil,' \
|
78
|
-
' log_method=nil,' \
|
79
|
-
' log_handler=nil,' \
|
80
|
-
' error_handler=#<Proc:.+>>')
|
65
|
+
should 'give attributes' do
|
66
|
+
RestGraph.new(:auto_decode => false).attributes.keys.map(&:to_s).sort.
|
67
|
+
should == RestGraphStruct.members.map(&:to_s).sort
|
81
68
|
end
|
82
69
|
end
|
data/test/test_old.rb
CHANGED
@@ -48,6 +48,38 @@ describe RestGraph do
|
|
48
48
|
RestGraph.new.fql_multi(:f0 => f0, :f1 => f1).should == []
|
49
49
|
end
|
50
50
|
|
51
|
+
should 'cache fake post in fql' do
|
52
|
+
query = 'select name from user where uid = 4'
|
53
|
+
body = '[{"name":"Mark Zuckerberg"}]'
|
54
|
+
stub_request(:post,
|
55
|
+
'https://api.facebook.com/method/fql.query?format=json').
|
56
|
+
with(:body => {:query => query}).
|
57
|
+
to_return(:body => body)
|
58
|
+
|
59
|
+
RestGraph.new(:cache => (cache = {})).fql(query, {}, :post => true).
|
60
|
+
first['name'] .should == 'Mark Zuckerberg'
|
61
|
+
cache.size .should == 1
|
62
|
+
cache.values.first.should == body
|
63
|
+
|
64
|
+
WebMock.reset! # should hit the cache
|
65
|
+
|
66
|
+
RestGraph.new(:cache => cache).fql(query, {}, :post => true).
|
67
|
+
first['name'] .should == 'Mark Zuckerberg'
|
68
|
+
cache.size .should == 1
|
69
|
+
cache.values.first.should == body
|
70
|
+
|
71
|
+
# query changed
|
72
|
+
should.raise(WebMock::NetConnectNotAllowedError) do
|
73
|
+
RestGraph.new(:cache => cache).fql(query.upcase, {}, :post => true)
|
74
|
+
end
|
75
|
+
|
76
|
+
# cache should work for normal get
|
77
|
+
RestGraph.new(:cache => cache).fql(query).
|
78
|
+
first['name'] .should == 'Mark Zuckerberg'
|
79
|
+
cache.size .should == 1
|
80
|
+
cache.values.first.should == body
|
81
|
+
end
|
82
|
+
|
51
83
|
should 'do facebook old rest api' do
|
52
84
|
body = 'hate facebook inconsistent'
|
53
85
|
stub_request(:get,
|
data/test/test_serialize.rb
CHANGED
@@ -32,4 +32,9 @@ describe RestGraph do
|
|
32
32
|
test[rg.lighten].should == rg
|
33
33
|
}
|
34
34
|
end
|
35
|
+
|
36
|
+
should 'lighten takes options to change attributes' do
|
37
|
+
RestGraph.new.lighten(:timeout => 100 ).timeout.should == 100
|
38
|
+
RestGraph.new.lighten(:lang => 'zh-TW').lang .should == 'zh-TW'
|
39
|
+
end
|
35
40
|
end
|
data/test/test_test_util.rb
CHANGED
@@ -71,4 +71,16 @@ describe RestGraph::TestUtil do
|
|
71
71
|
rg.authorized?.should == true
|
72
72
|
rg.get('me').should == RestGraph::TestUtil.user('1234')
|
73
73
|
end
|
74
|
+
|
75
|
+
should 'return correct response in fake get' do
|
76
|
+
RestGraph.new.fql('', {}, :post => true).
|
77
|
+
should == [RestGraph::TestUtil.default_response]
|
78
|
+
|
79
|
+
RestGraph.new.fql_multi({:a => '', :b => ''}, {}, :post => true).
|
80
|
+
sort_by{ |h| h['name'] }.
|
81
|
+
should == [{'name' => 'a',
|
82
|
+
'fql_result_set' => [RestGraph::TestUtil.default_response]},
|
83
|
+
{'name' => 'b',
|
84
|
+
'fql_result_set' => [RestGraph::TestUtil.default_response]}]
|
85
|
+
end
|
74
86
|
end
|
data/test/test_timeout.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest-graph
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,12 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2011-
|
14
|
-
default_executable:
|
13
|
+
date: 2011-05-26 00:00:00.000000000Z
|
15
14
|
dependencies:
|
16
15
|
- !ruby/object:Gem::Dependency
|
17
16
|
name: rest-client
|
18
|
-
requirement: &
|
17
|
+
requirement: &2153246120 !ruby/object:Gem::Requirement
|
19
18
|
none: false
|
20
19
|
requirements:
|
21
20
|
- - ! '>='
|
@@ -23,10 +22,10 @@ dependencies:
|
|
23
22
|
version: '0'
|
24
23
|
type: :development
|
25
24
|
prerelease: false
|
26
|
-
version_requirements: *
|
25
|
+
version_requirements: *2153246120
|
27
26
|
- !ruby/object:Gem::Dependency
|
28
27
|
name: em-http-request
|
29
|
-
requirement: &
|
28
|
+
requirement: &2153245560 !ruby/object:Gem::Requirement
|
30
29
|
none: false
|
31
30
|
requirements:
|
32
31
|
- - ! '>='
|
@@ -34,10 +33,10 @@ dependencies:
|
|
34
33
|
version: '0'
|
35
34
|
type: :development
|
36
35
|
prerelease: false
|
37
|
-
version_requirements: *
|
36
|
+
version_requirements: *2153245560
|
38
37
|
- !ruby/object:Gem::Dependency
|
39
38
|
name: rack
|
40
|
-
requirement: &
|
39
|
+
requirement: &2153235280 !ruby/object:Gem::Requirement
|
41
40
|
none: false
|
42
41
|
requirements:
|
43
42
|
- - ! '>='
|
@@ -45,10 +44,10 @@ dependencies:
|
|
45
44
|
version: '0'
|
46
45
|
type: :development
|
47
46
|
prerelease: false
|
48
|
-
version_requirements: *
|
47
|
+
version_requirements: *2153235280
|
49
48
|
- !ruby/object:Gem::Dependency
|
50
49
|
name: yajl-ruby
|
51
|
-
requirement: &
|
50
|
+
requirement: &2153234640 !ruby/object:Gem::Requirement
|
52
51
|
none: false
|
53
52
|
requirements:
|
54
53
|
- - ! '>='
|
@@ -56,10 +55,10 @@ dependencies:
|
|
56
55
|
version: '0'
|
57
56
|
type: :development
|
58
57
|
prerelease: false
|
59
|
-
version_requirements: *
|
58
|
+
version_requirements: *2153234640
|
60
59
|
- !ruby/object:Gem::Dependency
|
61
60
|
name: json
|
62
|
-
requirement: &
|
61
|
+
requirement: &2153233980 !ruby/object:Gem::Requirement
|
63
62
|
none: false
|
64
63
|
requirements:
|
65
64
|
- - ! '>='
|
@@ -67,10 +66,10 @@ dependencies:
|
|
67
66
|
version: '0'
|
68
67
|
type: :development
|
69
68
|
prerelease: false
|
70
|
-
version_requirements: *
|
69
|
+
version_requirements: *2153233980
|
71
70
|
- !ruby/object:Gem::Dependency
|
72
71
|
name: json_pure
|
73
|
-
requirement: &
|
72
|
+
requirement: &2153233340 !ruby/object:Gem::Requirement
|
74
73
|
none: false
|
75
74
|
requirements:
|
76
75
|
- - ! '>='
|
@@ -78,10 +77,10 @@ dependencies:
|
|
78
77
|
version: '0'
|
79
78
|
type: :development
|
80
79
|
prerelease: false
|
81
|
-
version_requirements: *
|
80
|
+
version_requirements: *2153233340
|
82
81
|
- !ruby/object:Gem::Dependency
|
83
82
|
name: ruby-hmac
|
84
|
-
requirement: &
|
83
|
+
requirement: &2153232560 !ruby/object:Gem::Requirement
|
85
84
|
none: false
|
86
85
|
requirements:
|
87
86
|
- - ! '>='
|
@@ -89,10 +88,10 @@ dependencies:
|
|
89
88
|
version: '0'
|
90
89
|
type: :development
|
91
90
|
prerelease: false
|
92
|
-
version_requirements: *
|
91
|
+
version_requirements: *2153232560
|
93
92
|
- !ruby/object:Gem::Dependency
|
94
93
|
name: webmock
|
95
|
-
requirement: &
|
94
|
+
requirement: &2153231940 !ruby/object:Gem::Requirement
|
96
95
|
none: false
|
97
96
|
requirements:
|
98
97
|
- - ! '>='
|
@@ -100,10 +99,10 @@ dependencies:
|
|
100
99
|
version: '0'
|
101
100
|
type: :development
|
102
101
|
prerelease: false
|
103
|
-
version_requirements: *
|
102
|
+
version_requirements: *2153231940
|
104
103
|
- !ruby/object:Gem::Dependency
|
105
104
|
name: bacon
|
106
|
-
requirement: &
|
105
|
+
requirement: &2153231260 !ruby/object:Gem::Requirement
|
107
106
|
none: false
|
108
107
|
requirements:
|
109
108
|
- - ! '>='
|
@@ -111,10 +110,10 @@ dependencies:
|
|
111
110
|
version: '0'
|
112
111
|
type: :development
|
113
112
|
prerelease: false
|
114
|
-
version_requirements: *
|
113
|
+
version_requirements: *2153231260
|
115
114
|
- !ruby/object:Gem::Dependency
|
116
115
|
name: rr
|
117
|
-
requirement: &
|
116
|
+
requirement: &2153230780 !ruby/object:Gem::Requirement
|
118
117
|
none: false
|
119
118
|
requirements:
|
120
119
|
- - ! '>='
|
@@ -122,7 +121,7 @@ dependencies:
|
|
122
121
|
version: '0'
|
123
122
|
type: :development
|
124
123
|
prerelease: false
|
125
|
-
version_requirements: *
|
124
|
+
version_requirements: *2153230780
|
126
125
|
description: A lightweight Facebook Graph API client
|
127
126
|
email:
|
128
127
|
- dev (XD) cardinalblue.com
|
@@ -135,6 +134,7 @@ extra_rdoc_files:
|
|
135
134
|
- TODO
|
136
135
|
files:
|
137
136
|
- .gitignore
|
137
|
+
- .gitmodules
|
138
138
|
- CHANGES
|
139
139
|
- CONTRIBUTORS
|
140
140
|
- Gemfile
|
@@ -146,13 +146,13 @@ files:
|
|
146
146
|
- doc/ToC.md
|
147
147
|
- doc/dependency.md
|
148
148
|
- doc/design.md
|
149
|
+
- doc/heroku-facebook.md
|
149
150
|
- doc/rails.md
|
150
151
|
- doc/test.md
|
151
152
|
- doc/tutorial.md
|
152
153
|
- example/multi/config.ru
|
153
154
|
- example/multi/rainbows.rb
|
154
155
|
- example/rails2/Gemfile
|
155
|
-
- example/rails2/Gemfile.lock
|
156
156
|
- example/rails2/README
|
157
157
|
- example/rails2/Rakefile
|
158
158
|
- example/rails2/app/controllers/application_controller.rb
|
@@ -173,7 +173,6 @@ files:
|
|
173
173
|
- example/rails2/test/test_helper.rb
|
174
174
|
- example/rails2/test/unit/rails_util_test.rb
|
175
175
|
- example/rails3/Gemfile
|
176
|
-
- example/rails3/Gemfile.lock
|
177
176
|
- example/rails3/Rakefile
|
178
177
|
- example/rails3/app/controllers/application_controller.rb
|
179
178
|
- example/rails3/app/views/application/helper.html.erb
|
@@ -190,10 +189,9 @@ files:
|
|
190
189
|
- example/rails3/test/functional/application_controller_test.rb
|
191
190
|
- example/rails3/test/test_helper.rb
|
192
191
|
- example/rails3/test/unit/rails_util_test.rb
|
192
|
+
- example/sinatra/config.ru
|
193
193
|
- init.rb
|
194
194
|
- lib/rest-graph.rb
|
195
|
-
- lib/rest-graph/auto_load.rb
|
196
|
-
- lib/rest-graph/autoload.rb
|
197
195
|
- lib/rest-graph/config_util.rb
|
198
196
|
- lib/rest-graph/core.rb
|
199
197
|
- lib/rest-graph/facebook_util.rb
|
@@ -221,8 +219,7 @@ files:
|
|
221
219
|
- test/test_serialize.rb
|
222
220
|
- test/test_test_util.rb
|
223
221
|
- test/test_timeout.rb
|
224
|
-
|
225
|
-
homepage: http://github.com/godfat/
|
222
|
+
homepage: https://github.com/godfat/
|
226
223
|
licenses: []
|
227
224
|
post_install_message:
|
228
225
|
rdoc_options:
|
@@ -244,7 +241,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
244
241
|
version: '0'
|
245
242
|
requirements: []
|
246
243
|
rubyforge_project:
|
247
|
-
rubygems_version: 1.
|
244
|
+
rubygems_version: 1.8.4
|
248
245
|
signing_key:
|
249
246
|
specification_version: 3
|
250
247
|
summary: A lightweight Facebook Graph API client
|
data/lib/rest-graph/auto_load.rb
DELETED
data/lib/rest-graph/autoload.rb
DELETED