rest-more 0.8.0 → 1.0.0
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/.travis.yml +4 -2
- data/CHANGES.md +54 -34
- data/Gemfile +3 -1
- data/README.md +187 -14
- data/Rakefile +1 -1
- data/TODO.md +2 -12
- data/doc/ToC.md +9 -0
- data/doc/dependency.md +4 -0
- data/doc/design.md +4 -0
- data/doc/rest-graph.md +4 -0
- data/doc/tutorial/facebook.md +173 -0
- data/example/async.rb +89 -0
- data/example/facebook.rb +13 -0
- data/example/multi.rb +28 -0
- data/example/rails3/Gemfile +1 -1
- data/example/rainbows.rb +40 -0
- data/example/simple.rb +8 -0
- data/lib/rest-core/client/bing.rb +15 -7
- data/lib/rest-core/client/dropbox.rb +104 -0
- data/lib/rest-core/client/facebook.rb +59 -15
- data/lib/rest-core/client/flurry.rb +11 -1
- data/lib/rest-core/client/github.rb +11 -1
- data/lib/rest-core/client/linkedin.rb +10 -6
- data/lib/rest-core/client/twitter.rb +18 -9
- data/lib/rest-core/util/config.rb +15 -9
- data/lib/rest-more.rb +1 -0
- data/lib/rest-more/version.rb +1 -1
- data/rest-more.gemspec +54 -41
- data/test/{client/bing → bing}/test_api.rb +0 -0
- data/test/dropbox/test_api.rb +37 -0
- data/test/{client/facebook → facebook}/config/rest-core.yaml +0 -0
- data/test/{client/facebook → facebook}/test_api.rb +0 -0
- data/test/{client/facebook → facebook}/test_cache.rb +0 -0
- data/test/{client/facebook → facebook}/test_default.rb +0 -0
- data/test/{client/facebook → facebook}/test_error.rb +0 -0
- data/test/{client/facebook → facebook}/test_handler.rb +0 -0
- data/test/{client/facebook → facebook}/test_load_config.rb +0 -0
- data/test/{client/facebook → facebook}/test_misc.rb +0 -0
- data/test/{client/facebook → facebook}/test_oauth.rb +0 -0
- data/test/{client/facebook → facebook}/test_old.rb +0 -0
- data/test/{client/facebook → facebook}/test_page.rb +16 -29
- data/test/{client/facebook → facebook}/test_parse.rb +2 -2
- data/test/{client/facebook → facebook}/test_serialize.rb +0 -0
- data/test/{client/facebook → facebook}/test_timeout.rb +0 -0
- data/test/{client/flurry → flurry}/test_metrics.rb +0 -0
- data/test/{client/mixi → mixi}/test_api.rb +0 -0
- data/test/{client/twitter → twitter}/test_api.rb +4 -3
- metadata +60 -41
File without changes
|
@@ -0,0 +1,37 @@
|
|
1
|
+
|
2
|
+
require 'rest-more/test'
|
3
|
+
|
4
|
+
describe RC::Dropbox do
|
5
|
+
after do
|
6
|
+
WebMock.reset!
|
7
|
+
RR.verify
|
8
|
+
end
|
9
|
+
|
10
|
+
should 'get right' do
|
11
|
+
stub_request(:get, 'https://api.dropbox.com/1/account/info').
|
12
|
+
to_return(:body => '{"status": "OK"}')
|
13
|
+
|
14
|
+
RC::Dropbox.new.me.should.eq({'status' => 'OK'})
|
15
|
+
end
|
16
|
+
|
17
|
+
def check status, klass
|
18
|
+
stub_request(:delete, 'https://api.dropbox.com/123').to_return(
|
19
|
+
:body => '{}', :status => status)
|
20
|
+
|
21
|
+
lambda{
|
22
|
+
RC::Dropbox.new.delete('123')
|
23
|
+
}.should.raise(klass)
|
24
|
+
|
25
|
+
WebMock.reset!
|
26
|
+
end
|
27
|
+
|
28
|
+
should 'raise exception when encountering error' do
|
29
|
+
[401, 402, 403].each{ |status|
|
30
|
+
check(status, RC::Dropbox::Error)
|
31
|
+
}
|
32
|
+
|
33
|
+
[500, 502, 503].each{ |status|
|
34
|
+
check(status, RC::Dropbox::Error::ServerError)
|
35
|
+
}
|
36
|
+
end
|
37
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -26,10 +26,9 @@ describe RC::Facebook do
|
|
26
26
|
kind = "#{type}_page"
|
27
27
|
data = {'paging' => {type => 'zzz'}, 'data' => ['z']}
|
28
28
|
|
29
|
-
|
30
|
-
(
|
31
|
-
|
32
|
-
}
|
29
|
+
rg.for_pages(data, -1, {}, kind).should == nil
|
30
|
+
rg.for_pages(data, 0, {}, kind).should == nil
|
31
|
+
rg.for_pages(data, 1, {}, kind).should == data
|
33
32
|
|
34
33
|
(2..4).each{ |pages|
|
35
34
|
# merge data
|
@@ -56,34 +55,27 @@ describe RC::Facebook do
|
|
56
55
|
data = {'paging' => {type => 'zzz'}, 'data' => ['z']}
|
57
56
|
|
58
57
|
# invalid pages or just the page itself
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
r.should.eq data
|
65
|
-
else
|
66
|
-
nils += 1
|
67
|
-
end
|
68
|
-
}.should.eq data
|
69
|
-
}
|
70
|
-
nils.should.eq ranges.to_a.size
|
58
|
+
rg.for_pages(data, -1, {}, kind){ |r| r.should.eq nil }.should.eq rg
|
59
|
+
rg.for_pages(data, 0, {}, kind){ |r| r.should.eq nil }.should.eq rg
|
60
|
+
a = []
|
61
|
+
rg.for_pages(data, 1, {}, kind){ |r| a << r }.should.eq rg
|
62
|
+
a.should.eq [data, nil]
|
71
63
|
|
72
64
|
(2..4).each{ |pages|
|
73
65
|
# merge data
|
74
66
|
stub_request(:get, 'zzz').to_return(:body => '{"data":["y"]}')
|
75
|
-
expects = [{'data' => %w[y]}, nil]
|
67
|
+
expects = [data, {'data' => %w[y]}, nil]
|
76
68
|
rg.for_pages(data, pages, {}, kind){ |r|
|
77
69
|
r.should.eq expects.shift
|
78
|
-
}.should.eq
|
70
|
+
}.should.eq rg
|
79
71
|
expects.empty?.should.eq true
|
80
72
|
|
81
73
|
# this data cannot be merged
|
82
74
|
stub_request(:get, 'zzz').to_return(:body => '{"data":"y"}')
|
83
|
-
expects = [{'data' => 'y'}, nil]
|
75
|
+
expects = [data, {'data' => 'y'}, nil]
|
84
76
|
rg.for_pages(data, pages, {}, kind){ |r|
|
85
77
|
r.should.eq expects.shift
|
86
|
-
}.should.eq
|
78
|
+
}.should.eq rg
|
87
79
|
expects.empty?.should.eq true
|
88
80
|
}
|
89
81
|
|
@@ -91,16 +83,11 @@ describe RC::Facebook do
|
|
91
83
|
'{"paging":{"'+type+'":"yyy"},"data":["y"]}')
|
92
84
|
stub_request(:get, 'yyy').to_return(:body => '{"data":["x"]}')
|
93
85
|
|
94
|
-
expects = [{'data' => %w[y]
|
95
|
-
|
96
|
-
|
97
|
-
r = rr.dup
|
98
|
-
r.delete('paging')
|
99
|
-
else
|
100
|
-
r = rr
|
101
|
-
end
|
86
|
+
expects = [data, {'data' => %w[y], 'paging' => {type => 'yyy'}},
|
87
|
+
{'data' => %w[x]}, nil]
|
88
|
+
rg.for_pages(data, 3, {}, kind){ |r|
|
102
89
|
r.should.eq expects.shift
|
103
|
-
}.should.eq
|
90
|
+
}.should.eq rg
|
104
91
|
}
|
105
92
|
end
|
106
93
|
end
|
@@ -112,8 +112,8 @@ describe RC::Facebook do
|
|
112
112
|
user_id = 123
|
113
113
|
app_id = 456
|
114
114
|
rg = RC::Facebook.new(:secret => secret,
|
115
|
-
|
116
|
-
mock(rg).authorize!(
|
115
|
+
:app_id => app_id)
|
116
|
+
mock(rg).authorize!(:code => code, :redirect_uri => ''){
|
117
117
|
rg.data = {'access_token' => access_token}
|
118
118
|
}.times(2)
|
119
119
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -8,10 +8,11 @@ describe RC::Twitter do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
should 'get right' do
|
11
|
-
stub_request(:get,
|
11
|
+
stub_request(:get,
|
12
|
+
'https://api.twitter.com/1/account/verify_credentials.json').
|
12
13
|
to_return(:body => '{"status": "OK"}')
|
13
14
|
|
14
|
-
|
15
|
+
RC::Twitter.new.me.should.eq({'status' => 'OK'})
|
15
16
|
end
|
16
17
|
|
17
18
|
def check status, klass
|
@@ -19,7 +20,7 @@ describe RC::Twitter do
|
|
19
20
|
:body => '{}', :status => status)
|
20
21
|
|
21
22
|
lambda{
|
22
|
-
|
23
|
+
RC::Twitter.new.delete('123')
|
23
24
|
}.should.raise(klass)
|
24
25
|
|
25
26
|
WebMock.reset!
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rest-more
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,19 +10,24 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2012-03-17 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rest-core
|
17
|
-
requirement:
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version:
|
22
|
+
version: 1.0.0
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements:
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: 1.0.0
|
26
31
|
description: ! 'Various REST clients such as Facebook and Twitter built with [rest-core][]
|
27
32
|
|
28
33
|
|
@@ -44,6 +49,14 @@ files:
|
|
44
49
|
- Rakefile
|
45
50
|
- TODO.md
|
46
51
|
- bin/rib-rest-core
|
52
|
+
- doc/ToC.md
|
53
|
+
- doc/dependency.md
|
54
|
+
- doc/design.md
|
55
|
+
- doc/rest-graph.md
|
56
|
+
- doc/tutorial/facebook.md
|
57
|
+
- example/async.rb
|
58
|
+
- example/facebook.rb
|
59
|
+
- example/multi.rb
|
47
60
|
- example/rails2/Gemfile
|
48
61
|
- example/rails2/README
|
49
62
|
- example/rails2/Rakefile
|
@@ -83,9 +96,12 @@ files:
|
|
83
96
|
- example/rails3/test/functional/application_controller_test.rb
|
84
97
|
- example/rails3/test/test_helper.rb
|
85
98
|
- example/rails3/test/unit/rails_util_test.rb
|
99
|
+
- example/rainbows.rb
|
100
|
+
- example/simple.rb
|
86
101
|
- example/sinatra/config.ru
|
87
102
|
- lib/rest-core/client/bing.rb
|
88
103
|
- lib/rest-core/client/bing/rails_util.rb
|
104
|
+
- lib/rest-core/client/dropbox.rb
|
89
105
|
- lib/rest-core/client/facebook.rb
|
90
106
|
- lib/rest-core/client/facebook/rails_util.rb
|
91
107
|
- lib/rest-core/client/flurry.rb
|
@@ -107,24 +123,25 @@ files:
|
|
107
123
|
- rest-more.gemspec
|
108
124
|
- task/.gitignore
|
109
125
|
- task/gemgem.rb
|
110
|
-
- test/
|
111
|
-
- test/
|
112
|
-
- test/
|
113
|
-
- test/
|
114
|
-
- test/
|
115
|
-
- test/
|
116
|
-
- test/
|
117
|
-
- test/
|
118
|
-
- test/
|
119
|
-
- test/
|
120
|
-
- test/
|
121
|
-
- test/
|
122
|
-
- test/
|
123
|
-
- test/
|
124
|
-
- test/
|
125
|
-
- test/
|
126
|
-
- test/
|
127
|
-
- test/
|
126
|
+
- test/bing/test_api.rb
|
127
|
+
- test/dropbox/test_api.rb
|
128
|
+
- test/facebook/config/rest-core.yaml
|
129
|
+
- test/facebook/test_api.rb
|
130
|
+
- test/facebook/test_cache.rb
|
131
|
+
- test/facebook/test_default.rb
|
132
|
+
- test/facebook/test_error.rb
|
133
|
+
- test/facebook/test_handler.rb
|
134
|
+
- test/facebook/test_load_config.rb
|
135
|
+
- test/facebook/test_misc.rb
|
136
|
+
- test/facebook/test_oauth.rb
|
137
|
+
- test/facebook/test_old.rb
|
138
|
+
- test/facebook/test_page.rb
|
139
|
+
- test/facebook/test_parse.rb
|
140
|
+
- test/facebook/test_serialize.rb
|
141
|
+
- test/facebook/test_timeout.rb
|
142
|
+
- test/flurry/test_metrics.rb
|
143
|
+
- test/mixi/test_api.rb
|
144
|
+
- test/twitter/test_api.rb
|
128
145
|
homepage: https://github.com/cardinalblue/rest-more
|
129
146
|
licenses: []
|
130
147
|
post_install_message:
|
@@ -145,25 +162,27 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
145
162
|
version: '0'
|
146
163
|
requirements: []
|
147
164
|
rubyforge_project:
|
148
|
-
rubygems_version: 1.8.
|
165
|
+
rubygems_version: 1.8.19
|
149
166
|
signing_key:
|
150
167
|
specification_version: 3
|
151
168
|
summary: Various REST clients such as Facebook and Twitter built with [rest-core][]
|
152
169
|
test_files:
|
153
|
-
- test/
|
154
|
-
- test/
|
155
|
-
- test/
|
156
|
-
- test/
|
157
|
-
- test/
|
158
|
-
- test/
|
159
|
-
- test/
|
160
|
-
- test/
|
161
|
-
- test/
|
162
|
-
- test/
|
163
|
-
- test/
|
164
|
-
- test/
|
165
|
-
- test/
|
166
|
-
- test/
|
167
|
-
- test/
|
168
|
-
- test/
|
169
|
-
- test/
|
170
|
+
- test/bing/test_api.rb
|
171
|
+
- test/dropbox/test_api.rb
|
172
|
+
- test/facebook/test_api.rb
|
173
|
+
- test/facebook/test_cache.rb
|
174
|
+
- test/facebook/test_default.rb
|
175
|
+
- test/facebook/test_error.rb
|
176
|
+
- test/facebook/test_handler.rb
|
177
|
+
- test/facebook/test_load_config.rb
|
178
|
+
- test/facebook/test_misc.rb
|
179
|
+
- test/facebook/test_oauth.rb
|
180
|
+
- test/facebook/test_old.rb
|
181
|
+
- test/facebook/test_page.rb
|
182
|
+
- test/facebook/test_parse.rb
|
183
|
+
- test/facebook/test_serialize.rb
|
184
|
+
- test/facebook/test_timeout.rb
|
185
|
+
- test/flurry/test_metrics.rb
|
186
|
+
- test/mixi/test_api.rb
|
187
|
+
- test/twitter/test_api.rb
|
188
|
+
has_rdoc:
|