parse-stack 1.6.11 → 1.6.12

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1e8c593e13180e83fb349eff383cab24f11e70e6
4
- data.tar.gz: 3e97c6ab5b0d7ef055f67553541178734d815fd6
3
+ metadata.gz: 641ab5a564cc0fc19b55697f77db532aab40b2b0
4
+ data.tar.gz: 2cebf9bd8e0337137801d0eb269e30a90d22ad42
5
5
  SHA512:
6
- metadata.gz: ed75d26379dd431857a469010d2497121c44bff4520076d72906164491dcee17e1a54b047a1c9ed8d2f9d8bc4eb482cd10d5414bf551d40f89a2961a253e8b99
7
- data.tar.gz: bcf0da08fd9a257b8ae6c6d9bda80e83de4ec5172b9bb0d6733ce3a3b0152a263bd5cae95d909d5a4a9a197a248af744ab0af64e273e1bb47892e8c45773ac52
6
+ metadata.gz: a8a5e7a2e7bbdb41adff46994b3fef930c070bd7d9842d8646180d571fa7a6e81007da0e2d07b2edd1d275732f99b81db8e8f2588c94dca762c4e04b0fc55ca4
7
+ data.tar.gz: 46f3b106aae7687d969b9193498a5258f648e1f5ae97d908f99f58bd9d465ca5bd2bd14ac89f5cf368d0f7509d142d46f9afa573100afd5d2a8694dba1d69970
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --no-private
data/Changes.md CHANGED
@@ -1,5 +1,19 @@
1
1
  ## Parse-Stack Changelog
2
2
 
3
+ ### 1.6.12
4
+ - NEW: Parse.use_shortnames! to utilize shorter class methods. (optional)
5
+ - NEW: parse-console supports `--url` option to load config from JSON url.
6
+ - FIXES: Issue #27 where core classes could not be auto-upgraded if they were missing.
7
+ - Warnings are now printed if auto_upgrade! is called without the master key.
8
+ - Use `Parse.use_shortnames!` to use short name class names Ex. Parse::User -> User
9
+ - Hosting documentation on https://www.modernistik.com/gems/parse-stack/ since rubydoc.info doesn't
10
+ use latest yard features.
11
+ - Parse::Query will raise an exception if a non-nil value is passed to `:session` that
12
+ does not provide a valid session token string.
13
+ - `save` and `destroy` will raise an exception if a non-nil `session` argument is passed
14
+ that does not provide a valid session token string.
15
+ - Additional documentation changes and tests.
16
+
3
17
  ### 1.6.11
4
18
  - NEW: Parse::Object#sig method to get quick information about an instance.
5
19
  - FIX: Typo fix when using Array#objectIds.
data/Gemfile.lock CHANGED
@@ -1,28 +1,28 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- parse-stack (1.6.11)
4
+ parse-stack (1.6.12)
5
5
  active_model_serializers (>= 0.9, < 1)
6
6
  activemodel (>= 4.2.1, < 6)
7
7
  activesupport (>= 4.2.1, < 6)
8
8
  faraday (>= 0.8, < 1)
9
9
  faraday_middleware (>= 0.9, < 1)
10
- moneta (>= 0.7, < 1)
10
+ moneta (< 2)
11
11
  parallel (>= 1.6, < 2)
12
12
  rack (< 3)
13
13
 
14
14
  GEM
15
15
  remote: https://rubygems.org/
16
16
  specs:
17
- actionpack (5.1.0)
18
- actionview (= 5.1.0)
19
- activesupport (= 5.1.0)
17
+ actionpack (5.1.1)
18
+ actionview (= 5.1.1)
19
+ activesupport (= 5.1.1)
20
20
  rack (~> 2.0)
21
21
  rack-test (~> 0.6.3)
22
22
  rails-dom-testing (~> 2.0)
23
23
  rails-html-sanitizer (~> 1.0, >= 1.0.2)
24
- actionview (5.1.0)
25
- activesupport (= 5.1.0)
24
+ actionview (5.1.1)
25
+ activesupport (= 5.1.1)
26
26
  builder (~> 3.1)
27
27
  erubi (~> 1.4)
28
28
  rails-dom-testing (~> 2.0)
@@ -32,9 +32,9 @@ GEM
32
32
  activemodel (>= 4.1, < 6)
33
33
  case_transform (>= 0.2)
34
34
  jsonapi-renderer (>= 0.1.1.beta1, < 0.2)
35
- activemodel (5.1.0)
36
- activesupport (= 5.1.0)
37
- activesupport (5.1.0)
35
+ activemodel (5.1.1)
36
+ activesupport (= 5.1.1)
37
+ activesupport (5.1.1)
38
38
  concurrent-ruby (~> 1.0, >= 1.0.2)
39
39
  i18n (~> 0.7)
40
40
  minitest (~> 5.1)
@@ -48,7 +48,7 @@ GEM
48
48
  coderay (1.1.1)
49
49
  concurrent-ruby (1.0.5)
50
50
  daemons (1.2.4)
51
- debug_inspector (0.0.2)
51
+ debug_inspector (0.0.3)
52
52
  dotenv (2.2.1)
53
53
  erubi (1.6.0)
54
54
  eventmachine (1.2.3)
@@ -56,18 +56,18 @@ GEM
56
56
  multipart-post (>= 1.2, < 3)
57
57
  faraday_middleware (0.11.0.1)
58
58
  faraday (>= 0.7.4, < 1.0)
59
- i18n (0.8.1)
59
+ i18n (0.8.4)
60
60
  jsonapi-renderer (0.1.2)
61
61
  loofah (2.0.3)
62
62
  nokogiri (>= 1.5.9)
63
63
  method_source (0.8.2)
64
- mini_portile2 (2.1.0)
65
- minitest (5.10.1)
66
- moneta (0.8.1)
64
+ mini_portile2 (2.2.0)
65
+ minitest (5.10.2)
66
+ moneta (1.0.0)
67
67
  multipart-post (2.0.0)
68
- nokogiri (1.7.1)
69
- mini_portile2 (~> 2.1.0)
70
- parallel (1.11.1)
68
+ nokogiri (1.8.0)
69
+ mini_portile2 (~> 2.2.0)
70
+ parallel (1.11.2)
71
71
  pry (0.10.4)
72
72
  coderay (~> 1.1.0)
73
73
  method_source (~> 0.8.1)
@@ -77,12 +77,12 @@ GEM
77
77
  pry-stack_explorer (0.4.9.2)
78
78
  binding_of_caller (>= 0.7)
79
79
  pry (>= 0.9.11)
80
- rack (2.0.1)
80
+ rack (2.0.3)
81
81
  rack-test (0.6.3)
82
82
  rack (>= 1.0)
83
- rails-dom-testing (2.0.2)
84
- activesupport (>= 4.2.0, < 6.0)
85
- nokogiri (~> 1.6)
83
+ rails-dom-testing (2.0.3)
84
+ activesupport (>= 4.2.0)
85
+ nokogiri (>= 1.6)
86
86
  rails-html-sanitizer (1.0.3)
87
87
  loofah (~> 2.0)
88
88
  rake (12.0.0)
@@ -116,4 +116,4 @@ DEPENDENCIES
116
116
  yard
117
117
 
118
118
  BUNDLED WITH
119
- 1.13.7
119
+ 1.15.1
data/README.md CHANGED
@@ -1,10 +1,10 @@
1
- <img src='https://raw.githubusercontent.com/modernistik/parse-stack/master/.github/parse-ruby-sdk.png?raw=true' width='500' alt='Ruby Parse SDK'/>
1
+ <img src='https://raw.githubusercontent.com/modernistik/parse-stack/master/.github/parse-ruby-sdk.png?raw=true' width='500' alt='Ruby Parse Server SDK'/>
2
2
 
3
- # Parse Stack - The Parse Ruby Client SDK
3
+ # Parse Stack - The Parse Server Ruby Client SDK
4
4
 
5
5
  [Parse Stack](https://github.com/modernistik/parse-stack) is the [Parse Server](https://github.com/ParsePlatform/parse-server) SDK, REST Client and ORM framework for [Ruby](https://www.ruby-lang.org/en/). It provides a client adapter, a query engine, an object relational mapper (ORM) and a Cloud Code Webhooks rack application.
6
6
 
7
- Below is a [quick start guide](https://github.com/modernistik/parse-stack#overview), but you can also check out the full [API Reference](http://www.rubydoc.info/github/modernistik/parse-stack) for more detailed information about our Parse Server SDK.
7
+ Below is a [quick start guide](https://github.com/modernistik/parse-stack#overview), but you can also check out the full *[API Reference](https://www.modernistik.com/gems/parse-stack/)* for more detailed information about our Parse Server SDK.
8
8
 
9
9
  #### Tutorial Videos
10
10
  1. Getting Started: https://youtu.be/zoYSGmciDlQ
@@ -15,52 +15,51 @@ Below is a [quick start guide](https://github.com/modernistik/parse-stack#overvi
15
15
  [![Gem Version](https://img.shields.io/gem/v/parse-stack.svg)](https://github.com/modernistik/parse-stack)
16
16
  [![Downloads](https://img.shields.io/gem/dt/parse-stack.svg)](https://rubygems.org/gems/parse-stack)
17
17
  [![Build Status](https://travis-ci.org/modernistik/parse-stack.svg?branch=master)](https://travis-ci.org/modernistik/parse-stack)
18
- [![API Reference](http://img.shields.io/badge/api-docs-blue.svg)](http://www.rubydoc.info/github/modernistik/parse-stack)
18
+ [![API Reference](http://img.shields.io/badge/api-docs-blue.svg)](https://www.modernistik.com/gems/parse-stack/)
19
19
 
20
20
  ### Questions?
21
21
  [![Gitter](https://badges.gitter.im/modernistik/parse-stack.svg)](https://gitter.im/modernistik/parse-stack?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge)
22
22
 
23
23
  ## Installation
24
24
 
25
- Add this line to your application's Gemfile:
26
-
27
- gem 'parse-stack'
28
-
25
+ Add this line to your application's `Gemfile`:
26
+ ```ruby
27
+ gem 'parse-stack'
28
+ ```
29
29
  And then execute:
30
-
31
- $ bundle
32
-
30
+ ```bash
31
+ $ bundle
32
+ ```
33
33
  Or install it yourself as:
34
-
35
- $ gem install parse-stack
36
-
34
+ ```bash
35
+ $ gem install parse-stack
36
+ ```
37
37
  ### Rack / Sinatra
38
38
  Parse-Stack API, models and webhooks easily integrate in your existing Rack/Sinatra based applications. For more details see [Parse-Stack Rack Example](https://github.com/modernistik/parse-stack-example).
39
39
 
40
40
  ### Rails
41
41
  Parse-Stack comes with support for Rails by adding additional rake tasks and generators. After adding `parse-stack` as a gem dependency in your Gemfile and running `bundle`, you should run the install script:
42
-
43
- $ rails g parse_stack:install
44
-
42
+ ```bash
43
+ $ rails g parse_stack:install
44
+ ```
45
45
  For a more details on the rails integration see [Parse-Stack Rails Example](https://github.com/modernistik/parse-stack-rails-example).
46
46
 
47
47
  ### Interactive Command Line Playground
48
48
  You can also used the bundled `parse-console` command line to connect and interact with your Parse Server and its data in an IRB-like console. This is useful for trying concepts and debugging as it will automatically connect to your Parse Server, and if provided the master key, automatically generate all the models entities.
49
49
 
50
50
  ```bash
51
- $ parse-console -h # see all options
52
- $ parse-console -v -a myAppId -m myMasterKey http://localhost:1337/parse
53
- Server : http://localhost:1337/parse
54
- App Id : myAppId
55
- Master : true
56
- 2.4.0 > Parse::User.first
51
+ $ parse-console -h # see all options
52
+ $ parse-console -v -a myAppId -m myMasterKey http://localhost:1337/parse
53
+ Server : http://localhost:1337/parse
54
+ App Id : myAppId
55
+ Master : true
56
+ 2.4.0 > Parse::User.first
57
57
  ```
58
58
 
59
59
  ## Overview
60
60
  Parse-Stack is a full stack framework that utilizes several ideas behind [DataMapper](http://datamapper.org/docs/find.html) and [ActiveModel](https://github.com/rails/rails/tree/master/activemodel) to manage and maintain larger scale ruby applications and tools that utilize the [Parse Server Platform](https://github.com/ParsePlatform/parse-server). If you are familiar with these technologies, the framework should feel familiar to you.
61
61
 
62
62
  ```ruby
63
-
64
63
  require 'parse/stack'
65
64
 
66
65
  Parse.setup server_url: 'https://localhost:1337/parse',
@@ -252,16 +251,16 @@ result = Parse.call_function :myFunctionName, {param: value}
252
251
  ## Architecture
253
252
  The architecture of `Parse::Stack` is broken into four main components.
254
253
 
255
- ### Parse::Client
254
+ ### [Parse::Client](https://www.modernistik.com/gems/parse-stack/Parse/Client.html)
256
255
  This class is the core and low level API for the Parse Server REST interface that is used by the other components. It can manage multiple sessions, which means you can have multiple client instances pointing to different Parse Server applications at the same time. It handles sending raw requests as well as providing Request/Response objects for all API handlers. The connection engine is Faraday, which means it is open to add any additional middleware for features you'd like to implement.
257
256
 
258
- ### Parse::Query
259
- This class implements the [Parse REST Querying](http://parseplatform.github.io/docs/rest/guide/#queries) interface in the [DataMapper finder syntax style](http://datamapper.org/docs/find.html). It compiles a set of query constraints and utilizes `Parse::Client` to send the request and provide the raw results. This class can be used without the need to define models.
257
+ ### [Parse::Query](https://www.modernistik.com/gems/parse-stack/Parse/Query.html)
258
+ This class implements the [Parse REST Querying](http://docs.parseplatform.org/rest/guide/#queries) interface in the [DataMapper finder syntax style](http://datamapper.org/docs/find.html). It compiles a set of query constraints and utilizes `Parse::Client` to send the request and provide the raw results. This class can be used without the need to define models.
260
259
 
261
- ### Parse::Object
260
+ ### [Parse::Object](https://www.modernistik.com/gems/parse-stack/Parse/Object.html)
262
261
  This component is main class for all object relational mapping subclasses for your application. It provides features in order to map your remote Parse records to a local ruby object. It implements the Active::Model interface to provide a lot of additional features, CRUD operations, querying, including dirty tracking, JSON serialization, save/destroy callbacks and others. While we are overlooking some functionality, for simplicity, you will mainly be working with Parse::Object as your superclass. While not required, it is highly recommended that you define a model (Parse::Object subclass) for all the Parse classes in your application.
263
262
 
264
- ### Parse::Webhooks
263
+ ### [Parse::Webhooks](https://www.modernistik.com/gems/parse-stack/Parse/Webhooks.html)
265
264
  Parse provides a feature called [Cloud Code Webhooks](http://blog.parse.com/announcements/introducing-cloud-code-webhooks/). For most applications, save/delete triggers and cloud functions tend to be implemented by Parse's own hosted Javascript solution called Cloud Code. However, Parse provides the ability to have these hooks utilize your hosted solution instead of their own, since their environment is limited in terms of resources and tools.
266
265
 
267
266
  ## Field Naming Conventions
@@ -387,7 +386,7 @@ You can always combine both approaches by defining special attributes before you
387
386
 
388
387
  ```
389
388
 
390
- ## Parse Config
389
+ ## [Parse Config](https://www.modernistik.com/gems/parse-stack/Parse/API/Config.html)
391
390
  Getting your configuration variables once you have a default client setup can be done with `Parse.config`. The first time this method is called, Parse-Stack will get the configuration from Parse Server, and cache it. To force a reload of the config, use `config!`. You
392
391
 
393
392
  ```ruby
@@ -410,7 +409,7 @@ Getting your configuration variables once you have a default client setup can be
410
409
  ## Core Classes
411
410
  While some native data types are similar to the ones supported by Ruby natively, other ones are more complex and require their dedicated classes.
412
411
 
413
- ### Parse::Pointer
412
+ ### [Parse::Pointer](https://www.modernistik.com/gems/parse-stack/Parse/Pointer.html)
414
413
  An important concept is the `Parse::Pointer` class. This is the superclass of `Parse::Object` and represents the pointer type in Parse. A `Parse::Pointer` only contains data about the specific Parse class and the `id` for the object. Therefore, creating an instance of any Parse::Object subclass with only the `:id` field set will be considered in "pointer" state even though its specific class is not `Parse::Pointer` type. The only case that you may have a Parse::Pointer is in the case where an object was received for one of your classes and the framework has no registered class handler for it. Using the example above, assume you have the tables `Post`, `Comment` and `Author` defined in your remote Parse application, but have only defined `Post` and `Commentary` locally.
415
414
 
416
415
  ```ruby
@@ -446,7 +445,7 @@ comment.post.pointer? # false, it is now a full object.
446
445
 
447
446
  The effect is that for any unknown classes that the framework encounters, it will generate Parse::Pointer instances until you define those classes with valid properties and associations. While this might be ok for some classes you do not use, we still recommend defining all your Parse classes locally in the framework.
448
447
 
449
- ### Parse::File
448
+ ### [Parse::File](https://www.modernistik.com/gems/parse-stack/Parse/File.html)
450
449
  This class represents a Parse file pointer. `Parse::File` has helper methods to upload Parse files directly to Parse and manage file associations with your classes. Using our Song class example:
451
450
 
452
451
  ```ruby
@@ -500,7 +499,7 @@ file.url # => https://www.example.com/file.png
500
499
 
501
500
  ```
502
501
 
503
- ### Parse::Date
502
+ ### [Parse::Date](https://www.modernistik.com/gems/parse-stack/Parse/Date.html)
504
503
  This class manages dates in the special JSON format it requires for properties of type `:date`. `Parse::Date` subclasses `DateTime`, which allows you to use any features or methods available to `DateTime` with `Parse::Date`. While the conversion between `Time` and `DateTime` objects to a `Parse::Date` object is done implicitly for you, you can use the added special methods, `DateTime#parse_date` and `Time#parse_date`, for special occasions.
505
504
 
506
505
  ```ruby
@@ -543,7 +542,7 @@ We include helper methods to calculate distances between GeoPoints: `distance_in
543
542
  # ~180.793 km
544
543
  ```
545
544
 
546
- ### Parse::Bytes
545
+ ### [Parse::Bytes](https://www.modernistik.com/gems/parse-stack/Parse/Bytes.html)
547
546
  The `Bytes` data type represents the storage format for binary content in a Parse column. The content is needs to be encoded into a base64 string.
548
547
 
549
548
  ```ruby
@@ -555,7 +554,7 @@ The `Bytes` data type represents the storage format for binary content in a Pars
555
554
  decoded = bytes.decoded # same as Base64.decode64
556
555
  ```
557
556
 
558
- ### Parse::ACL
557
+ ### [Parse::ACL](https://www.modernistik.com/gems/parse-stack/Parse/ACL.html)
559
558
  The `ACL` class represents the access control lists for each record. An ACL is represented by a JSON object with the keys being `Parse::User` object ids or the special key of `*`, which indicates the public access permissions.
560
559
  The value of each key in the hash is a `Parse::ACL::Permission` object which defines the boolean permission state for `read` and `write`.
561
560
 
@@ -592,10 +591,10 @@ All `Parse::Object` subclasses have an `acl` property by default. With this prop
592
591
  artist.save
593
592
  ```
594
593
 
595
- For more information about Parse record ACLs, see the documentation at [Security](https://parseplatform.github.io/docs/rest/guide/#security)
594
+ For more information about Parse record ACLs, see the documentation at [Security](http://docs.parseplatform.org/rest/guide/#security)
596
595
 
597
- ### Parse::Session
598
- This class represents the data and columns contained in the standard Parse `_Session` collection. You may add additional properties and methods to this class. See [Session API Reference](http://www.rubydoc.info/github/modernistik/parse-stack/Parse/Session).
596
+ ### [Parse::Session](https://www.modernistik.com/gems/parse-stack/Parse/Session.html)
597
+ This class represents the data and columns contained in the standard Parse `_Session` collection. You may add additional properties and methods to this class. See [Session API Reference](https://www.modernistik.com/gems/parse-stack/Parse/Session). You may call `Parse.use_shortnames!` to use `Session` in addition to `Parse::Session`.
599
598
 
600
599
  You can get a specific `Parse::Session` given a session_token by using the `session` method. You can also find the user tied to a specific Parse session or session token with `Parse::User.session`.
601
600
 
@@ -607,16 +606,25 @@ session.user # the Parse user for this session
607
606
  # or fetch user with a session token
608
607
  user = Parse::User.session(token)
609
608
 
609
+ # save an object with the priviledges (ACLs) of this user
610
+ some_object.save( session: user.session_token )
611
+
612
+ # delete an object with the priviledges of this user
613
+ some_object.destroy( session: user.session_token )
614
+
610
615
  ```
611
616
 
612
- ### Parse::Installation
613
- This class represents the data and columns contained in the standard Parse `_Installation` collection. You may add additional properties and methods to this class. See [Installation API Reference](http://www.rubydoc.info/github/modernistik/parse-stack/Parse/Installation).
617
+ ### [Parse::Installation](https://www.modernistik.com/gems/parse-stack/Parse/Installation)
618
+ This class represents the data and columns contained in the standard Parse `_Installation` collection. You may add additional properties and methods to this class. See [Installation API Reference](https://www.modernistik.com/gems/parse-stack/Parse/Installation). You may call `Parse.use_shortnames!` to use `Installation` in addition to `Parse::Installation`.
619
+
620
+ ### [Parse::Product](https://www.modernistik.com/gems/parse-stack/Parse/Product)
621
+ This class represents the data and columns contained in the standard Parse `_Product` collection. You may add additional properties and methods to this class. See [Product API Reference](https://www.modernistik.com/gems/parse-stack/Parse/Product). You may call `Parse.use_shortnames!` to use `Product` in addition to `Parse::Product`.
614
622
 
615
- ### Parse::Role
616
- This class represents the data and columns contained in the standard Parse `_Role` collection. You may add additional properties and methods to this class. See [Roles API Reference](http://www.rubydoc.info/github/modernistik/parse-stack/Parse/Role).
623
+ ### [Parse::Role](https://www.modernistik.com/gems/parse-stack/Parse/Role)
624
+ This class represents the data and columns contained in the standard Parse `_Role` collection. You may add additional properties and methods to this class. See [Roles API Reference](https://www.modernistik.com/gems/parse-stack/Parse/Role). You may call `Parse.use_shortnames!` to use `Role` in addition to `Parse::Role`.
617
625
 
618
- ### Parse::User
619
- This class represents the data and columns contained in the standard Parse `_User` collection. You may add additional properties and methods to this class. See [User API Reference](http://www.rubydoc.info/github/modernistik/parse-stack/Parse/User).
626
+ ### [Parse::User](https://www.modernistik.com/gems/parse-stack/Parse/User)
627
+ This class represents the data and columns contained in the standard Parse `_User` collection. You may add additional properties and methods to this class. See [User API Reference](https://www.modernistik.com/gems/parse-stack/Parse/User). You may call `Parse.use_shortnames!` to use `User` in addition to `Parse::User`.
620
628
 
621
629
  #### Signup
622
630
  You can signup new users in two ways. You can either use a class method `Parse::User.signup` to create a new user with the minimum fields of username, password and email, or create a `Parse::User` object can call the `signup!` method. If signup fails, it will raise the corresponding exception.
@@ -630,7 +638,7 @@ user.signup!
630
638
  ```
631
639
 
632
640
  ##### Third-Party Services
633
- You can signup users using third-party services like Facebook and Twitter as described in: [Signing Up and Logging In](https://parseplatform.github.io/docs/rest/guide/#signing-up-and-logging-in). To do this with Parse-Stack, you can call the `Parse::User.autologin_service` method by passing the service name and the corresponding authentication hash data. For a listing of supported third-party authentication services, see [OAuth](https://github.com/ParsePlatform/parse-server/wiki/OAuth).
641
+ You can signup users using third-party services like Facebook and Twitter as described in: [Signing Up and Logging In](http://docs.parseplatform.org/rest/guide/#signing-up). To do this with Parse-Stack, you can call the `Parse::User.autologin_service` method by passing the service name and the corresponding authentication hash data. For a listing of supported third-party authentication services, see [OAuth](https://github.com/ParsePlatform/parse-server/wiki/OAuth).
634
642
 
635
643
  ```ruby
636
644
  fb_auth = {}
@@ -686,7 +694,7 @@ user.logout # deletes the corresponding session
686
694
  ```
687
695
 
688
696
  #### Linking and Unlinking
689
- You can link or unlink user accounts with third-party services like Facebook and Twitter as described in: [Linking and Unlinking Users](https://parseplatform.github.io/docs/rest/guide/#linking). To do this, you must first get the corresponding authentication data for the specific service, and then apply it to the user using the linking and unlinking methods. Each method returns true or false if the action was successful. For a listing of supported third-party authentication services, see [OAuth](https://github.com/ParsePlatform/parse-server/wiki/OAuth).
697
+ You can link or unlink user accounts with third-party services like Facebook and Twitter as described in: [Linking and Unlinking Users](http://docs.parseplatform.org/rest/guide/#linking-users). To do this, you must first get the corresponding authentication data for the specific service, and then apply it to the user using the linking and unlinking methods. Each method returns true or false if the action was successful. For a listing of supported third-party authentication services, see [OAuth](http://docs.parseplatform.org/parse-server/guide/#oauth-and-3rd-party-authentication).
690
698
 
691
699
  ```ruby
692
700
 
@@ -995,7 +1003,7 @@ band.drummer # Artist object
995
1003
  ###### `:field`
996
1004
  This option allows you to set the name of the remote Parse column for this property. Using this will explicitly set the remote property name to the value of this option. The value provided for this option will affect the name of the alias method that is generated when `alias` option is used. **By default, the name of the remote column is the lower-first camel case version of the property name. As an example, for a property with key `:my_property_name`, the framework will implicitly assume that the remote column is `myPropertyName`.**
997
1005
 
998
- #### Has One
1006
+ #### [Has One](https://www.modernistik.com/gems/parse-stack/Parse/Associations/HasOne.html)
999
1007
  The `has_one` creates a one-to-one association with another Parse class. This association says that the other class in the association contains a foreign pointer column which references instances of this class. If your model contains a column that is a Parse pointer to another class, you should use `belongs_to` for that association instead.
1000
1008
 
1001
1009
  Defining a `has_one` property generates a helper query method to fetch a particular record from a foreign class. This is useful for setting up the inverse relationship accessors of a `belongs_to`. In the case of the `has_one` relationship, the `:field` option represents the name of the column of the foreign class where the Parse pointer is stored. By default, the lower-first camel case version of the Parse class name is used.
@@ -1054,8 +1062,8 @@ user.band_by_status(false)
1054
1062
 
1055
1063
  ```
1056
1064
 
1057
- #### Has Many
1058
- Parse has many ways to implement one-to-many and many-to-many associations: `Array`, `Parse Relation` or through a `Query`. How you decide to implement your associations, will affect how `has_many` works in Parse-Stack. Parse natively supports one-to-many and many-to-many relationships using `Array` and `Relations`, as described in [Relational Data](https://parseplatform.github.io/docs/js/guide/#relational-data). Both of these methods require you define a specific column type in your Parse table that will be used to store information about the association.
1065
+ #### [Has Many](https://www.modernistik.com/gems/parse-stack/Parse/Associations/HasMany.html)
1066
+ Parse has many ways to implement one-to-many and many-to-many associations: `Array`, `Parse Relation` or through a `Query`. How you decide to implement your associations, will affect how `has_many` works in Parse-Stack. Parse natively supports one-to-many and many-to-many relationships using `Array` and `Relations`, as described in [Relational Data](http://docs.parseplatform.org/js/guide/#relational-data). Both of these methods require you define a specific column type in your Parse table that will be used to store information about the association.
1059
1067
 
1060
1068
  In addition to `Array` and `Relation`, Parse-Stack also implements the standard `has_many` behavior prevalent in other frameworks through a query where the associated class contains a foreign pointer to the local class, usually the inverse of a `belongs_to`. This requires that the associated class has a defined column
1061
1069
  that contains a pointer the refers to the defining class.
@@ -1170,13 +1178,13 @@ band.save
1170
1178
  ```
1171
1179
 
1172
1180
  ##### Parse Relation
1173
- Other than the use of arrays, Parse supports native one-to-many and many-to-many associations through what is referred to as a [Parse Relation](https://parseplatform.github.io/docs/js/guide/#many-to-many-relationships). This is implemented by defining a column to be of type `Relation` which refers to a foreign class. Parse-Stack supports this by passing the `through: :relation` option to the `has_many` method. Designating a column as a Parse relation to another class type, will create a one-way intermediate "join-list" between the local class and the foreign class. One important distinction of this compared to other types of data stores (ex. PostgresSQL) is that:
1181
+ Other than the use of arrays, Parse supports native one-to-many and many-to-many associations through what is referred to as a [Parse Relation](http://docs.parseplatform.org/js/guide/#many-to-many-relationships). This is implemented by defining a column to be of type `Relation` which refers to a foreign class. Parse-Stack supports this by passing the `through: :relation` option to the `has_many` method. Designating a column as a Parse relation to another class type, will create a one-way intermediate "join-list" between the local class and the foreign class. One important distinction of this compared to other types of data stores (ex. PostgresSQL) is that:
1174
1182
 
1175
1183
  1. The inverse relationship association is not available automatically. Therefore, having a column of `artists` in a `Band` class that relates to members of the band (as `Artist` class), does not automatically make a set of `Band` records available to `Artist` records for which they have been related. If you need to maintain both the inverse relationship between a foreign class to its associations, you will need to manually manage that by adding two Parse relation columns in each class, or by creating a separate class (ex. `ArtistBands`) that is used as a join table.
1176
1184
  2. Querying the relation is actually performed against the implicit join table, not the local one.
1177
1185
  3. Applying query constraints for a set of records within a relation is performed against the foreign table class, not the class having the relational column.
1178
1186
 
1179
- The Parse documentation provides more details on associations, see [Parse Relations Guide](http://parseplatform.github.io/docs/ios/guide/#relations). Parse-Stack will handle the work for (2) and (3) automatically.
1187
+ The Parse documentation provides more details on associations, see [Parse Relations Guide](http://docs.parseplatform.org/ios/guide/#relations). Parse-Stack will handle the work for (2) and (3) automatically.
1180
1188
 
1181
1189
  In the example below, a `Band` can have thousands of `Fans`. We setup a `Relation<Fan>` column in the `Band` class that references the `Fan` class. Parse-Stack provides methods to manage the relationship under the [Parse::RelationCollectionProxy](https://github.com/modernistik/parse-stack/blob/master/lib/parse/model/associations/relation_collection_proxy.rb) class.
1182
1190
 
@@ -1261,7 +1269,7 @@ author.posts # => Posts where author's name is a tag
1261
1269
  ```
1262
1270
 
1263
1271
  ## Creating, Saving and Deleting Records
1264
- This section provides some of the basic methods when creating, updating and deleting objects from Parse. To illustrate the various methods available for saving Parse records, we use this example class:
1272
+ This section provides some of the basic methods when creating, updating and deleting objects from Parse. Additional documentation for these APIs can be found under [Parse::Core::Actions](https://www.modernistik.com/gems/parse-stack/Parse/Core/Actions.html). To illustrate the various methods available for saving Parse records, we use this example class:
1265
1273
 
1266
1274
  ```ruby
1267
1275
 
@@ -1365,6 +1373,20 @@ To commit a new record or changes to an existing record to Parse, use the `#save
1365
1373
 
1366
1374
  The save operation can handle both creating and updating existing objects. If you do not want to update the association data of a changed object, you may use the `#update` method to only save the changed property values. In the case where you want to force update an object even though it has not changed, to possibly trigger your `before_save` hooks, you can use the `#update!` method. In addition, just like with other ActiveModel objects, you may call `reload!` to fetch the current record again from the data store.
1367
1375
 
1376
+ ### Saving applying User ACLs
1377
+ You may save and delete objects from Parse on behalf of a logged in user by passing the session token to the call to `save` or `destroy`. Doing so will allow Parse to apply the ACLs of this user against the record to see if the user is authorized to read or write the record. See [Parse::Actions](https://www.modernistik.com/gems/parse-stack/Parse/Actions).
1378
+
1379
+ ```ruby
1380
+ user = Parse::User.login('myuser','pass')
1381
+
1382
+ song = Song.first
1383
+ song.title = "My New Title"
1384
+ # save this song as if you were this user.
1385
+ # If the user does not have access rights, it will fail
1386
+ song.save session: user.session_token
1387
+ # shorthand: song.save session: user
1388
+ ```
1389
+
1368
1390
  #### Raising an exception when save fails
1369
1391
  By default, we return `true` or `false` for save and destroy operations. If you prefer to have `Parse::Object` raise an exception instead, you can tell to do so either globally or on a per-model basis. When a save fails, it will raise a `Parse::RecordNotSaved`.
1370
1392
 
@@ -1628,7 +1650,7 @@ If you only need to know the result count for a query, provide count a non-zero
1628
1650
  ```
1629
1651
 
1630
1652
  ### Query Expressions
1631
- The set of supported expressions based on what is available through the Parse REST API. _For those who don't prefer the DataMapper style syntax, we have provided method accessors for each of the expressions._
1653
+ The set of supported expressions based on what is available through the Parse REST API. _For those who don't prefer the DataMapper style syntax, we have provided method accessors for each of the expressions._ A full description of supported query operations, please refer to the [`Parse::Query`](https://www.modernistik.com/gems/parse-stack/Parse/Query.html) API reference.
1632
1654
 
1633
1655
  #### :order
1634
1656
  Specify a field to sort by.
@@ -1724,7 +1746,7 @@ The `where` clause is based on utilizing a set of constraints on the defined col
1724
1746
  ```
1725
1747
 
1726
1748
  ## Query Constraints
1727
- Most of the constraints supported by Parse are available to `Parse::Query`. Assuming you have a column named `field`, here are some examples. For an explanation of the constraints, please see [Parse Query Constraints documentation](http://parseplatform.github.io/docs/rest/guide/#queries). You can build your own custom query constraints by creating a `Parse::Constraint` subclass. For all these `where` clauses assume `q` is a `Parse::Query` object.
1749
+ Most of the constraints supported by Parse are available to `Parse::Query`. Assuming you have a column named `field`, here are some examples. For an explanation of the constraints, please see [Parse Query Constraints documentation](http://docs.parseplatform.org/rest/guide/#queries). You can build your own custom query constraints by creating a `Parse::Constraint` subclass. For all these `where` clauses assume `q` is a `Parse::Query` object.
1728
1750
 
1729
1751
  #### Equals
1730
1752
  Default query constraint for matching a field to a single value.
@@ -2118,9 +2140,10 @@ puts song.name # 'My Title'
2118
2140
  There are also a special `:create` callback. A `before_create` will be called whenever a unsaved object will be saved, and `after_create` will be called when a previously unsaved object successfully saved for the first time.
2119
2141
 
2120
2142
  ## Schema Upgrades and Migrations
2121
- You may change your local Parse ruby classes by adding new properties. To easily propagate the changes to your Parse application (MongoDB), you can call `auto_upgrade!` on the class to perform an non-destructive additive schema change. This will create the new columns in Parse for the properties you have defined in your models. Parse Stack will calculate the changes and only modify the tables which need new columns to be added. *It will not destroy columns or data*
2143
+ You may change your local Parse ruby classes by adding new properties. To easily propagate the changes to your Parse Server application (MongoDB), you can call `auto_upgrade!` on the class to perform an non-destructive additive schema change. This will create the new columns in Parse for the properties you have defined in your models. Parse Stack will calculate the changes and only modify the tables which need new columns to be added. This feature does require the use of the master key when configuring the client. *It will NOT destroy columns or data.*
2122
2144
 
2123
2145
  ```ruby
2146
+ # auto_upgrade! requires use of master key
2124
2147
  # upgrade the a class individually
2125
2148
  Song.auto_upgrade!
2126
2149
 
@@ -2233,7 +2256,7 @@ You can register webhooks to handle the different object triggers: `:before_save
2233
2256
 
2234
2257
  For any `after_*` hook, return values are not needed since Parse does not utilize them. You may also register as many `after_save` or `after_delete` handlers as you prefer, all of them will be called.
2235
2258
 
2236
- `before_save` and `before_delete` hooks have special functionality. When the `error!` method is called by the provided block, the framework will return the correct error response to Parse with value provided. Returning an error will prevent Parse from saving the object in the case of `before_save` and will prevent Parse from deleting the object when in a `before_delete`. In addition, for a `before_save`, the last value returned by the block will be the value returned in the success response. If the block returns nil or an `empty?` value, it will return `true` as the default response. You can also return a JSON object in a hash format to override the values that will be saved. However, we recommend modifying the `parse_object` provided since it has dirty tracking, and then returning that same object. This will automatically call your model specific `before_save` callbacks and send the proper payload back to Parse. For more details, see [Cloud Code BeforeSave Webhooks](http://parseplatform.github.io/docs/cloudcode/guide/#cloud-code-advanced-beforesave-webhooks)
2259
+ `before_save` and `before_delete` hooks have special functionality. When the `error!` method is called by the provided block, the framework will return the correct error response to Parse with value provided. Returning an error will prevent Parse from saving the object in the case of `before_save` and will prevent Parse from deleting the object when in a `before_delete`. In addition, for a `before_save`, the last value returned by the block will be the value returned in the success response. If the block returns nil or an `empty?` value, it will return `true` as the default response. You can also return a JSON object in a hash format to override the values that will be saved. However, we recommend modifying the `parse_object` provided since it has dirty tracking, and then returning that same object. This will automatically call your model specific `before_save` callbacks and send the proper payload back to Parse. For more details, see [Cloud Code BeforeSave Webhooks](http://docs.parseplatform.org/cloudcode/guide/#beforesave-triggers)
2237
2260
 
2238
2261
  ```ruby
2239
2262
  # recommended way
@@ -2324,7 +2347,7 @@ However, we have predefined a few rake tasks you can use in your application. Ju
2324
2347
  Then you can see the tasks available by typing `rake -T`.
2325
2348
 
2326
2349
  ## Parse REST API Client
2327
- While in most cases you do not have to work with `Parse::Client` directly, you can still utilize it for any raw requests that are not supported by the framework. We provide support for most of the [Parse REST API](http://parseplatform.github.io/docs/rest/guide/#quick-reference) endpoints as helper methods, however you can use the `request()` method to make your own API requests. Parse::Client will handle header authentication, request/response generation and caching.
2350
+ While in most cases you do not have to work with `Parse::Client` directly, you can still utilize it for any raw requests that are not supported by the framework. We provide support for most of the [Parse REST API](http://docs.parseplatform.org/rest/guide/#quick-reference) endpoints as helper methods, however you can use the `request()` method to make your own API requests. Parse::Client will handle header authentication, request/response generation and caching.
2328
2351
 
2329
2352
  ```ruby
2330
2353
  client = Parse::Client.new(application_id: <string>, api_key: <string>) do |conn|
data/Rakefile CHANGED
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env rake
2
2
  require "bundler/gem_tasks"
3
-
3
+ require 'yard'
4
4
  require 'rake/testtask'
5
5
 
6
6
  Rake::TestTask.new do |t|
@@ -23,6 +23,12 @@ task 'yard:stats' do
23
23
  end
24
24
 
25
25
  desc 'Start the yard server'
26
- task 'yard' do
26
+ task 'docs' do
27
27
  exec 'rm -rf ./yard && yard server --reload'
28
28
  end
29
+
30
+ YARD::Rake::YardocTask.new do |t|
31
+ t.files = ['lib/**/*.rb'] # optional
32
+ # t.options = ['--any', '--extra', '--opts'] # optional
33
+ t.stats_options = ['--list-undoc'] # optional
34
+ end
data/bin/console CHANGED
@@ -11,8 +11,10 @@ Parse.setup # cache: 'redis://localhost:6379'
11
11
  puts "[ParseServerURL] #{Parse.client.server_url}"
12
12
  puts "[ParseAppID] #{Parse.client.app_id}"
13
13
 
14
- Parse.auto_generate_models!.each do |model|
15
- puts "Generated #{model}"
14
+ if Parse.client.master_key.present?
15
+ Parse.auto_generate_models!.each do |model|
16
+ puts "Generated #{model}"
17
+ end
16
18
  end
17
19
  # You can add fixtures and/or initialization code here to make experimenting
18
20
  # with your gem easier. You can also use a different console, if you like.
data/bin/parse-console CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  require 'optparse'
4
4
  require 'json'
5
+ require 'open-uri'
6
+
5
7
  DEFAULT_CONFIG_FILE = 'config.json'
6
8
  DEFAULT_CONFIG_CONTENTS = {
7
9
  "apps": [{
@@ -68,6 +70,21 @@ opt_parser = OptionParser.new do |o|
68
70
  end
69
71
 
70
72
  end
73
+ o.on('--url URL', 'Load the env config from a url.') do |url|
74
+ begin
75
+ puts "Loading config: #{url}"
76
+ json = JSON.load open(url)
77
+ raise "Contents not a JSON hash." unless json.is_a?(Hash)
78
+ json.each { |k,v| ENV[k.upcase] = v }
79
+ opts[:server_url] ||= ENV['PARSE_SERVER_URL']
80
+ opts[:app_id] ||= ENV['PARSE_APP_ID'] || ENV['PARSE_APPLICATION_ID']
81
+ opts[:api_key] ||= ENV['PARSE_REST_API_KEY'] || ENV['PARSE_API_KEY']
82
+ opts[:master_key] ||= ENV['PARSE_MASTER_KEY']
83
+ rescue Exception => e
84
+ $stderr.puts "Error: Invalid JSON format for #{url} (#{e})"
85
+ exit 1
86
+ end
87
+ end
71
88
  end
72
89
  opt_parser.parse!
73
90
 
@@ -94,9 +111,9 @@ Parse.setup server_url: opts[:server_url],
94
111
  Parse.logging = true if opts[:verbose]
95
112
  puts "Server : #{Parse.client.server_url}"
96
113
  puts "App Id : #{Parse.client.app_id}"
97
- puts "Master : #{opts[:master_key].present?}"
114
+ puts "Master : #{Parse.client.master_key.present?}"
98
115
 
99
- if opts[:master_key].present?
116
+ if Parse.client.master_key.present?
100
117
  puts "Schema : imported"
101
118
  Parse.auto_generate_models!.each do |model|
102
119
  puts "Generated #{model}" if opts[:verbose]
@@ -105,11 +122,7 @@ else
105
122
  puts "Schema : skipped (requires master key)"
106
123
  end
107
124
  # Create shortnames
108
- User = Parse::User
109
- Installation = Parse::Installation
110
- Session = Parse::Session
111
- Role = Parse::Role
112
- Product = Parse::Product
125
+ Parse.use_shortnames!
113
126
 
114
127
  if opts[:pry]
115
128
  require "pry"
@@ -35,8 +35,9 @@ module Parse
35
35
  end
36
36
 
37
37
  # Base64 encode and set the instance contents
38
- def encode(s)
39
- @base64 = Base64.encode64(s)
38
+ # @param str the string to encode
39
+ def encode(str)
40
+ @base64 = Base64.encode64(str)
40
41
  end
41
42
 
42
43
  # Get the content as decoded base64 bytes
@@ -499,18 +499,31 @@ module Parse
499
499
  @_session_token
500
500
  end
501
501
 
502
+ # @!visibility private
503
+ def _validate_session_token!(token, action = :save)
504
+ return nil if token.nil? # user explicitly requests no session token
505
+ token = token.session_token if token.respond_to?(:session_token)
506
+ return token if token.is_a?(String) && token.present?
507
+ raise ArgumentError, "#{self.class}##{action} error: Invalid session token passed (#{token})"
508
+ end
509
+
502
510
  # saves the object. If the object has not changed, it is a noop. If it is new,
503
511
  # we will create the object. If the object has an id, we will update the record.
512
+ #
513
+ # You may pass a session token to the `session` argument to perform this actions
514
+ # with the priviledges of a certain user.
515
+ #
504
516
  # You can define before and after :save callbacks
505
517
  # autoraise: set to true will automatically raise an exception if the save fails
506
518
  # @raise Parse::RecordNotSaved if the save fails
507
- # @param autoraise [Boolean] whether to raise an exception if the save fails.
519
+ # @raise ArgumentError if a non-nil value is passed to `session` that doesn't provide a session token string.
508
520
  # @param session [String] a session token in order to apply ACLs to this operation.
521
+ # @param autoraise [Boolean] whether to raise an exception if the save fails.
509
522
  # @return [Boolean] whether the save was successful.
510
- def save(autoraise: false, session: nil)
523
+ def save(session: nil, autoraise: false)
524
+ @_session_token = _validate_session_token! session, :save
511
525
  return true unless changed?
512
526
  success = false
513
- @_session_token = session
514
527
  run_callbacks :save do
515
528
  #first process the create/update action if any
516
529
  #then perform any relation changes that need to be performed
@@ -543,6 +556,7 @@ module Parse
543
556
 
544
557
  # Save this object and raise an exception if it fails.
545
558
  # @raise Parse::RecordNotSaved if the save fails
559
+ # @raise ArgumentError if a non-nil value is passed to `session` that doesn't provide a session token string.
546
560
  # @param session (see #save)
547
561
  # @return (see #save)
548
562
  def save!(session: nil)
@@ -553,10 +567,11 @@ module Parse
553
567
  # Delete this record from the Parse collection. Only valid if this object has an `id`.
554
568
  # This will run all the `destroy` callbacks.
555
569
  # @param session [String] a session token if you want to apply ACLs for a user in this operation.
570
+ # @raise ArgumentError if a non-nil value is passed to `session` that doesn't provide a session token string.
556
571
  # @return [Boolean] whether the operation was successful.
557
572
  def destroy(session: nil)
573
+ @_session_token = _validate_session_token! session, :destroy
558
574
  return false if new?
559
- @_session_token = session
560
575
  success = false
561
576
  run_callbacks :destroy do
562
577
  res = client.delete_object parse_class, id, session_token: _session_token
@@ -70,14 +70,34 @@ module Parse
70
70
  # the collection doesn't exist, we create the schema. If the collection already
71
71
  # exists, the current schema is fetched, and only add the additional fields
72
72
  # that are missing.
73
- # @note No columns or fields are removed, this is a safe non-destructive upgrade.
73
+ # @note This feature requires use of the master_key. No columns or fields are removed, this is a safe non-destructive upgrade.
74
74
  # @return [Parse::Response] if the remote schema was modified.
75
75
  # @return [Boolean] if no changes were made to the schema, it returns true.
76
76
  def auto_upgrade!
77
+
78
+ unless client.master_key.present?
79
+ warn "[Parse] Schema changes for #{parse_class} is only available with the master key!"
80
+ return false
81
+ end
82
+ # fetch the current schema (requires master key)
77
83
  response = fetch_schema
84
+
85
+ # if it's a core class that doesn't exist, then create the collection without any fields,
86
+ # since parse-server will automatically create the collection with the set of core fields.
87
+ # then fetch the schema again, to add the missing fields.
88
+ if response.error? && self.to_s.start_with?('Parse::') #is it a core class?
89
+ client.create_schema parse_class, {}
90
+ response = fetch_schema
91
+ # if it still wasn't able to be created, raise an error.
92
+ if response.error?
93
+ warn "[Parse] Schema error: unable to create class #{parse_class}"
94
+ return response
95
+ end
96
+ end
97
+
78
98
  if response.success?
79
99
  #let's figure out the diff fields
80
- remote_fields = response.result["fields"]
100
+ remote_fields = response.result['fields']
81
101
  current_schema = schema
82
102
  current_schema[:fields] = current_schema[:fields].reduce({}) do |h,(k,v)|
83
103
  #if the field does not exist in Parse, then add it to the update list
@@ -87,7 +107,7 @@ module Parse
87
107
  return true if current_schema[:fields].empty?
88
108
  return update_schema( current_schema )
89
109
  end
90
- create_schema
110
+ create_schema
91
111
  end
92
112
 
93
113
  end
@@ -61,6 +61,12 @@ module Parse
61
61
  end
62
62
  end
63
63
 
64
+ # Alias shorter names of core Parse class names.
65
+ # Ex, alias Parse::User to User, Parse::Installation to Installation, etc.
66
+ def self.use_shortnames!
67
+ require_relative 'shortnames'
68
+ end
69
+
64
70
  # This is the core class for all app specific Parse table subclasses. This class
65
71
  # in herits from Parse::Pointer since an Object is a Parse::Pointer with additional fields,
66
72
  # at a minimum, created_at, updated_at and ACLs.
@@ -0,0 +1,9 @@
1
+
2
+ require_relative 'object'
3
+
4
+ # Simple include to use short verion of core class names
5
+ ::Installation = Parse::Installation unless defined?(::Installation)
6
+ ::Role = Parse::Role unless defined?(::Role)
7
+ ::Product = Parse::Product unless defined?(::Product)
8
+ ::Session = Parse::Session unless defined?(::Session)
9
+ ::User = Parse::User unless defined?(::User)
data/lib/parse/query.rb CHANGED
@@ -136,11 +136,17 @@ module Parse
136
136
  # or a {Parse::Session} instance.
137
137
  # @example
138
138
  # # perform this query as user represented by session_token
139
-
140
139
  # query = Parse::Query.new("_User", :name => "Bob")
141
140
  # query.session_token = "r:XyX123..."
141
+ #
142
142
  # # or inline
143
143
  # query = Parse::Query.new("_User", :name => "Bob", :session => "r:XyX123...")
144
+ #
145
+ # # or with a logged in user object
146
+ # user = Parse::User.login('user','pass') # => logged in user'
147
+ # user.session_token # => "r:XyZ1234...."
148
+ # query = Parse::Query.new("_User", :name => "Bob", :session => user)
149
+ # @raise ArgumentError if a non-nil value is passed that doesn't provide a session token string.
144
150
  # @note Using a session_token automatically disables sending the master key in the request.
145
151
  # @return [String] the session token to send with this API request.
146
152
  attr_accessor :table, :client, :key, :cache, :use_master_key, :session_token
@@ -321,7 +327,6 @@ module Parse
321
327
  self.use_master_key = value
322
328
  elsif expression == :session
323
329
  # you can pass a session token or a Parse::Session
324
- value = value.respond_to?(:session_token) ? value.session_token : value
325
330
  self.session_token = value
326
331
  else
327
332
  add_constraint(expression, value)
@@ -334,6 +339,18 @@ module Parse
334
339
  @table = t.to_s.camelize
335
340
  end
336
341
 
342
+ def session_token=(value)
343
+ if value.respond_to?(:session_token) && value.session_token.is_a?(String)
344
+ value = value.session_token
345
+ end
346
+
347
+ if value.nil? || (value.is_a?(String) && value.present?)
348
+ @session_token = value
349
+ else
350
+ raise ArgumentError, "Invalid session token passed to query."
351
+ end
352
+ end
353
+
337
354
  # returns the query clause for the particular clause
338
355
  # @param clause_name [Symbol] One of supported clauses to return: :keys,
339
356
  # :where, :order, :includes, :limit, :skip
data/lib/parse/stack.rb CHANGED
@@ -1,6 +1,7 @@
1
1
  # encoding: UTF-8
2
2
  # frozen_string_literal: true
3
- # exit # don't use master branch
3
+
4
+ exit if ENV['MERCURY_URL'] # don't use master branch
4
5
  require_relative "stack/version"
5
6
  require_relative 'client'
6
7
  require_relative 'query'
@@ -6,6 +6,6 @@ module Parse
6
6
  # The Parse Server SDK for Ruby
7
7
  module Stack
8
8
  # The current version.
9
- VERSION = "1.6.11"
9
+ VERSION = "1.6.12"
10
10
  end
11
11
  end
data/parse-stack.gemspec CHANGED
@@ -33,7 +33,7 @@ Gem::Specification.new do |spec|
33
33
  spec.add_runtime_dependency "parallel", [">= 1.6", "< 2"]
34
34
  spec.add_runtime_dependency "faraday", [">= 0.8", "< 1"]
35
35
  spec.add_runtime_dependency "faraday_middleware", [">= 0.9", "< 1"]
36
- spec.add_runtime_dependency "moneta", [">= 0.7", "< 1"]
36
+ spec.add_runtime_dependency "moneta", "< 2"
37
37
  spec.add_runtime_dependency "rack", "< 3"
38
38
 
39
39
  # spec.post_install_message = <<UPGRADE
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: parse-stack
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.11
4
+ version: 1.6.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Persaud
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-05 00:00:00.000000000 Z
11
+ date: 2017-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -134,22 +134,16 @@ dependencies:
134
134
  name: moneta
135
135
  requirement: !ruby/object:Gem::Requirement
136
136
  requirements:
137
- - - ">="
138
- - !ruby/object:Gem::Version
139
- version: '0.7'
140
137
  - - "<"
141
138
  - !ruby/object:Gem::Version
142
- version: '1'
139
+ version: '2'
143
140
  type: :runtime
144
141
  prerelease: false
145
142
  version_requirements: !ruby/object:Gem::Requirement
146
143
  requirements:
147
- - - ">="
148
- - !ruby/object:Gem::Version
149
- version: '0.7'
150
144
  - - "<"
151
145
  - !ruby/object:Gem::Version
152
- version: '1'
146
+ version: '2'
153
147
  - !ruby/object:Gem::Dependency
154
148
  name: rack
155
149
  requirement: !ruby/object:Gem::Requirement
@@ -177,6 +171,7 @@ files:
177
171
  - ".github/parse-ruby-sdk.png"
178
172
  - ".gitignore"
179
173
  - ".travis.yml"
174
+ - ".yardopts"
180
175
  - Changes.md
181
176
  - Gemfile
182
177
  - Gemfile.lock
@@ -237,6 +232,7 @@ files:
237
232
  - lib/parse/model/object.rb
238
233
  - lib/parse/model/pointer.rb
239
234
  - lib/parse/model/push.rb
235
+ - lib/parse/model/shortnames.rb
240
236
  - lib/parse/query.rb
241
237
  - lib/parse/query/constraint.rb
242
238
  - lib/parse/query/constraints.rb
@@ -278,7 +274,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
278
274
  version: '0'
279
275
  requirements: []
280
276
  rubyforge_project:
281
- rubygems_version: 2.6.8
277
+ rubygems_version: 2.6.12
282
278
  signing_key:
283
279
  specification_version: 4
284
280
  summary: Parse Server Ruby Client SDK