parse-stack 1.4.3 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/Changes.md +52 -39
  3. data/Gemfile.lock +2 -2
  4. data/README.md +609 -124
  5. data/bin/console +0 -9
  6. data/lib/parse/api/all.rb +3 -0
  7. data/lib/parse/api/analytics.rb +2 -2
  8. data/lib/parse/api/apps.rb +15 -17
  9. data/lib/parse/api/batch.rb +4 -1
  10. data/lib/parse/api/cloud_functions.rb +2 -0
  11. data/lib/parse/api/config.rb +14 -2
  12. data/lib/parse/api/files.rb +6 -3
  13. data/lib/parse/api/hooks.rb +4 -4
  14. data/lib/parse/api/objects.rb +14 -11
  15. data/lib/parse/api/push.rb +4 -2
  16. data/lib/parse/api/schemas.rb +6 -5
  17. data/lib/parse/api/sessions.rb +11 -1
  18. data/lib/parse/api/users.rb +65 -15
  19. data/lib/parse/client/authentication.rb +4 -2
  20. data/lib/parse/client/body_builder.rb +11 -3
  21. data/lib/parse/client/caching.rb +17 -6
  22. data/lib/parse/client/protocol.rb +14 -8
  23. data/lib/parse/client/request.rb +4 -1
  24. data/lib/parse/client/response.rb +59 -6
  25. data/lib/parse/client.rb +72 -42
  26. data/lib/parse/model/acl.rb +22 -4
  27. data/lib/parse/model/associations/belongs_to.rb +22 -10
  28. data/lib/parse/model/associations/collection_proxy.rb +14 -1
  29. data/lib/parse/model/associations/has_many.rb +76 -15
  30. data/lib/parse/model/associations/has_one.rb +69 -0
  31. data/lib/parse/model/associations/pointer_collection_proxy.rb +13 -6
  32. data/lib/parse/model/associations/relation_collection_proxy.rb +5 -2
  33. data/lib/parse/model/bytes.rb +6 -2
  34. data/lib/parse/model/classes/installation.rb +27 -0
  35. data/lib/parse/model/classes/role.rb +20 -0
  36. data/lib/parse/model/classes/session.rb +26 -0
  37. data/lib/parse/model/classes/user.rb +185 -0
  38. data/lib/parse/model/core/actions.rb +40 -26
  39. data/lib/parse/model/core/properties.rb +126 -20
  40. data/lib/parse/model/core/querying.rb +63 -3
  41. data/lib/parse/model/core/schema.rb +9 -6
  42. data/lib/parse/model/date.rb +5 -1
  43. data/lib/parse/model/file.rb +12 -9
  44. data/lib/parse/model/geopoint.rb +6 -4
  45. data/lib/parse/model/model.rb +29 -21
  46. data/lib/parse/model/object.rb +29 -76
  47. data/lib/parse/model/pointer.rb +8 -6
  48. data/lib/parse/model/push.rb +4 -1
  49. data/lib/parse/query/constraint.rb +3 -0
  50. data/lib/parse/query/constraints.rb +6 -3
  51. data/lib/parse/query/operation.rb +3 -0
  52. data/lib/parse/query/ordering.rb +3 -0
  53. data/lib/parse/query.rb +85 -38
  54. data/lib/parse/stack/generators/rails.rb +3 -0
  55. data/lib/parse/stack/railtie.rb +2 -0
  56. data/lib/parse/stack/tasks.rb +4 -1
  57. data/lib/parse/stack/version.rb +4 -1
  58. data/lib/parse/stack.rb +3 -0
  59. data/lib/parse/webhooks/payload.rb +14 -8
  60. data/lib/parse/webhooks/registration.rb +11 -8
  61. data/lib/parse/webhooks.rb +11 -8
  62. data/lib/parse-stack.rb +3 -0
  63. data/parse-stack.gemspec +10 -8
  64. metadata +16 -4
@@ -1,3 +1,6 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
1
4
  require 'active_support'
2
5
  require 'active_support/inflector'
3
6
  require 'active_support/core_ext/object'
@@ -27,9 +30,9 @@ module Parse
27
30
  client.triggers.results.sort_by { |f| [f['triggerName'],f['className']] }.each do |f|
28
31
  next unless f["url"].present?
29
32
  triggerName = f["triggerName"]
30
- className = f["className"]
33
+ className = f[Parse::Model::KEY_CLASS_NAME]
31
34
  client.delete_trigger triggerName, className
32
- yield(f['triggerName'], f['className']) if block_given?
35
+ yield(f['triggerName'], f[Parse::Model::KEY_CLASS_NAME]) if block_given?
33
36
  end
34
37
 
35
38
  end
@@ -37,7 +40,7 @@ module Parse
37
40
  def register_functions!(endpoint)
38
41
 
39
42
  unless endpoint.present? && endpoint.starts_with?('https://')
40
- raise "The HOOKS_URL must be https: '#{endpoint}''"
43
+ raise ArgumentError, "The HOOKS_URL must be https: '#{endpoint}''"
41
44
  end
42
45
  endpoint += '/' unless endpoint.ends_with?('/')
43
46
  functionsMap = {}
@@ -62,7 +65,7 @@ module Parse
62
65
  def register_triggers!(endpoint, include_wildcard: false)
63
66
 
64
67
  unless endpoint.present? && endpoint.starts_with?('https://')
65
- raise "The HOOKS_URL must be https: '#{endpoint}''"
68
+ raise ArgumentError, "The HOOKS_URL must be https: '#{endpoint}''"
66
69
  end
67
70
  endpoint += '/' unless endpoint.ends_with?('/')
68
71
 
@@ -89,7 +92,7 @@ module Parse
89
92
  end
90
93
 
91
94
  classNames.sort.each do |className|
92
- next if className == '*'.freeze
95
+ next if className == '*'
93
96
  url = endpoint + "#{trigger}/#{className}"
94
97
  if current_triggers[trigger][className].present? #then you may need to update
95
98
  next if current_triggers[trigger][className] == url
@@ -105,13 +108,13 @@ module Parse
105
108
 
106
109
  def register_webhook!(trigger, name, url)
107
110
  trigger = trigger.to_s.camelize(:lower).to_sym
108
- raise "Invalid hook trigger #{trigger}" unless ALLOWED_HOOKS.include?(trigger)
111
+ raise ArgumentError, "Invalid hook trigger #{trigger}" unless ALLOWED_HOOKS.include?(trigger)
109
112
  if trigger == :function
110
113
  response = client.fetch_function(name)
111
114
  # if it is either an error (which has no results) or there is a result but
112
115
  # no registered item with a URL (which implies either none registered or only cloud code registered)
113
116
  # then create it.
114
- if response.results.none? { |d| d.has_key?("url".freeze) }
117
+ if response.results.none? { |d| d.has_key?("url") }
115
118
  response = client.create_function(name, url)
116
119
  else
117
120
  # update it
@@ -126,7 +129,7 @@ module Parse
126
129
  # if it is either an error (which has no results) or there is a result but
127
130
  # no registered item with a URL (which implies either none registered or only cloud code registered)
128
131
  # then create it.
129
- if response.results.none? { |d| d.has_key?("url".freeze) }
132
+ if response.results.none? { |d| d.has_key?("url") }
130
133
  # create it
131
134
  response = client.create_trigger(trigger, name, url)
132
135
  else
@@ -1,3 +1,6 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
1
4
  require 'active_model'
2
5
  require 'active_support'
3
6
  require 'active_support/inflector'
@@ -53,7 +56,7 @@ module Parse
53
56
 
54
57
  if type == :function
55
58
  unless block.is_a?(String) || block.is_a?(Symbol)
56
- raise "Invalid Cloud Code function name: #{block}"
59
+ raise ArgumentError, "Invalid Cloud Code function name: #{block}"
57
60
  end
58
61
  Parse::Webhooks.route(:function, block, &Proc.new)
59
62
  # then block must be a symbol or a string
@@ -76,7 +79,7 @@ module Parse
76
79
  end
77
80
  end
78
81
 
79
- class WebhookErrorResponse < Exception; end;
82
+ class WebhookErrorResponse < StandardError; end;
80
83
  class Webhooks
81
84
 
82
85
  def self.reload!(args = {})
@@ -86,9 +89,9 @@ module Parse
86
89
  include Client::Connectable
87
90
  extend Webhook::Registration
88
91
 
89
- HTTP_PARSE_WEBHOOK = "HTTP_X_PARSE_WEBHOOK_KEY".freeze
90
- HTTP_PARSE_APPLICATION_ID = "HTTP_X_PARSE_APPLICATION_ID".freeze
91
- CONTENT_TYPE = "application/json".freeze
92
+ HTTP_PARSE_WEBHOOK = "HTTP_X_PARSE_WEBHOOK_KEY"
93
+ HTTP_PARSE_APPLICATION_ID = "HTTP_X_PARSE_APPLICATION_ID"
94
+ CONTENT_TYPE = "application/json"
92
95
  attr_accessor :key
93
96
  class << self
94
97
  attr_accessor :logging
@@ -108,7 +111,7 @@ module Parse
108
111
  className = className.to_s
109
112
  block = Proc.new if block_given?
110
113
  if routes[type].nil? || block.respond_to?(:call) == false
111
- raise "Invalid Webhook registration trigger #{type} #{className}"
114
+ raise ArgumentError, "Invalid Webhook registration trigger #{type} #{className}"
112
115
  end
113
116
 
114
117
  # AfterSave/AfterDelete hooks support more than one
@@ -189,7 +192,7 @@ module Parse
189
192
  request.body.rewind
190
193
  begin
191
194
  payload = Parse::Payload.new request.body.read
192
- rescue Exception => e
195
+ rescue => e
193
196
  warn "Invalid webhook payload format: #{e}"
194
197
  response.write error("Invalid payload format. Should be valid JSON.")
195
198
  return response.finish
@@ -231,7 +234,7 @@ module Parse
231
234
  end
232
235
  response.write success(result)
233
236
  return response.finish
234
- rescue Parse::WebhookErrorResponse => e
237
+ rescue Parse::WebhookErrorResponse, ActiveModel::ValidationError => e
235
238
  if payload.trigger?
236
239
  puts "[Webhook ResponseError] >> #{payload.trigger_name} #{payload.parse_class}:#{payload.parse_id}: #{e}"
237
240
  elsif payload.function?
data/lib/parse-stack.rb CHANGED
@@ -1,2 +1,5 @@
1
+ # encoding: UTF-8
2
+ # frozen_string_literal: true
3
+
1
4
  # Useful for some users that require 'parse-stack' manually
2
5
  require_relative "./parse/stack.rb"
data/parse-stack.gemspec CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
9
9
  spec.authors = ["Anthony Persaud"]
10
10
  spec.email = ["persaud@modernistik.com"]
11
11
 
12
- spec.summary = %q{Parse-Server Ruby Client and Active Model Object Relational Mapping}
12
+ spec.summary = %q{Parse-Server Ruby Client and Relational Mapper}
13
13
  spec.description = %q{Parse-Server Ruby Client, Active Model based Data Mapper, and Query engine to manage larger scale Parse server applications}
14
14
  spec.homepage = "https://github.com/modernistik/parse-stack"
15
15
  spec.license = "MIT"
@@ -36,11 +36,13 @@ Gem::Specification.new do |spec|
36
36
  spec.add_runtime_dependency "moneta", [">= 0.7", "< 1"]
37
37
  spec.add_runtime_dependency "rack", "< 3"
38
38
 
39
- # spec.post_install_message = <<UPGRADE
40
- #
41
- # ** IMPORTANT **
42
- # Parse::Webhook exception handling has changed in 1.3.0 and later.
43
- # See guide: https://github.com/modernistik/parse-stack/wiki/Webhook-Migration-1.2.x-to-1.3.0
44
- #
45
- # UPGRADE
39
+ spec.post_install_message = <<UPGRADE
40
+
41
+ ** BREAKING CHANGES **
42
+ The default `has_many` association form has changed from :array to :query.
43
+ To use arrays, you must now pass `through: :array` option to `has_many`.
44
+
45
+ Visit: https://github.com/modernistik/parse-stack/wiki/Changes-to-has_many-in-1.5.0
46
+
47
+ UPGRADE
46
48
  end
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.4.3
4
+ version: 1.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Anthony Persaud
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-03 00:00:00.000000000 Z
11
+ date: 2016-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -208,9 +208,14 @@ files:
208
208
  - lib/parse/model/associations/belongs_to.rb
209
209
  - lib/parse/model/associations/collection_proxy.rb
210
210
  - lib/parse/model/associations/has_many.rb
211
+ - lib/parse/model/associations/has_one.rb
211
212
  - lib/parse/model/associations/pointer_collection_proxy.rb
212
213
  - lib/parse/model/associations/relation_collection_proxy.rb
213
214
  - lib/parse/model/bytes.rb
215
+ - lib/parse/model/classes/installation.rb
216
+ - lib/parse/model/classes/role.rb
217
+ - lib/parse/model/classes/session.rb
218
+ - lib/parse/model/classes/user.rb
214
219
  - lib/parse/model/core/actions.rb
215
220
  - lib/parse/model/core/properties.rb
216
221
  - lib/parse/model/core/querying.rb
@@ -247,7 +252,14 @@ homepage: https://github.com/modernistik/parse-stack
247
252
  licenses:
248
253
  - MIT
249
254
  metadata: {}
250
- post_install_message:
255
+ post_install_message: |2+
256
+
257
+ ** BREAKING CHANGES **
258
+ The default `has_many` association form has changed from :array to :query.
259
+ To use arrays, you must now pass `through: :array` option to `has_many`.
260
+
261
+ Visit: https://github.com/modernistik/parse-stack/wiki/Changes-to-has_many-in-1.5.0
262
+
251
263
  rdoc_options: []
252
264
  require_paths:
253
265
  - lib
@@ -266,5 +278,5 @@ rubyforge_project:
266
278
  rubygems_version: 2.6.6
267
279
  signing_key:
268
280
  specification_version: 4
269
- summary: Parse-Server Ruby Client and Active Model Object Relational Mapping
281
+ summary: Parse-Server Ruby Client and Relational Mapper
270
282
  test_files: []