parse-ruby-client 0.2.0 → 0.3.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.
Files changed (49) hide show
  1. checksums.yaml +15 -0
  2. data/.travis.yml +2 -1
  3. data/Gemfile +4 -6
  4. data/Gemfile.lock +18 -18
  5. data/README.md +1 -1
  6. data/Rakefile +1 -1
  7. data/VERSION +1 -1
  8. data/example.rb +2 -1
  9. data/fixtures/vcr_cassettes/test_batch_update_nils_delete_keys.yml +57 -0
  10. data/fixtures/vcr_cassettes/test_empty_response.yml +72 -0
  11. data/fixtures/vcr_cassettes/test_get_missing.yml +95 -38
  12. data/fixtures/vcr_cassettes/test_image_file_associate_with_object.yml +2089 -0
  13. data/fixtures/vcr_cassettes/test_image_file_save.yml +1928 -0
  14. data/fixtures/vcr_cassettes/test_object_id.yml +56 -0
  15. data/fixtures/vcr_cassettes/test_reset_password.yml +109 -0
  16. data/fixtures/vcr_cassettes/test_retries.yml +357 -0
  17. data/fixtures/vcr_cassettes/test_retries_404.yml +72 -0
  18. data/fixtures/vcr_cassettes/test_retries_404_correct.yml +72 -0
  19. data/fixtures/vcr_cassettes/test_retries_json_error.yml +357 -0
  20. data/fixtures/vcr_cassettes/test_retries_server_error.yml +357 -0
  21. data/fixtures/vcr_cassettes/test_server_update.yml +248 -191
  22. data/fixtures/vcr_cassettes/test_user_login.yml +276 -0
  23. data/fixtures/vcr_cassettes/test_xget.yml +280 -0
  24. data/lib/faraday/better_retry.rb +94 -0
  25. data/lib/faraday/extended_parse_json.rb +39 -0
  26. data/lib/faraday/get_method_override.rb +32 -0
  27. data/lib/parse-ruby-client.rb +9 -9
  28. data/lib/parse/batch.rb +2 -3
  29. data/lib/parse/client.rb +72 -161
  30. data/lib/parse/cloud.rb +2 -1
  31. data/lib/parse/datatypes.rb +6 -1
  32. data/lib/parse/error.rb +7 -3
  33. data/lib/parse/installation.rb +18 -0
  34. data/lib/parse/model.rb +2 -1
  35. data/lib/parse/object.rb +7 -1
  36. data/lib/parse/protocol.rb +10 -0
  37. data/lib/parse/push.rb +3 -0
  38. data/lib/parse/query.rb +5 -2
  39. data/lib/parse/user.rb +1 -0
  40. data/lib/parse/util.rb +2 -0
  41. data/parse-ruby-client.gemspec +35 -15
  42. data/test/helper.rb +55 -1
  43. data/test/middleware/better_retry_test.rb +57 -0
  44. data/test/middleware/extend_parse_json_test.rb +55 -0
  45. data/test/test_client.rb +78 -28
  46. data/test/test_datatypes.rb +14 -0
  47. data/test/test_object.rb +16 -0
  48. metadata +39 -34
  49. data/lib/parse/http_client.rb +0 -84
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NDdhODlhODg5YzViOTcxMWI5NjJlMzBiYmMxODZmZGVmNDY0ZTcwMw==
5
+ data.tar.gz: !binary |-
6
+ NGFjMmJkY2Y2MWUyMWM2ODM4NDdkMjFmNGY3ZDBkNzUyNDg4MjJlMA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ ZTMzNTFlOWNjOWQyN2VhMWFlMmU2MjcxN2ZiNzU4Y2YwY2NiYjAxYjdkYTdl
10
+ M2UxYThiNDM1Y2I0ZjcwYTRjNGQ5ZTE1Zjg3NjY3Yzk1MTAwYzM5YzJkZGRk
11
+ MGNjNjczMzQ0NWIyNGMyNDQ2MTE0ZTA2NmU5MzM2YzgwYmIwNjY=
12
+ data.tar.gz: !binary |-
13
+ ZDU0YzMxOGRmZTdmNzAxMjc5NDM0NDMzYzhjNzNmY2ExNmY1NjE3Yjk2YWRj
14
+ ZGZkOTdjMmM1YzE1MDc2ZjNlY2IxMDg5MWNiZjA2ZGVlYjVmNjMyN2I3MzNh
15
+ NTRiYzY0NDI4M2RhMjkxMjQ3ZDMxNWViZmRkYmI1MzRiYThlNDc=
@@ -1,9 +1,10 @@
1
1
  language: ruby
2
2
  rvm:
3
+ - 2.1.0
3
4
  - 2.0.0
4
5
  - 1.9.3
5
6
  - 1.9.2
6
7
  - jruby-19mode
7
8
 
8
9
  env:
9
- - PARSE_APPLICATION_ID=Slw1ACyMSVguo79pWvfIq15pkUjfwTLNPpL4984b PARSE_REST_API_KEY=qJKM8CGOAn70WOyR16f16YbyKWM0nBJCEbbtAMOm
10
+ - PARSE_APPLICATION_ID=Slw1ACyMSVguo79pWvfIq15pkUjfwTLNPpL4984b PARSE_REST_API_KEY=qJKM8CGOAn70WOyR16f16YbyKWM0nBJCEbbtAMOm
data/Gemfile CHANGED
@@ -7,12 +7,10 @@ group :development do
7
7
  gem 'mocha', '= 0.12.0', :require => false
8
8
  gem 'jeweler', '~> 1.8.5'
9
9
  gem 'simplecov', :require => false
10
- gem 'webmock'
10
+ gem 'webmock', '~> 1.9.0'
11
11
  gem 'vcr'
12
+ gem 'pry'
12
13
  end
13
14
 
14
- platforms :ruby do
15
- gem 'patron' # skip patron for jruby
16
- end
17
-
18
- gem 'iron_mq'
15
+ gem 'faraday'
16
+ gem 'faraday_middleware'
@@ -3,9 +3,13 @@ GEM
3
3
  specs:
4
4
  addressable (2.3.5)
5
5
  builder (3.2.2)
6
- crack (0.3.1)
6
+ coderay (1.1.0)
7
+ crack (0.4.1)
8
+ safe_yaml (~> 0.9.0)
7
9
  faraday (0.8.7)
8
10
  multipart-post (~> 1.1)
11
+ faraday_middleware (0.9.0)
12
+ faraday (>= 0.7.4, < 0.9)
9
13
  git (1.2.5)
10
14
  github_api (0.10.1)
11
15
  addressable
@@ -17,10 +21,6 @@ GEM
17
21
  hashie (2.0.5)
18
22
  highline (1.6.19)
19
23
  httpauth (0.2.0)
20
- iron_core (0.5.1)
21
- rest (>= 2.2.0)
22
- iron_mq (2.1.3)
23
- iron_core (>= 0.4.2)
24
24
  jeweler (1.8.6)
25
25
  builder
26
26
  bundler (~> 1.0)
@@ -34,13 +34,12 @@ GEM
34
34
  jwt (0.1.8)
35
35
  multi_json (>= 1.5)
36
36
  metaclass (0.0.1)
37
- mime-types (1.20.1)
37
+ method_source (0.8.2)
38
38
  mocha (0.12.0)
39
39
  metaclass (~> 0.0.1)
40
40
  multi_json (1.7.7)
41
41
  multi_xml (0.5.4)
42
42
  multipart-post (1.2.0)
43
- net-http-persistent (2.8)
44
43
  nokogiri (1.5.10)
45
44
  oauth2 (0.9.2)
46
45
  faraday (~> 0.8)
@@ -49,38 +48,39 @@ GEM
49
48
  multi_json (~> 1.0)
50
49
  multi_xml (~> 0.5)
51
50
  rack (~> 1.2)
52
- patron (0.4.18)
51
+ pry (0.9.12.6)
52
+ coderay (~> 1.0)
53
+ method_source (~> 0.8)
54
+ slop (~> 3.4)
53
55
  rack (1.5.2)
54
56
  rake (10.1.0)
55
57
  rdoc (4.0.1)
56
58
  json (~> 1.4)
57
- rest (2.2.0)
58
- net-http-persistent
59
- rest-client (>= 0.3.0)
60
- rest-client (1.6.7)
61
- mime-types (>= 1.16)
59
+ safe_yaml (0.9.7)
62
60
  shoulda (2.11.3)
63
61
  simplecov (0.7.1)
64
62
  multi_json (~> 1.0)
65
63
  simplecov-html (~> 0.7.1)
66
64
  simplecov-html (0.7.1)
65
+ slop (3.4.7)
67
66
  test-unit (2.5.0)
68
67
  vcr (2.4.0)
69
- webmock (1.8.10)
68
+ webmock (1.9.3)
70
69
  addressable (>= 2.2.7)
71
- crack (>= 0.1.7)
70
+ crack (>= 0.3.2)
72
71
 
73
72
  PLATFORMS
74
73
  ruby
75
74
 
76
75
  DEPENDENCIES
77
76
  bundler
78
- iron_mq
77
+ faraday
78
+ faraday_middleware
79
79
  jeweler (~> 1.8.5)
80
80
  mocha (= 0.12.0)
81
- patron
81
+ pry
82
82
  shoulda
83
83
  simplecov
84
84
  test-unit (= 2.5.0)
85
85
  vcr
86
- webmock
86
+ webmock (~> 1.9.0)
data/README.md CHANGED
@@ -324,7 +324,7 @@ Dates are useful in combination with the built-in createdAt and updatedAt fields
324
324
 
325
325
  ```ruby
326
326
  game_score = Parse::Query.new("GameScore").tap do |q|
327
- g.greater_than("createdAt", Parse::Object.new(DateTime.now)) # query options explained in more detail later in this document
327
+ g.greater_than("createdAt", Parse::Date.new(DateTime.now)) # query options explained in more detail later in this document
328
328
  end.get.first
329
329
  ```
330
330
 
data/Rakefile CHANGED
@@ -28,7 +28,7 @@ Jeweler::RubygemsDotOrgTasks.new
28
28
  require 'rake/testtask'
29
29
  Rake::TestTask.new(:test) do |test|
30
30
  test.libs << 'lib' << 'test'
31
- test.pattern = 'test/**/test_*.rb'
31
+ test.test_files = FileList['test/test*.rb', 'test/middleware/*_test.rb']
32
32
  test.verbose = true
33
33
  end
34
34
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.2.0
1
+ 0.3.0
data/example.rb CHANGED
@@ -1,3 +1,4 @@
1
+ # -*- encoding : utf-8 -*-
1
2
  Parse.init :application_id => "your_application_id",
2
3
  :api_key => "your_REST_API_Key"
3
4
 
@@ -31,4 +32,4 @@ Parse::Query.new(cls) \
31
32
  # Pushes
32
33
  push = Parse::Push.new({ "alert"=> "I'm sending this push to all my app users!" })
33
34
  push.save
34
-
35
+
@@ -236,4 +236,61 @@ http_interactions:
236
236
  string: '{"createdAt":"2013-05-22T16:29:53.618Z","updatedAt":"2013-05-22T16:29:53.704Z","objectId":"2ymFSQYHfE"}'
237
237
  http_version:
238
238
  recorded_at: Wed, 22 May 2013 16:31:59 GMT
239
+ - request:
240
+ method: post
241
+ uri: https://api.parse.com/1/classes/BatchTestObject/2ymFSQYHfE
242
+ body:
243
+ encoding: UTF-8
244
+ string: ''
245
+ headers:
246
+ User-Agent:
247
+ - Parse for Ruby, 0.0
248
+ Content-Type:
249
+ - application/json
250
+ X-Parse-Application-Id:
251
+ - <X-Parse-Application-Id>
252
+ X-Parse-Rest-Api-Key:
253
+ - <X-Parse-REST-API-Key>
254
+ X-Http-Method-Override:
255
+ - GET
256
+ Content-Length:
257
+ - '0'
258
+ Accept-Encoding:
259
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
260
+ Accept:
261
+ - '*/*'
262
+ response:
263
+ status:
264
+ code: 404
265
+ message: Not Found
266
+ headers:
267
+ Access-Control-Allow-Origin:
268
+ - '*'
269
+ Access-Control-Request-Method:
270
+ - '*'
271
+ Cache-Control:
272
+ - no-cache
273
+ Content-Type:
274
+ - application/json; charset=utf-8
275
+ Date:
276
+ - Wed, 26 Mar 2014 15:21:12 GMT
277
+ Server:
278
+ - nginx/1.4.2
279
+ Set-Cookie:
280
+ - <COOKIE-KEY>
281
+ Status:
282
+ - 404 Not Found
283
+ X-Runtime:
284
+ - '0.118475'
285
+ X-Ua-Compatible:
286
+ - IE=Edge,chrome=1
287
+ Content-Length:
288
+ - '65'
289
+ Connection:
290
+ - keep-alive
291
+ body:
292
+ encoding: UTF-8
293
+ string: '{"code":101,"error":"object not found for get"}'
294
+ http_version:
295
+ recorded_at: Wed, 26 Mar 2014 15:21:13 GMT
239
296
  recorded_with: VCR 2.4.0
@@ -0,0 +1,72 @@
1
+ ---
2
+ http_interactions:
3
+ - request:
4
+ method: get
5
+ uri: https://api.parse.com/
6
+ body:
7
+ encoding: US-ASCII
8
+ string: ''
9
+ headers:
10
+ User-Agent:
11
+ - Parse for Ruby, 0.0
12
+ Content-Type:
13
+ - application/json
14
+ X-Parse-Application-Id:
15
+ - <X-Parse-Application-Id>
16
+ X-Parse-Rest-Api-Key:
17
+ - <X-Parse-REST-API-Key>
18
+ Accept-Encoding:
19
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
20
+ Accept:
21
+ - '*/*'
22
+ response:
23
+ status:
24
+ code: 404
25
+ message: Not Found
26
+ headers:
27
+ Content-Type:
28
+ - text/html; charset=utf-8
29
+ Date:
30
+ - Wed, 26 Mar 2014 16:48:05 GMT
31
+ Server:
32
+ - nginx/1.4.4
33
+ Status:
34
+ - 404 Not Found
35
+ X-Runtime:
36
+ - '0.005618'
37
+ Content-Length:
38
+ - '433'
39
+ Connection:
40
+ - keep-alive
41
+ body:
42
+ encoding: UTF-8
43
+ string: |
44
+ <!DOCTYPE html>
45
+ <html>
46
+ <head>
47
+ <title>The page you were looking for doesn't exist (404)</title>
48
+ <style type="text/css">
49
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
50
+ div.dialog {
51
+ width: 25em;
52
+ padding: 0 4em;
53
+ margin: 4em auto 0 auto;
54
+ border: 1px solid #ccc;
55
+ border-right-color: #999;
56
+ border-bottom-color: #999;
57
+ }
58
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
59
+ </style>
60
+ </head>
61
+
62
+ <body>
63
+ <!-- This file lives in public/404.html -->
64
+ <div class="dialog">
65
+ <h1>The page you were looking for doesn't exist.</h1>
66
+ <p>You may have mistyped the address or the page may have moved.</p>
67
+ </div>
68
+ </body>
69
+ </html>
70
+ http_version:
71
+ recorded_at: Wed, 26 Mar 2014 16:48:05 GMT
72
+ recorded_with: VCR 2.4.0
@@ -1,60 +1,117 @@
1
- ---
2
- http_interactions:
3
- - request:
1
+ ---
2
+ http_interactions:
3
+ - request:
4
4
  method: get
5
5
  uri: https://api.parse.com/1/classes/SomeClass/someIdThatDoesNotExist
6
- body:
6
+ body:
7
7
  encoding: US-ASCII
8
- string: ""
9
- headers:
10
- Content-Type:
8
+ string: ''
9
+ headers:
10
+ Content-Type:
11
11
  - application/json
12
- Accept:
12
+ Accept:
13
13
  - application/json
14
- User-Agent:
14
+ User-Agent:
15
15
  - Parse for Ruby, 0.0
16
- X-Parse-Master-Key:
17
- - ""
18
- X-Parse-Rest-Api-Key:
16
+ X-Parse-Master-Key:
17
+ - ''
18
+ X-Parse-Rest-Api-Key:
19
19
  - <X-Parse-REST-API-Key>
20
- X-Parse-Application-Id:
20
+ X-Parse-Application-Id:
21
21
  - <X-Parse-Application-Id>
22
- X-Parse-Session-Token:
23
- - ""
24
- Expect:
25
- - ""
26
- response:
27
- status:
22
+ X-Parse-Session-Token:
23
+ - ''
24
+ Expect:
25
+ - ''
26
+ response:
27
+ status:
28
28
  code: 404
29
29
  message: Not Found
30
- headers:
31
- Access-Control-Allow-Origin:
32
- - "*"
33
- Access-Control-Request-Method:
34
- - "*"
35
- Cache-Control:
30
+ headers:
31
+ Access-Control-Allow-Origin:
32
+ - '*'
33
+ Access-Control-Request-Method:
34
+ - '*'
35
+ Cache-Control:
36
36
  - no-cache
37
- Content-Type:
37
+ Content-Type:
38
38
  - application/json; charset=utf-8
39
- Date:
39
+ Date:
40
40
  - Mon, 22 Apr 2013 16:03:14 GMT
41
- Server:
41
+ Server:
42
42
  - nginx/1.2.2
43
- Set-Cookie:
43
+ Set-Cookie:
44
44
  - <COOKIE-KEY>
45
- Status:
45
+ Status:
46
46
  - 404 Not Found
47
- X-Runtime:
48
- - "0.050654"
49
- X-Ua-Compatible:
47
+ X-Runtime:
48
+ - '0.050654'
49
+ X-Ua-Compatible:
50
50
  - IE=Edge,chrome=1
51
- Content-Length:
52
- - "47"
53
- Connection:
51
+ Content-Length:
52
+ - '47'
53
+ Connection:
54
54
  - keep-alive
55
- body:
55
+ body:
56
56
  encoding: ASCII-8BIT
57
- string: "{\"code\":101,\"error\":\"object not found for get\"}"
57
+ string: '{"code":101,"error":"object not found for get"}'
58
58
  http_version:
59
59
  recorded_at: Mon, 22 Apr 2013 16:03:14 GMT
60
+ - request:
61
+ method: post
62
+ uri: https://api.parse.com/1/classes/SomeClass/someIdThatDoesNotExist
63
+ body:
64
+ encoding: UTF-8
65
+ string: ''
66
+ headers:
67
+ User-Agent:
68
+ - Parse for Ruby, 0.0
69
+ Content-Type:
70
+ - application/json
71
+ X-Parse-Application-Id:
72
+ - <X-Parse-Application-Id>
73
+ X-Parse-Rest-Api-Key:
74
+ - <X-Parse-REST-API-Key>
75
+ X-Http-Method-Override:
76
+ - GET
77
+ Content-Length:
78
+ - '0'
79
+ Accept-Encoding:
80
+ - gzip;q=1.0,deflate;q=0.6,identity;q=0.3
81
+ Accept:
82
+ - '*/*'
83
+ response:
84
+ status:
85
+ code: 404
86
+ message: Not Found
87
+ headers:
88
+ Access-Control-Allow-Origin:
89
+ - '*'
90
+ Access-Control-Request-Method:
91
+ - '*'
92
+ Cache-Control:
93
+ - no-cache
94
+ Content-Type:
95
+ - application/json; charset=utf-8
96
+ Date:
97
+ - Wed, 26 Mar 2014 15:21:14 GMT
98
+ Server:
99
+ - nginx/1.4.4
100
+ Set-Cookie:
101
+ - <COOKIE-KEY>
102
+ Status:
103
+ - 404 Not Found
104
+ X-Runtime:
105
+ - '0.156791'
106
+ X-Ua-Compatible:
107
+ - IE=Edge,chrome=1
108
+ Content-Length:
109
+ - '65'
110
+ Connection:
111
+ - keep-alive
112
+ body:
113
+ encoding: UTF-8
114
+ string: '{"code":101,"error":"object not found for get"}'
115
+ http_version:
116
+ recorded_at: Wed, 26 Mar 2014 15:21:14 GMT
60
117
  recorded_with: VCR 2.4.0