dm-parse 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/dm-parse.gemspec +3 -3
- data/lib/{parse → adapters/parse}/engine.rb +8 -2
- data/lib/adapters/parse_adapter.rb +4 -6
- data/lib/dm-parse.rb +1 -3
- data/spec/integration_spec.rb +11 -0
- metadata +4 -4
- /data/lib/{parse → adapters/parse}/query.rb +0 -0
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.3.
|
1
|
+
0.3.1
|
data/dm-parse.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "dm-parse"
|
8
|
-
s.version = "0.3.
|
8
|
+
s.version = "0.3.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Zhi-Qiang Lei"]
|
@@ -28,12 +28,12 @@ Gem::Specification.new do |s|
|
|
28
28
|
"Rakefile",
|
29
29
|
"VERSION",
|
30
30
|
"dm-parse.gemspec",
|
31
|
+
"lib/adapters/parse/engine.rb",
|
32
|
+
"lib/adapters/parse/query.rb",
|
31
33
|
"lib/adapters/parse_adapter.rb",
|
32
34
|
"lib/collection.rb",
|
33
35
|
"lib/dm-parse.rb",
|
34
36
|
"lib/is/parse.rb",
|
35
|
-
"lib/parse/engine.rb",
|
36
|
-
"lib/parse/query.rb",
|
37
37
|
"lib/property/parse_date.rb",
|
38
38
|
"lib/property/parse_file.rb",
|
39
39
|
"lib/property/parse_geo_point.rb",
|
@@ -15,7 +15,7 @@ module DataMapper
|
|
15
15
|
@session.connect_timeout = 10
|
16
16
|
|
17
17
|
@session.base_url = "https://#{host}"
|
18
|
-
@session.headers["Content-Type"] = "application/json"
|
18
|
+
@session.headers["Content-Type"] = data[:content_type] || "application/json"
|
19
19
|
@session.headers["Accept"] = "application/json"
|
20
20
|
@session.headers["User-Agent"] = "Parse for Ruby, 0.0"
|
21
21
|
@session.headers[Protocol::HEADER_APP_ID] = @app_id
|
@@ -33,7 +33,8 @@ module DataMapper
|
|
33
33
|
attr_reader :client
|
34
34
|
|
35
35
|
def initialize(app_id, api_key, master)
|
36
|
-
@
|
36
|
+
@app_id, @api_key, @master = app_id, api_key, master
|
37
|
+
@client = build_client
|
37
38
|
end
|
38
39
|
|
39
40
|
def read(storage_name, params)
|
@@ -60,6 +61,7 @@ module DataMapper
|
|
60
61
|
end
|
61
62
|
|
62
63
|
def upload_file(filename, content, content_type)
|
64
|
+
client = build_client(content_type: content_type)
|
63
65
|
client.post ::Parse::Protocol.file_uri(URI.escape(filename)), content
|
64
66
|
end
|
65
67
|
|
@@ -69,6 +71,10 @@ module DataMapper
|
|
69
71
|
|
70
72
|
private
|
71
73
|
|
74
|
+
def build_client(options = {})
|
75
|
+
::Parse::Client.new options.merge(app_id: @app_id, api_key: @api_key, master: @master)
|
76
|
+
end
|
77
|
+
|
72
78
|
def uri_for(storage_name, id = nil)
|
73
79
|
storage_name == "_User" ? ::Parse::Protocol.user_uri(id) : ::Parse::Protocol.class_uri(storage_name, id)
|
74
80
|
end
|
@@ -1,3 +1,7 @@
|
|
1
|
+
$: << File.join(File.dirname(__FILE__), "parse")
|
2
|
+
require "engine"
|
3
|
+
require "query"
|
4
|
+
|
1
5
|
module DataMapper
|
2
6
|
module Adapters
|
3
7
|
|
@@ -5,12 +9,6 @@ module DataMapper
|
|
5
9
|
include Parse::Conditions
|
6
10
|
include Query::Conditions
|
7
11
|
|
8
|
-
HOST = "https://api.parse.com"
|
9
|
-
VERSION = "1"
|
10
|
-
APP_ID_HEADER = "X-Parse-Application-Id"
|
11
|
-
API_KEY_HEADER = "X-Parse-REST-API-Key"
|
12
|
-
MASTER_KEY_HEADER = "X-Parse-Master-Key"
|
13
|
-
|
14
12
|
attr_reader :engine
|
15
13
|
|
16
14
|
def initialize(name, options)
|
data/lib/dm-parse.rb
CHANGED
@@ -8,7 +8,5 @@ require "property/parse_pointer"
|
|
8
8
|
require "property/parse_date"
|
9
9
|
require "property/parse_file"
|
10
10
|
require "property/parse_geo_point"
|
11
|
-
require "parse/engine"
|
12
|
-
require "parse/query"
|
13
|
-
require "adapters/parse_adapter"
|
14
11
|
require "is/parse"
|
12
|
+
require "adapters/parse_adapter"
|
data/spec/integration_spec.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
require "spec_helper"
|
2
|
+
require "uri"
|
3
|
+
require "net/http"
|
4
|
+
require "net/https"
|
2
5
|
|
3
6
|
describe "resource" do
|
4
7
|
subject { resource }
|
@@ -126,6 +129,14 @@ describe "adapter" do
|
|
126
129
|
|
127
130
|
it { should be_has_key("name") }
|
128
131
|
it { should be_has_key("url") }
|
132
|
+
|
133
|
+
describe "its content" do
|
134
|
+
subject { Net::HTTP.get URI(url) }
|
135
|
+
|
136
|
+
let(:url) { adapter.upload_file(filename, content, content_type)["url"] }
|
137
|
+
|
138
|
+
it { should eq(content) }
|
139
|
+
end
|
129
140
|
end
|
130
141
|
|
131
142
|
describe "#request_password_reset" do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dm-parse
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -206,12 +206,12 @@ files:
|
|
206
206
|
- Rakefile
|
207
207
|
- VERSION
|
208
208
|
- dm-parse.gemspec
|
209
|
+
- lib/adapters/parse/engine.rb
|
210
|
+
- lib/adapters/parse/query.rb
|
209
211
|
- lib/adapters/parse_adapter.rb
|
210
212
|
- lib/collection.rb
|
211
213
|
- lib/dm-parse.rb
|
212
214
|
- lib/is/parse.rb
|
213
|
-
- lib/parse/engine.rb
|
214
|
-
- lib/parse/query.rb
|
215
215
|
- lib/property/parse_date.rb
|
216
216
|
- lib/property/parse_file.rb
|
217
217
|
- lib/property/parse_geo_point.rb
|
@@ -241,7 +241,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
241
241
|
version: '0'
|
242
242
|
segments:
|
243
243
|
- 0
|
244
|
-
hash:
|
244
|
+
hash: -4597148251358288016
|
245
245
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
246
246
|
none: false
|
247
247
|
requirements:
|
File without changes
|