parse-ruby-client 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +8 -1
- data/VERSION +1 -1
- data/lib/parse/client.rb +10 -0
- data/lib/parse/datatypes.rb +0 -4
- data/lib/parse/object.rb +8 -2
- data/parse-ruby-client.gemspec +4 -2
- data/test/config/global.json +14 -0
- data/test/test_init_from_cloud_code.rb +8 -0
- data/test/test_object.rb +10 -2
- metadata +5 -3
data/README.md
CHANGED
@@ -48,6 +48,14 @@ Parse.init
|
|
48
48
|
|
49
49
|
The test folder assumes this naming convention for environment variables, so if you want to run the tests, you *must* do this. But it's easy. And good for you, too.
|
50
50
|
|
51
|
+
### New: Load API keys from `global.json` created by Cloud Code
|
52
|
+
|
53
|
+
```ruby
|
54
|
+
Parse.init_from_cloud_code("path/to/global.json")
|
55
|
+
```
|
56
|
+
|
57
|
+
The path defaults to `"../config/global.json"`. So if you create a folder inside the root of a Cloud Code directory, and in that folder is a `.rb` file, just call `Parse.init_from_cloud_code` with no arguments and you're set.
|
58
|
+
|
51
59
|
## Creating and Saving Objects
|
52
60
|
|
53
61
|
Create an instance of ```Parse::Object``` with your class name supplied as a string, set some keys, and call ```save()```.
|
@@ -133,7 +141,6 @@ params = {"foo" => "bar"}
|
|
133
141
|
function.call(params)
|
134
142
|
```
|
135
143
|
|
136
|
-
|
137
144
|
# TODO
|
138
145
|
|
139
146
|
- Add some form of debug logging
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.5
|
data/lib/parse/client.rb
CHANGED
@@ -110,6 +110,16 @@ module Parse
|
|
110
110
|
@@client = Client.new(defaulted)
|
111
111
|
end
|
112
112
|
|
113
|
+
# A convenience method for using global.json
|
114
|
+
def Parse.init_from_cloud_code(path="../config/global.json")
|
115
|
+
global = JSON.parse(Object::File.open(path).read) # warning: toplevel constant File referenced by Parse::Object::File
|
116
|
+
application_name = global["applications"]["_default"]["link"]
|
117
|
+
application_id = global["applications"][application_name]["applicationId"]
|
118
|
+
master_key = global["applications"][application_name]["masterKey"]
|
119
|
+
Parse.init :application_id => application_id,
|
120
|
+
:master_key => master_key
|
121
|
+
end
|
122
|
+
|
113
123
|
# Used mostly for testing. Lets you delete the api key global vars.
|
114
124
|
def Parse.destroy
|
115
125
|
@@client = nil
|
data/lib/parse/datatypes.rb
CHANGED
data/lib/parse/object.rb
CHANGED
@@ -61,7 +61,7 @@ module Parse
|
|
61
61
|
def new?
|
62
62
|
self["objectId"].nil?
|
63
63
|
end
|
64
|
-
|
64
|
+
|
65
65
|
def safe_json
|
66
66
|
without_reserved = self.dup
|
67
67
|
Protocol::RESERVED_KEYS.each { |k| without_reserved.delete(k) }
|
@@ -103,7 +103,13 @@ module Parse
|
|
103
103
|
|
104
104
|
def as_json(*a)
|
105
105
|
Hash[self.map do |key, value|
|
106
|
-
|
106
|
+
value = if value
|
107
|
+
value.respond_to?(:as_json) ? value.as_json : value
|
108
|
+
else
|
109
|
+
Protocol::DELETE_OP
|
110
|
+
end
|
111
|
+
|
112
|
+
[key, value]
|
107
113
|
end]
|
108
114
|
end
|
109
115
|
|
data/parse-ruby-client.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "parse-ruby-client"
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.5"
|
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-10-
|
12
|
+
s.date = "2012-10-14"
|
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 = [
|
@@ -57,11 +57,13 @@ Gem::Specification.new do |s|
|
|
57
57
|
"pkg/parse-ruby-client-1-0.0.1.gem",
|
58
58
|
"pkg/parse-ruby-client.gem",
|
59
59
|
"test/cloud_functions/MyCloudCode/cloud/main.js",
|
60
|
+
"test/config/global.json",
|
60
61
|
"test/helper.rb",
|
61
62
|
"test/test_client.rb",
|
62
63
|
"test/test_cloud.rb",
|
63
64
|
"test/test_datatypes.rb",
|
64
65
|
"test/test_init.rb",
|
66
|
+
"test/test_init_from_cloud_code.rb",
|
65
67
|
"test/test_object.rb",
|
66
68
|
"test/test_push.rb",
|
67
69
|
"test/test_query.rb",
|
data/test/test_object.rb
CHANGED
@@ -25,7 +25,7 @@ class TestObject < Test::Unit::TestCase
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def test_pointer
|
28
|
-
VCR.use_cassette('test_pointer', :record => :new_episodes) do
|
28
|
+
VCR.use_cassette('test_pointer', :record => :new_episodes) do
|
29
29
|
post = Parse::Object.new "Post"
|
30
30
|
assert_nil post.pointer
|
31
31
|
|
@@ -89,11 +89,19 @@ class TestObject < Test::Unit::TestCase
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
+
def test_deep_as_json
|
93
|
+
VCR.use_cassette('test_deep_as_json', :record => :new_episodes) do
|
94
|
+
other = Parse::Object.new "Post"
|
95
|
+
other['date'] = Parse::Date.new(DateTime.now)
|
96
|
+
assert other.as_json['date']['iso']
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
92
100
|
def test_nils_delete_keys
|
93
101
|
VCR.use_cassette('test_nils_delete_keys', :record => :new_episodes) do
|
94
102
|
post = Parse::Object.new "Post"
|
95
103
|
post["title"] = "hello"
|
96
|
-
post.save
|
104
|
+
post.save
|
97
105
|
post["title"] = nil
|
98
106
|
post.save
|
99
107
|
assert_false post.refresh.keys.include?("title")
|
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.1.
|
4
|
+
version: 0.1.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-10-
|
13
|
+
date: 2012-10-14 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: patron
|
@@ -204,11 +204,13 @@ files:
|
|
204
204
|
- pkg/parse-ruby-client-1-0.0.1.gem
|
205
205
|
- pkg/parse-ruby-client.gem
|
206
206
|
- test/cloud_functions/MyCloudCode/cloud/main.js
|
207
|
+
- test/config/global.json
|
207
208
|
- test/helper.rb
|
208
209
|
- test/test_client.rb
|
209
210
|
- test/test_cloud.rb
|
210
211
|
- test/test_datatypes.rb
|
211
212
|
- test/test_init.rb
|
213
|
+
- test/test_init_from_cloud_code.rb
|
212
214
|
- test/test_object.rb
|
213
215
|
- test/test_push.rb
|
214
216
|
- test/test_query.rb
|
@@ -228,7 +230,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
228
230
|
version: '0'
|
229
231
|
segments:
|
230
232
|
- 0
|
231
|
-
hash:
|
233
|
+
hash: 2994353426493104333
|
232
234
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
233
235
|
none: false
|
234
236
|
requirements:
|