parse-ruby-client 0.0.7 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -19,7 +19,7 @@ This currently depends on the gems 'json' and 'patron' for JSON support and HTTP
19
19
 
20
20
  ## Installation
21
21
 
22
- `gem "parse-ruby-client", "~> 0.0.7"`
22
+ `gem "parse-ruby-client", "~> 0.0.8"`
23
23
 
24
24
  ---
25
25
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.7
1
+ 0.1.0
data/example.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  Parse.init :application_id => "your_application_id",
2
- :api_key => "your_api_key"
2
+ :api_key => "your_REST_API_Key"
3
3
 
4
4
  profile = Parse::Object.new "Profile"
5
5
  profile["first_name"] = "John"
data/lib/parse/client.rb CHANGED
@@ -18,8 +18,8 @@ module Parse
18
18
  @application_id = data[:application_id]
19
19
  @api_key = data[:api_key]
20
20
  @session = Patron::Session.new
21
- @session.timeout = 10
22
- @session.connect_timeout = 10
21
+ @session.timeout = 30
22
+ @session.connect_timeout = 30
23
23
 
24
24
  @session.base_url = "https://#{host}"
25
25
  @session.headers["Content-Type"] = "application/json"
@@ -33,7 +33,7 @@ module Parse
33
33
  # with common basic response handling. Will raise a
34
34
  # ParseProtocolError if the response has an error status code,
35
35
  # and will return the parsed JSON body on success, if there is one.
36
- def request(uri, method = :get, body = nil, query = nil)
36
+ def request(uri, method = :get, body = nil, query = nil, max_retries = 2)
37
37
  options = {}
38
38
  if body
39
39
  options[:data] = body
@@ -42,7 +42,18 @@ module Parse
42
42
  options[:query] = query
43
43
  end
44
44
 
45
- response = @session.request(method, uri, {}, options)
45
+ num_tries = 0
46
+ begin
47
+ response = @session.request(method, uri, {}, options)
48
+ rescue Patron::TimeoutError
49
+ num_tries += 1
50
+ if num_tries <= max_retries
51
+ retry
52
+ else
53
+ raise Patron::TimeoutError
54
+ end
55
+ end
56
+
46
57
  if response.status >= 400
47
58
  raise ParseError, "#{JSON.parse(response.body)['code']}: #{JSON.parse(response.body)['error']}"
48
59
  else
data/lib/parse/object.rb CHANGED
@@ -24,7 +24,7 @@ module Parse
24
24
  end
25
25
 
26
26
  def pointer
27
- Parse::Pointer.new self
27
+ Parse::Pointer.new self.merge(Parse::Protocol::KEY_CLASS_NAME => class_name)
28
28
  end
29
29
 
30
30
  # Merge a hash parsed from the JSON representation into
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "parse-ruby-client"
8
- s.version = "0.0.7"
8
+ s.version = "0.1.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Alan deLevie", "Adam Alpern"]
12
- s.date = "2012-05-23"
12
+ s.date = "2012-06-22"
13
13
  s.description = "A simple Ruby client for the parse.com REST API"
14
14
  s.email = "adelevie@gmail.com"
15
15
  s.extra_rdoc_files = [
data/test/test_object.rb CHANGED
@@ -20,6 +20,13 @@ class TestObject < Test::Unit::TestCase
20
20
  assert_equal post.id.class, String
21
21
  end
22
22
 
23
+ def test_pointer
24
+ post = Parse::Object.new "Post"
25
+ pointer = post.pointer
26
+ assert_equal pointer.parse_object_id, post.parse_object_id
27
+ assert_equal pointer.class_name, post.class_name
28
+ end
29
+
23
30
  def test_created_at
24
31
  post = Parse::Object.new "Post"
25
32
  assert_equal post.created_at, nil
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parse-ruby-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.1.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-05-23 00:00:00.000000000Z
13
+ date: 2012-06-22 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: patron
17
- requirement: &70225208830000 !ruby/object:Gem::Requirement
17
+ requirement: &70170651043480 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70225208830000
25
+ version_requirements: *70170651043480
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: vcr
28
- requirement: &70225208829340 !ruby/object:Gem::Requirement
28
+ requirement: &70170651042660 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70225208829340
36
+ version_requirements: *70170651042660
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: shoulda
39
- requirement: &70225208828520 !ruby/object:Gem::Requirement
39
+ requirement: &70170651041740 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '0'
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *70225208828520
47
+ version_requirements: *70170651041740
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: bundler
50
- requirement: &70225208827840 !ruby/object:Gem::Requirement
50
+ requirement: &70170651040900 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ~>
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: 1.0.0
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *70225208827840
58
+ version_requirements: *70170651040900
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: jeweler
61
- requirement: &70225208827360 !ruby/object:Gem::Requirement
61
+ requirement: &70170651040320 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ~>
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: 1.6.4
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *70225208827360
69
+ version_requirements: *70170651040320
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rcov
72
- requirement: &70225208826800 !ruby/object:Gem::Requirement
72
+ requirement: &70170651039720 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ! '>='
@@ -77,7 +77,7 @@ dependencies:
77
77
  version: '0'
78
78
  type: :development
79
79
  prerelease: false
80
- version_requirements: *70225208826800
80
+ version_requirements: *70170651039720
81
81
  description: A simple Ruby client for the parse.com REST API
82
82
  email: adelevie@gmail.com
83
83
  executables: []
@@ -132,7 +132,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
132
132
  version: '0'
133
133
  segments:
134
134
  - 0
135
- hash: -2906797593999528264
135
+ hash: 3505975398628412091
136
136
  required_rubygems_version: !ruby/object:Gem::Requirement
137
137
  none: false
138
138
  requirements: