Skip to content

Commit

Permalink
Bump 1.10.1, removes dependency on faraday_middleware
Browse files Browse the repository at this point in the history
[modernistik#62] Separate positional and keyword arguments for Ruby 3.0

Replaces deprecated Proc.new usage

“warning: Capturing the given block using Proc.new is deprecated; use `&block` instead”

Remove upper bound for dependencies versions

Remove extra comma

remove dependence on AMS

ignore leading underscore

Updated dependencies

Updates version + dependencies

ruby 3.0 compatibility

fix block param

more ruby 3 compatibility

faraday 2 compatibility

Remove models overrides templates

Can't have two autoloaded files defining the same class. It results in
inconsistent behavior.
Built-in parse classes have to be properly reopened with class_eval.

compatibility with Rails strong parameters

update doc with reopening builtin classes

Removing dependencies for faraday_middleware

Bumping to 1.10.1

Bumping to 1.10.1
  • Loading branch information
apersaud authored and jorgeacaballero committed May 25, 2023
1 parent ecdb13e commit 090785a
Show file tree
Hide file tree
Showing 38 changed files with 269 additions and 145 deletions.
8 changes: 8 additions & 0 deletions .idea/.gitignore

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

34 changes: 34 additions & 0 deletions .idea/parse-stack.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion .solargraph.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ max_files: 5000
require:
- activemodel
- faraday
- faraday_middleware
- moneta
- activesupport
- rack
Expand Down
95 changes: 47 additions & 48 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,28 +1,27 @@
PATH
remote: .
specs:
parse-stack (1.9.1)
active_model_serializers (>= 0.9, < 1)
activemodel (>= 5, < 7)
activesupport (>= 5, < 7)
faraday (< 1)
faraday_middleware (>= 0.9, < 2)
moneta (< 2)
parallel (>= 1.6, < 2)
rack (>= 2.0.6, < 3)
parse-stack (1.10.1)
active_model_serializers (>= 0.9)
activemodel (>= 5)
activesupport (>= 5)
faraday
moneta
parallel (>= 1.6)
rack (>= 2.0.6)

GEM
remote: https://rubygems.org/
specs:
actionpack (6.1.7.1)
actionview (= 6.1.7.1)
activesupport (= 6.1.7.1)
rack (~> 2.0, >= 2.0.9)
actionpack (7.0.5)
actionview (= 7.0.5)
activesupport (= 7.0.5)
rack (~> 2.0, >= 2.2.4)
rack-test (>= 0.6.3)
rails-dom-testing (~> 2.0)
rails-html-sanitizer (~> 1.0, >= 1.2.0)
actionview (6.1.7.1)
activesupport (= 6.1.7.1)
actionview (7.0.5)
activesupport (= 7.0.5)
builder (~> 3.1)
erubi (~> 1.4)
rails-dom-testing (~> 2.0)
Expand All @@ -32,14 +31,13 @@ GEM
activemodel (>= 4.1, < 7.1)
case_transform (>= 0.2)
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
activemodel (6.1.7.1)
activesupport (= 6.1.7.1)
activesupport (6.1.7.1)
activemodel (7.0.5)
activesupport (= 7.0.5)
activesupport (7.0.5)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (>= 1.6, < 2)
minitest (>= 5.1)
tzinfo (~> 2.0)
zeitwerk (~> 2.3)
ansi (1.5.0)
binding_of_caller (1.0.0)
debug_inspector (>= 0.0.1)
Expand All @@ -48,38 +46,39 @@ GEM
case_transform (0.2)
activesupport
coderay (1.1.3)
concurrent-ruby (1.1.10)
connection_pool (2.3.0)
concurrent-ruby (1.2.2)
connection_pool (2.4.1)
crass (1.0.6)
daemons (1.4.1)
debug_inspector (1.1.0)
dotenv (2.8.1)
erubi (1.12.0)
eventmachine (1.2.7)
faraday (0.17.6)
multipart-post (>= 1.2, < 3)
faraday_middleware (0.14.0)
faraday (>= 0.7.4, < 1.0)
i18n (1.12.0)
faraday (2.7.5)
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
faraday-net_http (3.0.2)
i18n (1.13.0)
concurrent-ruby (~> 1.0)
jsonapi-renderer (0.2.2)
loofah (2.19.1)
loofah (2.21.3)
crass (~> 1.0.2)
nokogiri (>= 1.5.9)
nokogiri (>= 1.12.0)
method_source (1.0.0)
mini_portile2 (2.8.1)
minitest (5.17.0)
minitest-reporters (1.5.0)
mini_portile2 (2.8.2)
minitest (5.18.0)
minitest-reporters (1.6.0)
ansi
builder
minitest (>= 5.0)
ruby-progressbar
moneta (1.5.2)
multipart-post (2.2.3)
nokogiri (1.13.10)
mini_portile2 (~> 2.8.0)
moneta (1.6.0)
nokogiri (1.15.2)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
parallel (1.22.1)
nokogiri (1.15.2-x86_64-darwin)
racc (~> 1.4)
parallel (1.23.0)
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
Expand All @@ -89,35 +88,35 @@ GEM
binding_of_caller (~> 1.0)
pry (~> 0.13)
racc (1.6.2)
rack (2.2.6.2)
rack-test (2.0.2)
rack (2.2.7)
rack-test (2.1.0)
rack (>= 1.3)
rails-dom-testing (2.0.3)
activesupport (>= 4.2.0)
nokogiri (>= 1.6)
rails-html-sanitizer (1.5.0)
loofah (~> 2.19, >= 2.19.1)
rake (13.0.6)
redcarpet (3.5.1)
redcarpet (3.6.0)
redis (5.0.6)
redis-client (>= 0.9.0)
redis-client (0.12.1)
redis-client (0.14.1)
connection_pool
ruby-progressbar (1.11.0)
rufo (0.13.0)
thin (1.8.1)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
rufo (0.16.1)
thin (1.8.2)
daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0, >= 1.0.4)
rack (>= 1, < 3)
tzinfo (2.0.5)
tzinfo (2.0.6)
concurrent-ruby (~> 1.0)
webrick (1.7.0)
yard (0.9.28)
webrick (~> 1.7.0)
zeitwerk (2.6.6)
yard (0.9.34)

PLATFORMS
ruby
x86_64-darwin-20
x86_64-darwin-22

DEPENDENCIES
byebug
Expand Down
33 changes: 33 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,39 @@ data.acl # => ACL({"role:Admin"=>{"read"=>true, "write"=>true}})

For more information about Parse record ACLs, see the documentation at [Security](http://docs.parseplatform.org/rest/guide/#security)

## Builtin parse collections

These classes match parse builtin collections. Do not redeclare them as rails autoloader don't support multiple class declarations. To add properties and methods to these classes, properly reopen them with overrides, using this class_eval method.

First, append this to config/application.rb

```ruby
##
# Don't autoload overrides but preload them instead
overrides = "#{Rails.root}/app/overrides"
Rails.autoloaders.main.ignore(overrides)

config.to_prepare do
Dir.glob("#{overrides}/**/*_override.rb").each do |override|
load override
end
end
```

Then, create the folder app/overrides/models. Create a file named [collection]_override.rb in this folder to reopen one of these classes. Example with the _User collection:

```ruby
# app/overrides/models/user_override.rb
Parse::User.class_eval do
has_many :created_articles, as: :articles, field: :creator

property :first_name
property :last_name
property :picture
end
```


### [Parse::Session](https://www.modernistik.com/gems/parse-stack/Parse/Session.html)
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.html). You may call `Parse.use_shortnames!` to use `Session` in addition to `Parse::Session`.

Expand Down
4 changes: 2 additions & 2 deletions lib/parse/api/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def update_user(id, body = {}, headers: {}, **opts)
# @return [Parse::Response]
def set_service_auth_data(id, service_name, auth_data, headers: {}, **opts)
body = { authData: { service_name => auth_data } }
update_user(id, body, opts)
update_user(id, body, **opts)
end

# Delete a {Parse::User} record given an objectId.
Expand Down Expand Up @@ -143,7 +143,7 @@ def logout(session_token, headers: {}, **opts)
def signup(username, password, email = nil, body: {}, **opts)
body = body.merge({ username: username, password: password })
body[:email] = email || body[:email]
create_user(body, opts)
create_user(body, **opts)
end
end # Users
end #API
Expand Down
13 changes: 6 additions & 7 deletions lib/parse/client.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
require "faraday"
require "faraday_middleware"
require "active_support"
require "moneta"
require "active_model_serializers"

require "active_support/inflector"
require "active_support/core_ext/object"
require "active_support/core_ext/string"
Expand Down Expand Up @@ -202,8 +201,8 @@ def client(conn = :default)
# @see Parse::Middleware::Caching
# @see Parse::Middleware::Authentication
# @see Parse::Protocol
def setup(opts = {})
@clients[:default] = self.new(opts, &Proc.new)
def setup(opts = {}, &block)
@clients[:default] = self.new(opts, &block)
end
end

Expand Down Expand Up @@ -481,7 +480,7 @@ def request(method, uri = nil, body: nil, query: nil, headers: nil, opts: {})
retry
end
raise
rescue Faraday::Error::ClientError, Net::OpenTimeout => e
rescue Faraday::ClientError, Net::OpenTimeout => e
if _retry_count > 0
warn "[Parse:Retry] Retries remaining #{_retry_count} : #{_request}"
_retry_count -= 1
Expand Down Expand Up @@ -579,9 +578,9 @@ def client
# @yield (see Parse::Client.setup)
# @return (see Parse::Client.setup)
# @see Parse::Client.setup
def self.setup(opts = {})
def self.setup(opts = {}, &block)
if block_given?
Parse::Client.new(opts, &Proc.new)
Parse::Client.new(opts, &block)
else
Parse::Client.new(opts)
end
Expand Down
1 change: 0 additions & 1 deletion lib/parse/client/authentication.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# frozen_string_literal: true

require "faraday"
require "faraday_middleware"
require "active_support"
require "active_support/core_ext"

Expand Down
8 changes: 4 additions & 4 deletions lib/parse/client/batch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,9 @@ def change_requests
end

# @return [Array]
def each
def each(&block)
return enum_for(:each) unless block_given?
@requests.each(&Proc.new)
@requests.each(&block)
end

# @return [Hash] a formatted payload for the batch request.
Expand Down Expand Up @@ -125,15 +125,15 @@ def error?
# @param segment [Integer] the number of requests to send in each batch. Default 50.
# @return [Array<Parse::Response>] the corresponding set of responses for
# each request in the batch.
def submit(segment = 50)
def submit(segment = 50, &block)
@responses = []
@requests.uniq!(&:signature)
@responses = @requests.each_slice(segment).to_a.threaded_map(2) do |slice|
client.batch_request(BatchOperation.new(slice))
end
@responses.flatten!
#puts "Requests: #{@requests.count} == Response: #{@responses.count}"
@requests.zip(@responses).each(&Proc.new) if block_given?
@requests.zip(@responses).each(&block) if block_given?
@responses
end

Expand Down
3 changes: 1 addition & 2 deletions lib/parse/client/body_builder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@
# frozen_string_literal: true

require "faraday"
require "faraday_middleware"
require_relative "response"
require_relative "protocol"
require "active_support"
require "active_support/core_ext"
require "active_model_serializers"


module Parse

Expand Down

0 comments on commit 090785a

Please sign in to comment.