cancancan_pub_sub 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7c1f7d83289e7d8a4483151c67896099524244c375d2ffdfed056516cd2e1f3c
4
+ data.tar.gz: d990040b89e1e6801a67ed1fd591e1ce0f5409d20d5e099f07236a4c051b4c76
5
+ SHA512:
6
+ metadata.gz: fbbc19fcc8ce3282b51fd7f47b4ad5b12258ba73b2838007ba7608f9822353abda470081637a3fed6d2db2800693e646df370212eba4139d95ae1ce3ea3395e5
7
+ data.tar.gz: b3b4d60a8347f6f2830694e1cc98470010746b591787bc1cad45307a0cd980efec76d48fde6337e70669caeb18d34e98606841ced0ba54bb60c5e9bc23726f6b
@@ -0,0 +1,58 @@
1
+ # Ruby CircleCI 2.0 configuration file
2
+ #
3
+ # Check https://circleci.com/docs/2.0/language-ruby/ for more details
4
+ #
5
+ version: 2
6
+ jobs:
7
+ build:
8
+ docker:
9
+ # specify the version you desire here
10
+ - image: circleci/ruby:2.6.3-stretch
11
+ environment:
12
+
13
+ working_directory: ~/repo
14
+
15
+ steps:
16
+ - checkout
17
+
18
+ # Download and cache dependencies
19
+ - restore_cache:
20
+ keys:
21
+ - v1-dependencies-{{ checksum "Gemfile.lock" }}
22
+ # fallback to using the latest cache if no exact match is found
23
+ - v1-dependencies-
24
+
25
+ - run:
26
+ name: Install system dependencies
27
+ command: |
28
+ sudo apt-get update
29
+ sudo apt-get install cmake
30
+
31
+ - run:
32
+ name: install dependencies
33
+ command: |
34
+ gem install bundler
35
+ bundle install --jobs=4 --retry=3 --path vendor/bundle
36
+
37
+ - save_cache:
38
+ paths:
39
+ - ./venv
40
+ key: v1-dependencies-{{ checksum "Gemfile.lock" }}
41
+
42
+ # run tests!
43
+ - run:
44
+ name: run tests
45
+ command: |
46
+ mkdir /tmp/test-results
47
+
48
+ bundle exec rspec --format progress \
49
+ --format RspecJunitFormatter \
50
+ --out /tmp/test-results/rspec.xml \
51
+ --format progress
52
+
53
+ # collect reports
54
+ - store_test_results:
55
+ path: /tmp/test-results
56
+ - store_artifacts:
57
+ path: /tmp/test-results
58
+ destination: test-results
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rakeTasks ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Settings><!--This file was automatically generated by Ruby plugin.
3
+ You are allowed to:
4
+ 1. Remove rake task
5
+ 2. Add existing rake tasks
6
+ To add existing rake tasks automatically delete this file and reload the project.
7
+ --><RakeGroup description="" fullCmd="" taksId="rake" /></Settings>
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,391 @@
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rspec
4
+
5
+ AllCops:
6
+ TargetRubyVersion: 2.7
7
+ Exclude:
8
+ - 'spec/dummy/bin/**/*'
9
+ - 'vendor/**/*'
10
+ - 'db/schema.rb'
11
+ - 'Guardfile'
12
+ - 'config.ru'
13
+ - 'bin/**/*'
14
+ - 'node_modules/**/*'
15
+ NewCops: enable
16
+ UseCache: false
17
+
18
+ Layout/BlockAlignment:
19
+ Description: "Align block ends correctly."
20
+ Enabled: true
21
+ EnforcedStyleAlignWith: either
22
+ SupportedStylesAlignWith:
23
+ - either
24
+ - start_of_block
25
+ - start_of_line
26
+ Layout/CaseIndentation:
27
+ EnforcedStyle: case
28
+ IndentOneStep: true
29
+ Layout/DotPosition:
30
+ Description: "Checks the position of the dot in multi-line method calls."
31
+ Enabled: true
32
+ EnforcedStyle: trailing
33
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains"
34
+ SupportedStyles:
35
+ - leading
36
+ - trailing
37
+ Layout/EmptyLinesAroundAttributeAccessor:
38
+ Enabled: true
39
+ Layout/FirstArgumentIndentation:
40
+ IndentationWidth: 4
41
+ Layout/FirstArrayElementIndentation:
42
+ IndentationWidth: 4
43
+ Layout/FirstHashElementIndentation:
44
+ IndentationWidth: 4
45
+ Layout/HashAlignment:
46
+ Description: "Align the elements of a hash literal if they span more than one line."
47
+ Enabled: true
48
+ EnforcedColonStyle: table
49
+ EnforcedHashRocketStyle: table
50
+ EnforcedLastArgumentHashStyle: always_inspect
51
+ SupportedColonStyles:
52
+ - key
53
+ - separator
54
+ - table
55
+ SupportedHashRocketStyles:
56
+ - key
57
+ - separator
58
+ - table
59
+ SupportedLastArgumentHashStyles:
60
+ - always_inspect
61
+ - always_ignore
62
+ - ignore_implicit
63
+ - ignore_explicit
64
+ VersionAdded: "0.49"
65
+ Layout/LineLength:
66
+ Max: 150
67
+ Layout/MultilineHashBraceLayout:
68
+ Enabled: true
69
+ EnforcedStyle: symmetrical
70
+ SupportedStyles:
71
+ - symmetrical
72
+ - new_line
73
+ - same_line
74
+ Layout/MultilineMethodCallIndentation:
75
+ Enabled: false
76
+ EnforcedStyle: indented_relative_to_receiver
77
+ IndentationWidth: 4
78
+ Layout/MultilineOperationIndentation:
79
+ Enabled: false
80
+ EnforcedStyle: indented
81
+ IndentationWidth: 4
82
+ Layout/ParameterAlignment:
83
+ Description: "Align the parameters of a method call if they span more than one line."
84
+ Enabled: true
85
+ EnforcedStyle: with_first_parameter
86
+ Layout/SpaceAroundMethodCallOperator:
87
+ Enabled: true
88
+ Layout/TrailingEmptyLines:
89
+ Description: "Checks trailing blank lines and final newline."
90
+ Enabled: false
91
+ StyleGuide: "#newline-eof"
92
+ Lint/AssignmentInCondition:
93
+ AllowSafeAssignment: true
94
+ Description: "Don't use assignment in conditions."
95
+ Enabled: true
96
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition"
97
+ Lint/DeprecatedOpenSSLConstant:
98
+ Enabled: true
99
+ Lint/DisjunctiveAssignmentInConstructor:
100
+ Enabled: false
101
+ Lint/DuplicateElsifCondition:
102
+ Enabled: false
103
+ Lint/EachWithObjectArgument:
104
+ Description: "Check for immutable argument given to each_with_object."
105
+ Enabled: true
106
+ Lint/LiteralAsCondition:
107
+ Description: "Checks of literals used in conditions."
108
+ Enabled: false
109
+ Lint/LiteralInInterpolation:
110
+ Description: "Checks for literals used in interpolation."
111
+ Enabled: false
112
+ Lint/MixedRegexpCaptureTypes:
113
+ Enabled: true
114
+ Lint/RaiseException:
115
+ Description: "This cop checks for raise or fail statements which are raising Exception class."
116
+ Enabled: true
117
+ Lint/StructNewOverride:
118
+ Description: "This cop checks unexpected overrides of the Struct built-in methods via Struct.new"
119
+ Enabled: true
120
+ Lint/SuppressedException:
121
+ Description: "Don't suppress exception."
122
+ Enabled: true
123
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions"
124
+ Metrics/AbcSize:
125
+ Description: "A calculated magnitude based on number of assignments, branches, and conditions."
126
+ Enabled: true
127
+ Max: 15
128
+ Metrics/ClassLength:
129
+ CountComments: false
130
+ Description: "Avoid classes longer than 100 lines of code."
131
+ Enabled: true
132
+ Max: 150
133
+ Metrics/CyclomaticComplexity:
134
+ Description: "A complexity metric that is strongly correlated to the number of test cases needed to validate a method."
135
+ Enabled: true
136
+ Max: 8
137
+ Metrics/MethodLength:
138
+ CountComments: false
139
+ Description: "Avoid methods longer than 15 lines of code."
140
+ Enabled: true
141
+ Max: 15
142
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#short-methods"
143
+ Metrics/ModuleLength:
144
+ CountComments: false
145
+ Description: "Avoid modules longer than 100 lines of code."
146
+ Enabled: false
147
+ Max: 100
148
+ Metrics/ParameterLists:
149
+ CountKeywordArgs: true
150
+ Description: "Avoid parameter lists longer than three or four parameters."
151
+ Enabled: true
152
+ Max: 5
153
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#too-many-params"
154
+ Metrics/PerceivedComplexity:
155
+ Description: "A complexity metric geared towards measuring complexity for a human reader."
156
+ Enabled: true
157
+ Max: 7
158
+ Naming/AccessorMethodName:
159
+ Description: "Check the naming of accessor methods for get_/set_."
160
+ Enabled: false
161
+ Naming/FileName:
162
+ Description: "Use snake_case for source file names."
163
+ Enabled: true
164
+ Exclude: []
165
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#snake-case-files"
166
+ Naming/PredicateName:
167
+ Description: "Check the names of predicate methods."
168
+ Enabled: true
169
+ ForbiddenPrefixes:
170
+ - is_
171
+ NamePrefix:
172
+ - is_
173
+ - has_
174
+ - have_
175
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark"
176
+ Naming/RescuedExceptionsVariableName:
177
+ PreferredName: error
178
+ Naming/VariableNumber:
179
+ EnforcedStyle: snake_case
180
+ Performance/AncestorsInclude:
181
+ Enabled: false
182
+ Performance/BigDecimalWithNumericArgument:
183
+ Enabled: false
184
+ Performance/RedundantSortBlock:
185
+ Enabled: true
186
+ Performance/RedundantStringChars:
187
+ Enabled: true
188
+ Performance/ReverseFirst:
189
+ Enabled: true
190
+ Performance/SortReverse:
191
+ Enabled: true
192
+ Performance/Squeeze:
193
+ Enabled: true
194
+ Performance/StringInclude:
195
+ Enabled: true
196
+ RedundantBlockCall:
197
+ Enabled: false
198
+ Style/AccessorGrouping:
199
+ Enabled: true
200
+ Style/Alias:
201
+ Description: "Use alias_method instead of alias."
202
+ Enabled: true
203
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#alias-method"
204
+ Style/ArrayCoercion:
205
+ Enabled: true
206
+ Style/BisectedAttrAccessor:
207
+ Enabled: true
208
+ Style/CaseLikeIf:
209
+ Enabled: true
210
+ Style/CollectionMethods:
211
+ Description: "Preferred collection methods."
212
+ Enabled: true
213
+ PreferredMethods:
214
+ collect: map
215
+ collect!: map!
216
+ find: detect
217
+ find_all: select
218
+ inject: reduce
219
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#map-find-select-reduce-size"
220
+ Style/Documentation:
221
+ Description: "Document classes and non-namespace modules."
222
+ Enabled: false
223
+ Style/DoubleNegation:
224
+ Description: "Checks for uses of double negation (!!)."
225
+ Enabled: false
226
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#no-bang-bang"
227
+ Style/EachWithObject:
228
+ Description: "Prefer `each_with_object` over `inject` or `reduce`."
229
+ Enabled: false
230
+ Style/EmptyLiteral:
231
+ Description: "Prefer literals to Array.new/Hash.new/String.new."
232
+ Enabled: true
233
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#literal-array-hash"
234
+ Style/EmptyMethod:
235
+ Enabled: false
236
+ Style/ExponentialNotation:
237
+ Enabled: true
238
+ Style/FormatStringToken:
239
+ Enabled: false
240
+ Style/FrozenStringLiteralComment:
241
+ Enabled: true
242
+ Style/GuardClause:
243
+ Description: "Check for conditionals that can be replaced with guard clauses"
244
+ Enabled: true
245
+ MinBodyLength: 1
246
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals"
247
+ Style/HashAsLastArrayItem:
248
+ Enabled: true
249
+ Style/HashEachMethods:
250
+ Enabled: true
251
+ Style/HashLikeCase:
252
+ Enabled: true
253
+ Style/HashSyntax:
254
+ Enabled: true
255
+ EnforcedStyle: ruby19
256
+ SupportedStyles:
257
+ - ruby19
258
+ - hash_rockets
259
+ - no_mixed_keys
260
+ - ruby19_no_mixed_keys
261
+ Style/HashTransformKeys:
262
+ Enabled: true
263
+ Style/HashTransformValues:
264
+ Enabled: true
265
+ Style/IfUnlessModifier:
266
+ Description: "Favor modifier if/unless usage when you have a single-line body."
267
+ Enabled: false
268
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier"
269
+ Style/InlineComment:
270
+ Description: "Avoid inline comments."
271
+ Enabled: false
272
+ Style/ModuleFunction:
273
+ Description: "Checks for usage of `extend self` in modules."
274
+ Enabled: false
275
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#module-function"
276
+ Style/OneLineConditional:
277
+ Description: "Favor the ternary operator(?:) over if/then/else/end constructs."
278
+ Enabled: false
279
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#ternary-operator"
280
+ Style/OptionHash:
281
+ Description: "Don't use option hashes when you can use keyword arguments."
282
+ Enabled: false
283
+ Style/PerlBackrefs:
284
+ Description: "Avoid Perl-style regex back references."
285
+ Enabled: true
286
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers"
287
+ Style/RaiseArgs:
288
+ Description: "Checks the arguments passed to raise/fail."
289
+ Enabled: true
290
+ EnforcedStyle: exploded
291
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#exception-class-messages"
292
+ SupportedStyles:
293
+ - compact
294
+ - exploded
295
+ Style/RedundantAssignment:
296
+ Enabled: true
297
+ Style/RedundantFetchBlock:
298
+ Enabled: true
299
+ Style/RedundantFileExtensionInRequire:
300
+ Enabled: true
301
+ Style/RedundantRegexpCharacterClass:
302
+ Enabled: true
303
+ Style/RedundantRegexpEscape:
304
+ Enabled: true
305
+ Style/Send:
306
+ Description: "Prefer `Object#__send__` or `Object#public_send` to `send`, as `send` may overlap with existing methods."
307
+ Enabled: false
308
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#prefer-public-send"
309
+ Style/SignalException:
310
+ Description: "Checks for proper usage of fail and raise."
311
+ Enabled: false
312
+ EnforcedStyle: semantic
313
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#fail-method"
314
+ SupportedStyles:
315
+ - only_raise
316
+ - only_fail
317
+ - semantic
318
+ Style/SingleLineBlockParams:
319
+ Description: "Enforces the names of some block params."
320
+ Enabled: false
321
+ Methods:
322
+ -
323
+ reduce:
324
+ - a
325
+ - e
326
+ -
327
+ inject:
328
+ - a
329
+ - e
330
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#reduce-blocks"
331
+ Style/SingleLineMethods:
332
+ AllowIfMethodIsEmpty: true
333
+ Description: "Avoid single-line methods."
334
+ Enabled: true
335
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#no-single-line-methods"
336
+ Style/SlicingWithRange:
337
+ Enabled: true
338
+ Style/SpecialGlobalVars:
339
+ Description: "Avoid Perl-style global variables."
340
+ Enabled: true
341
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms"
342
+ Style/StringLiterals:
343
+ Description: "Checks if uses of quotes match the configured preference."
344
+ Enabled: true
345
+ EnforcedStyle: double_quotes
346
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#consistent-string-literals"
347
+ SupportedStyles:
348
+ - single_quotes
349
+ - double_quotes
350
+ Style/StringLiteralsInInterpolation:
351
+ Description: "Checks if uses of quotes inside expressions in interpolated strings match the configured preference."
352
+ Enabled: true
353
+ EnforcedStyle: double_quotes
354
+ SupportedStyles:
355
+ - single_quotes
356
+ - double_quotes
357
+ Style/TrailingCommaInArguments:
358
+ Description: "Checks for trailing comma in argument lists."
359
+ Enabled: true
360
+ EnforcedStyleForMultiline: no_comma
361
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas"
362
+ SupportedStylesForMultiline:
363
+ - comma
364
+ - consistent_comma
365
+ - no_comma
366
+ Style/TrailingCommaInArrayLiteral:
367
+ Description: "Checks for trailing comma in array and hash literals."
368
+ Enabled: true
369
+ EnforcedStyleForMultiline: no_comma
370
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas"
371
+ SupportedStylesForMultiline:
372
+ - comma
373
+ - consistent_comma
374
+ - no_comma
375
+ Style/TrailingCommaInHashLiteral:
376
+ Description: "Checks for trailing comma in array and hash literals."
377
+ Enabled: true
378
+ EnforcedStyleForMultiline: no_comma
379
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas"
380
+ SupportedStylesForMultiline:
381
+ - comma
382
+ - consistent_comma
383
+ - no_comma
384
+ Style/VariableInterpolation:
385
+ Description: "Don't interpolate global, instance and class variables directly in strings."
386
+ Enabled: false
387
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#curlies-interpolate"
388
+ Style/WhenThen:
389
+ Description: "Use when x then ... for one-line cases."
390
+ Enabled: false
391
+ StyleGuide: "https://github.com/bbatsov/ruby-style-guide#one-line-cases"
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 2.7.1
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at jason@cardtapp.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ # Specify your gem's dependencies in cancancan_notifications.gemspec
8
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,84 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ cancancan_pub_sub (0.1.0)
5
+ activesupport
6
+ cancancan
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ activesupport (6.1.0)
12
+ concurrent-ruby (~> 1.0, >= 1.0.2)
13
+ i18n (>= 1.6, < 2)
14
+ minitest (>= 5.1)
15
+ tzinfo (~> 2.0)
16
+ zeitwerk (~> 2.3)
17
+ ast (2.4.1)
18
+ cancancan (3.2.0)
19
+ concurrent-ruby (1.1.7)
20
+ database_cleaner (1.8.5)
21
+ diff-lcs (1.4.4)
22
+ i18n (1.8.5)
23
+ concurrent-ruby (~> 1.0)
24
+ minitest (5.14.2)
25
+ parallel (1.20.1)
26
+ parser (3.0.0.0)
27
+ ast (~> 2.4.1)
28
+ rainbow (3.0.0)
29
+ rake (10.5.0)
30
+ regexp_parser (2.0.3)
31
+ rexml (3.2.4)
32
+ rspec (3.10.0)
33
+ rspec-core (~> 3.10.0)
34
+ rspec-expectations (~> 3.10.0)
35
+ rspec-mocks (~> 3.10.0)
36
+ rspec-core (3.10.1)
37
+ rspec-support (~> 3.10.0)
38
+ rspec-expectations (3.10.1)
39
+ diff-lcs (>= 1.2.0, < 2.0)
40
+ rspec-support (~> 3.10.0)
41
+ rspec-mocks (3.10.0)
42
+ diff-lcs (>= 1.2.0, < 2.0)
43
+ rspec-support (~> 3.10.0)
44
+ rspec-support (3.10.1)
45
+ rspec_junit_formatter (0.4.1)
46
+ rspec-core (>= 2, < 4, != 2.12.0)
47
+ rubocop (1.7.0)
48
+ parallel (~> 1.10)
49
+ parser (>= 2.7.1.5)
50
+ rainbow (>= 2.2.2, < 4.0)
51
+ regexp_parser (>= 1.8, < 3.0)
52
+ rexml
53
+ rubocop-ast (>= 1.2.0, < 2.0)
54
+ ruby-progressbar (~> 1.7)
55
+ unicode-display_width (>= 1.4.0, < 2.0)
56
+ rubocop-ast (1.3.0)
57
+ parser (>= 2.7.1.5)
58
+ rubocop-performance (1.9.1)
59
+ rubocop (>= 0.90.0, < 2.0)
60
+ rubocop-ast (>= 0.4.0)
61
+ rubocop-rspec (2.1.0)
62
+ rubocop (~> 1.0)
63
+ rubocop-ast (>= 1.1.0)
64
+ ruby-progressbar (1.10.1)
65
+ tzinfo (2.0.4)
66
+ concurrent-ruby (~> 1.0)
67
+ unicode-display_width (1.7.0)
68
+ zeitwerk (2.4.2)
69
+
70
+ PLATFORMS
71
+ ruby
72
+
73
+ DEPENDENCIES
74
+ cancancan_pub_sub!
75
+ database_cleaner
76
+ rake (~> 10.0)
77
+ rspec (~> 3.0)
78
+ rspec_junit_formatter
79
+ rubocop
80
+ rubocop-performance
81
+ rubocop-rspec
82
+
83
+ BUNDLED WITH
84
+ 2.1.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 Jason Risch
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # CancancanCallbacks
2
+
3
+ Adds notifications to cancan ability calls
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ ```ruby
10
+ gem 'cancancan_callbacks'
11
+ ```
12
+
13
+ And then execute:
14
+
15
+ $ bundle
16
+
17
+ Or install it yourself as:
18
+
19
+ $ gem install cancancan_pub_sub
20
+
21
+ ## Usage
22
+
23
+ Include CanCan::PubSub in your CanCan::Ability
24
+ ```
25
+ class My::Ability
26
+ include CanCan::Ability
27
+ include CanCan::PubSub
28
+ end
29
+ ```
30
+
31
+ Subscribe to publications.
32
+ ```
33
+ ability = My::Ability.new
34
+ ability.subscribe("before_authorize!") do
35
+
36
+ end
37
+ ```
38
+
39
+ Available subscriptions: can, cannot, can?, cannot?, authorize!
40
+
41
+ ## Development
42
+
43
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
44
+
45
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
46
+
47
+ ## Contributing
48
+
49
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/cancancan_pub_sub. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
50
+
51
+ ## License
52
+
53
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
54
+
55
+ ## Code of Conduct
56
+
57
+ Everyone interacting in the CancancanCallbacks project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/cancancan_pub_sub/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "cancancan_pub_sub"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path("lib", __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require_relative "lib/version"
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = "cancancan_pub_sub"
9
+ spec.version = Cancan::PubSub::VERSION
10
+ spec.authors = ["Jason Risch"]
11
+ spec.email = ["jason@cardtapp.com"]
12
+
13
+ spec.summary = "Add notifications to cancancan authorization gem"
14
+ spec.homepage = "https://www.cardtapp.com"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ if spec.respond_to?(:metadata)
20
+ spec.metadata["homepage_uri"] = spec.homepage
21
+ spec.metadata["source_code_uri"] = "https://github.com/CardTapp/cancancan_pub_sub"
22
+ spec.metadata["changelog_uri"] = "https://github.com/CardTapp/cancancan_pub_sub/CHANGELOG.md"
23
+ else
24
+ raise "RubyGems 2.0 or newer is required to protect against " \
25
+ "public gem pushes."
26
+ end
27
+
28
+ # Specify which files should be added to the gem when it is released.
29
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
30
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
31
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
32
+ end
33
+ spec.bindir = "exe"
34
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
35
+ spec.require_paths = ["lib"]
36
+
37
+ spec.add_dependency "activesupport"
38
+ spec.add_dependency "cancancan"
39
+
40
+ spec.add_development_dependency "database_cleaner"
41
+ spec.add_development_dependency "rake", "~> 10.0"
42
+ spec.add_development_dependency "rspec", "~> 3.0"
43
+ spec.add_development_dependency "rspec_junit_formatter"
44
+ spec.add_development_dependency "rubocop"
45
+ spec.add_development_dependency "rubocop-performance"
46
+ spec.add_development_dependency "rubocop-rspec"
47
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ module CanCan
4
+ module PubSub
5
+ extend ActiveSupport::Concern
6
+
7
+ def subscribe(event, target = nil, &block)
8
+ events[event] ||= []
9
+ if target
10
+ events[event] << target
11
+ elsif block
12
+ events[event] << block
13
+ else
14
+ raise ArgumentError
15
+ end
16
+ self
17
+ end
18
+
19
+ private
20
+
21
+ def events
22
+ @events ||= {}.with_indifferent_access
23
+ end
24
+
25
+ def publish(event)
26
+ return if events[event].nil?
27
+
28
+ events[event].each do |handler|
29
+ if handler.is_a? Symbol
30
+ send(handler, event, self)
31
+ else
32
+ handler.call(event, self)
33
+ end
34
+ end
35
+ end
36
+
37
+ included do
38
+ methods = %i[can cannot can? cannot? authorize!]
39
+ methods.each.each do |method|
40
+ alias_method "#{method}_original", method
41
+ define_method(method) do |*args, &block|
42
+ publish("before_#{method}".to_sym)
43
+ result = send("#{method}_original", *args, &block)
44
+ publish("after_#{method}".to_sym)
45
+ result
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support"
4
+ require "active_support/core_ext/hash/indifferent_access"
5
+ require "active_support/core_ext/string/inflections"
6
+ require "cancan"
7
+ require "cancan/pub_sub"
data/lib/version.rb ADDED
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Cancan
4
+ module PubSub
5
+ VERSION = "0.1.0"
6
+ end
7
+ end
metadata ADDED
@@ -0,0 +1,190 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: cancancan_pub_sub
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Jason Risch
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2021-04-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: cancancan
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: database_cleaner
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: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec_junit_formatter
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: rubocop
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
+ - !ruby/object:Gem::Dependency
112
+ name: rubocop-performance
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop-rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ description:
140
+ email:
141
+ - jason@cardtapp.com
142
+ executables: []
143
+ extensions: []
144
+ extra_rdoc_files: []
145
+ files:
146
+ - ".circleci/config.yml"
147
+ - ".gitignore"
148
+ - ".rakeTasks"
149
+ - ".rspec"
150
+ - ".rubocop.yml"
151
+ - ".ruby-version"
152
+ - CODE_OF_CONDUCT.md
153
+ - Gemfile
154
+ - Gemfile.lock
155
+ - LICENSE.txt
156
+ - README.md
157
+ - Rakefile
158
+ - bin/console
159
+ - bin/setup
160
+ - cancancan_pubsub.gemspec
161
+ - lib/cancan/pub_sub.rb
162
+ - lib/cancancan_pub_sub.rb
163
+ - lib/version.rb
164
+ homepage: https://www.cardtapp.com
165
+ licenses:
166
+ - MIT
167
+ metadata:
168
+ homepage_uri: https://www.cardtapp.com
169
+ source_code_uri: https://github.com/CardTapp/cancancan_pub_sub
170
+ changelog_uri: https://github.com/CardTapp/cancancan_pub_sub/CHANGELOG.md
171
+ post_install_message:
172
+ rdoc_options: []
173
+ require_paths:
174
+ - lib
175
+ required_ruby_version: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - ">="
178
+ - !ruby/object:Gem::Version
179
+ version: '0'
180
+ required_rubygems_version: !ruby/object:Gem::Requirement
181
+ requirements:
182
+ - - ">="
183
+ - !ruby/object:Gem::Version
184
+ version: '0'
185
+ requirements: []
186
+ rubygems_version: 3.1.2
187
+ signing_key:
188
+ specification_version: 4
189
+ summary: Add notifications to cancancan authorization gem
190
+ test_files: []