parse-stack 1.7.3 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. checksums.yaml +5 -5
  2. data/.github/workflows/ruby.yml +36 -0
  3. data/.solargraph.yml +23 -0
  4. data/.travis.yml +6 -3
  5. data/Changes.md +84 -22
  6. data/Gemfile +14 -12
  7. data/Gemfile.lock +110 -60
  8. data/README.md +67 -24
  9. data/Rakefile +14 -14
  10. data/bin/parse-console +1 -0
  11. data/lib/parse/api/aggregate.rb +59 -0
  12. data/lib/parse/api/all.rb +2 -1
  13. data/lib/parse/api/analytics.rb +0 -3
  14. data/lib/parse/api/batch.rb +3 -5
  15. data/lib/parse/api/cloud_functions.rb +0 -3
  16. data/lib/parse/api/config.rb +0 -4
  17. data/lib/parse/api/files.rb +3 -7
  18. data/lib/parse/api/hooks.rb +4 -8
  19. data/lib/parse/api/objects.rb +9 -14
  20. data/lib/parse/api/push.rb +0 -4
  21. data/lib/parse/api/schema.rb +2 -6
  22. data/lib/parse/api/server.rb +4 -7
  23. data/lib/parse/api/sessions.rb +2 -5
  24. data/lib/parse/api/users.rb +9 -14
  25. data/lib/parse/client.rb +55 -50
  26. data/lib/parse/client/authentication.rb +29 -33
  27. data/lib/parse/client/batch.rb +8 -11
  28. data/lib/parse/client/body_builder.rb +19 -20
  29. data/lib/parse/client/caching.rb +23 -28
  30. data/lib/parse/client/protocol.rb +11 -12
  31. data/lib/parse/client/request.rb +4 -6
  32. data/lib/parse/client/response.rb +5 -7
  33. data/lib/parse/model/acl.rb +14 -12
  34. data/lib/parse/model/associations/belongs_to.rb +19 -24
  35. data/lib/parse/model/associations/collection_proxy.rb +328 -317
  36. data/lib/parse/model/associations/has_many.rb +22 -27
  37. data/lib/parse/model/associations/has_one.rb +7 -12
  38. data/lib/parse/model/associations/pointer_collection_proxy.rb +5 -13
  39. data/lib/parse/model/associations/relation_collection_proxy.rb +5 -9
  40. data/lib/parse/model/bytes.rb +8 -10
  41. data/lib/parse/model/classes/installation.rb +2 -4
  42. data/lib/parse/model/classes/product.rb +2 -5
  43. data/lib/parse/model/classes/role.rb +3 -5
  44. data/lib/parse/model/classes/session.rb +2 -5
  45. data/lib/parse/model/classes/user.rb +21 -17
  46. data/lib/parse/model/core/actions.rb +31 -46
  47. data/lib/parse/model/core/builder.rb +6 -6
  48. data/lib/parse/model/core/errors.rb +0 -1
  49. data/lib/parse/model/core/fetching.rb +45 -50
  50. data/lib/parse/model/core/properties.rb +53 -68
  51. data/lib/parse/model/core/querying.rb +292 -282
  52. data/lib/parse/model/core/schema.rb +89 -92
  53. data/lib/parse/model/date.rb +16 -23
  54. data/lib/parse/model/file.rb +171 -174
  55. data/lib/parse/model/geopoint.rb +12 -16
  56. data/lib/parse/model/model.rb +31 -37
  57. data/lib/parse/model/object.rb +58 -70
  58. data/lib/parse/model/pointer.rb +177 -176
  59. data/lib/parse/model/push.rb +8 -10
  60. data/lib/parse/model/shortnames.rb +1 -2
  61. data/lib/parse/model/time_zone.rb +3 -5
  62. data/lib/parse/query.rb +70 -37
  63. data/lib/parse/query/constraint.rb +4 -6
  64. data/lib/parse/query/constraints.rb +62 -20
  65. data/lib/parse/query/operation.rb +8 -11
  66. data/lib/parse/query/ordering.rb +45 -49
  67. data/lib/parse/stack.rb +15 -11
  68. data/lib/parse/stack/generators/rails.rb +28 -30
  69. data/lib/parse/stack/generators/templates/model.erb +5 -6
  70. data/lib/parse/stack/generators/templates/model_installation.rb +0 -1
  71. data/lib/parse/stack/generators/templates/model_role.rb +0 -1
  72. data/lib/parse/stack/generators/templates/model_session.rb +0 -1
  73. data/lib/parse/stack/generators/templates/model_user.rb +0 -1
  74. data/lib/parse/stack/generators/templates/parse.rb +9 -9
  75. data/lib/parse/stack/generators/templates/webhooks.rb +1 -2
  76. data/lib/parse/stack/railtie.rb +2 -4
  77. data/lib/parse/stack/tasks.rb +70 -86
  78. data/lib/parse/stack/version.rb +1 -1
  79. data/lib/parse/webhooks.rb +19 -26
  80. data/lib/parse/webhooks/payload.rb +26 -28
  81. data/lib/parse/webhooks/registration.rb +23 -31
  82. data/parse-stack.gemspec +28 -28
  83. data/parse-stack.png +0 -0
  84. metadata +27 -25
  85. data/.github/parse-ruby-sdk.png +0 -0
@@ -1,9 +1,8 @@
1
1
  # encoding: UTF-8
2
2
  # frozen_string_literal: true
3
3
 
4
- require 'active_support'
5
- require 'active_support/inflector'
6
-
4
+ require "active_support"
5
+ require "active_support/inflector"
7
6
 
8
7
  module Parse
9
8
 
@@ -36,7 +35,7 @@ module Parse
36
35
 
37
36
  # Whether this operation is defined properly.
38
37
  def valid?
39
- ! (@operand.nil? || @operator.nil? || handler.nil?)
38
+ !(@operand.nil? || @operator.nil? || handler.nil?)
40
39
  end
41
40
 
42
41
  # @return [Parse::Constraint] the constraint class designed to handle
@@ -69,13 +68,11 @@ module Parse
69
68
 
70
69
  # Register a new symbol operator method mapped to a specific {Parse::Constraint}.
71
70
  def self.register(op, klass)
72
- Operation.operators[op.to_sym] = klass
73
- Symbol.send :define_method, op do |value = nil|
74
- operation = Operation.new self, op
75
- value.nil? ? operation : operation.constraint(value)
76
- end
71
+ Operation.operators[op.to_sym] = klass
72
+ Symbol.send :define_method, op do |value = nil|
73
+ operation = Operation.new self, op
74
+ value.nil? ? operation : operation.constraint(value)
75
+ end
77
76
  end
78
-
79
77
  end
80
-
81
78
  end
@@ -1,62 +1,59 @@
1
1
  # encoding: UTF-8
2
2
  # frozen_string_literal: true
3
3
 
4
-
5
4
  module Parse
6
- # This class adds support for describing ordering for Parse queries. You can
7
- # either order by ascending (asc) or descending (desc) order.
8
- #
9
- # Ordering is implemented similarly to constraints in which we add
10
- # special methods to the Symbol class. The developer can then pass one
11
- # or an array of fields (as symbols) and call the particular ordering
12
- # polarity (ex. _:name.asc_ would create a Parse::Order where we want
13
- # things to be sortd by the name field in ascending order)
14
- # For more information about the query design pattern from DataMapper
15
- # that inspired this, see http://datamapper.org/docs/find.html'
16
- # @example
17
- # :name.asc # => Parse::Order by ascending :name
18
- # :like_count.desc # => Parse::Order by descending :like_count
19
- #
20
- class Order
21
- # The Parse operators to indicate ordering direction.
22
- ORDERING = {asc: '', desc: '-'}.freeze
23
-
24
- # @!attribute [rw] field
25
- # @return [Symbol] the name of the field
26
- attr_accessor :field
5
+ # This class adds support for describing ordering for Parse queries. You can
6
+ # either order by ascending (asc) or descending (desc) order.
7
+ #
8
+ # Ordering is implemented similarly to constraints in which we add
9
+ # special methods to the Symbol class. The developer can then pass one
10
+ # or an array of fields (as symbols) and call the particular ordering
11
+ # polarity (ex. _:name.asc_ would create a Parse::Order where we want
12
+ # things to be sortd by the name field in ascending order)
13
+ # For more information about the query design pattern from DataMapper
14
+ # that inspired this, see http://datamapper.org/docs/find.html'
15
+ # @example
16
+ # :name.asc # => Parse::Order by ascending :name
17
+ # :like_count.desc # => Parse::Order by descending :like_count
18
+ #
19
+ class Order
20
+ # The Parse operators to indicate ordering direction.
21
+ ORDERING = { asc: "", desc: "-" }.freeze
27
22
 
28
- # @!attribute [rw] direction
29
- # The direction of the sorting. This is either `:asc` or `:desc`.
30
- # @return [Symbol]
31
- attr_accessor :direction
23
+ # @!attribute [rw] field
24
+ # @return [Symbol] the name of the field
25
+ attr_accessor :field
32
26
 
33
- def initialize(field, order = :asc)
34
- @field = field.to_sym || :objectId
35
- @direction = order
36
- end
27
+ # @!attribute [rw] direction
28
+ # The direction of the sorting. This is either `:asc` or `:desc`.
29
+ # @return [Symbol]
30
+ attr_accessor :direction
37
31
 
38
- def field=(f)
39
- @field = f.to_sym
40
- end
41
-
42
- # @return [String] the sort direction
43
- def polarity
44
- ORDERING[@direction] || ORDERING[:asc]
45
- end # polarity
32
+ def initialize(field, order = :asc)
33
+ @field = field.to_sym || :objectId
34
+ @direction = order
35
+ end
46
36
 
47
- # @return [String] the ordering as a string
48
- def to_s
49
- "" if @field.nil?
50
- polarity + @field.to_s
51
- end
37
+ def field=(f)
38
+ @field = f.to_sym
39
+ end
52
40
 
53
- # @!visibility private
54
- def inspect
55
- "#{@direction.to_s}(#{@field.inspect})"
56
- end
41
+ # @return [String] the sort direction
42
+ def polarity
43
+ ORDERING[@direction] || ORDERING[:asc]
44
+ end # polarity
57
45
 
58
- end # Order
46
+ # @return [String] the ordering as a string
47
+ def to_s
48
+ "" if @field.nil?
49
+ polarity + @field.to_s
50
+ end
59
51
 
52
+ # @!visibility private
53
+ def inspect
54
+ "#{@direction.to_s}(#{@field.inspect})"
55
+ end
56
+ end # Order
60
57
  end
61
58
 
62
59
  # Extension to add all the operator instance methods to the Symbol classe
@@ -66,5 +63,4 @@ class Symbol
66
63
  Parse::Order.new self, sym
67
64
  end
68
65
  end # each
69
-
70
66
  end
@@ -2,27 +2,31 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require_relative "stack/version"
5
- require_relative 'client'
6
- require_relative 'query'
7
- require_relative 'model/object'
8
- require_relative 'webhooks'
9
-
5
+ require_relative "client"
6
+ require_relative "query"
7
+ require_relative "model/object"
8
+ require_relative "webhooks"
10
9
 
11
10
  module Parse
12
- class Error < StandardError; end;
11
+ class Error < StandardError; end
12
+
13
13
  module Stack
14
+ end
15
+
16
+ # Special class to support Modernistik Hyperdrive server.
17
+ class Hyperdrive
14
18
  # Applies a remote JSON hash containing the ENV keys and values from a remote
15
19
  # URL. Values from the JSON hash are only applied to the current ENV hash ONLY if
16
20
  # it does not already have a value. Therefore local ENV values will take precedence
17
21
  # over remote ones. By default, it uses the url in environment value in 'CONFIG_URL' or 'HYPERDRIVE_URL'.
18
22
  # @param url [String] the remote url that responds with the JSON body.
19
23
  # @return [Boolean] true if the JSON hash was found and applied successfully.
20
- def self.hyperdrive_config!(url = nil)
21
- url ||= ENV["HYPERDRIVE_URL"] || ENV['CONFIG_URL']
24
+ def self.config!(url = nil)
25
+ url ||= ENV["HYPERDRIVE_URL"] || ENV["CONFIG_URL"]
22
26
  if url.present?
23
27
  begin
24
- remote_config = JSON.load open( url )
25
- remote_config.each do |key,value|
28
+ remote_config = JSON.load open(url)
29
+ remote_config.each do |key, value|
26
30
  k = key.upcase
27
31
  next unless ENV[k].nil?
28
32
  ENV[k] ||= value.to_s
@@ -37,4 +41,4 @@ module Parse
37
41
  end
38
42
  end
39
43
 
40
- require_relative 'stack/railtie' if defined?(::Rails)
44
+ require_relative "stack/railtie" if defined?(::Rails)
@@ -1,42 +1,40 @@
1
1
  # encoding: UTF-8
2
2
  # frozen_string_literal: true
3
3
 
4
- require 'parse/stack'
5
- require 'parse/stack/tasks'
6
- require 'rails/generators'
7
- require 'rails/generators/named_base'
4
+ require "parse/stack"
5
+ require "parse/stack/tasks"
6
+ require "rails/generators"
7
+ require "rails/generators/named_base"
8
8
 
9
9
  # Module namespace to show up in the generators list for Rails.
10
10
  module ParseStack
11
- # Adds support for rails when installing Parse::Stack to a Rails project.
12
- class InstallGenerator < Rails::Generators::Base
13
- source_root File.expand_path("../templates", __FILE__)
14
-
15
- desc "This generator creates an initializer file at config/initializers"
16
- # @!visibility private
17
- def generate_initializer
18
- copy_file "parse.rb", "config/initializers/parse.rb"
19
- copy_file "model_user.rb", File.join("app/models", "user.rb")
20
- copy_file "model_role.rb", File.join("app/models", "role.rb")
21
- copy_file "model_session.rb", File.join("app/models", "session.rb")
22
- copy_file "model_installation.rb", File.join("app/models", "installation.rb")
23
- copy_file "webhooks.rb", File.join("app/models", "webhooks.rb")
24
- end
25
- end
11
+ # Adds support for rails when installing Parse::Stack to a Rails project.
12
+ class InstallGenerator < Rails::Generators::Base
13
+ source_root File.expand_path("../templates", __FILE__)
26
14
 
15
+ desc "This generator creates an initializer file at config/initializers"
27
16
  # @!visibility private
28
- class ModelGenerator < Rails::Generators::NamedBase
29
- source_root File.expand_path(__dir__ + "/templates")
30
- desc "Creates a Parse::Object model subclass."
31
- argument :attributes, type: :array, default: [], banner: "field:type field:type"
32
- check_class_collision
17
+ def generate_initializer
18
+ copy_file "parse.rb", "config/initializers/parse.rb"
19
+ copy_file "model_user.rb", File.join("app/models", "user.rb")
20
+ copy_file "model_role.rb", File.join("app/models", "role.rb")
21
+ copy_file "model_session.rb", File.join("app/models", "session.rb")
22
+ copy_file "model_installation.rb", File.join("app/models", "installation.rb")
23
+ copy_file "webhooks.rb", File.join("app/models", "webhooks.rb")
24
+ end
25
+ end
33
26
 
34
- # @!visibility private
35
- def create_model_file
36
- @allowed_types = Parse::Properties::TYPES - [:acl, :id, :relation]
37
- template "model.erb", File.join("app/models", class_path, "#{file_name}.rb")
38
- end
27
+ # @!visibility private
28
+ class ModelGenerator < Rails::Generators::NamedBase
29
+ source_root File.expand_path(__dir__ + "/templates")
30
+ desc "Creates a Parse::Object model subclass."
31
+ argument :attributes, type: :array, default: [], banner: "field:type field:type"
32
+ check_class_collision
39
33
 
34
+ # @!visibility private
35
+ def create_model_file
36
+ @allowed_types = Parse::Properties::TYPES - [:acl, :id, :relation]
37
+ template "model.erb", File.join("app/models", class_path, "#{file_name}.rb")
40
38
  end
41
-
39
+ end
42
40
  end
@@ -5,12 +5,11 @@ class <%= class_name %> < Parse::Object
5
5
  # You can change the inferred Parse table/collection name below
6
6
  # parse_class "<%= class_name.to_s.to_parse_class %>"
7
7
  <% attributes.each do |attr|
8
- parse_type = attr.type.to_s.downcase.to_sym
9
- unless @allowed_types.include?(parse_type)
10
- puts "\n[Warning] Skipping property `#{attr.name}` with type `#{parse_type}`. Type should be one of #{@allowed_types}."
11
- next
12
- end
13
- %>
8
+ parse_type = attr.type.to_s.downcase.to_sym
9
+ unless @allowed_types.include?(parse_type)
10
+ puts "\n[Warning] Skipping property `#{attr.name}` with type `#{parse_type}`. Type should be one of #{@allowed_types}."
11
+ next
12
+ end %>
14
13
  property :<%= attr.name %>, :<%= parse_type -%>
15
14
  <% end %>
16
15
 
@@ -1,4 +1,3 @@
1
-
2
1
  class Parse::Installation < Parse::Object
3
2
  # See: https://github.com/modernistik/parse-stack#parseinstallation
4
3
  # add additional properties here
@@ -1,4 +1,3 @@
1
-
2
1
  class Parse::Role < Parse::Object
3
2
  # See: https://github.com/modernistik/parse-stack#parserole
4
3
  # add additional properties here
@@ -1,4 +1,3 @@
1
-
2
1
  class Parse::Session < Parse::Object
3
2
  # See: https://github.com/modernistik/parse-stack#parsesession
4
3
  # add additional properties here
@@ -1,4 +1,3 @@
1
-
2
1
  class Parse::User < Parse::Object
3
2
  # add additional properties
4
3
 
@@ -1,12 +1,12 @@
1
- require 'parse/stack'
1
+ require "parse/stack"
2
2
 
3
3
  # Set your specific Parse keys in your ENV. For all connection options, see
4
4
  # https://github.com/modernistik/parse-stack#connection-setup
5
- Parse.setup app_id: ENV['PARSE_SERVER_APPLICATION_ID'],
6
- api_key: ENV['PARSE_SERVER_REST_API_KEY'],
7
- master_key: ENV['PARSE_SERVER_MASTER_KEY'], # optional
8
- server_url: 'https://localhost:1337/parse'
9
- # optional
10
- # logging: false,
11
- # cache: Moneta.new(:File, dir: 'tmp/cache'),
12
- # expires: 1 # cache ttl 1 second
5
+ Parse.setup app_id: ENV["PARSE_SERVER_APPLICATION_ID"],
6
+ api_key: ENV["PARSE_SERVER_REST_API_KEY"],
7
+ master_key: ENV["PARSE_SERVER_MASTER_KEY"], # optional
8
+ server_url: "https://localhost:1337/parse"
9
+ # optional
10
+ # logging: false,
11
+ # cache: Moneta.new(:File, dir: 'tmp/cache'),
12
+ # expires: 1 # cache ttl 1 second
@@ -1,8 +1,7 @@
1
-
2
1
  # See: https://github.com/modernistik/parse-stack#cloud-code-webhooks
3
2
  Parse::Webhooks.route(:function, :helloWorld) do
4
3
  # use the Parse::Payload instance methods in this block
5
- name = params['name'].to_s #function params
4
+ name = params["name"].to_s #function params
6
5
 
7
6
  # will return proper error response
8
7
  # error!("Missing argument 'name'.") unless name.present?
@@ -5,16 +5,14 @@ module Parse
5
5
  module Stack
6
6
  # Support for adding rake tasks to a Rails project.
7
7
  class Railtie < ::Rails::Railtie
8
-
9
8
  rake_tasks do
10
- require_relative 'tasks'
9
+ require_relative "tasks"
11
10
  Parse::Stack.load_tasks
12
11
  end
13
12
 
14
13
  generators do
15
- require_relative 'generators/rails'
14
+ require_relative "generators/rails"
16
15
  end
17
-
18
16
  end
19
17
  end
20
18
  end
@@ -1,15 +1,14 @@
1
1
  # encoding: UTF-8
2
2
  # frozen_string_literal: true
3
3
 
4
- require_relative '../stack.rb'
5
- require 'active_support'
6
- require 'active_support/inflector'
7
- require 'active_support/core_ext'
8
- require 'rake'
9
- require 'rake/dsl_definition'
4
+ require_relative "../stack.rb"
5
+ require "active_support"
6
+ require "active_support/inflector"
7
+ require "active_support/core_ext"
8
+ require "rake"
9
+ require "rake/dsl_definition"
10
10
 
11
11
  module Parse
12
-
13
12
  module Stack
14
13
  # Loads and installs all Parse::Stack related tasks in a rake file.
15
14
  def self.load_tasks
@@ -22,42 +21,36 @@ module Parse
22
21
 
23
22
  # Installs the rake tasks.
24
23
  def install_tasks
25
-
26
24
  if defined?(::Rails)
27
- unless Rake::Task.task_defined?('db:seed') || Rails.root.blank?
25
+ unless Rake::Task.task_defined?("db:seed") || Rails.root.blank?
28
26
  namespace :db do
29
27
  desc "Seeds your database with by loading db/seeds.rb"
30
- task :seed => 'parse:env' do
31
- load Rails.root.join("db","seeds.rb")
28
+ task :seed => "parse:env" do
29
+ load Rails.root.join("db", "seeds.rb")
32
30
  end
33
31
  end
34
32
  end
35
33
  end
36
34
 
37
35
  namespace :parse do
38
-
39
36
  task :env do
40
-
41
- if Rake::Task.task_defined?('environment')
42
- Rake::Task['environment'].invoke
37
+ if Rake::Task.task_defined?("environment")
38
+ Rake::Task["environment"].invoke
43
39
  if defined?(::Rails)
44
40
  Rails.application.eager_load! if Rails.application.present?
45
41
  end
46
-
47
42
  end
48
43
  end
49
44
 
50
45
  task :verify_env => :env do
51
-
52
46
  unless Parse::Client.client?
53
47
  raise "Please make sure you have setup the Parse.setup configuration before invoking task. Usually done in the :environment task."
54
48
  end
55
49
 
56
- endpoint = ENV['HOOKS_URL'] || ''
57
- unless endpoint.starts_with?('http://') || endpoint.starts_with?('https://')
50
+ endpoint = ENV["HOOKS_URL"] || ""
51
+ unless endpoint.starts_with?("http://") || endpoint.starts_with?("https://")
58
52
  raise "The ENV variable HOOKS_URL must be a <http/s> url : '#{endpoint}'. Ex. https://12345678.ngrok.io/webhooks"
59
53
  end
60
-
61
54
  end
62
55
 
63
56
  desc "Run auto_upgrade on all of your Parse models."
@@ -69,92 +62,83 @@ module Parse
69
62
  end
70
63
 
71
64
  namespace :webhooks do
65
+ desc "Register local webhooks with Parse server"
66
+ task :register => :verify_env do
67
+ endpoint = ENV["HOOKS_URL"]
68
+ puts "Registering Parse Webhooks @ #{endpoint}"
69
+ Rake::Task["parse:webhooks:register:functions"].invoke
70
+ Rake::Task["parse:webhooks:register:triggers"].invoke
71
+ end
72
72
 
73
- desc "Register local webhooks with Parse server"
74
- task :register => :verify_env do
75
- endpoint = ENV['HOOKS_URL']
76
- puts "Registering Parse Webhooks @ #{endpoint}"
77
- Rake::Task['parse:webhooks:register:functions'].invoke
78
- Rake::Task['parse:webhooks:register:triggers'].invoke
79
- end
80
-
81
- desc "List all webhooks and triggers registered with the Parse Server"
82
- task :list => :verify_env do
83
- Rake::Task['parse:webhooks:list:functions'].invoke
84
- Rake::Task['parse:webhooks:list:triggers'].invoke
85
- end
73
+ desc "List all webhooks and triggers registered with the Parse Server"
74
+ task :list => :verify_env do
75
+ Rake::Task["parse:webhooks:list:functions"].invoke
76
+ Rake::Task["parse:webhooks:list:triggers"].invoke
77
+ end
86
78
 
87
- desc "Remove all locally registered webhooks from the Parse Application."
88
- task :remove => :verify_env do
89
- Rake::Task['parse:webhooks:remove:functions'].invoke
90
- Rake::Task['parse:webhooks:remove:triggers'].invoke
91
- end
79
+ desc "Remove all locally registered webhooks from the Parse Application."
80
+ task :remove => :verify_env do
81
+ Rake::Task["parse:webhooks:remove:functions"].invoke
82
+ Rake::Task["parse:webhooks:remove:triggers"].invoke
83
+ end
92
84
 
93
- namespace :list do
94
- task :functions => :verify_env do
95
- endpoint = ENV['HOOKS_URL'] || '-'
96
- Parse.client.functions.each do |r|
97
- name = r['functionName']
98
- url = r['url']
99
- star = url.starts_with?(endpoint) ? '*' : ' '
100
- puts "[#{star}] #{name} -> #{url}"
85
+ namespace :list do
86
+ task :functions => :verify_env do
87
+ endpoint = ENV["HOOKS_URL"] || "-"
88
+ Parse.client.functions.each do |r|
89
+ name = r["functionName"]
90
+ url = r["url"]
91
+ star = url.starts_with?(endpoint) ? "*" : " "
92
+ puts "[#{star}] #{name} -> #{url}"
93
+ end
101
94
  end
102
- end
103
95
 
104
- task :triggers => :verify_env do
105
- endpoint = ENV['HOOKS_URL'] || '-'
106
- triggers = Parse.client.triggers.results
107
- triggers.sort! { |x,y| [x['className'],x['triggerName']] <=> [y['className'], y['triggerName'] ] }
108
- triggers.each do |r|
109
- name = r['className']
110
- trigger = r['triggerName']
111
- url = r['url']
112
- star = url.starts_with?(endpoint) ? '*' : ' '
113
- puts "[#{star}] #{name}.#{trigger} -> #{url}"
96
+ task :triggers => :verify_env do
97
+ endpoint = ENV["HOOKS_URL"] || "-"
98
+ triggers = Parse.client.triggers.results
99
+ triggers.sort! { |x, y| [x["className"], x["triggerName"]] <=> [y["className"], y["triggerName"]] }
100
+ triggers.each do |r|
101
+ name = r["className"]
102
+ trigger = r["triggerName"]
103
+ url = r["url"]
104
+ star = url.starts_with?(endpoint) ? "*" : " "
105
+ puts "[#{star}] #{name}.#{trigger} -> #{url}"
106
+ end
114
107
  end
115
108
  end
116
109
 
117
- end
118
-
119
- namespace :register do
120
-
121
- task :functions => :verify_env do
122
- endpoint = ENV['HOOKS_URL']
123
- Parse::Webhooks.register_functions!(endpoint) do |name|
124
- puts "[+] function - #{name}"
110
+ namespace :register do
111
+ task :functions => :verify_env do
112
+ endpoint = ENV["HOOKS_URL"]
113
+ Parse::Webhooks.register_functions!(endpoint) do |name|
114
+ puts "[+] function - #{name}"
115
+ end
125
116
  end
126
- end
127
117
 
128
- task :triggers => :verify_env do
129
- endpoint = ENV['HOOKS_URL']
130
- Parse::Webhooks.register_triggers!(endpoint, {include_wildcard: true}) do |trigger,name|
131
- puts "[+] #{trigger.to_s.ljust(12, ' ')} - #{name}"
118
+ task :triggers => :verify_env do
119
+ endpoint = ENV["HOOKS_URL"]
120
+ Parse::Webhooks.register_triggers!(endpoint, { include_wildcard: true }) do |trigger, name|
121
+ puts "[+] #{trigger.to_s.ljust(12, " ")} - #{name}"
122
+ end
132
123
  end
133
124
  end
134
125
 
135
- end
136
-
137
- namespace :remove do
138
-
139
- task :functions => :verify_env do
140
- Parse::Webhooks.remove_all_functions! do |name|
141
- puts "[-] function - #{name}"
126
+ namespace :remove do
127
+ task :functions => :verify_env do
128
+ Parse::Webhooks.remove_all_functions! do |name|
129
+ puts "[-] function - #{name}"
130
+ end
142
131
  end
143
- end
144
132
 
145
- task :triggers => :verify_env do
146
- Parse::Webhooks.remove_all_triggers! do |trigger,name|
147
- puts "[-] #{trigger.to_s.ljust(12, ' ')} - #{name}"
133
+ task :triggers => :verify_env do
134
+ Parse::Webhooks.remove_all_triggers! do |trigger, name|
135
+ puts "[-] #{trigger.to_s.ljust(12, " ")} - #{name}"
136
+ end
148
137
  end
149
138
  end
150
-
151
- end
152
-
153
139
  end # webhooks
154
-
155
140
  end # webhooks namespace
156
141
  end
157
142
  end # Tasks
158
143
  end # Webhooks
159
-
160
144
  end # Parse