parse-stack 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Changes.md +6 -0
- data/Gemfile.lock +1 -1
- data/README.md +1 -3
- data/lib/parse/api/analytics.rb +1 -1
- data/lib/parse/api/apps.rb +4 -4
- data/lib/parse/api/batch.rb +2 -2
- data/lib/parse/api/cloud_functions.rb +2 -2
- data/lib/parse/api/config.rb +1 -1
- data/lib/parse/api/files.rb +1 -1
- data/lib/parse/api/hooks.rb +1 -1
- data/lib/parse/api/objects.rb +2 -2
- data/lib/parse/api/push.rb +1 -1
- data/lib/parse/api/schemas.rb +1 -1
- data/lib/parse/api/users.rb +1 -1
- data/lib/parse/client.rb +8 -8
- data/lib/parse/client/caching.rb +4 -3
- data/lib/parse/client/protocol.rb +1 -0
- data/lib/parse/stack/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7b2f443ea3100a01208cc85a71fdc0b6ec2724c0
|
4
|
+
data.tar.gz: 253a1845c48fe6a9ffbdd728660efbab38bea5a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e083d6466f4dc40f2d207c192966027f6a0adf8e928183f129c6be81d569c6ed51a9eb4b5ff4e909ba46465d74fa818bd24025a52ef756c1b14e0235986d40d5
|
7
|
+
data.tar.gz: cfc551f79913f5fe87f29e642fcf22bdd51652b2b15db71650cd3727b0e62103e767e29e128b246dea5b5b4febd9eb28cff4e3ff639ec7e2441ae25928b936c9
|
data/Changes.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Parse-Stack Changes
|
2
2
|
|
3
|
+
1.0.4
|
4
|
+
-----------
|
5
|
+
- Fixes minor issue when storing and retrieving objects from the cache.
|
6
|
+
- Support for providing :server_url as a connection option for those migrating hosting
|
7
|
+
their own parse-server.
|
8
|
+
|
3
9
|
1.0.3
|
4
10
|
-----------
|
5
11
|
- Fixes minor issue when passing `nil` to the class `find` method.
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -86,6 +86,7 @@ Parse::Stack is a full stack framework that utilizes several ideas behind [DataM
|
|
86
86
|
require 'parse/stack'
|
87
87
|
|
88
88
|
Parse.setup application_id: APP_ID, api_key: REST_API_KEY
|
89
|
+
# you may pass `server_url` as an option. Defaults to `https://api.parse.com/1/`
|
89
90
|
|
90
91
|
# Object Mapper
|
91
92
|
class Song < Parse::Object
|
@@ -99,9 +100,6 @@ class Song < Parse::Object
|
|
99
100
|
has_many :likes, as: :user, through: :relation
|
100
101
|
end
|
101
102
|
|
102
|
-
# Optional schema updates (requires master key)
|
103
|
-
Song.auto_upgrade!
|
104
|
-
|
105
103
|
artist = Artist.first(:name.like => /Sinatra/, :genres.in => ['swing'])
|
106
104
|
|
107
105
|
song = Song.new name: "Fly Me to the Moon"
|
data/lib/parse/api/analytics.rb
CHANGED
data/lib/parse/api/apps.rb
CHANGED
@@ -9,25 +9,25 @@ module Parse
|
|
9
9
|
def fetch_app_keys(appid, email, password)
|
10
10
|
headers = {}
|
11
11
|
headers.merge!( { 'X-Parse-Email' => email, 'X-Parse-Password' => password } )
|
12
|
-
request :get, "
|
12
|
+
request :get, "apps/#{appid}", headers: headers
|
13
13
|
end
|
14
14
|
|
15
15
|
def fetch_apps(email, password)
|
16
16
|
headers = {}
|
17
17
|
headers.merge!( { 'X-Parse-Email' => email, 'X-Parse-Password' => password } )
|
18
|
-
request :get, "
|
18
|
+
request :get, "apps", headers: headers
|
19
19
|
end
|
20
20
|
|
21
21
|
def create_app(opts, email, password)
|
22
22
|
headers = {}
|
23
23
|
headers.merge!( { 'X-Parse-Email' => email, 'X-Parse-Password' => password } )
|
24
|
-
request :post, "
|
24
|
+
request :post, "apps", body: opts, headers: headers
|
25
25
|
end
|
26
26
|
|
27
27
|
def update_app(appid, opts, email, password)
|
28
28
|
headers = {}
|
29
29
|
headers.merge!( { 'X-Parse-Email' => email, 'X-Parse-Password' => password } )
|
30
|
-
request :put, "
|
30
|
+
request :put, "apps/#{appid}", body: opts, headers: headers
|
31
31
|
end
|
32
32
|
|
33
33
|
|
data/lib/parse/api/batch.rb
CHANGED
@@ -47,7 +47,7 @@ module Parse
|
|
47
47
|
end
|
48
48
|
|
49
49
|
class BatchOperation
|
50
|
-
MAX_REQ_SEC =
|
50
|
+
MAX_REQ_SEC = 40
|
51
51
|
|
52
52
|
attr_accessor :requests, :responses
|
53
53
|
include Enumerable
|
@@ -139,7 +139,7 @@ module Parse
|
|
139
139
|
unless batch_operations.is_a?(Parse::BatchOperation)
|
140
140
|
batch_operations = Parse::BatchOperation.new batch_operations
|
141
141
|
end
|
142
|
-
response = request(:post, "
|
142
|
+
response = request(:post, "batch", body: batch_operations.as_json)
|
143
143
|
response.success? && response.batch? ? response.batch_responses : response
|
144
144
|
end
|
145
145
|
|
@@ -5,11 +5,11 @@ module Parse
|
|
5
5
|
module CloudFunctions
|
6
6
|
|
7
7
|
def call_function(name, body = {})
|
8
|
-
request :post, "
|
8
|
+
request :post, "functions/#{name}", body: body
|
9
9
|
end
|
10
10
|
|
11
11
|
def trigger_job(name, body = {})
|
12
|
-
request :post, "
|
12
|
+
request :post, "jobs/#{name}", body: body
|
13
13
|
end
|
14
14
|
|
15
15
|
end
|
data/lib/parse/api/config.rb
CHANGED
data/lib/parse/api/files.rb
CHANGED
@@ -9,7 +9,7 @@ module Parse
|
|
9
9
|
def create_file(fileName, data = {}, content_type = nil)
|
10
10
|
headers = {}
|
11
11
|
headers.merge!( { Parse::Protocol::CONTENT_TYPE => content_type.to_s } ) if content_type.present?
|
12
|
-
response = request :post, "
|
12
|
+
response = request :post, "files/#{fileName}", body: data, headers: headers
|
13
13
|
response.parse_class = "_File".freeze
|
14
14
|
response
|
15
15
|
end
|
data/lib/parse/api/hooks.rb
CHANGED
@@ -6,7 +6,7 @@ module Parse
|
|
6
6
|
|
7
7
|
module API
|
8
8
|
module Hooks
|
9
|
-
HOOKS_PREFIX = "
|
9
|
+
HOOKS_PREFIX = "hooks/".freeze
|
10
10
|
TRIGGER_NAMES = [:beforeSave, :afterSave, :beforeDelete, :afterDelete].freeze
|
11
11
|
def _verify_trigger(triggerName)
|
12
12
|
triggerName = triggerName.to_s.camelize(:lower).to_sym
|
data/lib/parse/api/objects.rb
CHANGED
@@ -5,7 +5,7 @@ module Parse
|
|
5
5
|
#object fetch methods
|
6
6
|
module Objects
|
7
7
|
|
8
|
-
CLASS_PATH_PREFIX = "
|
8
|
+
CLASS_PATH_PREFIX = "classes/".freeze
|
9
9
|
PREFIX_MAP = { installation: "installations", _installation: "installations",
|
10
10
|
user: "users", _user: "users",
|
11
11
|
role: "roles", _role: "roles",
|
@@ -25,7 +25,7 @@ module Parse
|
|
25
25
|
uri = "#{CLASS_PATH_PREFIX}#{className}"
|
26
26
|
class_prefix = className.downcase.to_sym
|
27
27
|
if PREFIX_MAP.has_key?(class_prefix)
|
28
|
-
uri = "
|
28
|
+
uri = "#{PREFIX_MAP[class_prefix]}/"
|
29
29
|
end
|
30
30
|
id.present? ? "#{uri}/#{id}" : uri
|
31
31
|
end
|
data/lib/parse/api/push.rb
CHANGED
data/lib/parse/api/schemas.rb
CHANGED
data/lib/parse/api/users.rb
CHANGED
@@ -6,7 +6,7 @@ module Parse
|
|
6
6
|
module Users
|
7
7
|
# Note that Parse::Objects mainly use the objects.rb API since we can
|
8
8
|
# detect class names to proper URI handlers
|
9
|
-
USER_PATH_PREFIX = "
|
9
|
+
USER_PATH_PREFIX = "users".freeze
|
10
10
|
USER_CLASS = "_User".freeze
|
11
11
|
def fetch_user(id)
|
12
12
|
request :get, "#{USER_PATH_PREFIX}/#{id}"
|
data/lib/parse/client.rb
CHANGED
@@ -26,7 +26,7 @@ module Parse
|
|
26
26
|
include Parse::API::Schema
|
27
27
|
|
28
28
|
attr_accessor :session, :cache
|
29
|
-
attr_reader :application_id, :api_key, :master_key, :
|
29
|
+
attr_reader :application_id, :api_key, :master_key, :server_url
|
30
30
|
# The client can support multiple sessions. The first session created, will be placed
|
31
31
|
# under the default session tag. The :default session will be the default client to be used
|
32
32
|
# by the other classes including Parse::Query and Parse::Objects
|
@@ -59,10 +59,9 @@ module Parse
|
|
59
59
|
# :cache - Moneta::Transformer - if set, it should be a Moneta store instance
|
60
60
|
# :expires - Integer - if set, it should be a Moneta store instance
|
61
61
|
# :adapter - the HTTP adapter to use with Faraday, defaults to Faraday.default_adapter
|
62
|
-
# :host - defaults to Parse::Protocol::
|
62
|
+
# :host - defaults to Parse::Protocol::SERVER_URL (https://api.parse.com/1/)
|
63
63
|
def initialize(opts = {})
|
64
|
-
@
|
65
|
-
@version = 1
|
64
|
+
@server_url = opts[:server_url] || ENV["PARSE_SERVER_URL"] || Parse::Protocol::SERVER_URL
|
66
65
|
@application_id = opts[:application_id] || ENV["PARSE_APP_ID"]
|
67
66
|
@api_key = opts[:api_key] || ENV["PARSE_API_KEY"]
|
68
67
|
@master_key = opts[:master_key] || ENV["PARSE_MASTER_KEY"]
|
@@ -71,9 +70,11 @@ module Parse
|
|
71
70
|
if @application_id.nil? || ( @api_key.nil? && @master_key.nil? )
|
72
71
|
raise "Please call Parse.setup(application_id:, api_key:) to setup a session"
|
73
72
|
end
|
74
|
-
@
|
73
|
+
@server_url += '/' unless @server_url.ends_with?('/')
|
75
74
|
#Configure Faraday
|
76
|
-
|
75
|
+
opts[:faraday] ||= {}
|
76
|
+
opts[:faraday].merge!(:url => @server_url)
|
77
|
+
@session = Faraday.new(opts[:faraday]) do |conn|
|
77
78
|
#conn.request :json
|
78
79
|
|
79
80
|
conn.response :logger if opts[:logging]
|
@@ -138,11 +139,10 @@ module Parse
|
|
138
139
|
# http method
|
139
140
|
method = method.downcase.to_sym
|
140
141
|
# set the User-Agent
|
141
|
-
headers["User-Agent"
|
142
|
+
headers["User-Agent"] = "Parse-Ruby-Client v#{Parse::Stack::VERSION}"
|
142
143
|
#if it is a :get request, then use query params, otherwise body.
|
143
144
|
params = (method == :get ? query : body) || {}
|
144
145
|
# if the path does not start with the '/1/' prefix, then add it to be nice.
|
145
|
-
uri.replace(@version_prefix + uri) unless uri.start_with?(@version_prefix)
|
146
146
|
# actually send the request and return the body
|
147
147
|
@session.send(method, uri, params, headers).body
|
148
148
|
rescue Faraday::Error::ClientError => e
|
data/lib/parse/client/caching.rb
CHANGED
@@ -64,7 +64,8 @@ module Parse
|
|
64
64
|
if method == :get && url.present? && @store.key?(url)
|
65
65
|
puts("[Parse::Cache] >>> #{url}") if self.class.logging.present?
|
66
66
|
response = Faraday::Response.new
|
67
|
-
|
67
|
+
res_env = @store[url] # previous cached response
|
68
|
+
body = res_env.respond_to?(:body) ? res_env.body : nil
|
68
69
|
if body.present?
|
69
70
|
response.finish({status: 200, response_headers: {}, body: body })
|
70
71
|
return response
|
@@ -77,12 +78,12 @@ module Parse
|
|
77
78
|
# request for the same '/1/classes/Artist/<objectId>' where objectId are equivalent
|
78
79
|
@store.delete url
|
79
80
|
end
|
80
|
-
rescue
|
81
|
+
rescue Errno::EINVAL, Redis::CannotConnectError => e
|
81
82
|
# if the cache store fails to connect, catch the exception but proceed
|
82
83
|
# with the regular request, but turn off caching for this request. It is possible
|
83
84
|
# that the cache connection resumes at a later point, so this is temporary.
|
84
85
|
cache_enabled = false
|
85
|
-
warn "[Parse::Cache Error]
|
86
|
+
warn "[Parse::Cache Error] #{e}"
|
86
87
|
end
|
87
88
|
|
88
89
|
|
data/lib/parse/stack/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: parse-stack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Persaud
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-02-
|
12
|
+
date: 2016-02-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|