rest-more 0.8.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. data/.travis.yml +4 -2
  2. data/CHANGES.md +54 -34
  3. data/Gemfile +3 -1
  4. data/README.md +187 -14
  5. data/Rakefile +1 -1
  6. data/TODO.md +2 -12
  7. data/doc/ToC.md +9 -0
  8. data/doc/dependency.md +4 -0
  9. data/doc/design.md +4 -0
  10. data/doc/rest-graph.md +4 -0
  11. data/doc/tutorial/facebook.md +173 -0
  12. data/example/async.rb +89 -0
  13. data/example/facebook.rb +13 -0
  14. data/example/multi.rb +28 -0
  15. data/example/rails3/Gemfile +1 -1
  16. data/example/rainbows.rb +40 -0
  17. data/example/simple.rb +8 -0
  18. data/lib/rest-core/client/bing.rb +15 -7
  19. data/lib/rest-core/client/dropbox.rb +104 -0
  20. data/lib/rest-core/client/facebook.rb +59 -15
  21. data/lib/rest-core/client/flurry.rb +11 -1
  22. data/lib/rest-core/client/github.rb +11 -1
  23. data/lib/rest-core/client/linkedin.rb +10 -6
  24. data/lib/rest-core/client/twitter.rb +18 -9
  25. data/lib/rest-core/util/config.rb +15 -9
  26. data/lib/rest-more.rb +1 -0
  27. data/lib/rest-more/version.rb +1 -1
  28. data/rest-more.gemspec +54 -41
  29. data/test/{client/bing → bing}/test_api.rb +0 -0
  30. data/test/dropbox/test_api.rb +37 -0
  31. data/test/{client/facebook → facebook}/config/rest-core.yaml +0 -0
  32. data/test/{client/facebook → facebook}/test_api.rb +0 -0
  33. data/test/{client/facebook → facebook}/test_cache.rb +0 -0
  34. data/test/{client/facebook → facebook}/test_default.rb +0 -0
  35. data/test/{client/facebook → facebook}/test_error.rb +0 -0
  36. data/test/{client/facebook → facebook}/test_handler.rb +0 -0
  37. data/test/{client/facebook → facebook}/test_load_config.rb +0 -0
  38. data/test/{client/facebook → facebook}/test_misc.rb +0 -0
  39. data/test/{client/facebook → facebook}/test_oauth.rb +0 -0
  40. data/test/{client/facebook → facebook}/test_old.rb +0 -0
  41. data/test/{client/facebook → facebook}/test_page.rb +16 -29
  42. data/test/{client/facebook → facebook}/test_parse.rb +2 -2
  43. data/test/{client/facebook → facebook}/test_serialize.rb +0 -0
  44. data/test/{client/facebook → facebook}/test_timeout.rb +0 -0
  45. data/test/{client/flurry → flurry}/test_metrics.rb +0 -0
  46. data/test/{client/mixi → mixi}/test_api.rb +0 -0
  47. data/test/{client/twitter → twitter}/test_api.rb +4 -3
  48. 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
@@ -26,10 +26,9 @@ describe RC::Facebook do
26
26
  kind = "#{type}_page"
27
27
  data = {'paging' => {type => 'zzz'}, 'data' => ['z']}
28
28
 
29
- # invalid pages or just the page itself
30
- (-1..1).each{ |page|
31
- rg.for_pages(data, page, {}, kind).should == data
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
- nils = 0
60
- ranges = -1..1
61
- ranges.each{ |page|
62
- rg.for_pages(data, page, {}, kind){ |r|
63
- if r
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({'data' => %w[z y]})
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({'data' => %w[z]})
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]}, {'data' => %w[x]}, nil]
95
- rg.for_pages(data, 3, {}, kind){ |rr|
96
- if rr
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({'data' => %w[z y x]})
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
- :app_id => app_id)
116
- mock(rg).authorize!(hash_including(:code => code)){
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
@@ -8,10 +8,11 @@ describe RC::Twitter do
8
8
  end
9
9
 
10
10
  should 'get right' do
11
- stub_request(:get, 'https://api.twitter.com/me').
11
+ stub_request(:get,
12
+ 'https://api.twitter.com/1/account/verify_credentials.json').
12
13
  to_return(:body => '{"status": "OK"}')
13
14
 
14
- RestCore::Twitter.new.get('me').should.eq({'status' => 'OK'})
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
- RestCore::Twitter.new.delete('123')
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.8.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: 2011-11-29 00:00:00.000000000 Z
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: &2158239560 !ruby/object:Gem::Requirement
17
+ requirement: !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
21
21
  - !ruby/object:Gem::Version
22
- version: '0'
22
+ version: 1.0.0
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *2158239560
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/client/bing/test_api.rb
111
- - test/client/facebook/config/rest-core.yaml
112
- - test/client/facebook/test_api.rb
113
- - test/client/facebook/test_cache.rb
114
- - test/client/facebook/test_default.rb
115
- - test/client/facebook/test_error.rb
116
- - test/client/facebook/test_handler.rb
117
- - test/client/facebook/test_load_config.rb
118
- - test/client/facebook/test_misc.rb
119
- - test/client/facebook/test_oauth.rb
120
- - test/client/facebook/test_old.rb
121
- - test/client/facebook/test_page.rb
122
- - test/client/facebook/test_parse.rb
123
- - test/client/facebook/test_serialize.rb
124
- - test/client/facebook/test_timeout.rb
125
- - test/client/flurry/test_metrics.rb
126
- - test/client/mixi/test_api.rb
127
- - test/client/twitter/test_api.rb
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.11
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/client/bing/test_api.rb
154
- - test/client/facebook/test_api.rb
155
- - test/client/facebook/test_cache.rb
156
- - test/client/facebook/test_default.rb
157
- - test/client/facebook/test_error.rb
158
- - test/client/facebook/test_handler.rb
159
- - test/client/facebook/test_load_config.rb
160
- - test/client/facebook/test_misc.rb
161
- - test/client/facebook/test_oauth.rb
162
- - test/client/facebook/test_old.rb
163
- - test/client/facebook/test_page.rb
164
- - test/client/facebook/test_parse.rb
165
- - test/client/facebook/test_serialize.rb
166
- - test/client/facebook/test_timeout.rb
167
- - test/client/flurry/test_metrics.rb
168
- - test/client/mixi/test_api.rb
169
- - test/client/twitter/test_api.rb
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: