diff --git a/CHANGELOG.md b/CHANGELOG.md index 67075804..686e8492 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -305,7 +305,7 @@ Enhancements: Bug Fixes: -* Fix a bug which ActivityNotificaion.config.mailer configuration was ignored +* Fix a bug which ActivityNotification.config.mailer configuration was ignored ## 1.4.1 / 2017-05-17 [Full Changelog](http://github.com/simukappu/activity_notification/compare/v1.4.0...v1.4.1) diff --git a/app/channels/activity_notification/notification_api_with_devise_channel.rb b/app/channels/activity_notification/notification_api_with_devise_channel.rb index 1a4fde17..ee37724d 100644 --- a/app/channels/activity_notification/notification_api_with_devise_channel.rb +++ b/app/channels/activity_notification/notification_api_with_devise_channel.rb @@ -18,7 +18,7 @@ def find_current_target(devise_type = nil) end # Set @target instance variable from request parameters. - # This method overrides super (ActivityNotiication::NotificationChannel#set_target) + # This method overrides super (ActivityNotification::NotificationChannel#set_target) # to set devise authenticated target when the target_id params is not specified. # @api protected # @return [Object] Target instance (Reject subscription when request parameters are not enough) diff --git a/app/channels/activity_notification/notification_with_devise_channel.rb b/app/channels/activity_notification/notification_with_devise_channel.rb index c8967c01..c7fe1ff7 100644 --- a/app/channels/activity_notification/notification_with_devise_channel.rb +++ b/app/channels/activity_notification/notification_with_devise_channel.rb @@ -23,7 +23,7 @@ def session end # Sets @target instance variable from request parameters. - # This method override super (ActivityNotiication::NotificationChannel#set_target) + # This method override super (ActivityNotification::NotificationChannel#set_target) # to set devise authenticated target when the target_id params is not specified. # @api protected # @return [Object] Target instance (Reject subscription when request parameters are not enough) diff --git a/app/jobs/activity_notification/notify_all_job.rb b/app/jobs/activity_notification/notify_all_job.rb index d082e8b9..1ab20afb 100644 --- a/app/jobs/activity_notification/notify_all_job.rb +++ b/app/jobs/activity_notification/notify_all_job.rb @@ -16,8 +16,8 @@ class ActivityNotification::NotifyAllJob < ActivityNotification.config.parent_jo # @option options [Boolean] :send_email (true) Whether it sends notification email # @option options [Boolean] :send_later (true) Whether it sends notification email asynchronously # @option options [Boolean] :publish_optional_targets (true) Whether it publishes notification to optional targets - # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc) and values are options - # @return [Array] Array of generated notifications + # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc.) and values are options + # @return [Array] Array of generated notifications def perform(targets, notifiable, options = {}) ActivityNotification::Notification.notify_all(targets, notifiable, options) end diff --git a/app/jobs/activity_notification/notify_job.rb b/app/jobs/activity_notification/notify_job.rb index 022c229b..52888327 100644 --- a/app/jobs/activity_notification/notify_job.rb +++ b/app/jobs/activity_notification/notify_job.rb @@ -17,8 +17,8 @@ class ActivityNotification::NotifyJob < ActivityNotification.config.parent_job.c # @option options [Boolean] :send_later (true) Whether it sends notification email asynchronously # @option options [Boolean] :publish_optional_targets (true) Whether it publishes notification to optional targets # @option options [Boolean] :pass_full_options (false) Whether it passes full options to notifiable.notification_targets, not a key only - # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc) and values are options - # @return [Array] Array of generated notifications + # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc.) and values are options + # @return [Array] Array of generated notifications def perform(target_type, notifiable, options = {}) ActivityNotification::Notification.notify(target_type, notifiable, options) end diff --git a/app/jobs/activity_notification/notify_to_job.rb b/app/jobs/activity_notification/notify_to_job.rb index 2d1cbea3..15748809 100644 --- a/app/jobs/activity_notification/notify_to_job.rb +++ b/app/jobs/activity_notification/notify_to_job.rb @@ -16,7 +16,7 @@ class ActivityNotification::NotifyToJob < ActivityNotification.config.parent_job # @option options [Boolean] :send_email (true) Whether it sends notification email # @option options [Boolean] :send_later (true) Whether it sends notification email asynchronously # @option options [Boolean] :publish_optional_targets (true) Whether it publishes notification to optional targets - # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc) and values are options + # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc.) and values are options # @return [Notification] Generated notification instance def perform(target, notifiable, options = {}) ActivityNotification::Notification.notify_to(target, notifiable, options) diff --git a/app/mailers/activity_notification/mailer.rb b/app/mailers/activity_notification/mailer.rb index 4e33b9fa..29574f79 100644 --- a/app/mailers/activity_notification/mailer.rb +++ b/app/mailers/activity_notification/mailer.rb @@ -1,5 +1,5 @@ if defined?(ActionMailer) - # Mailer for email notification of ActivityNotificaion. + # Mailer for email notification of ActivityNotification. class ActivityNotification::Mailer < ActivityNotification.config.parent_mailer.constantize include ActivityNotification::Mailers::Helpers diff --git a/app/views/activity_notification/mailer/default/batch_default.text.erb b/app/views/activity_notification/mailer/default/batch_default.text.erb index 71926051..0ce64a22 100644 --- a/app/views/activity_notification/mailer/default/batch_default.text.erb +++ b/app/views/activity_notification/mailer/default/batch_default.text.erb @@ -1,6 +1,6 @@ Dear <%= @target.printable_target_name %> -You have recieved follwing notifications. +You have received the following notifications. <% @notifications.each do |notification| %> <%= notification.notifier.present? ? notification.notifier.printable_notifier_name : 'Someone' %> notified you of <%= notification.notifiable.printable_notifiable_name(notification.target) %><%= " in #{notification.group.printable_group_name}" if notification.group.present? %>. diff --git a/app/views/activity_notification/notifications/default/index.html.erb b/app/views/activity_notification/notifications/default/index.html.erb index 274b2bbc..3ecf6e43 100644 --- a/app/views/activity_notification/notifications/default/index.html.erb +++ b/app/views/activity_notification/notifications/default/index.html.erb @@ -67,7 +67,7 @@ $(".notifications").prepend(notification.group_owner_view); $(".notification_count").html("" + notification.unopened_notification_count + ""); } - // Push notificaion using Web Notification API by Push.js + // Push notification using Web Notification API by Push.js Push.create('ActivityNotification', { body: notification.text, timeout: 5000, diff --git a/app/views/activity_notification/subscriptions/default/_notification_keys.html.erb b/app/views/activity_notification/subscriptions/default/_notification_keys.html.erb index 8f986572..104b2b6a 100644 --- a/app/views/activity_notification/subscriptions/default/_notification_keys.html.erb +++ b/app/views/activity_notification/subscriptions/default/_notification_keys.html.erb @@ -49,7 +49,7 @@ <% target.notifications.filtered_by_key(key).latest.optional_target_names.each do |optional_target_name| %>
diff --git a/app/views/activity_notification/subscriptions/default/_subscription.html.erb b/app/views/activity_notification/subscriptions/default/_subscription.html.erb index 099661c0..6f13e459 100644 --- a/app/views/activity_notification/subscriptions/default/_subscription.html.erb +++ b/app/views/activity_notification/subscriptions/default/_subscription.html.erb @@ -70,7 +70,7 @@ <% subscription.optional_target_names.each do |optional_target_name| %>
diff --git a/docs/Functions.md b/docs/Functions.md index b08c0087..7c23a035 100644 --- a/docs/Functions.md +++ b/docs/Functions.md @@ -525,7 +525,7 @@ config.subscribe_to_email_as_default = false config.subscribe_to_optional_targets_as_default = true ``` -However if **subscribe_as_default** is not enabled, **subscribe_to_email_as_default** and **subscribe_to_optional_targets_as_default** won't change anything. +However, if **subscribe_as_default** is not enabled, **subscribe_to_email_as_default** and **subscribe_to_optional_targets_as_default** won't change anything. ##### Creating and updating subscriptions @@ -860,7 +860,7 @@ See [Devise Token Auth documents](https://devise-token-auth.gitbook.io/devise-to *activity_notification* supports push notification with Action Cable by WebSocket. *activity_notification* only provides Action Cable channels implementation, does not connections. -You can use default implementaion in Rails or your custom `ApplicationCable::Connection` for Action Cable connections. +You can use default implementation in Rails or your custom `ApplicationCable::Connection` for Action Cable connections. #### Enabling broadcasting notifications to channels @@ -928,7 +928,7 @@ You can simply create subscriptions for the specified target in your view like t received: function(notification) { // Display notification - // Push notificaion using Web Notification API by Push.js + // Push notification using Web Notification API by Push.js Push.create('ActivityNotification', { body: notification.text, timeout: 5000, @@ -978,7 +978,7 @@ export default { notify (data) { // Display notification - // Push notificaion using Web Notification API by Push.js + // Push notification using Web Notification API by Push.js Push.create('ActivityNotification', { body: data.notification.text, timeout: 5000, @@ -1045,7 +1045,7 @@ App.activity_notification = App.cable.subscriptions.create( *ActivityNotification::NotificationWithDeviseChannel* will confirm subscription requests from authenticated cookies by Devise. If the user has not signed in, the subscription request will be rejected. If the user has signed in as unauthorized user, the subscription request will be also rejected. -In addtion, you can use `Target#notification_action_cable_channel_class_name` method to select channel class depending on your *action_cable_with_devise* configuration for the target. +In addition, you can use `Target#notification_action_cable_channel_class_name` method to select channel class depending on your *action_cable_with_devise* configuration for the target. ```js App.activity_notification = App.cable.subscriptions.create( @@ -1253,7 +1253,7 @@ First, add **slack-notifier** gem to your Gemfile and create Incoming WebHooks i gem 'slack-notifier' ``` -Then, write `require 'activity_notification/optional_targets/slack'` statement in your notifiable model and set *ActivityNotification::OptionalTarget::Slack* to *acts_as_notifiable* with *:webhook_url* and *:target_username* initializing parameters. *:webhook_url* is created WebHook URL and required, *:target_username* is target's slack user name as String value, symbol method name or lambda function and is optional. +Then, write `require 'activity_notification/optional_targets/slack'` statement in your notifiable model and set *ActivityNotification::OptionalTarget::Slack* to *acts_as_notifiable* with *:webhook_url* and *:target_username* initializing parameters. *:webhook_url* is created WebHook URL and required, *:target_username* is target's slack username as String value, symbol method name or lambda function and is optional. Any other options for `Slack::Notifier.new` are available as initializing parameters. See [Github slack-notifier](https://github.com/stevenosloan/slack-notifier) and [API Reference of Class: Slack::Notifier](http://www.rubydoc.info/gems/slack-notifier/1.5.1/Slack/Notifier) for more details. ```ruby @@ -1323,10 +1323,10 @@ end *ActivityNotification::Subscription* model provides API to subscribe and unsubscribe optional notification targets. Call these methods with optional target name like this: ```ruby -# Subscribe Acltion Cable channel for 'comment.reply' notifications +# Subscribe Action Cable channel for 'comment.reply' notifications user.find_or_create_subscription('comment.reply').subscribe_to_optional_target(:action_cable_channel) -# Subscribe Acltion Cable API channel for 'comment.reply' notifications +# Subscribe Action Cable API channel for 'comment.reply' notifications user.find_or_create_subscription('comment.reply').subscribe_to_optional_target(:action_cable_api_channel) # Unsubscribe Slack notification for 'comment.reply' notifications diff --git a/docs/Setup.md b/docs/Setup.md index 3436e522..06ca0139 100644 --- a/docs/Setup.md +++ b/docs/Setup.md @@ -20,7 +20,7 @@ $ bin/rails generate activity_notification:install ``` The generator will install an initializer which describes all configuration options of *activity_notification*. -It also generates a i18n based translation file which we can configure the presentation of notifications. +It also generates an i18n based translation file which we can configure the presentation of notifications. #### ORM Dependencies @@ -147,7 +147,7 @@ In such cases, you can use **store_with_associated_records** option in initializ config.store_with_associated_records = true ``` -When **store_with_associated_records** is set to *false* as default, *activity_notification* stores notificaion records with association like this: +When **store_with_associated_records** is set to *false* as default, *activity_notification* stores notification records with association like this: ```json { @@ -181,7 +181,7 @@ When **store_with_associated_records** is set to *false* as default, *activity_n } ``` -When you set **store_with_associated_records** to *true*, *activity_notification* stores notificaion records including associated target, notifiable, notifier and several instance methods like this: +When you set **store_with_associated_records** to *true*, *activity_notification* stores notification records including associated target, notifiable, notifier and several instance methods like this: ```json { @@ -561,7 +561,7 @@ ActivityNotification::Notification.notify :users, @comment, key: "comment.reply" The first argument is the plural symbol name of your target model, which is configured in notifiable model by *acts_as_notifiable*. The new instances of **ActivityNotification::Notification** model will be generated for the specified targets. -*Hint*: *:key* is a option. Default key `#{notifiable_type}.default` which means *comment.default* will be used without specified key. +*Hint*: *:key* is an option. Default key `#{notifiable_type}.default` which means *comment.default* will be used without specified key. You can override it by *Notifiable#default_notification_key*. #### Asynchronous notification API with ActiveJob @@ -580,7 +580,7 @@ You can also use *:notify_later* option in *notify* method. This is the same ope *Note*: *notify_now* is an alias for *notify* and does the same. -When you use asynchronous notification API, you should setup ActiveJob with background queuing service such as Sidekiq. +When you use asynchronous notification API, you should set up ActiveJob with background queuing service such as Sidekiq. You can set *config.active_job_queue* in your initializer to specify a queue name *activity_notification* will use. The default queue name is *:activity_notification*. @@ -725,7 +725,7 @@ For example, if you have a notification with *:key* set to *"notification.commen *Hint*: the *"notification."* prefix in *:key* is completely optional, you can skip it in your projects or use this prefix only to make namespace. -If you would like to fallback to a partial, you can utilize the **:fallback** parameter to specify the path of a partial to use when one is missing: +If you would like to fall back to a partial, you can utilize the **:fallback** parameter to specify the path of a partial to use when one is missing: ```erb <%= render_notification(@notification, target: :users, fallback: :default) %> @@ -741,7 +741,7 @@ If you do not specify *:target* option like this, the gem will look for a partial in *default* as the target type which means *activity_notification/notifications/default/_default.html.(|erb|haml|slim|something_else)*. -If a view file does not exist then *ActionView::MisingTemplate* will be raised. If you wish to fallback to the old behaviour and use an i18n based translation in this situation you can specify a *:fallback* parameter of *:text* to fallback to this mechanism like such: +If a view file does not exist then *ActionView::MisingTemplate* will be raised. If you wish to fall back to the old behaviour and use an i18n based translation in this situation you can specify a *:fallback* parameter of *:text* to fall back to this mechanism like such: ```erb <%= render_notification(@notification, fallback: :text) %> diff --git a/docs/Testing.md b/docs/Testing.md index c3522974..65971690 100644 --- a/docs/Testing.md +++ b/docs/Testing.md @@ -149,7 +149,7 @@ $ export AN_ORM=dynamoid AN_TEST_DB=postgresql ``` Then, configure *spec/rails_app/config/database.yml* or *spec/rails_app/config/mongoid.yml*, *spec/rails_app/config/dynamoid.rb* as your local database. -Finally, run database migration, seed data script and the example appliation. +Finally, run database migration, seed data script and the example application. ```console $ cd spec/rails_app $ # You don't need migration when you use MongoDB only (AN_ORM=mongoid and AN_TEST_DB=mongodb) diff --git a/lib/activity_notification/apis/notification_api.rb b/lib/activity_notification/apis/notification_api.rb index af91febb..ab47b886 100644 --- a/lib/activity_notification/apis/notification_api.rb +++ b/lib/activity_notification/apis/notification_api.rb @@ -25,7 +25,7 @@ module NotificationApi # @notifications = @user.notifications.group_owners_only.latest_order # @param [Boolean] reverse If notification index will be ordered as earliest first # @param [Boolean] with_group_members If notification index will include group members - # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of filtered notifications + # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of filtered notifications scope :all_index!, ->(reverse = false, with_group_members = false) { target_index = with_group_members ? self : group_owners_only reverse ? target_index.earliest_order : target_index.latest_order @@ -36,12 +36,12 @@ module NotificationApi # is defined same as # ActivityNotification::Notification.unopened_only.group_owners_only.latest_order # @scope class - # @example Get unopened notificaton index of the @user + # @example Get unopened notification index of the @user # @notifications = @user.notifications.unopened_index # @notifications = @user.notifications.unopened_only.group_owners_only.latest_order # @param [Boolean] reverse If notification index will be ordered as earliest first # @param [Boolean] with_group_members If notification index will include group members - # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of filtered notifications + # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of filtered notifications scope :unopened_index, ->(reverse = false, with_group_members = false) { target_index = with_group_members ? unopened_only : unopened_only.group_owners_only reverse ? target_index.earliest_order : target_index.latest_order @@ -52,54 +52,54 @@ module NotificationApi # is defined same as # ActivityNotification::Notification.opened_only(limit).group_owners_only.latest_order # @scope class - # @example Get unopened notificaton index of the @user with limit 10 + # @example Get unopened notification index of the @user with limit 10 # @notifications = @user.notifications.opened_index(10) # @notifications = @user.notifications.opened_only(10).group_owners_only.latest_order # @param [Integer] limit Limit to query for opened notifications # @param [Boolean] reverse If notification index will be ordered as earliest first # @param [Boolean] with_group_members If notification index will include group members - # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of filtered notifications + # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of filtered notifications scope :opened_index, ->(limit, reverse = false, with_group_members = false) { target_index = with_group_members ? opened_only(limit) : opened_only(limit).group_owners_only reverse ? target_index.earliest_order : target_index.latest_order } # Selects filtered notifications by target_type. - # @example Get filtered unopened notificatons of User as target type + # @example Get filtered unopened notification of User as target type # @notifications = ActivityNotification.Notification.unopened_only.filtered_by_target_type('User') # @scope class # @param [String] target_type Target type for filter - # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of filtered notifications + # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of filtered notifications scope :filtered_by_target_type, ->(target_type) { where(target_type: target_type) } # Selects filtered notifications by notifiable_type. - # @example Get filtered unopened notificatons of the @user for Comment notifiable class + # @example Get filtered unopened notification of the @user for Comment notifiable class # @notifications = @user.notifications.unopened_only.filtered_by_type('Comment') # @scope class # @param [String] notifiable_type Notifiable type for filter - # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of filtered notifications + # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of filtered notifications scope :filtered_by_type, ->(notifiable_type) { where(notifiable_type: notifiable_type) } # Selects filtered notifications by key. - # @example Get filtered unopened notificatons of the @user with key 'comment.reply' + # @example Get filtered unopened notification of the @user with key 'comment.reply' # @notifications = @user.notifications.unopened_only.filtered_by_key('comment.reply') # @scope class # @param [String] key Key of the notification for filter - # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of filtered notifications + # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of filtered notifications scope :filtered_by_key, ->(key) { where(key: key) } # Selects filtered notifications by notifiable_type, group or key with filter options. - # @example Get filtered unopened notificatons of the @user for Comment notifiable class + # @example Get filtered unopened notification of the @user for Comment notifiable class # @notifications = @user.notifications.unopened_only.filtered_by_options({ filtered_by_type: 'Comment' }) - # @example Get filtered unopened notificatons of the @user for @article as group + # @example Get filtered unopened notification of the @user for @article as group # @notifications = @user.notifications.unopened_only.filtered_by_options({ filtered_by_group: @article }) - # @example Get filtered unopened notificatons of the @user for Article instance id=1 as group + # @example Get filtered unopened notification of the @user for Article instance id=1 as group # @notifications = @user.notifications.unopened_only.filtered_by_options({ filtered_by_group_type: 'Article', filtered_by_group_id: '1' }) - # @example Get filtered unopened notificatons of the @user with key 'comment.reply' + # @example Get filtered unopened notification of the @user with key 'comment.reply' # @notifications = @user.notifications.unopened_only.filtered_by_options({ filtered_by_key: 'comment.reply' }) - # @example Get filtered unopened notificatons of the @user for Comment notifiable class with key 'comment.reply' + # @example Get filtered unopened notification of the @user for Comment notifiable class with key 'comment.reply' # @notifications = @user.notifications.unopened_only.filtered_by_options({ filtered_by_type: 'Comment', filtered_by_key: 'comment.reply' }) - # @example Get custom filtered notificatons of the @user + # @example Get custom filtered notification of the @user # @notifications = @user.notifications.unopened_only.filtered_by_options({ custom_filter: ["created_at >= ?", time.hour.ago] }) # @scope class # @param [Hash] options Options for filter @@ -111,7 +111,7 @@ module NotificationApi # @option options [String] :later_than (nil) ISO 8601 format time to filter notification index later than specified time # @option options [String] :earlier_than (nil) ISO 8601 format time to filter notification index earlier than specified time # @option options [Array|Hash] :custom_filter (nil) Custom notification filter (e.g. ["created_at >= ?", time.hour.ago] with ActiveRecord or {:created_at.gt => time.hour.ago} with Mongoid) - # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of filtered notifications + # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of filtered notifications scope :filtered_by_options, ->(options = {}) { options = ActivityNotification.cast_to_indifferent_hash(options) filtered_notifications = all @@ -141,22 +141,22 @@ module NotificationApi } # Orders by latest (newest) first as created_at: :desc. - # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of notifications ordered by latest first + # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of notifications ordered by latest first scope :latest_order, -> { order(created_at: :desc) } # Orders by earliest (older) first as created_at: :asc. - # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of notifications ordered by earliest first + # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of notifications ordered by earliest first scope :earliest_order, -> { order(created_at: :asc) } # Orders by latest (newest) first as created_at: :desc. # This method is to be overridden in implementation for each ORM. # @param [Boolean] reverse If notifications will be ordered as earliest first - # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of ordered notifications + # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of ordered notifications scope :latest_order!, ->(reverse = false) { reverse ? earliest_order : latest_order } # Orders by earliest (older) first as created_at: :asc. # This method is to be overridden in implementation for each ORM. - # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of notifications ordered by earliest first + # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of notifications ordered by earliest first scope :earliest_order!, -> { earliest_order } # Returns latest notification instance. @@ -224,8 +224,8 @@ def self.uniq_keys # @option options [Boolean] :send_later (true) Whether it sends notification email asynchronously # @option options [Boolean] :publish_optional_targets (true) Whether it publishes notification to optional targets # @option options [Boolean] :pass_full_options (false) Whether it passes full options to notifiable.notification_targets, not a key only - # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc) and values are options - # @return [Array] Array of generated notifications + # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc.) and values are options + # @return [Array] Array of generated notifications def notify(target_type, notifiable, options = {}) if options[:notify_later] notify_later(target_type, notifiable, options) @@ -263,8 +263,8 @@ def notify(target_type, notifiable, options = {}) # @option options [Boolean] :send_later (true) Whether it sends notification email asynchronously # @option options [Boolean] :publish_optional_targets (true) Whether it publishes notification to optional targets # @option options [Boolean] :pass_full_options (false) Whether it passes full options to notifiable.notification_targets, not a key only - # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc) and values are options - # @return [Array] Array of generated notifications + # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc.) and values are options + # @return [Array] Array of generated notifications def notify_later(target_type, notifiable, options = {}) target_type = target_type.to_s if target_type.is_a? Symbol options.delete(:notify_later) @@ -296,8 +296,8 @@ def notify_later(target_type, notifiable, options = {}) # @option options [Boolean] :send_later (true) Whether it sends notification email asynchronously # @option options [Boolean] :publish_optional_targets (true) Whether it publishes notification to optional targets # @option options [Integer] :batch_size (1000) Batch size for ActiveRecord find_each (optional) - # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc) and values are options - # @return [Array] Array of generated notifications + # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc.) and values are options + # @return [Array] Array of generated notifications def notify_all(targets, notifiable, options = {}) if options[:notify_later] notify_all_later(targets, notifiable, options) @@ -331,8 +331,8 @@ def notify_all(targets, notifiable, options = {}) # @option options [Boolean] :send_email (true) Whether it sends notification email # @option options [Boolean] :send_later (true) Whether it sends notification email asynchronously # @option options [Boolean] :publish_optional_targets (true) Whether it publishes notification to optional targets - # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc) and values are options - # @return [Array] Array of generated notifications + # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc.) and values are options + # @return [Array] Array of generated notifications def notify_all_later(targets, notifiable, options = {}) options.delete(:notify_later) ActivityNotification::NotifyAllJob.perform_later(targets, notifiable, options) @@ -341,7 +341,7 @@ def notify_all_later(targets, notifiable, options = {}) # Generates notifications to one target. # # @example Notify to one user - # ActivityNotification::Notification.notify_to @comment.auther, @comment + # ActivityNotification::Notification.notify_to @comment.author, @comment # # @param [Object] target Target to send notifications # @param [Object] notifiable Notifiable instance @@ -355,7 +355,7 @@ def notify_all_later(targets, notifiable, options = {}) # @option options [Boolean] :send_email (true) Whether it sends notification email # @option options [Boolean] :send_later (true) Whether it sends notification email asynchronously # @option options [Boolean] :publish_optional_targets (true) Whether it publishes notification to optional targets - # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc) and values are options + # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc.) and values are options # @return [Notification] Generated notification instance def notify_to(target, notifiable, options = {}) if options[:notify_later] @@ -383,7 +383,7 @@ def notify_to(target, notifiable, options = {}) # Generates notifications to one target later by ActiveJob queue. # # @example Notify to one user later - # ActivityNotification::Notification.notify_later_to @comment.auther, @comment + # ActivityNotification::Notification.notify_later_to @comment.author, @comment # # @param [Object] target Target to send notifications # @param [Object] notifiable Notifiable instance @@ -396,7 +396,7 @@ def notify_to(target, notifiable, options = {}) # @option options [Boolean] :send_email (true) Whether it sends notification email # @option options [Boolean] :send_later (true) Whether it sends notification email asynchronously # @option options [Boolean] :publish_optional_targets (true) Whether it publishes notification to optional targets - # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc) and values are options + # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc.) and values are options # @return [Notification] Generated notification instance def notify_later_to(target, notifiable, options = {}) options.delete(:notify_later) @@ -491,7 +491,7 @@ def destroy_all_of(target, options = {}) # Returns if group member of the notifications exists. # This method is designed to be called from controllers or views to avoid N+1. # - # @param [Array, ActiveRecord_AssociationRelation, Mongoid::Criteria] notifications Array or database query of the notifications to test member exists + # @param [Array, ActiveRecord_AssociationRelation, Mongoid::Criteria] notifications Array or database query of the notifications to test member exists # @return [Boolean] If group member of the notifications exists def group_member_exists?(notifications) notifications.present? and group_members_of_owner_ids_only(notifications.map(&:id)).exists? @@ -520,7 +520,7 @@ def send_batch_notification_email(target, notifications, options = {}) # Returns available options for kinds of notify methods. # - # @return [Array] Available options for kinds of notify methods + # @return [Array] Available options for kinds of notify methods def available_options [:key, :group, :group_expiry_delay, :notifier, :parameters, :send_email, :send_later, :pass_full_options].freeze end @@ -537,7 +537,7 @@ def set_notification_mailer # @param [String] key Key of the notification # @param [Object] group Group unit of the notifications # @param [ActiveSupport::Duration] group_expiry_delay Expiry period of a notification group - # @return [Notificaion] Valid group owner within the expiration period + # @return [Notification] Valid group owner within the expiration period def valid_group_owner(target, notifiable, key, group, group_expiry_delay) return nil if group.blank? # Bundle notification group by target, notifiable_type, group and key @@ -783,7 +783,7 @@ def group_notifier_count(limit = ActivityNotification.config.opened_index_limit) # Returns the latest group member notification instance of this notification. # If this group owner has no group members, group owner instance self will be returned. # - # @return [Notificaion] Notification instance of the latest group member notification + # @return [Notification] Notification instance of the latest group member notification def latest_group_member notification = group_member? && group_owner.present? ? group_owner : self notification.group_member_exists? ? notification.group_members.latest : self @@ -791,7 +791,7 @@ def latest_group_member # Remove from notification group and make a new group owner. # - # @return [Notificaion] New group owner instance of the notification group + # @return [Notification] New group owner instance of the notification group def remove_from_group new_group_owner = group_members.earliest if new_group_owner.present? diff --git a/lib/activity_notification/apis/subscription_api.rb b/lib/activity_notification/apis/subscription_api.rb index f15dbb2e..573a1d1c 100644 --- a/lib/activity_notification/apis/subscription_api.rb +++ b/lib/activity_notification/apis/subscription_api.rb @@ -11,7 +11,7 @@ module SubscriptionApi # @subscriptions = @user.subscriptions.filtered_by_key('comment.reply') # @scope class # @param [String] key Key of the subscription for filter - # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of filtered subscriptions + # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of filtered subscriptions scope :filtered_by_key, ->(key) { where(key: key) } # Selects filtered subscriptions by key with filter options. @@ -23,7 +23,7 @@ module SubscriptionApi # @param [Hash] options Options for filter # @option options [String] :filtered_by_key (nil) Key of the subscription for filter # @option options [Array|Hash] :custom_filter (nil) Custom subscription filter (e.g. ["created_at >= ?", time.hour.ago] or ['created_at.gt': time.hour.ago]) - # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of filtered subscriptions + # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of filtered subscriptions scope :filtered_by_options, ->(options = {}) { options = ActivityNotification.cast_to_indifferent_hash(options) filtered_subscriptions = all @@ -37,34 +37,34 @@ module SubscriptionApi } # Orders by latest (newest) first as created_at: :desc. - # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of subscriptions ordered by latest first + # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of subscriptions ordered by latest first scope :latest_order, -> { order(created_at: :desc) } # Orders by earliest (older) first as created_at: :asc. - # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of subscriptions ordered by earliest first + # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of subscriptions ordered by earliest first scope :earliest_order, -> { order(created_at: :asc) } # Orders by latest (newest) first as created_at: :desc. # This method is to be overridden in implementation for each ORM. # @param [Boolean] reverse If subscriptions will be ordered as earliest first - # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of ordered subscriptions + # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of ordered subscriptions scope :latest_order!, ->(reverse = false) { reverse ? earliest_order : latest_order } # Orders by earliest (older) first as created_at: :asc. # This method is to be overridden in implementation for each ORM. - # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of subscriptions ordered by earliest first + # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of subscriptions ordered by earliest first scope :earliest_order!, -> { earliest_order } # Orders by latest (newest) first as subscribed_at: :desc. - # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of subscriptions ordered by latest subscribed_at first + # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of subscriptions ordered by latest subscribed_at first scope :latest_subscribed_order, -> { order(subscribed_at: :desc) } # Orders by earliest (older) first as subscribed_at: :asc. - # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of subscriptions ordered by earliest subscribed_at first + # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of subscriptions ordered by earliest subscribed_at first scope :earliest_subscribed_order, -> { order(subscribed_at: :asc) } # Orders by key name as key: :asc. - # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of subscriptions ordered by key name + # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of subscriptions ordered by key name scope :key_order, -> { order(key: :asc) } # Convert Time value to store in database as Hash value. @@ -182,7 +182,7 @@ def unsubscribe_to_email(options = {}) # Returns if the target subscribes to the specified optional target. # # @param [Symbol] optional_target_name Symbol class name of the optional target implementation (e.g. :amazon_sns, :slack) - # @param [Boolean] subscribe_as_default Default subscription value to use when the subscription record does not configured + # @param [Boolean] subscribe_as_default Default subscription value to use when the subscription record is not configured # @return [Boolean] If the target subscribes to the specified optional target def subscribing_to_optional_target?(optional_target_name, subscribe_as_default = ActivityNotification.config.subscribe_to_optional_targets_as_default) optional_target_key = Subscription.to_optional_target_key(optional_target_name) diff --git a/lib/activity_notification/common.rb b/lib/activity_notification/common.rb index 389758f6..aa7974f5 100644 --- a/lib/activity_notification/common.rb +++ b/lib/activity_notification/common.rb @@ -105,7 +105,7 @@ def resolve_value(thing, *args) end end - # Convets to class name. + # Converts to class name. # This function returns base_class name for STI models if the class responds to base_class method. # @see https://github.com/simukappu/activity_notification/issues/89 # @see https://github.com/simukappu/activity_notification/pull/139 @@ -114,26 +114,26 @@ def to_class_name self.class.respond_to?(:base_class) ? self.class.base_class.name : self.class.name end - # Convets to singularized model name (resource name). + # Converts to singularized model name (resource name). # @return [String] Singularized model name (resource name) def to_resource_name self.to_class_name.demodulize.singularize.underscore end - # Convets to pluralized model name (resources name). + # Converts to pluralized model name (resources name). # @return [String] Pluralized model name (resources name) def to_resources_name self.to_class_name.demodulize.pluralize.underscore end - # Convets to printable model type name to be humanized. + # Converts to printable model type name to be humanized. # @return [String] Printable model type name # @todo Is this the best to make readable? def printable_type "#{self.to_class_name.demodulize.humanize}" end - # Convets to printable model name to show in view or email. + # Converts to printable model name to show in view or email. # @return [String] Printable model name def printable_name "#{self.printable_type} (#{id})" diff --git a/lib/activity_notification/config.rb b/lib/activity_notification/config.rb index f83b6cb2..49bc8e9a 100644 --- a/lib/activity_notification/config.rb +++ b/lib/activity_notification/config.rb @@ -173,8 +173,8 @@ class Config attr_accessor :composite_key_delimiter # @overload store_with_associated_records - # Returns whether activity_notification stores notificaion records including associated records like target and notifiable - # @return [Boolean] Whether activity_notification stores notificaion records including associated records like target and notifiable. + # Returns whether activity_notification stores notification records including associated records like target and notifiable + # @return [Boolean] Whether activity_notification stores Notification records including associated records like target and notifiable. attr_reader :store_with_associated_records # @overload action_cable_enabled @@ -271,10 +271,10 @@ def orm=(orm) @orm = orm.to_sym end - # Sets whether activity_notification stores notificaion records including associated records like target and notifiable. + # Sets whether activity_notification stores notification records including associated records like target and notifiable. # This store_with_associated_records option can be set true only when you use mongoid or dynamoid ORM. # @param [Boolean] store_with_associated_records The new store_with_associated_records - # @return [Boolean] Whether activity_notification stores notificaion records including associated records like target and notifiable. + # @return [Boolean] Whether activity_notification stores notification records including associated records like target and notifiable. def store_with_associated_records=(store_with_associated_records) if store_with_associated_records && [:mongoid, :dynamoid].exclude?(@orm) then raise ActivityNotification::ConfigError, "config.store_with_associated_records can be set true only when you use mongoid or dynamoid ORM." end @store_with_associated_records = store_with_associated_records @@ -289,7 +289,7 @@ def subscribe_to_email_as_default end # Returns default optional target subscription value to use when the subscription record does not configured - # @return [Boolean] Default optinal target subscription value to use when the subscription record does not configured. + # @return [Boolean] Default optional target subscription value to use when the subscription record does not configured. def subscribe_to_optional_targets_as_default return false unless @subscribe_as_default diff --git a/lib/activity_notification/controllers/common_controller.rb b/lib/activity_notification/controllers/common_controller.rb index 0e1a0773..52b03036 100644 --- a/lib/activity_notification/controllers/common_controller.rb +++ b/lib/activity_notification/controllers/common_controller.rb @@ -67,7 +67,7 @@ def controller_path end # Returns path of the target view templates. - # Do not make this method public unless Rendarable module calls controller's target_view_path method to render resources. + # Do not make this method public unless Renderable module calls controller's target_view_path method to render resources. # @api protected def target_view_path target_type = @target.to_resources_name diff --git a/lib/activity_notification/controllers/devise_authentication_controller.rb b/lib/activity_notification/controllers/devise_authentication_controller.rb index a1df559a..88884c9c 100644 --- a/lib/activity_notification/controllers/devise_authentication_controller.rb +++ b/lib/activity_notification/controllers/devise_authentication_controller.rb @@ -14,7 +14,7 @@ module DeviseAuthenticationController # Authenticate devise resource by Devise (e.g. calling authenticate_user! method). # @api protected # @todo Needs to call authenticate method by more secure way - # @return [Response] Redirects for unsigned in target by Devise, returns HTTP 403 without neccesary target method or returns 400 when request parameters are not enough + # @return [Response] Redirects for unsigned in target by Devise, returns HTTP 403 without necessary target method or returns 400 when request parameters are not enough def authenticate_devise_resource! if params[:devise_type].present? authenticate_method_name = "authenticate_#{params[:devise_type].to_resource_name}!" @@ -29,7 +29,7 @@ def authenticate_devise_resource! end # Sets @target instance variable from request parameters. - # This method override super (ActivityNotiication::CommonController#set_target) + # This method override super (ActivityNotification::CommonController#set_target) # to set devise authenticated target when the target_id params is not specified. # @api protected # @return [Object] Target instance (Returns HTTP 400 when request parameters are not enough) diff --git a/lib/activity_notification/helpers/polymorphic_helpers.rb b/lib/activity_notification/helpers/polymorphic_helpers.rb index e77b0251..a7bdff42 100644 --- a/lib/activity_notification/helpers/polymorphic_helpers.rb +++ b/lib/activity_notification/helpers/polymorphic_helpers.rb @@ -5,35 +5,35 @@ module PolymorphicHelpers included do class ::String - # Convets to model instance. + # Converts to model instance. # @return [Object] Model instance def to_model_name singularize.camelize end - # Convets to model class. + # Converts to model class. # @return [Class] Model class def to_model_class to_model_name.classify.constantize end - # Convets to singularized model name (resource name). + # Converts to singularized model name (resource name). # @return [String] Singularized model name (resource name) def to_resource_name singularize.underscore end - # Convets to pluralized model name (resources name). + # Converts to pluralized model name (resources name). # @return [String] Pluralized model name (resources name) def to_resources_name pluralize.underscore end - # Convets to boolean. + # Converts to boolean. # Returns true for 'true', '1', 'yes', 'on' and 't'. # Returns false for 'false', '0', 'no', 'off' and 'f'. # @param [Boolean] default Default value to return when the String is not interpretable - # @return [Boolean] Convered boolean value + # @return [Boolean] Converted boolean value def to_boolean(default = nil) return true if ['true', '1', 'yes', 'on', 't'].include? self return false if ['false', '0', 'no', 'off', 'f'].include? self diff --git a/lib/activity_notification/helpers/view_helpers.rb b/lib/activity_notification/helpers/view_helpers.rb index ac302e47..66dd5a29 100644 --- a/lib/activity_notification/helpers/view_helpers.rb +++ b/lib/activity_notification/helpers/view_helpers.rb @@ -2,10 +2,10 @@ module ActivityNotification # Provides a shortcut from views to the rendering method. # Module extending ActionView::Base and adding `render_notification` helper. module ViewHelpers - # View helper for rendering an notification, calls {Notification#render} internally. + # View helper for rendering a notification, calls {Notification#render} internally. # @see Notification#render # - # @param [Notification, Array] notifications Array or single instance of notifications to render + # @param [Notification, Array] notifications Array or single instance of notifications to render # @param [Hash] options Options for rendering notifications # @option options [String, Symbol] :target (nil) Target type name to find template or i18n text # @option options [String] :partial ("activity_notification/notifications/#{target}", controller.target_view_path, 'activity_notification/notifications/default') Partial template name @@ -489,7 +489,7 @@ def load_notification_index(target, index_content, options = {}) # @api private # # @param [Object] target Notification target instance - # @param [Array] notification_index Array notification index + # @param [Array] notification_index Array notification index # @param [Hash] params Option parameter to send render_notification def prepare_content_for(target, notification_index, params) content_for :notification_index do diff --git a/lib/activity_notification/models/concerns/notifiable.rb b/lib/activity_notification/models/concerns/notifiable.rb index 1e5a6e55..e166603a 100644 --- a/lib/activity_notification/models/concerns/notifiable.rb +++ b/lib/activity_notification/models/concerns/notifiable.rb @@ -14,7 +14,7 @@ module Notifiable # Has many notification instances for this notifiable. # Dependency for these notifications can be overridden from acts_as_notifiable. # @scope instance - # @return [Array, Mongoid::Criteria] Array or database query of notifications for this notifiable + # @return [Array, Mongoid::Criteria] Array or database query of notifications for this notifiable has_many_records :generated_notifications_as_notifiable, class_name: "::ActivityNotification::Notification", as: :notifiable @@ -65,13 +65,13 @@ def set_notifiable_class_defaults end # Returns notification targets from configured field or overridden method. - # This method is able to be overridden. + # This method can be overridden. # # @param [String] target_type Target type to notify # @param [Hash] options Options for notifications # @option options [String] :key (notifiable.default_notification_key) Key of the notification # @option options [Hash] :parameters ({}) Additional parameters of the notifications - # @return [Array | ActiveRecord_AssociationRelation] Array or database query of the notification targets + # @return [Array | ActiveRecord_AssociationRelation] Array or database query of the notification targets def notification_targets(target_type, options = {}) target_typed_method_name = "notification_#{cast_to_resources_name(target_type)}" resolved_parameter = resolve_parameter( @@ -87,7 +87,7 @@ def notification_targets(target_type, options = {}) end # Returns group unit of the notifications from configured field or overridden method. - # This method is able to be overridden. + # This method can be overridden. # # @param [String] target_type Target type to notify # @param [String] key Key of the notification @@ -101,7 +101,7 @@ def notification_group(target_type, key = nil) end # Returns group expiry period of the notifications from configured field or overridden method. - # This method is able to be overridden. + # This method can be overridden. # # @param [String] target_type Target type to notify # @param [String] key Key of the notification @@ -115,7 +115,7 @@ def notification_group_expiry_delay(target_type, key = nil) end # Returns additional notification parameters from configured field or overridden method. - # This method is able to be overridden. + # This method can be overridden. # # @param [String] target_type Target type to notify # @param [String] key Key of the notification @@ -129,7 +129,7 @@ def notification_parameters(target_type, key = nil) end # Returns notifier of the notification from configured field or overridden method. - # This method is able to be overridden. + # This method can be overridden. # # @param [String] target_type Target type to notify # @param [String] key Key of the notification @@ -143,7 +143,7 @@ def notifier(target_type, key = nil) end # Returns if sending notification email is allowed for the notifiable from configured field or overridden method. - # This method is able to be overridden. + # This method can be overridden. # # @param [Object] target Target instance to notify # @param [String] key Key of the notification @@ -157,7 +157,7 @@ def notification_email_allowed?(target, key = nil) end # Returns if publishing WebSocket using ActionCable is allowed for the notifiable from configured field or overridden method. - # This method is able to be overridden. + # This method can be overridden. # # @param [Object] target Target instance to notify # @param [String] key Key of the notification @@ -171,7 +171,7 @@ def notifiable_action_cable_allowed?(target, key = nil) end # Returns if publishing WebSocket API using ActionCable is allowed for the notifiable from configured field or overridden method. - # This method is able to be overridden. + # This method can be overridden. # # @param [Object] target Target instance to notify # @param [String] key Key of the notification @@ -185,7 +185,7 @@ def notifiable_action_cable_api_allowed?(target, key = nil) end # Returns notifiable_path to move after opening notification from configured field or overridden method. - # This method is able to be overridden. + # This method can be overridden. # # @param [String] target_type Target type to notify # @param [String] key Key of the notification @@ -219,7 +219,7 @@ def printable_notifiable_name(target, key = nil) end # Returns optional_targets of the notification from configured field or overridden method. - # This method is able to be overridden. + # This method can be overridden. # # @param [String] target_type Target type to notify # @param [String] key Key of the notification @@ -233,7 +233,7 @@ def optional_targets(target_type, key = nil) end # Returns optional_target names of the notification from configured field or overridden method. - # This method is able to be overridden. + # This method can be overridden. # # @param [String] target_type Target type to notify # @param [String] key Key of the notification @@ -275,8 +275,8 @@ def optional_target_names(target_type, key = nil) # @option options [Boolean] :send_email (true) Whether it sends notification email # @option options [Boolean] :send_later (true) Whether it sends notification email asynchronously # @option options [Boolean] :publish_optional_targets (true) Whether it publishes notification to optional targets - # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc) and values are options - # @return [Array] Array of generated notifications + # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc.) and values are options + # @return [Array] Array of generated notifications def notify(target_type, options = {}) Notification.notify(target_type, self, options) end @@ -295,8 +295,8 @@ def notify(target_type, options = {}) # @option options [Boolean] :send_email (true) Whether it sends notification email # @option options [Boolean] :send_later (true) Whether it sends notification email asynchronously # @option options [Boolean] :publish_optional_targets (true) Whether it publishes notification to optional targets - # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc) and values are options - # @return [Array] Array of generated notifications + # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc.) and values are options + # @return [Array] Array of generated notifications def notify_later(target_type, options = {}) Notification.notify_later(target_type, self, options) end @@ -316,8 +316,8 @@ def notify_later(target_type, options = {}) # @option options [Boolean] :send_email (true) Whether it sends notification email # @option options [Boolean] :send_later (true) Whether it sends notification email asynchronously # @option options [Boolean] :publish_optional_targets (true) Whether it publishes notification to optional targets - # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc) and values are options - # @return [Array] Array of generated notifications + # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc.) and values are options + # @return [Array] Array of generated notifications def notify_all(targets, options = {}) Notification.notify_all(targets, self, options) end @@ -337,8 +337,8 @@ def notify_all(targets, options = {}) # @option options [Boolean] :send_email (true) Whether it sends notification email # @option options [Boolean] :send_later (true) Whether it sends notification email asynchronously # @option options [Boolean] :publish_optional_targets (true) Whether it publishes notification to optional targets - # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc) and values are options - # @return [Array] Array of generated notifications + # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc.) and values are options + # @return [Array] Array of generated notifications def notify_all_later(targets, options = {}) Notification.notify_all_later(targets, self, options) end @@ -357,7 +357,7 @@ def notify_all_later(targets, options = {}) # @option options [Boolean] :send_email (true) Whether it sends notification email # @option options [Boolean] :send_later (true) Whether it sends notification email asynchronously # @option options [Boolean] :publish_optional_targets (true) Whether it publishes notification to optional targets - # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc) and values are options + # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc.) and values are options # @return [Notification] Generated notification instance def notify_to(target, options = {}) Notification.notify_to(target, self, options) @@ -378,14 +378,14 @@ def notify_to(target, options = {}) # @option options [Boolean] :send_email (true) Whether it sends notification email # @option options [Boolean] :send_later (true) Whether it sends notification email asynchronously # @option options [Boolean] :publish_optional_targets (true) Whether it publishes notification to optional targets - # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc) and values are options + # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc.) and values are options # @return [Notification] Generated notification instance def notify_later_to(target, options = {}) Notification.notify_later_to(target, self, options) end # Returns default key of the notification. - # This method is able to be overridden. + # This method can be overridden. # "#{to_resource_name}.default" is defined as default key. # # @return [String] Default key of the notification @@ -394,7 +394,7 @@ def default_notification_key end # Returns key of the notification for tracked notifiable creation. - # This method is able to be overridden. + # This method can be overridden. # "#{to_resource_name}.create" is defined as default creation key. # # @return [String] Key of the notification for tracked notifiable creation @@ -403,7 +403,7 @@ def notification_key_for_tracked_creation end # Returns key of the notification for tracked notifiable update. - # This method is able to be overridden. + # This method can be overridden. # "#{to_resource_name}.update" is defined as default update key. # # @return [String] Key of the notification for tracked notifiable update @@ -438,7 +438,7 @@ def generated_notifications_as_notifiable_for(target_type = nil) target_type.nil? ? generated_notifications_as_notifiable.all : generated_notifications_as_notifiable.filtered_by_target_type(target_type.to_s.to_model_name) end - # Destroies generated notifications for specified target type with dependency. + # Destroys generated notifications for specified target type with dependency. # This method is intended to be called before destroy this notifiable as dependent configuration. # @api private # @param [Symbol] dependent Has_many dependency, [:delete_all, :destroy, :restrict_with_error, :restrict_with_exception] are available diff --git a/lib/activity_notification/models/concerns/notifier.rb b/lib/activity_notification/models/concerns/notifier.rb index 07f775e1..65232498 100644 --- a/lib/activity_notification/models/concerns/notifier.rb +++ b/lib/activity_notification/models/concerns/notifier.rb @@ -9,7 +9,7 @@ module Notifier # Has many sent notification instances from this notifier. # @scope instance - # @return [Array, Mongoid::Criteria] Array or database query of sent notifications from this notifier + # @return [Array, Mongoid::Criteria] Array or database query of sent notifications from this notifier has_many_records :sent_notifications, class_name: "::ActivityNotification::Notification", as: :notifier diff --git a/lib/activity_notification/models/concerns/subscriber.rb b/lib/activity_notification/models/concerns/subscriber.rb index c152057f..f9b249e8 100644 --- a/lib/activity_notification/models/concerns/subscriber.rb +++ b/lib/activity_notification/models/concerns/subscriber.rb @@ -101,7 +101,7 @@ def build_subscription(subscription_params = {}) # @option options [String] :filtered_by_key (nil) Key of the notification for filter # @option options [Array|Hash] :custom_filter (nil) Custom subscription filter (e.g. ["created_at >= ?", time.hour.ago]) # @option options [Boolean] :with_target (false) If it includes target with subscriptions - # @return [Array] Configured subscription index of the target + # @return [Array] Configured subscription index of the target def subscription_index(options = {}) target_index = subscriptions.filtered_by_options(options) target_index = options[:reverse] ? target_index.earliest_order : target_index.latest_order @@ -120,7 +120,7 @@ def subscription_index(options = {}) # @option options [Symbol|String] :filter (nil) Filter option to load notification keys (Nothing as all, 'configured' with configured subscriptions or 'unconfigured' without subscriptions) # @option options [String] :filtered_by_key (nil) Key of the notification for filter # @option options [Array|Hash] :custom_filter (nil) Custom subscription filter (e.g. ["created_at >= ?", time.hour.ago]) - # @return [Array] Unconfigured notification keys of the target + # @return [Array] Unconfigured notification keys of the target def notification_keys(options = {}) subscription_keys = subscriptions.uniq_keys target_notifications = notifications.filtered_by_options(options.select { |k, _| [:filtered_by_key, :custom_filter].include?(k) }) @@ -146,7 +146,7 @@ def notification_keys(options = {}) # @api protected # # @param [String] key Key of the notification - # @param [Boolean] subscribe_as_default Default subscription value to use when the subscription record does not configured + # @param [Boolean] subscribe_as_default Default subscription value to use when the subscription record is not configured # @return [Boolean] If the target subscribes to the notification def _subscribes_to_notification?(key, subscribe_as_default = ActivityNotification.config.subscribe_as_default) evaluate_subscription(subscriptions.where(key: key).first, :subscribing?, subscribe_as_default) @@ -157,7 +157,7 @@ def _subscribes_to_notification?(key, subscribe_as_default = ActivityNotificatio # @api protected # # @param [String] key Key of the notification - # @param [Boolean] subscribe_as_default Default subscription value to use when the subscription record does not configured + # @param [Boolean] subscribe_as_default Default subscription value to use when the subscription record is not configured # @return [Boolean] If the target subscribes to the notification def _subscribes_to_notification_email?(key, subscribe_as_default = ActivityNotification.config.subscribe_to_email_as_default) evaluate_subscription(subscriptions.where(key: key).first, :subscribing_to_email?, subscribe_as_default) @@ -170,7 +170,7 @@ def _subscribes_to_notification_email?(key, subscribe_as_default = ActivityNotif # # @param [String] key Key of the notification # @param [String, Symbol] optional_target_name Class name of the optional target implementation (e.g. :amazon_sns, :slack) - # @param [Boolean] subscribe_as_default Default subscription value to use when the subscription record does not configured + # @param [Boolean] subscribe_as_default Default subscription value to use when the subscription record is not configured # @return [Boolean] If the target subscribes to the specified optional target def _subscribes_to_optional_target?(key, optional_target_name, subscribe_as_default = ActivityNotification.config.subscribe_to_optional_targets_as_default) _subscribes_to_notification?(key, subscribe_as_default) && @@ -183,7 +183,7 @@ def _subscribes_to_optional_target?(key, optional_target_name, subscribe_as_defa # @api private # @param [Boolean] record Subscription record # @param [Symbol] field Evaluating subscription field or method of the record - # @param [Boolean] default Default subscription value to use when the subscription record does not configured + # @param [Boolean] default Default subscription value to use when the subscription record is not configured # @param [Array] args Arguments of evaluating subscription method # @return [Boolean] If the target subscribes def evaluate_subscription(record, field, default, *args) diff --git a/lib/activity_notification/models/concerns/target.rb b/lib/activity_notification/models/concerns/target.rb index 90302bfe..ca0f3f9b 100644 --- a/lib/activity_notification/models/concerns/target.rb +++ b/lib/activity_notification/models/concerns/target.rb @@ -9,7 +9,7 @@ module Target # Has many notification instances of this target. # @scope instance - # @return [Array, Mongoid::Criteria] Array or database query of notifications of this target + # @return [Array, Mongoid::Criteria] Array or database query of notifications of this target has_many_records :notifications, class_name: "::ActivityNotification::Notification", as: :target, @@ -64,7 +64,7 @@ def set_target_class_defaults # @option options [String] :later_than (nil) ISO 8601 format time to filter notifications later than specified time # @option options [String] :earlier_than (nil) ISO 8601 format time to filter notifications earlier than specified time # @option options [Array|Hash] :custom_filter (nil) Custom notification filter (e.g. ["created_at >= ?", time.hour.ago]) - # @return [Array] All notifications for this target type + # @return [Array] All notifications for this target type def all_notifications(options = {}) reverse = options[:reverse] || false with_group_members = options[:with_group_members] || false @@ -106,7 +106,7 @@ def all_notifications(options = {}) # @option options [String] :later_than (nil) ISO 8601 format time to filter notifications later than specified time # @option options [String] :earlier_than (nil) ISO 8601 format time to filter notifications earlier than specified time # @option options [Array|Hash] :custom_filter (nil) Custom notification filter (e.g. ["created_at >= ?", time.hour.ago]) - # @return [Hash] All notifications for this target type grouped by targets + # @return [Hash] All notifications for this target type grouped by targets def notification_index_map(options = {}) all_notifications(options).group_by(&:target) end @@ -143,7 +143,7 @@ def send_batch_unopened_notification_email(options = {}) end # Resolves current authenticated target by devise authentication from current resource signed in with Devise. - # This method is able to be overridden. + # This method can be overridden. # # @param [Object] current_resource Current resource signed in with Devise # @return [Object] Current authenticated target by devise authentication @@ -160,7 +160,7 @@ def subscription_enabled? end # Returns target email address for email notification. - # This method is able to be overridden. + # This method can be overridden. # # @return [String] Target email address def mailer_to @@ -168,7 +168,7 @@ def mailer_to end # Returns if sending notification email is allowed for the target from configured field or overridden method. - # This method is able to be overridden. + # This method can be overridden. # # @param [Object] notifiable Notifiable instance of the notification # @param [String] key Key of the notification @@ -178,7 +178,7 @@ def notification_email_allowed?(notifiable, key) end # Returns if sending batch notification email is allowed for the target from configured field or overridden method. - # This method is able to be overridden. + # This method can be overridden. # # @param [String] key Key of the notifications # @return [Boolean] If sending batch notification email is allowed for the target @@ -187,7 +187,7 @@ def batch_notification_email_allowed?(key) end # Returns if subscription management is allowed for the target from configured field or overridden method. - # This method is able to be overridden. + # This method can be overridden. # # @param [String] key Key of the notifications # @return [Boolean] If subscription management is allowed for the target @@ -197,7 +197,7 @@ def subscription_allowed?(key) alias_method :notification_subscription_allowed?, :subscription_allowed? # Returns if publishing WebSocket using ActionCable is allowed for the target from configured field or overridden method. - # This method is able to be overridden. + # This method can be overridden. # # @param [Object] notifiable Notifiable instance of the notification # @param [String] key Key of the notification @@ -228,7 +228,7 @@ def notification_devise_resource end # Returns if current resource signed in with Devise is authenticated for the notification. - # This method is able to be overridden. + # This method can be overridden. # # @param [Object] current_resource Current resource signed in with Devise # @return [Boolean] If current resource signed in with Devise is authenticated for the notification @@ -288,8 +288,8 @@ def has_unopened_notifications?(options = {}) # Returns automatically arranged notification index of the target. # This method is the typical way to get notification index from controller and view. # When the target has unopened notifications, it returns unopened notifications first. - # Additionaly, it returns opened notifications unless unopened index size overs the limit. - # @todo Is this conbimned array the best solution? + # Additionally, it returns opened notifications unless unopened index size overs the limit. + # @todo Is this combined array the best solution? # # @example Get automatically arranged notification index of @user # @notifications = @user.notification_index @@ -307,7 +307,7 @@ def has_unopened_notifications?(options = {}) # @option options [String] :later_than (nil) ISO 8601 format time to filter notifications later than specified time # @option options [String] :earlier_than (nil) ISO 8601 format time to filter notifications earlier than specified time # @option options [Array|Hash] :custom_filter (nil) Custom notification filter (e.g. ["created_at >= ?", time.hour.ago]) - # @return [Array] Notification index of the target + # @return [Array] Notification index of the target def notification_index(options = {}) arrange_notification_index(method(:unopened_notification_index), method(:opened_notification_index), @@ -332,7 +332,7 @@ def notification_index(options = {}) # @option options [String] :later_than (nil) ISO 8601 format time to filter notifications later than specified time # @option options [String] :earlier_than (nil) ISO 8601 format time to filter notifications earlier than specified time # @option options [Array|Hash] :custom_filter (nil) Custom notification filter (e.g. ["created_at >= ?", time.hour.ago]) - # @return [Array] Unopened notification index of the target + # @return [Array] Unopened notification index of the target def unopened_notification_index(options = {}) arrange_single_notification_index(method(:_unopened_notification_index), options) end @@ -355,7 +355,7 @@ def unopened_notification_index(options = {}) # @option options [String] :later_than (nil) ISO 8601 format time to filter notifications later than specified time # @option options [String] :earlier_than (nil) ISO 8601 format time to filter notifications earlier than specified time # @option options [Array|Hash] :custom_filter (nil) Custom notification filter (e.g. ["created_at >= ?", time.hour.ago]) - # @return [Array] Opened notification index of the target + # @return [Array] Opened notification index of the target def opened_notification_index(options = {}) arrange_single_notification_index(method(:_opened_notification_index), options) end @@ -374,7 +374,7 @@ def opened_notification_index(options = {}) # @option options [Boolean] :send_email (true) Whether it sends notification email # @option options [Boolean] :send_later (true) Whether it sends notification email asynchronously # @option options [Boolean] :publish_optional_targets (true) Whether it publishes notification to optional targets - # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc) and values are options + # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc.) and values are options # @return [Notification] Generated notification instance def receive_notification_of(notifiable, options = {}) Notification.notify_to(self, notifiable, options) @@ -395,7 +395,7 @@ def receive_notification_of(notifiable, options = {}) # @option options [Boolean] :send_email (true) Whether it sends notification email # @option options [Boolean] :send_later (true) Whether it sends notification email asynchronously # @option options [Boolean] :publish_optional_targets (true) Whether it publishes notification to optional targets - # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc) and values are options + # @option options [Hash] :optional_targets ({}) Options for optional targets, keys are optional target name (:amazon_sns or :slack etc.) and values are options # @return [Notification] Generated notification instance def receive_notification_later_of(notifiable, options = {}) Notification.notify_later_to(self, notifiable, options) @@ -439,7 +439,7 @@ def destroy_all_notifications(options = {}) # Gets automatically arranged notification index of the target with included attributes like target, notifiable, group and notifier. # This method is the typical way to get notifications index from controller of view. # When the target have unopened notifications, it returns unopened notifications first. - # Additionaly, it returns opened notifications unless unopened index size overs the limit. + # Additionally, it returns opened notifications unless unopened index size overs the limit. # @todo Is this switching the best solution? # # @example Get automatically arranged notification index of the @user with included attributes @@ -461,7 +461,7 @@ def destroy_all_notifications(options = {}) # @option options [String] :later_than (nil) ISO 8601 format time to filter notifications later than specified time # @option options [String] :earlier_than (nil) ISO 8601 format time to filter notifications earlier than specified time # @option options [Array|Hash] :custom_filter (nil) Custom notification filter (e.g. ["created_at >= ?", time.hour.ago]) - # @return [Array] Notification index of the target with attributes + # @return [Array] Notification index of the target with attributes def notification_index_with_attributes(options = {}) arrange_notification_index(method(:unopened_notification_index_with_attributes), method(:opened_notification_index_with_attributes), @@ -486,7 +486,7 @@ def notification_index_with_attributes(options = {}) # @option options [String] :later_than (nil) ISO 8601 format time to filter notifications later than specified time # @option options [String] :earlier_than (nil) ISO 8601 format time to filter notifications earlier than specified time # @option options [Array|Hash] :custom_filter (nil) Custom notification filter (e.g. ["created_at >= ?", time.hour.ago]) - # @return [Array] Unopened notification index of the target with attributes + # @return [Array] Unopened notification index of the target with attributes def unopened_notification_index_with_attributes(options = {}) include_attributes(_unopened_notification_index(options)).to_a end @@ -509,7 +509,7 @@ def unopened_notification_index_with_attributes(options = {}) # @option options [String] :later_than (nil) ISO 8601 format time to filter notifications later than specified time # @option options [String] :earlier_than (nil) ISO 8601 format time to filter notifications earlier than specified time # @option options [Array|Hash] :custom_filter (nil) Custom notification filter (e.g. ["created_at >= ?", time.hour.ago]) - # @return [Array] Opened notification index of the target with attributes + # @return [Array] Opened notification index of the target with attributes def opened_notification_index_with_attributes(options = {}) include_attributes(_opened_notification_index(options)).to_a end @@ -545,7 +545,7 @@ def send_batch_notification_email(notifications, options = {}) # It also returns true when the subscription management is not allowed for the target. # # @param [String] key Key of the notification - # @param [Boolean] subscribe_as_default Default subscription value to use when the subscription record does not configured + # @param [Boolean] subscribe_as_default Default subscription value to use when the subscription record is not configured # @return [Boolean] If the target subscribes the notification or the subscription management is not allowed for the target def subscribes_to_notification?(key, subscribe_as_default = ActivityNotification.config.subscribe_as_default) !subscription_allowed?(key) || _subscribes_to_notification?(key, subscribe_as_default) @@ -555,7 +555,7 @@ def subscribes_to_notification?(key, subscribe_as_default = ActivityNotification # It also returns true when the subscription management is not allowed for the target. # # @param [String] key Key of the notification - # @param [Boolean] subscribe_as_default Default subscription value to use when the subscription record does not configured + # @param [Boolean] subscribe_as_default Default subscription value to use when the subscription record is not configured # @return [Boolean] If the target subscribes the notification email or the subscription management is not allowed for the target def subscribes_to_notification_email?(key, subscribe_as_default = ActivityNotification.config.subscribe_to_email_as_default) !subscription_allowed?(key) || _subscribes_to_notification_email?(key, subscribe_as_default) @@ -567,7 +567,7 @@ def subscribes_to_notification_email?(key, subscribe_as_default = ActivityNotifi # # @param [String] key Key of the notification # @param [String, Symbol] optional_target_name Class name of the optional target implementation (e.g. :amazon_sns, :slack) - # @param [Boolean] subscribe_as_default Default subscription value to use when the subscription record does not configured + # @param [Boolean] subscribe_as_default Default subscription value to use when the subscription record is not configured # @return [Boolean] If the target subscribes the notification email or the subscription management is not allowed for the target def subscribes_to_optional_target?(key, optional_target_name, subscribe_as_default = ActivityNotification.config.subscribe_to_optional_targets_as_default) !subscription_allowed?(key) || _subscribes_to_optional_target?(key, optional_target_name, subscribe_as_default) @@ -590,7 +590,7 @@ def subscribes_to_optional_target?(key, optional_target_name, subscribe_as_defau # @option options [String] :later_than (nil) ISO 8601 format time to filter notifications later than specified time # @option options [String] :earlier_than (nil) ISO 8601 format time to filter notifications earlier than specified time # @option options [Array|Hash] :custom_filter (nil) Custom notification filter (e.g. ["created_at >= ?", time.hour.ago]) - # @return [ActiveRecord_AssociationRelation|Mongoid::Criteria|Dynamoid::Criteria::Chain] Unopened notification index of the target + # @return [ActiveRecord_AssociationRelation|Mongoid::Criteria|Dynamoid::Criteria::Chain] Unopened notification index of the target def _unopened_notification_index(options = {}) reverse = options[:reverse] || false with_group_members = options[:with_group_members] || false @@ -612,7 +612,7 @@ def _unopened_notification_index(options = {}) # @option options [String] :later_than (nil) ISO 8601 format time to filter notifications later than specified time # @option options [String] :earlier_than (nil) ISO 8601 format time to filter notifications earlier than specified time # @option options [Array|Hash] :custom_filter (nil) Custom notification filter (e.g. ["created_at >= ?", time.hour.ago]) - # @return [ActiveRecord_AssociationRelation|Mongoid::Criteria|Dynamoid::Criteria::Chain] Opened notification index of the target + # @return [ActiveRecord_AssociationRelation|Mongoid::Criteria|Dynamoid::Criteria::Chain] Opened notification index of the target def _opened_notification_index(options = {}) limit = options[:limit] || ActivityNotification.config.opened_index_limit reverse = options[:reverse] || false @@ -622,11 +622,11 @@ def _opened_notification_index(options = {}) # Includes attributes like target, notifiable, group or notifier from the notification index. # When group member exists in the notification index, group will be included in addition to target, notifiable and or notifier. - # Otherwise, target, notifiable and or notifier will be include without group. + # Otherwise, target, notifiable and or notifier will be included without group. # @api private # - # @param [ActiveRecord_AssociationRelation|Mongoid::Criteria|Dynamoid::Criteria::Chain] target_index Notification index - # @return [ActiveRecord_AssociationRelation|Mongoid::Criteria|Dynamoid::Criteria::Chain] Notification index with attributes + # @param [ActiveRecord_AssociationRelation|Mongoid::Criteria|Dynamoid::Criteria::Chain] target_index Notification index + # @return [ActiveRecord_AssociationRelation|Mongoid::Criteria|Dynamoid::Criteria::Chain] Notification index with attributes def include_attributes(target_index) if target_index.present? Notification.group_member_exists?(target_index.to_a) ? @@ -654,7 +654,7 @@ def include_attributes(target_index) # @option options [String] :later_than (nil) ISO 8601 format time to filter notifications later than specified time # @option options [String] :earlier_than (nil) ISO 8601 format time to filter notifications earlier than specified time # @option options [Array|Hash] :custom_filter (nil) Custom notification filter (e.g. ["created_at >= ?", time.hour.ago]) - # @return [Array] Notification index of the target + # @return [Array] Notification index of the target def arrange_single_notification_index(loading_index_method, options = {}) as_latest_group_member = options[:as_latest_group_member] || false as_latest_group_member ? @@ -664,7 +664,7 @@ def arrange_single_notification_index(loading_index_method, options = {}) # Gets automatically arranged notification index of the target. # When the target have unopened notifications, it returns unopened notifications first. - # Additionaly, it returns opened notifications unless unopened index size overs the limit. + # Additionally, it returns opened notifications unless unopened index size overs the limit. # @api private # @todo Is this switching the best solution? # @@ -683,7 +683,7 @@ def arrange_single_notification_index(loading_index_method, options = {}) # @option options [String] :later_than (nil) ISO 8601 format time to filter notifications later than specified time # @option options [String] :earlier_than (nil) ISO 8601 format time to filter notifications earlier than specified time # @option options [Array|Hash] :custom_filter (nil) Custom notification filter (e.g. ["created_at >= ?", time.hour.ago]) - # @return [Array] Notification index of the target + # @return [Array] Notification index of the target def arrange_notification_index(loading_unopened_index_method, loading_opened_index_method, options = {}) # When the target have unopened notifications if has_unopened_notifications?(options) @@ -691,7 +691,7 @@ def arrange_notification_index(loading_unopened_index_method, loading_opened_ind target_unopened_index = arrange_single_notification_index(loading_unopened_index_method, options) # Total limit of notification index total_limit = options[:limit] || ActivityNotification.config.opened_index_limit - # Additionaly, return opened notifications unless unopened index size overs the limit + # Additionally, return opened notifications unless unopened index size overs the limit if (opened_limit = total_limit - target_unopened_index.size) > 0 target_opened_index = arrange_single_notification_index(loading_opened_index_method, options.merge(limit: opened_limit)) target_unopened_index.concat(target_opened_index.to_a) diff --git a/lib/activity_notification/optional_targets/action_cable_api_channel.rb b/lib/activity_notification/optional_targets/action_cable_api_channel.rb index c8fc9856..070376f0 100644 --- a/lib/activity_notification/optional_targets/action_cable_api_channel.rb +++ b/lib/activity_notification/optional_targets/action_cable_api_channel.rb @@ -57,7 +57,7 @@ def notification_json_options } end - # Overriden rendering notification message using format_message + # Overridden rendering notification message using format_message # @param [Notification] notification Notification instance # @param [Hash] options Options for rendering # @return [String] Rendered json formatted message to broadcast diff --git a/lib/activity_notification/optional_targets/slack.rb b/lib/activity_notification/optional_targets/slack.rb index d567a0ea..1e32350b 100644 --- a/lib/activity_notification/optional_targets/slack.rb +++ b/lib/activity_notification/optional_targets/slack.rb @@ -6,7 +6,7 @@ class Slack < ActivityNotification::OptionalTarget::Base # Initialize method to prepare Slack::Notifier # @param [Hash] options Options for initializing - # @option options [String, Proc, Symbol] :target_username (nil) Target user name of Slack, it resolved by target instance like email_allowed? + # @option options [String, Proc, Symbol] :target_username (nil) Target username of Slack, it resolved by target instance like email_allowed? # @option options [required, String] :webhook_url (nil) Webhook URL of Slack Incoming WebHooks integration # @option options [Hash] others Other options to be set Slack::Notifier.new, like :channel, :username, :icon_emoji etc def initialize_target(options = {}) @@ -17,7 +17,7 @@ def initialize_target(options = {}) # Publishes notification message to Slack # @param [Notification] notification Notification instance # @param [Hash] options Options for publishing - # @option options [String, Proc, Symbol] :target_username (nil) Target user name of Slack, it resolved by target instance like email_allowed? + # @option options [String, Proc, Symbol] :target_username (nil) Target username of Slack, it resolved by target instance like email_allowed? # @option options [String] :partial_root ("activity_notification/optional_targets/#{target}/#{optional_target_name}", "activity_notification/optional_targets/#{target}/base", "activity_notification/optional_targets/default/#{optional_target_name}", "activity_notification/optional_targets/default/base") Partial template name # @option options [String] :partial (self.key.tr('.', '/')) Root path of partial template # @option options [String] :layout (nil) Layout template name diff --git a/lib/activity_notification/orm/active_record/notification.rb b/lib/activity_notification/orm/active_record/notification.rb index 68596bd2..db175fb1 100644 --- a/lib/activity_notification/orm/active_record/notification.rb +++ b/lib/activity_notification/orm/active_record/notification.rb @@ -36,7 +36,7 @@ class Notification < ::ActiveRecord::Base # Only group owner instance has :group_members value. # Group member instance has nil as :group_members association. # @scope instance - # @return [ActiveRecord_AssociationRelation] Database query of the group member notification instances of this notification + # @return [ActiveRecord_AssociationRelation] Database query of the group member notification instances of this notification has_many :group_members, class_name: "ActivityNotification::Notification", foreign_key: :group_owner_id # Belongs to :notifier instance of this notification. @@ -59,52 +59,52 @@ class Notification < ::ActiveRecord::Base # Selects group owner notifications only. # @scope class - # @return [ActiveRecord_AssociationRelation] Database query of filtered notifications + # @return [ActiveRecord_AssociationRelation] Database query of filtered notifications scope :group_owners_only, -> { where(group_owner_id: nil) } # Selects group member notifications only. # @scope class - # @return [ActiveRecord_AssociationRelation] Database query of filtered notifications + # @return [ActiveRecord_AssociationRelation] Database query of filtered notifications scope :group_members_only, -> { where.not(group_owner_id: nil) } # Selects unopened notifications only. # @scope class - # @return [ActiveRecord_AssociationRelation] Database query of filtered notifications + # @return [ActiveRecord_AssociationRelation] Database query of filtered notifications scope :unopened_only, -> { where(opened_at: nil) } # Selects opened notifications only without limit. # Be careful to get too many records with this method. # @scope class - # @return [ActiveRecord_AssociationRelation] Database query of filtered notifications + # @return [ActiveRecord_AssociationRelation] Database query of filtered notifications scope :opened_only!, -> { where.not(opened_at: nil) } # Selects opened notifications only with limit. # @scope class # @param [Integer] limit Limit to query for opened notifications - # @return [ActiveRecord_AssociationRelation] Database query of filtered notifications + # @return [ActiveRecord_AssociationRelation] Database query of filtered notifications scope :opened_only, ->(limit) { opened_only!.limit(limit) } # Selects group member notifications in unopened_index. # @scope class - # @return [ActiveRecord_AssociationRelation] Database query of filtered notifications + # @return [ActiveRecord_AssociationRelation] Database query of filtered notifications scope :unopened_index_group_members_only, -> { where(group_owner_id: unopened_index.map(&:id)) } # Selects group member notifications in opened_index. # @scope class # @param [Integer] limit Limit to query for opened notifications - # @return [ActiveRecord_AssociationRelation] Database query of filtered notifications + # @return [ActiveRecord_AssociationRelation] Database query of filtered notifications scope :opened_index_group_members_only, ->(limit) { where(group_owner_id: opened_index(limit).map(&:id)) } # Selects notifications within expiration. # @scope class # @param [ActiveSupport::Duration] expiry_delay Expiry period of notifications - # @return [ActiveRecord_AssociationRelation] Database query of filtered notifications + # @return [ActiveRecord_AssociationRelation] Database query of filtered notifications scope :within_expiration_only, ->(expiry_delay) { where("created_at > ?", expiry_delay.ago) } # Selects group member notifications with specified group owner ids. # @scope class # @param [Array] owner_ids Array of group owner ids - # @return [ActiveRecord_AssociationRelation] Database query of filtered notifications + # @return [ActiveRecord_AssociationRelation] Database query of filtered notifications scope :group_members_of_owner_ids_only, ->(owner_ids) { where(group_owner_id: owner_ids) } # Selects filtered notifications by target instance. @@ -113,63 +113,63 @@ class Notification < ::ActiveRecord::Base # @user.notifications # @scope class # @param [Object] target Target instance for filter - # @return [ActiveRecord_AssociationRelation] Database query of filtered notifications + # @return [ActiveRecord_AssociationRelation] Database query of filtered notifications scope :filtered_by_target, ->(target) { where(target: target) } # Selects filtered notifications by notifiable instance. - # @example Get filtered unopened notificatons of the @user for @comment as notifiable + # @example Get filtered unopened notifications of the @user for @comment as notifiable # @notifications = @user.notifications.unopened_only.filtered_by_instance(@comment) # @scope class # @param [Object] notifiable Notifiable instance for filter - # @return [ActiveRecord_AssociationRelation] Database query of filtered notifications + # @return [ActiveRecord_AssociationRelation] Database query of filtered notifications scope :filtered_by_instance, ->(notifiable) { where(notifiable: notifiable) } # Selects filtered notifications by group instance. - # @example Get filtered unopened notificatons of the @user for @article as group + # @example Get filtered unopened notifications of the @user for @article as group # @notifications = @user.notifications.unopened_only.filtered_by_group(@article) # @scope class # @param [Object] group Group instance for filter - # @return [ActiveRecord_AssociationRelation] Database query of filtered notifications + # @return [ActiveRecord_AssociationRelation] Database query of filtered notifications scope :filtered_by_group, ->(group) { where(group: group) } # Selects filtered notifications later than specified time. - # @example Get filtered unopened notificatons of the @user later than @notification + # @example Get filtered unopened notifications of the @user later than @notification # @notifications = @user.notifications.unopened_only.later_than(@notification.created_at) # @scope class # @param [Time] Created time of the notifications for filter - # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of filtered notifications + # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of filtered notifications scope :later_than, ->(created_time) { where('created_at > ?', created_time) } # Selects filtered notifications earlier than specified time. - # @example Get filtered unopened notificatons of the @user earlier than @notification + # @example Get filtered unopened notifications of the @user earlier than @notification # @notifications = @user.notifications.unopened_only.earlier_than(@notification.created_at) # @scope class # @param [Time] Created time of the notifications for filter - # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of filtered notifications + # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of filtered notifications scope :earlier_than, ->(created_time) { where('created_at < ?', created_time) } # Includes target instance with query for notifications. - # @return [ActiveRecord_AssociationRelation] Database query of notifications with target + # @return [ActiveRecord_AssociationRelation] Database query of notifications with target scope :with_target, -> { includes(:target) } # Includes notifiable instance with query for notifications. - # @return [ActiveRecord_AssociationRelation] Database query of notifications with notifiable + # @return [ActiveRecord_AssociationRelation] Database query of notifications with notifiable scope :with_notifiable, -> { includes(:notifiable) } # Includes group instance with query for notifications. - # @return [ActiveRecord_AssociationRelation] Database query of notifications with group + # @return [ActiveRecord_AssociationRelation] Database query of notifications with group scope :with_group, -> { includes(:group) } # Includes group owner instances with query for notifications. - # @return [ActiveRecord_AssociationRelation] Database query of notifications with group owner + # @return [ActiveRecord_AssociationRelation] Database query of notifications with group owner scope :with_group_owner, -> { includes(:group_owner) } # Includes group member instances with query for notifications. - # @return [ActiveRecord_AssociationRelation] Database query of notifications with group members + # @return [ActiveRecord_AssociationRelation] Database query of notifications with group members scope :with_group_members, -> { includes(:group_members) } # Includes notifier instance with query for notifications. - # @return [ActiveRecord_AssociationRelation] Database query of notifications with notifier + # @return [ActiveRecord_AssociationRelation] Database query of notifications with notifier scope :with_notifier, -> { includes(:notifier) } # Raise DeleteRestrictionError for notifications. diff --git a/lib/activity_notification/orm/dynamoid.rb b/lib/activity_notification/orm/dynamoid.rb index 884eb7a0..705bccf5 100644 --- a/lib/activity_notification/orm/dynamoid.rb +++ b/lib/activity_notification/orm/dynamoid.rb @@ -117,7 +117,7 @@ class ActiveModel::NullMutationTracker def force_change(attr_name); end if Rails::VERSION::MAJOR >= 6 end -# Entend Dynamoid to support ActivityNotification scope in Dynamoid::Criteria::Chain +# Extend Dynamoid to support ActivityNotification scope in Dynamoid::Criteria::Chain # @private module Dynamoid # :nodoc: all # https://github.com/Dynamoid/dynamoid/blob/master/lib/dynamoid/criteria.rb @@ -147,7 +147,7 @@ def all_index!(reverse = false, with_group_members = false) # is defined same as # ActivityNotification::Notification.unopened_only.group_owners_only.latest_order # @scope class - # @example Get unopened notificaton index of the @user + # @example Get unopened notification index of the @user # @notifications = @user.notifications.unopened_index # @notifications = @user.notifications.unopened_only.group_owners_only.latest_order # @param [Boolean] reverse If notification index will be ordered as earliest first @@ -163,7 +163,7 @@ def unopened_index(reverse = false, with_group_members = false) # is defined same as # ActivityNotification::Notification.opened_only(limit).group_owners_only.latest_order # @scope class - # @example Get unopened notificaton index of the @user with limit 10 + # @example Get unopened notification index of the @user with limit 10 # @notifications = @user.notifications.opened_index(10) # @notifications = @user.notifications.opened_only(10).group_owners_only.latest_order # @param [Integer] limit Limit to query for opened notifications @@ -217,7 +217,7 @@ def filtered_by_target(target) end # Selects filtered notifications by notifiable instance. - # @example Get filtered unopened notificatons of the @user for @comment as notifiable + # @example Get filtered unopened notifications of the @user for @comment as notifiable # @notifications = @user.notifications.unopened_only.filtered_by_instance(@comment) # @scope class # @param [Object] notifiable Notifiable instance for filter @@ -227,7 +227,7 @@ def filtered_by_instance(notifiable) end # Selects filtered notifications by group instance. - # @example Get filtered unopened notificatons of the @user for @article as group + # @example Get filtered unopened notifications of the @user for @article as group # @notifications = @user.notifications.unopened_only.filtered_by_group(@article) # @scope class # @param [Object] group Group instance for filter @@ -237,7 +237,7 @@ def filtered_by_group(group) end # Selects filtered notifications or subscriptions by target_type. - # @example Get filtered unopened notificatons of User as target type + # @example Get filtered unopened notifications of User as target type # @notifications = ActivityNotification.Notification.unopened_only.filtered_by_target_type('User') # @scope class # @param [String] target_type Target type for filter @@ -247,7 +247,7 @@ def filtered_by_target_type(target_type) end # Selects filtered notifications by notifiable_type. - # @example Get filtered unopened notificatons of the @user for Comment notifiable class + # @example Get filtered unopened notifications of the @user for Comment notifiable class # @notifications = @user.notifications.unopened_only.filtered_by_type('Comment') # @scope class # @param [String] notifiable_type Notifiable type for filter @@ -257,7 +257,7 @@ def filtered_by_type(notifiable_type) end # Selects filtered notifications or subscriptions by key. - # @example Get filtered unopened notificatons of the @user with key 'comment.reply' + # @example Get filtered unopened notifications of the @user with key 'comment.reply' # @notifications = @user.notifications.unopened_only.filtered_by_key('comment.reply') # @scope class # @param [String] key Key of the notification for filter @@ -267,37 +267,37 @@ def filtered_by_key(key) end # Selects filtered notifications later than specified time. - # @example Get filtered unopened notificatons of the @user later than @notification + # @example Get filtered unopened notifications of the @user later than @notification # @notifications = @user.notifications.unopened_only.later_than(@notification.created_at) # @scope class # @param [Time] Created time of the notifications for filter - # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of filtered notifications + # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of filtered notifications def later_than(created_time) where('created_at.gt': created_time) end # Selects filtered notifications earlier than specified time. - # @example Get filtered unopened notificatons of the @user earlier than @notification + # @example Get filtered unopened notifications of the @user earlier than @notification # @notifications = @user.notifications.unopened_only.earlier_than(@notification.created_at) # @scope class # @param [Time] Created time of the notifications for filter - # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of filtered notifications + # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of filtered notifications def earlier_than(created_time) where('created_at.lt': created_time) end # Selects filtered notifications or subscriptions by notifiable_type, group or key with filter options. - # @example Get filtered unopened notificatons of the @user for Comment notifiable class + # @example Get filtered unopened notifications of the @user for Comment notifiable class # @notifications = @user.notifications.unopened_only.filtered_by_options({ filtered_by_type: 'Comment' }) - # @example Get filtered unopened notificatons of the @user for @article as group + # @example Get filtered unopened notifications of the @user for @article as group # @notifications = @user.notifications.unopened_only.filtered_by_options({ filtered_by_group: @article }) - # @example Get filtered unopened notificatons of the @user for Article instance id=1 as group + # @example Get filtered unopened notifications of the @user for Article instance id=1 as group # @notifications = @user.notifications.unopened_only.filtered_by_options({ filtered_by_group_type: 'Article', filtered_by_group_id: '1' }) - # @example Get filtered unopened notificatons of the @user with key 'comment.reply' + # @example Get filtered unopened notifications of the @user with key 'comment.reply' # @notifications = @user.notifications.unopened_only.filtered_by_options({ filtered_by_key: 'comment.reply' }) - # @example Get filtered unopened notificatons of the @user for Comment notifiable class with key 'comment.reply' + # @example Get filtered unopened notifications of the @user for Comment notifiable class with key 'comment.reply' # @notifications = @user.notifications.unopened_only.filtered_by_options({ filtered_by_type: 'Comment', filtered_by_key: 'comment.reply' }) - # @example Get custom filtered notificatons of the @user + # @example Get custom filtered notifications of the @user # @notifications = @user.notifications.unopened_only.filtered_by_options({ custom_filter: ["created_at >= ?", time.hour.ago] }) # @scope class # @param [Hash] options Options for filter diff --git a/lib/activity_notification/orm/dynamoid/extension.rb b/lib/activity_notification/orm/dynamoid/extension.rb index d82106f5..85b3fa98 100644 --- a/lib/activity_notification/orm/dynamoid/extension.rb +++ b/lib/activity_notification/orm/dynamoid/extension.rb @@ -1,6 +1,6 @@ require 'dynamoid/adapter_plugin/aws_sdk_v3' -# Entend Dynamoid v3.1.0 to support none, limit, exists?, update_all, serializable_hash in Dynamoid::Criteria::Chain. +# Extend Dynamoid v3.1.0 to support none, limit, exists?, update_all, serializable_hash in Dynamoid::Criteria::Chain. # ActivityNotification project will try to contribute these fundamental functions to Dynamoid upstream. # @private module Dynamoid # :nodoc: all @@ -83,13 +83,13 @@ module ClassMethods end end -# Entend Dynamoid to support uniqueness validator +# Extend Dynamoid to support uniqueness validator # @private module Dynamoid # :nodoc: all # https://github.com/Dynamoid/dynamoid/blob/master/lib/dynamoid/validations.rb # @private module Validations - # Validates whether or not a field is unique against the records in the database. + # Validates whether a field is unique against the records in the database. class UniquenessValidator < ActiveModel::EachValidator # Validate the document for uniqueness violations. # @param [Document] document The document to validate. diff --git a/lib/activity_notification/orm/mongoid.rb b/lib/activity_notification/orm/mongoid.rb index 2a852689..8a7e6b88 100644 --- a/lib/activity_notification/orm/mongoid.rb +++ b/lib/activity_notification/orm/mongoid.rb @@ -7,7 +7,7 @@ module Association # @scope class # @param [String] name Association name # @param [Object] instance Associated instance - # @return [Mongoid::Criteria] Database query of filtered notifications + # @return [Mongoid::Criteria] Database query of filtered notifications scope :filtered_by_association, ->(name, instance) { where("#{name}_id" => instance.present? ? instance.id : nil, "#{name}_type" => instance.present? ? instance.class.name : nil) } end diff --git a/lib/activity_notification/orm/mongoid/notification.rb b/lib/activity_notification/orm/mongoid/notification.rb index 79789eb4..b953d54a 100644 --- a/lib/activity_notification/orm/mongoid/notification.rb +++ b/lib/activity_notification/orm/mongoid/notification.rb @@ -47,7 +47,7 @@ class Notification # Only group owner instance has :group_members value. # Group member instance has nil as :group_members association. # @scope instance - # @return [Mongoid::Criteria] Database query of the group member notification instances of this notification + # @return [Mongoid::Criteria] Database query of the group member notification instances of this notification has_many :group_members, class_name: "ActivityNotification::Notification", foreign_key: :group_owner_id # Belongs to :otifier instance of this notification. @@ -66,52 +66,52 @@ class Notification # Selects group owner notifications only. # @scope class - # @return [Mongoid::Criteria] Database query of filtered notifications + # @return [Mongoid::Criteria] Database query of filtered notifications scope :group_owners_only, -> { where(:group_owner_id.exists => false) } # Selects group member notifications only. # @scope class - # @return [Mongoid::Criteria] Database query of filtered notifications + # @return [Mongoid::Criteria] Database query of filtered notifications scope :group_members_only, -> { where(:group_owner_id.exists => true) } # Selects unopened notifications only. # @scope class - # @return [Mongoid::Criteria] Database query of filtered notifications + # @return [Mongoid::Criteria] Database query of filtered notifications scope :unopened_only, -> { where(:opened_at.exists => false) } # Selects opened notifications only without limit. # Be careful to get too many records with this method. # @scope class - # @return [Mongoid::Criteria] Database query of filtered notifications + # @return [Mongoid::Criteria] Database query of filtered notifications scope :opened_only!, -> { where(:opened_at.exists => true) } # Selects opened notifications only with limit. # @scope class # @param [Integer] limit Limit to query for opened notifications - # @return [Mongoid::Criteria] Database query of filtered notifications + # @return [Mongoid::Criteria] Database query of filtered notifications scope :opened_only, ->(limit) { limit == 0 ? none : opened_only!.limit(limit) } # Selects group member notifications in unopened_index. # @scope class - # @return [Mongoid::Criteria] Database query of filtered notifications + # @return [Mongoid::Criteria] Database query of filtered notifications scope :unopened_index_group_members_only, -> { where(:group_owner_id.in => unopened_index.map(&:id)) } # Selects group member notifications in opened_index. # @scope class # @param [Integer] limit Limit to query for opened notifications - # @return [Mongoid::Criteria] Database query of filtered notifications + # @return [Mongoid::Criteria] Database query of filtered notifications scope :opened_index_group_members_only, ->(limit) { where(:group_owner_id.in => opened_index(limit).map(&:id)) } # Selects notifications within expiration. # @scope class # @param [ActiveSupport::Duration] expiry_delay Expiry period of notifications - # @return [Mongoid::Criteria] Database query of filtered notifications + # @return [Mongoid::Criteria] Database query of filtered notifications scope :within_expiration_only, ->(expiry_delay) { where(:created_at.gt => expiry_delay.ago) } # Selects group member notifications with specified group owner ids. # @scope class # @param [Array] owner_ids Array of group owner ids - # @return [Mongoid::Criteria] Database query of filtered notifications + # @return [Mongoid::Criteria] Database query of filtered notifications scope :group_members_of_owner_ids_only, ->(owner_ids) { where(:group_owner_id.in => owner_ids) } # Selects filtered notifications by target instance. @@ -120,23 +120,23 @@ class Notification # @user.notifications # @scope class # @param [Object] target Target instance for filter - # @return [Mongoid::Criteria] Database query of filtered notifications + # @return [Mongoid::Criteria] Database query of filtered notifications scope :filtered_by_target, ->(target) { filtered_by_association("target", target) } # Selects filtered notifications by notifiable instance. - # @example Get filtered unopened notificatons of the @user for @comment as notifiable + # @example Get filtered unopened notifications of the @user for @comment as notifiable # @notifications = @user.notifications.unopened_only.filtered_by_instance(@comment) # @scope class # @param [Object] notifiable Notifiable instance for filter - # @return [Mongoid::Criteria] Database query of filtered notifications + # @return [Mongoid::Criteria] Database query of filtered notifications scope :filtered_by_instance, ->(notifiable) { filtered_by_association("notifiable", notifiable) } # Selects filtered notifications by group instance. - # @example Get filtered unopened notificatons of the @user for @article as group + # @example Get filtered unopened notifications of the @user for @article as group # @notifications = @user.notifications.unopened_only.filtered_by_group(@article) # @scope class # @param [Object] group Group instance for filter - # @return [Mongoid::Criteria] Database query of filtered notifications + # @return [Mongoid::Criteria] Database query of filtered notifications scope :filtered_by_group, ->(group) { group.present? ? where(group_id: group.id, group_type: group.class.name) : @@ -146,43 +146,43 @@ class Notification } # Selects filtered notifications later than specified time. - # @example Get filtered unopened notificatons of the @user later than @notification + # @example Get filtered unopened notifications of the @user later than @notification # @notifications = @user.notifications.unopened_only.later_than(@notification.created_at) # @scope class # @param [Time] Created time of the notifications for filter - # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of filtered notifications + # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of filtered notifications scope :later_than, ->(created_time) { where(:created_at.gt => created_time) } # Selects filtered notifications earlier than specified time. - # @example Get filtered unopened notificatons of the @user earlier than @notification + # @example Get filtered unopened notifications of the @user earlier than @notification # @notifications = @user.notifications.unopened_only.earlier_than(@notification.created_at) # @scope class # @param [Time] Created time of the notifications for filter - # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of filtered notifications + # @return [ActiveRecord_AssociationRelation, Mongoid::Criteria] Database query of filtered notifications scope :earlier_than, ->(created_time) { where(:created_at.lt => created_time) } # Includes target instance with query for notifications. - # @return [Mongoid::Criteria] Database query of notifications with target + # @return [Mongoid::Criteria] Database query of notifications with target scope :with_target, -> { } # Includes notifiable instance with query for notifications. - # @return [Mongoid::Criteria] Database query of notifications with notifiable + # @return [Mongoid::Criteria] Database query of notifications with notifiable scope :with_notifiable, -> { } # Includes group instance with query for notifications. - # @return [Mongoid::Criteria] Database query of notifications with group + # @return [Mongoid::Criteria] Database query of notifications with group scope :with_group, -> { } # Includes group owner instances with query for notifications. - # @return [Mongoid::Criteria] Database query of notifications with group owner + # @return [Mongoid::Criteria] Database query of notifications with group owner scope :with_group_owner, -> { } # Includes group member instances with query for notifications. - # @return [Mongoid::Criteria] Database query of notifications with group members + # @return [Mongoid::Criteria] Database query of notifications with group members scope :with_group_members, -> { } # Includes notifier instance with query for notifications. - # @return [Mongoid::Criteria] Database query of notifications with notifier + # @return [Mongoid::Criteria] Database query of notifications with notifier scope :with_notifier, -> { } # Dummy reload method for test of notifications. diff --git a/lib/activity_notification/rails/routes.rb b/lib/activity_notification/rails/routes.rb index 49c21e23..c6adda0f 100644 --- a/lib/activity_notification/rails/routes.rb +++ b/lib/activity_notification/rails/routes.rb @@ -45,10 +45,10 @@ class Mapper # open_myscope_user_notification PUT /myscope/users/:user_id/notifications/:id/open(.:format) # { controller:"activity_notification/notifications", action:"open", target_type:"users", routing_scope: :myscope } # - # When you use devise authentication and you want make notification targets assciated with devise, + # When you use devise authentication and you want to make notification targets associated with devise, # you can create as follows in your routes: # notify_to :users, with_devise: :users - # This with_devise option creates the needed routes assciated with devise authentication: + # This with_devise option creates the needed routes associated with devise authentication: # # Notification with devise routes # user_notifications GET /users/:user_id/notifications(.:format) # { controller:"activity_notification/notifications_with_devise", action:"index", target_type:"users", devise_type:"users" } @@ -65,7 +65,7 @@ class Mapper # # When you use with_devise option and you want to make simple default routes as follows, you can use devise_default_routes option: # notify_to :users, with_devise: :users, devise_default_routes: true - # These with_devise and devise_default_routes options create the needed routes assciated with authenticated devise resource as the default target + # These with_devise and devise_default_routes options create the needed routes associated with authenticated devise resource as the default target # # Notification with default devise routes # user_notifications GET /notifications(.:format) # { controller:"activity_notification/notifications_with_devise", action:"index", target_type:"users", devise_type:"users" } @@ -135,7 +135,7 @@ class Mapper # @param [Symbol] resources Resources to notify # @option options [String] :routing_scope (nil) Routing scope for notification routes # @option options [Symbol] :with_devise (false) Devise resources name for devise integration. Devise integration will be enabled by this option. - # @option options [Boolean] :devise_default_routes (false) Whether you will create routes as device default routes assciated with authenticated devise resource as the default target + # @option options [Boolean] :devise_default_routes (false) Whether you will create routes as device default routes associated with authenticated devise resource as the default target # @option options [Boolean] :api_mode (false) Whether you will use activity_notification controllers as REST API mode # @option options [Hash|Boolean] :with_subscription (false) Subscription path options to define subscription management paths with notification paths. Calls subscribed_by routing when truthy value is passed as this option. # @option options [String] :model (:notifications) Model name of notifications @@ -168,7 +168,7 @@ def notify_to(*resources) # Includes subscribed_by method for routes, which is responsible to generate all necessary routes for subscriptions of activity_notification. # - # When you have an User model configured as a target (e.g. defined acts_as_target), + # When you have a User model configured as a target (e.g. defined acts_as_target), # you can create as follows in your routes: # subscribed_by :users # This method creates the needed routes: @@ -225,10 +225,10 @@ def notify_to(*resources) # unsubscribe_to_optional_target_myscope_user_subscription PUT /myscope/users/:user_id/subscriptions/:id/unsubscribe_to_optional_target(.:format) # { controller:"activity_notification/subscriptions", action:"unsubscribe_to_optional_target", target_type:"users", routing_scope: :myscope } # - # When you use devise authentication and you want make subscription targets assciated with devise, + # When you use devise authentication and you want to make subscription targets associated with devise, # you can create as follows in your routes: # subscribed_by :users, with_devise: :users - # This with_devise option creates the needed routes assciated with devise authentication: + # This with_devise option creates the needed routes associated with devise authentication: # # Subscription with devise routes # user_subscriptions GET /users/:user_id/subscriptions(.:format) # { controller:"activity_notification/subscriptions_with_devise", action:"index", target_type:"users", devise_type:"users" } @@ -255,7 +255,7 @@ def notify_to(*resources) # # When you use with_devise option and you want to make simple default routes as follows, you can use devise_default_routes option: # subscribed_by :users, with_devise: :users, devise_default_routes: true - # These with_devise and devise_default_routes options create the needed routes assciated with authenticated devise resource as the default target + # These with_devise and devise_default_routes options create the needed routes associated with authenticated devise resource as the default target # # Subscription with devise routes # user_subscriptions GET /subscriptions(.:format) # { controller:"activity_notification/subscriptions_with_devise", action:"index", target_type:"users", devise_type:"users" } @@ -331,7 +331,7 @@ def notify_to(*resources) # @param [Symbol] resources Resources to notify # @option options [String] :routing_scope (nil) Routing scope for subscription routes # @option options [Symbol] :with_devise (false) Devise resources name for devise integration. Devise integration will be enabled by this option. - # @option options [Boolean] :devise_default_routes (false) Whether you will create routes as device default routes assciated with authenticated devise resource as the default target + # @option options [Boolean] :devise_default_routes (false) Whether you will create routes as device default routes associated with authenticated devise resource as the default target # @option options [Boolean] :api_mode (false) Whether you will use activity_notification controllers as REST API mode # @option options [String] :model (:subscriptions) Model name of subscriptions # @option options [String] :controller ("activity_notification/subscriptions" | activity_notification/subscriptions_with_devise") :controller option as resources routing diff --git a/lib/activity_notification/roles/acts_as_group.rb b/lib/activity_notification/roles/acts_as_group.rb index 4b3d8164..1d6d1333 100644 --- a/lib/activity_notification/roles/acts_as_group.rb +++ b/lib/activity_notification/roles/acts_as_group.rb @@ -9,7 +9,7 @@ module ActsAsGroup # == Parameters: # * :printable_name or :printable_notification_group_name # * Printable notification group name. - # This parameter is a optional since `ActivityNotification::Common.printable_name` is used as default value. + # This parameter is optional since `ActivityNotification::Common.printable_name` is used as default value. # :printable_name is the same option as :printable_notification_group_name # @example Define printable name with article title # # app/models/article.rb diff --git a/lib/activity_notification/roles/acts_as_notifiable.rb b/lib/activity_notification/roles/acts_as_notifiable.rb index f7b2f6a8..da109d1d 100644 --- a/lib/activity_notification/roles/acts_as_notifiable.rb +++ b/lib/activity_notification/roles/acts_as_notifiable.rb @@ -14,8 +14,8 @@ module ActsAsNotifiable # == Parameters: # * :targets # * Targets to send notifications. - # It it set as ActiveRecord records or array of models. - # This is a only necessary option. + # It is set as ActiveRecord records or array of models. + # This is the only necessary option. # If you do not specify this option, you have to override notification_targets # or notification_[plural target type] (e.g. notification_users) method. # @example Notify to all users @@ -189,10 +189,10 @@ module ActsAsNotifiable # end # # * :optional_targets - # * Optional targets to integrate external notification serveces like Amazon SNS or Slack. + # * Optional targets to integrate external notification services like Amazon SNS or Slack. # You can use hash of optional target implementation class as key and initializing parameters as value for this parameter. # When the hash parameter is passed, acts_as_notifiable will create new instance of optional target class and call initialize_target method with initializing parameters, then configure them as optional_targets for this notifiable and target. - # You can also use symbol of method name or lambda function which returns array of initialized optional target intstances. + # You can also use symbol of method name or lambda function which returns array of initialized optional target instances. # All optional target class must extends ActivityNotification::OptionalTarget::Base. # This parameter is completely optional. # @example Define to integrate with Amazon SNS, Slack and your custom ConsoleOutput targets @@ -203,7 +203,7 @@ module ActsAsNotifiable # require 'custom_optional_targets/console_output' # acts_as_notifiable :admins, targets: Admin.all, # optional_targets: { - # ActivityNotification::OptionalTarget::AmazonSNS => { topic_arn: '' }, + # ActivityNotification::OptionalTarget::AmazonSNS => { topic_arn: '' }, # ActivityNotification::OptionalTarget::Slack => { # webhook_url: '', # slack_name: :slack_name, channel: 'activity_notification', username: 'ActivityNotification', icon_emoji: ":ghost:" diff --git a/lib/activity_notification/roles/acts_as_notifier.rb b/lib/activity_notification/roles/acts_as_notifier.rb index 576091f7..86243184 100644 --- a/lib/activity_notification/roles/acts_as_notifier.rb +++ b/lib/activity_notification/roles/acts_as_notifier.rb @@ -9,7 +9,7 @@ module ActsAsNotifier # == Parameters: # * :printable_name or :printable_notifier_name # * Printable notifier name. - # This parameter is a optional since `ActivityNotification::Common.printable_name` is used as default value. + # This parameter is optional since `ActivityNotification::Common.printable_name` is used as default value. # :printable_name is the same option as :printable_notifier_name # @example Define printable name with user name of name field # # app/models/user.rb diff --git a/lib/activity_notification/roles/acts_as_target.rb b/lib/activity_notification/roles/acts_as_target.rb index 28c3dc0e..27a1c1fc 100644 --- a/lib/activity_notification/roles/acts_as_target.rb +++ b/lib/activity_notification/roles/acts_as_target.rb @@ -9,7 +9,7 @@ module ActsAsTarget # == Parameters: # * :email # * Email address to send notification email. - # This is a necessary option when you enables email notification. + # This is a necessary option when you enable email notification. # @example Simply use :email field # # app/models/user.rb # class User < ActiveRecord::Base diff --git a/lib/generators/templates/activity_notification.rb b/lib/generators/templates/activity_notification.rb index c0559818..911fd1aa 100644 --- a/lib/generators/templates/activity_notification.rb +++ b/lib/generators/templates/activity_notification.rb @@ -38,7 +38,7 @@ # Configure default optional target subscription value to use when the subscription record does not configured. # Note that you can configure them for each method calling as default argument. - # Set false when you want to unsubscribe to optinal target notifications as default. + # Set false when you want to unsubscribe to optional target notifications as default. # config.subscribe_to_optional_targets_as_default = true # Configure the e-mail address which will be shown in ActivityNotification::Mailer, @@ -80,7 +80,7 @@ # Configure delimiter of composite key for DynamoDB. # config.composite_key_delimiter = '#' - # Configure if activity_notification stores notificaion records including associated records like target and notifiable.. + # Configure if activity_notification stores notification records including associated records like target and notifiable.. # This store_with_associated_records option can be set true only when you use mongoid or dynamoid ORM. config.store_with_associated_records = false diff --git a/spec/rails_app/app/javascript/components/notifications/Index.vue b/spec/rails_app/app/javascript/components/notifications/Index.vue index 5d96fa6c..d40a2b90 100644 --- a/spec/rails_app/app/javascript/components/notifications/Index.vue +++ b/spec/rails_app/app/javascript/components/notifications/Index.vue @@ -172,7 +172,7 @@ export default { this.notifications.unshift(data.group_owner); this.getUnopenedNotificationCount(); } - // Push notificaion using Web Notification API by Push.js + // Push notification using Web Notification API by Push.js Push.create('ActivityNotification', { body: data.notification.text, timeout: 5000, diff --git a/spec/rails_app/config/initializers/activity_notification.rb b/spec/rails_app/config/initializers/activity_notification.rb index df3cca66..a6c57aff 100644 --- a/spec/rails_app/config/initializers/activity_notification.rb +++ b/spec/rails_app/config/initializers/activity_notification.rb @@ -72,7 +72,7 @@ # Configure delimiter of composite key for DynamoDB. # config.composite_key_delimiter = '#' - # Configure if activity_notification stores notificaion records including associated records like target and notifiable.. + # Configure if activity_notification stores notification records including associated records like target and notifiable.. # This store_with_associated_records option can be set true only when you use mongoid or dynamoid ORM. config.store_with_associated_records = (config.orm != :active_record)