noticed 1.6.0 → 1.6.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eade1cdb53653ae77fa61a1348340402ea37625188677a16baddda26bc42bd49
4
- data.tar.gz: 11d1d9ba60517005306714fc028fd312bbee7bef489d19218e7ba5c6938e22eb
3
+ metadata.gz: dec51920d13ba117cce592dc0545e22d5618528033e736b267238a8456cf8341
4
+ data.tar.gz: 503d20af8d1640173e066e99fe3c8794155666d1f84456731253de6524f1d8e0
5
5
  SHA512:
6
- metadata.gz: '08b57a6181fa23484fa7c21eb7153a75c2bb05750532d2c649a8bc46e30b57be8041039802396167e639fede5595c64bb09d683eaeb1f23a0b0d346f2e76ca5e'
7
- data.tar.gz: cc01ee47a638c02f1e5311c1433735607052130be9b4beaf61ced7482fd31910ab8c8a17915ff9c60a50bccddbc86bcb14f44519d8119632a95a1eba214f22a4
6
+ metadata.gz: 3d05f0f58b8d10e06782472cca617de0ba0140e42ffa0a7995adf80467fa88ae49f7656e0dd3c52d4e3130e9c3908543e5b72d05884431940422b092c50b7258
7
+ data.tar.gz: 602e15164492cf2de75d6b3b43a33d67312fdd18fa0cd42fd1b3a6d4f3397ab5d283b2346a3b019dfb9dd7f79b265387b927e135fb41e560fb3fa13ba0d99d7a
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators/named_base"
4
+
5
+ module Noticed
6
+ module Generators
7
+ module Model
8
+ class BaseGenerator < Rails::Generators::NamedBase
9
+ include Rails::Generators::ResourceHelpers
10
+
11
+ source_root File.expand_path("../templates", __FILE__)
12
+
13
+ desc "Generates a Notification model for storing notifications."
14
+
15
+ argument :name, type: :string, default: "Notification", banner: "Notification"
16
+ argument :attributes, type: :array, default: [], banner: "field:type field:type"
17
+
18
+ def generate_notification
19
+ binding.irb
20
+ generate :model, name, "recipient:references{polymorphic}", "type", "params:#{json_column_type}", "read_at:datetime:index", *attributes
21
+ end
22
+
23
+ def add_noticed_model
24
+ inject_into_class model_path, class_name, " include Noticed::Model\n"
25
+ end
26
+
27
+ def add_not_nullable
28
+ migration_path = Dir.glob(Rails.root.join("db/migrate/*")).max_by { |f| File.mtime(f) }
29
+
30
+ # Force is required because null: false already exists in the file and Thor isn't smart enough to tell the difference
31
+ insert_into_file migration_path, after: "t.string :type", force: true do
32
+ ", null: false"
33
+ end
34
+ end
35
+
36
+ def done
37
+ readme "README" if behavior == :invoke
38
+ end
39
+
40
+ private
41
+
42
+ def model_path
43
+ @model_path ||= File.join("app", "models", "#{file_path}.rb")
44
+ end
45
+ end
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators/named_base"
4
+ require_relative "base_generator"
5
+
6
+ module Noticed
7
+ module Generators
8
+ module Model
9
+ class MysqlGenerator < BaseGenerator
10
+ private
11
+
12
+ def json_column_type
13
+ "json"
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators/named_base"
4
+ require_relative "base_generator"
5
+
6
+ module Noticed
7
+ module Generators
8
+ module Model
9
+ class PostgresqlGenerator < BaseGenerator
10
+ private
11
+
12
+ def json_column_type
13
+ "jsonb"
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators/named_base"
4
+ require_relative "base_generator"
5
+
6
+ module Noticed
7
+ module Generators
8
+ module Model
9
+ class Sqlite3Generator < BaseGenerator
10
+ private
11
+
12
+ def json_column_type
13
+ "json"
14
+ end
15
+ end
16
+ end
17
+ end
18
+ end
@@ -5,9 +5,9 @@ module Noticed
5
5
 
6
6
  def deliver
7
7
  if options[:enqueue]
8
- mailer.with(format).send(method.to_sym).deliver_later
8
+ mailer.with(format).send(mailer_method.to_sym).deliver_later
9
9
  else
10
- mailer.with(format).send(method.to_sym).deliver_now
10
+ mailer.with(format).send(mailer_method.to_sym).deliver_now
11
11
  end
12
12
  end
13
13
 
@@ -33,7 +33,7 @@ module Noticed
33
33
  # If notification responds to symbol, call that method and use return value
34
34
  # If notification does not respond to symbol, use the symbol for the mailer method
35
35
  # Otherwise, use the underscored notification class name as the mailer method
36
- def method
36
+ def mailer_method
37
37
  method_name = options[:method]&.to_sym
38
38
  if method_name.present?
39
39
  notification.respond_to?(method_name) ? notification.send(method_name) : method_name
data/lib/noticed/model.rb CHANGED
@@ -13,7 +13,11 @@ module Noticed
13
13
  included do
14
14
  self.inheritance_column = nil
15
15
 
16
- serialize :params, noticed_coder
16
+ if Rails.gem_version >= Gem::Version.new("7.1")
17
+ serialize :params, coder: noticed_coder
18
+ else
19
+ serialize :params, noticed_coder
20
+ end
17
21
 
18
22
  belongs_to :recipient, polymorphic: true
19
23
 
@@ -1,3 +1,3 @@
1
1
  module Noticed
2
- VERSION = "1.6.0"
2
+ VERSION = "1.6.1"
3
3
  end
@@ -5,7 +5,7 @@ module ActionCable
5
5
  module Server
6
6
  class Configuration
7
7
  def pubsub_adapter
8
- cable["adapter"] == "test" ? ActionCable::SubscriptionAdapter::Test : super
8
+ (cable["adapter"] == "test") ? ActionCable::SubscriptionAdapter::Test : super
9
9
  end
10
10
  end
11
11
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: noticed
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.0
4
+ version: 1.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Oliver
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-22 00:00:00.000000000 Z
11
+ date: 2023-04-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -38,76 +38,6 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: 4.0.0
41
- - !ruby/object:Gem::Dependency
42
- name: pg
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - ">="
46
- - !ruby/object:Gem::Version
47
- version: '0'
48
- type: :development
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - ">="
53
- - !ruby/object:Gem::Version
54
- version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: standard
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ">="
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :development
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ">="
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
- - !ruby/object:Gem::Dependency
70
- name: webmock
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: mysql2
85
- requirement: !ruby/object:Gem::Requirement
86
- requirements:
87
- - - ">="
88
- - !ruby/object:Gem::Version
89
- version: '0'
90
- type: :development
91
- prerelease: false
92
- version_requirements: !ruby/object:Gem::Requirement
93
- requirements:
94
- - - ">="
95
- - !ruby/object:Gem::Version
96
- version: '0'
97
- - !ruby/object:Gem::Dependency
98
- name: sqlite3
99
- requirement: !ruby/object:Gem::Requirement
100
- requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: '0'
104
- type: :development
105
- prerelease: false
106
- version_requirements: !ruby/object:Gem::Requirement
107
- requirements:
108
- - - ">="
109
- - !ruby/object:Gem::Version
110
- version: '0'
111
41
  description: Database, browser, realtime ActionCable, Email, SMS, Slack notifications,
112
42
  and more for Rails apps
113
43
  email:
@@ -120,6 +50,10 @@ files:
120
50
  - README.md
121
51
  - Rakefile
122
52
  - lib/generators/noticed/delivery_method_generator.rb
53
+ - lib/generators/noticed/model/base_generator.rb
54
+ - lib/generators/noticed/model/mysql_generator.rb
55
+ - lib/generators/noticed/model/postgresql_generator.rb
56
+ - lib/generators/noticed/model/sqlite3_generator.rb
123
57
  - lib/generators/noticed/model_generator.rb
124
58
  - lib/generators/noticed/notification_generator.rb
125
59
  - lib/generators/noticed/templates/README
@@ -170,7 +104,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
170
104
  - !ruby/object:Gem::Version
171
105
  version: '0'
172
106
  requirements: []
173
- rubygems_version: 3.3.7
107
+ rubygems_version: 3.4.12
174
108
  signing_key:
175
109
  specification_version: 4
176
110
  summary: Notifications for Ruby on Rails applications