stance 0.8.0 → 0.8.2

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: 7d3da127347d4aa45a684e5d4b5f50b6e2bf0450fd3a4c31275db63d92795a9c
4
- data.tar.gz: 7809c5b0ac48089ddb6f68aea05c74e435b3ca85a64d40a8bcce8a909419d4fe
3
+ metadata.gz: f679d8376ef01172a2fe04995062885020f1810423df94a0621c3d863262267b
4
+ data.tar.gz: 2941c4c5af5f147eb0105294e19c3d23a7e9b8887fbc67661ea4e59bb14791f0
5
5
  SHA512:
6
- metadata.gz: 9414f176abd6c14837c562534ae1130c989ab54f79483c0c1b9ce0ae1b88f343922f9e0e60c3f1349cf797a20a0dc1fbcf799ac722afa18b79a4542d61f4dad6
7
- data.tar.gz: 648e01a5b37bf44abef52efa508b3fbaddeb3d087f638a645c1b5aee446199643f193cc9c2714b89ec7d3c555a038642b8c99d5d4515296b3bb0c85644d706e3
6
+ metadata.gz: '080ac5b578744bcd5103b049f103718b9bb8ffc5ef878893da96f4618e1097b4b5c4b3ea1296d4f8f06578701b2b2ddc881773623d20c76ce685755c97bf7954'
7
+ data.tar.gz: 7cdad4e4fd10b3c53081bbca1def4134efdb9d83ec5f4e40991e7238e2451d0b270a1874c27a0f4a1def5cc31f37bce238c893f7ffb03dcd013ab93c61e46c3b
data/.gitignore CHANGED
@@ -6,5 +6,5 @@
6
6
  /pkg/
7
7
  /spec/reports/
8
8
  /tmp/
9
- /test/internal/db/*.sqlite
9
+ /test/internal/db/*.sqlite*
10
10
  .DS_Store
data/Gemfile CHANGED
@@ -7,6 +7,7 @@ gemspec
7
7
 
8
8
  gem 'autotest-suffix'
9
9
  gem 'combustion'
10
+ gem 'debug'
10
11
  gem 'minitest'
11
12
  gem 'minitest-autotest'
12
13
  gem 'minitest-focus'
data/Gemfile.lock CHANGED
@@ -1,197 +1,238 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- stance (0.7.1)
5
- multi_json
6
- rails (>= 7.0.4)
4
+ stance (0.8.2)
5
+ multi_json (~> 1.15)
6
+ rails (>= 7.0, < 8.0)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
10
10
  specs:
11
- actioncable (7.0.4)
12
- actionpack (= 7.0.4)
13
- activesupport (= 7.0.4)
11
+ actioncable (7.1.2)
12
+ actionpack (= 7.1.2)
13
+ activesupport (= 7.1.2)
14
14
  nio4r (~> 2.0)
15
15
  websocket-driver (>= 0.6.1)
16
- actionmailbox (7.0.4)
17
- actionpack (= 7.0.4)
18
- activejob (= 7.0.4)
19
- activerecord (= 7.0.4)
20
- activestorage (= 7.0.4)
21
- activesupport (= 7.0.4)
16
+ zeitwerk (~> 2.6)
17
+ actionmailbox (7.1.2)
18
+ actionpack (= 7.1.2)
19
+ activejob (= 7.1.2)
20
+ activerecord (= 7.1.2)
21
+ activestorage (= 7.1.2)
22
+ activesupport (= 7.1.2)
22
23
  mail (>= 2.7.1)
23
24
  net-imap
24
25
  net-pop
25
26
  net-smtp
26
- actionmailer (7.0.4)
27
- actionpack (= 7.0.4)
28
- actionview (= 7.0.4)
29
- activejob (= 7.0.4)
30
- activesupport (= 7.0.4)
27
+ actionmailer (7.1.2)
28
+ actionpack (= 7.1.2)
29
+ actionview (= 7.1.2)
30
+ activejob (= 7.1.2)
31
+ activesupport (= 7.1.2)
31
32
  mail (~> 2.5, >= 2.5.4)
32
33
  net-imap
33
34
  net-pop
34
35
  net-smtp
35
- rails-dom-testing (~> 2.0)
36
- actionpack (7.0.4)
37
- actionview (= 7.0.4)
38
- activesupport (= 7.0.4)
39
- rack (~> 2.0, >= 2.2.0)
36
+ rails-dom-testing (~> 2.2)
37
+ actionpack (7.1.2)
38
+ actionview (= 7.1.2)
39
+ activesupport (= 7.1.2)
40
+ nokogiri (>= 1.8.5)
41
+ racc
42
+ rack (>= 2.2.4)
43
+ rack-session (>= 1.0.1)
40
44
  rack-test (>= 0.6.3)
41
- rails-dom-testing (~> 2.0)
42
- rails-html-sanitizer (~> 1.0, >= 1.2.0)
43
- actiontext (7.0.4)
44
- actionpack (= 7.0.4)
45
- activerecord (= 7.0.4)
46
- activestorage (= 7.0.4)
47
- activesupport (= 7.0.4)
45
+ rails-dom-testing (~> 2.2)
46
+ rails-html-sanitizer (~> 1.6)
47
+ actiontext (7.1.2)
48
+ actionpack (= 7.1.2)
49
+ activerecord (= 7.1.2)
50
+ activestorage (= 7.1.2)
51
+ activesupport (= 7.1.2)
48
52
  globalid (>= 0.6.0)
49
53
  nokogiri (>= 1.8.5)
50
- actionview (7.0.4)
51
- activesupport (= 7.0.4)
54
+ actionview (7.1.2)
55
+ activesupport (= 7.1.2)
52
56
  builder (~> 3.1)
53
- erubi (~> 1.4)
54
- rails-dom-testing (~> 2.0)
55
- rails-html-sanitizer (~> 1.1, >= 1.2.0)
56
- activejob (7.0.4)
57
- activesupport (= 7.0.4)
57
+ erubi (~> 1.11)
58
+ rails-dom-testing (~> 2.2)
59
+ rails-html-sanitizer (~> 1.6)
60
+ activejob (7.1.2)
61
+ activesupport (= 7.1.2)
58
62
  globalid (>= 0.3.6)
59
- activemodel (7.0.4)
60
- activesupport (= 7.0.4)
61
- activerecord (7.0.4)
62
- activemodel (= 7.0.4)
63
- activesupport (= 7.0.4)
64
- activestorage (7.0.4)
65
- actionpack (= 7.0.4)
66
- activejob (= 7.0.4)
67
- activerecord (= 7.0.4)
68
- activesupport (= 7.0.4)
63
+ activemodel (7.1.2)
64
+ activesupport (= 7.1.2)
65
+ activerecord (7.1.2)
66
+ activemodel (= 7.1.2)
67
+ activesupport (= 7.1.2)
68
+ timeout (>= 0.4.0)
69
+ activestorage (7.1.2)
70
+ actionpack (= 7.1.2)
71
+ activejob (= 7.1.2)
72
+ activerecord (= 7.1.2)
73
+ activesupport (= 7.1.2)
69
74
  marcel (~> 1.0)
70
- mini_mime (>= 1.1.0)
71
- activesupport (7.0.4)
75
+ activesupport (7.1.2)
76
+ base64
77
+ bigdecimal
72
78
  concurrent-ruby (~> 1.0, >= 1.0.2)
79
+ connection_pool (>= 2.2.5)
80
+ drb
73
81
  i18n (>= 1.6, < 2)
74
82
  minitest (>= 5.1)
83
+ mutex_m
75
84
  tzinfo (~> 2.0)
76
85
  ast (2.4.2)
77
86
  autotest-suffix (1.1.0)
87
+ base64 (0.2.0)
88
+ bigdecimal (3.1.5)
78
89
  builder (3.2.4)
79
90
  combustion (1.3.7)
80
91
  activesupport (>= 3.0.0)
81
92
  railties (>= 3.0.0)
82
93
  thor (>= 0.14.6)
83
- concurrent-ruby (1.1.10)
94
+ concurrent-ruby (1.2.2)
95
+ connection_pool (2.4.1)
84
96
  crass (1.0.6)
85
- date (3.3.3)
97
+ date (3.3.4)
98
+ debug (1.9.1)
99
+ irb (~> 1.10)
100
+ reline (>= 0.3.8)
101
+ drb (2.2.0)
102
+ ruby2_keywords
86
103
  erubi (1.12.0)
87
- globalid (1.0.0)
88
- activesupport (>= 5.0)
89
- i18n (1.12.0)
104
+ globalid (1.2.1)
105
+ activesupport (>= 6.1)
106
+ i18n (1.14.1)
90
107
  concurrent-ruby (~> 1.0)
91
- json (2.6.3)
92
- loofah (2.19.1)
108
+ io-console (0.7.1)
109
+ irb (1.11.0)
110
+ rdoc
111
+ reline (>= 0.3.8)
112
+ json (2.7.1)
113
+ language_server-protocol (3.17.0.3)
114
+ loofah (2.22.0)
93
115
  crass (~> 1.0.2)
94
- nokogiri (>= 1.5.9)
95
- mail (2.8.0)
116
+ nokogiri (>= 1.12.0)
117
+ mail (2.8.1)
96
118
  mini_mime (>= 0.1.1)
97
119
  net-imap
98
120
  net-pop
99
121
  net-smtp
100
122
  marcel (1.0.2)
101
- method_source (1.0.0)
102
- mini_mime (1.1.2)
103
- mini_portile2 (2.8.1)
104
- minitest (5.17.0)
123
+ mini_mime (1.1.5)
124
+ mini_portile2 (2.8.5)
125
+ minitest (5.20.0)
105
126
  minitest-autotest (1.1.1)
106
127
  minitest-server (~> 1.0)
107
128
  path_expander (~> 1.0)
108
- minitest-focus (1.3.1)
129
+ minitest-focus (1.4.0)
109
130
  minitest (>= 4, < 6)
110
131
  minitest-server (1.0.7)
111
132
  minitest (~> 5.16)
112
- mocha (2.0.2)
133
+ mocha (2.1.0)
113
134
  ruby2_keywords (>= 0.0.5)
114
135
  multi_json (1.15.0)
115
- net-imap (0.3.4)
136
+ mutex_m (0.2.0)
137
+ net-imap (0.4.9.1)
116
138
  date
117
139
  net-protocol
118
140
  net-pop (0.1.2)
119
141
  net-protocol
120
- net-protocol (0.2.1)
142
+ net-protocol (0.2.2)
121
143
  timeout
122
- net-smtp (0.3.3)
144
+ net-smtp (0.4.0.1)
123
145
  net-protocol
124
- nio4r (2.5.8)
125
- nokogiri (1.13.10)
126
- mini_portile2 (~> 2.8.0)
146
+ nio4r (2.7.0)
147
+ nokogiri (1.16.0)
148
+ mini_portile2 (~> 2.8.2)
127
149
  racc (~> 1.4)
128
- parallel (1.22.1)
129
- parser (3.2.0.0)
150
+ parallel (1.24.0)
151
+ parser (3.3.0.2)
130
152
  ast (~> 2.4.1)
153
+ racc
131
154
  path_expander (1.1.1)
132
- racc (1.6.2)
133
- rack (2.2.5)
134
- rack-test (2.0.2)
155
+ psych (5.1.2)
156
+ stringio
157
+ racc (1.7.3)
158
+ rack (3.0.8)
159
+ rack-session (2.0.0)
160
+ rack (>= 3.0.0)
161
+ rack-test (2.1.0)
135
162
  rack (>= 1.3)
136
- rails (7.0.4)
137
- actioncable (= 7.0.4)
138
- actionmailbox (= 7.0.4)
139
- actionmailer (= 7.0.4)
140
- actionpack (= 7.0.4)
141
- actiontext (= 7.0.4)
142
- actionview (= 7.0.4)
143
- activejob (= 7.0.4)
144
- activemodel (= 7.0.4)
145
- activerecord (= 7.0.4)
146
- activestorage (= 7.0.4)
147
- activesupport (= 7.0.4)
163
+ rackup (2.1.0)
164
+ rack (>= 3)
165
+ webrick (~> 1.8)
166
+ rails (7.1.2)
167
+ actioncable (= 7.1.2)
168
+ actionmailbox (= 7.1.2)
169
+ actionmailer (= 7.1.2)
170
+ actionpack (= 7.1.2)
171
+ actiontext (= 7.1.2)
172
+ actionview (= 7.1.2)
173
+ activejob (= 7.1.2)
174
+ activemodel (= 7.1.2)
175
+ activerecord (= 7.1.2)
176
+ activestorage (= 7.1.2)
177
+ activesupport (= 7.1.2)
148
178
  bundler (>= 1.15.0)
149
- railties (= 7.0.4)
150
- rails-dom-testing (2.0.3)
151
- activesupport (>= 4.2.0)
179
+ railties (= 7.1.2)
180
+ rails-dom-testing (2.2.0)
181
+ activesupport (>= 5.0.0)
182
+ minitest
152
183
  nokogiri (>= 1.6)
153
- rails-html-sanitizer (1.4.4)
154
- loofah (~> 2.19, >= 2.19.1)
155
- railties (7.0.4)
156
- actionpack (= 7.0.4)
157
- activesupport (= 7.0.4)
158
- method_source
184
+ rails-html-sanitizer (1.6.0)
185
+ loofah (~> 2.21)
186
+ nokogiri (~> 1.14)
187
+ railties (7.1.2)
188
+ actionpack (= 7.1.2)
189
+ activesupport (= 7.1.2)
190
+ irb
191
+ rackup (>= 1.0.0)
159
192
  rake (>= 12.2)
160
- thor (~> 1.0)
161
- zeitwerk (~> 2.5)
193
+ thor (~> 1.0, >= 1.2.2)
194
+ zeitwerk (~> 2.6)
162
195
  rainbow (3.1.1)
163
- rake (13.0.6)
164
- regexp_parser (2.6.1)
165
- rexml (3.2.5)
166
- rubocop (1.42.0)
196
+ rake (13.1.0)
197
+ rdoc (6.6.2)
198
+ psych (>= 4.0.0)
199
+ regexp_parser (2.8.3)
200
+ reline (0.4.2)
201
+ io-console (~> 0.5)
202
+ rexml (3.2.6)
203
+ rubocop (1.59.0)
167
204
  json (~> 2.3)
205
+ language_server-protocol (>= 3.17.0)
168
206
  parallel (~> 1.10)
169
- parser (>= 3.1.2.1)
207
+ parser (>= 3.2.2.4)
170
208
  rainbow (>= 2.2.2, < 4.0)
171
209
  regexp_parser (>= 1.8, < 3.0)
172
210
  rexml (>= 3.2.5, < 4.0)
173
- rubocop-ast (>= 1.24.1, < 2.0)
211
+ rubocop-ast (>= 1.30.0, < 2.0)
174
212
  ruby-progressbar (~> 1.7)
175
- unicode-display_width (>= 1.4.0, < 3.0)
176
- rubocop-ast (1.24.1)
177
- parser (>= 3.1.1.0)
178
- rubocop-minitest (0.25.1)
179
- rubocop (>= 0.90, < 2.0)
213
+ unicode-display_width (>= 2.4.0, < 3.0)
214
+ rubocop-ast (1.30.0)
215
+ parser (>= 3.2.1.0)
216
+ rubocop-minitest (0.34.3)
217
+ rubocop (>= 1.39, < 2.0)
218
+ rubocop-ast (>= 1.30.0, < 2.0)
180
219
  rubocop-rake (0.6.0)
181
220
  rubocop (~> 1.0)
182
- ruby-progressbar (1.11.0)
221
+ ruby-progressbar (1.13.0)
183
222
  ruby2_keywords (0.0.5)
184
- sqlite3 (1.5.4)
223
+ sqlite3 (1.7.0)
185
224
  mini_portile2 (~> 2.8.0)
186
- thor (1.2.1)
187
- timeout (0.3.1)
188
- tzinfo (2.0.5)
225
+ stringio (3.1.0)
226
+ thor (1.3.0)
227
+ timeout (0.4.1)
228
+ tzinfo (2.0.6)
189
229
  concurrent-ruby (~> 1.0)
190
- unicode-display_width (2.4.2)
191
- websocket-driver (0.7.5)
230
+ unicode-display_width (2.5.0)
231
+ webrick (1.8.1)
232
+ websocket-driver (0.7.6)
192
233
  websocket-extensions (>= 0.1.0)
193
234
  websocket-extensions (0.1.5)
194
- zeitwerk (2.6.6)
235
+ zeitwerk (2.6.12)
195
236
 
196
237
  PLATFORMS
197
238
  ruby
@@ -199,6 +240,7 @@ PLATFORMS
199
240
  DEPENDENCIES
200
241
  autotest-suffix
201
242
  combustion
243
+ debug
202
244
  minitest
203
245
  minitest-autotest
204
246
  minitest-focus
@@ -56,7 +56,7 @@ module Stance
56
56
  end
57
57
 
58
58
  unless connection.adapter_name =~ /postg|mysql/i
59
- serialize :metadata, ::JSONWithIndifferentAccess
59
+ serialize :metadata, coder: ::JSONWithIndifferentAccess
60
60
  end
61
61
  end
62
62
  end
data/lib/stance/event.rb CHANGED
@@ -8,6 +8,8 @@ module Stance
8
8
  attr_reader :record, :options, :name
9
9
 
10
10
  class << self
11
+ attr_accessor :callback_methods
12
+
11
13
  def before_create(*methods, &block)
12
14
  set_callback :create, :before, *methods, &block
13
15
  end
@@ -15,6 +17,15 @@ module Stance
15
17
  def after_create(*methods, &block)
16
18
  set_callback :create, :after, *methods, &block
17
19
  end
20
+
21
+ def method_added(method_name)
22
+ super
23
+
24
+ return if self == Stance::Event
25
+
26
+ self.callback_methods ||= []
27
+ self.callback_methods << method_name
28
+ end
18
29
  end
19
30
 
20
31
  def initialize(name, subject, metadata, options)
@@ -44,9 +55,9 @@ module Stance
44
55
  run_callbacks :create do
45
56
  # Call each public method of the Event class if a custom class.
46
57
  if self.class.name != 'Stance::Event'
47
- Rails.logger.info "Event: #{full_name}"
58
+ Rails.logger.debug "Event: #{full_name}"
48
59
 
49
- callback_methods.each { |method| send method }
60
+ self.class.callback_methods&.each { |method| send method }
50
61
  end
51
62
 
52
63
  record.save if @options[:record]
@@ -66,10 +77,6 @@ module Stance
66
77
 
67
78
  private
68
79
 
69
- def callback_methods
70
- public_methods(false) - Stance::Event.instance_methods(false)
71
- end
72
-
73
80
  # Event is a singleton and already exists.
74
81
  def singleton_exists?
75
82
  options[:singleton] && subject.events.active.exists?(name: name)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Stance
4
- VERSION = '0.8.0'
4
+ VERSION = '0.8.2'
5
5
  end
data/stance.gemspec CHANGED
@@ -25,6 +25,6 @@ Gem::Specification.new do |spec|
25
25
  end
26
26
  spec.require_paths = ['lib']
27
27
 
28
- spec.add_dependency 'multi_json'
29
- spec.add_dependency 'rails', '>= 7.0.4'
28
+ spec.add_dependency 'multi_json', '~> 1.15'
29
+ spec.add_dependency 'rails', ['>= 7.0', '< 8.0']
30
30
  end
metadata CHANGED
@@ -1,43 +1,49 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stance
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joel Moss
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-01-04 00:00:00.000000000 Z
11
+ date: 2024-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0'
19
+ version: '1.15'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0'
26
+ version: '1.15'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rails
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
32
32
  - !ruby/object:Gem::Version
33
- version: 7.0.4
33
+ version: '7.0'
34
+ - - "<"
35
+ - !ruby/object:Gem::Version
36
+ version: '8.0'
34
37
  type: :runtime
35
38
  prerelease: false
36
39
  version_requirements: !ruby/object:Gem::Requirement
37
40
  requirements:
38
41
  - - ">="
39
42
  - !ruby/object:Gem::Version
40
- version: 7.0.4
43
+ version: '7.0'
44
+ - - "<"
45
+ - !ruby/object:Gem::Version
46
+ version: '8.0'
41
47
  description:
42
48
  email:
43
49
  - joel@developwithstyle.com
@@ -91,7 +97,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
91
97
  - !ruby/object:Gem::Version
92
98
  version: '0'
93
99
  requirements: []
94
- rubygems_version: 3.4.1
100
+ rubygems_version: 3.5.3
95
101
  signing_key:
96
102
  specification_version: 4
97
103
  summary: Event System for Rails