webhook_system 2.4.0 → 2.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -0
- data/.github/workflows/{build.yml → ci.yml} +17 -22
- data/.github/workflows/rubocop-challenger.yml +1 -1
- data/.rubocop.yml +40 -1
- data/.rubocop_challenge.yml +4 -0
- data/.rubocop_todo.yml +148 -111
- data/Gemfile +0 -1
- data/Rakefile +5 -7
- data/gemfiles/rails_6.1.gemfile +1 -1
- data/gemfiles/rails_7.0.gemfile +2 -0
- data/gemfiles/rails_7.1.gemfile +9 -0
- data/lib/webhook_system/base_event.rb +17 -8
- data/lib/webhook_system/encoder.rb +7 -9
- data/lib/webhook_system/job.rb +14 -13
- data/lib/webhook_system/subscription.rb +5 -5
- data/lib/webhook_system/version.rb +1 -1
- data/webhook_system.gemspec +7 -4
- metadata +53 -25
- data/.rubocop.hound.yml +0 -221
- data/gemfiles/rails_4.2.gemfile +0 -8
- data/gemfiles/rails_4.2.gemfile.lock +0 -295
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: de4c38dac5024e7faf9075fa7d08458c23742609626569b61c376c941ba701d0
|
4
|
+
data.tar.gz: 80aec1c6d60554d14e54e4e922e6389aa0dec26bced551bec63c0aa684ae3886
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55b2362374a9683a4c920b507d68e0c70b1c79aad11003315a6fae1bb417cfa568cde6621418dffc196f8ffb1863f82edd01fda9591e6c9bfcd8679b67d0e0ea
|
7
|
+
data.tar.gz: 3d03fe8f357631ff856a09c50b98fea1cb5096954413283d5367f5be6eda5c20f3cddf60f870e9f4ccdbe073d707c61a2ccd0716f555929246f33f8ed0792e74
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: github
|
@@ -5,9 +5,11 @@
|
|
5
5
|
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
6
|
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
7
|
|
8
|
-
name:
|
8
|
+
name: ci
|
9
9
|
|
10
|
-
on:
|
10
|
+
on:
|
11
|
+
- push
|
12
|
+
- pull_request
|
11
13
|
|
12
14
|
jobs:
|
13
15
|
test:
|
@@ -15,42 +17,35 @@ jobs:
|
|
15
17
|
strategy:
|
16
18
|
fail-fast: false
|
17
19
|
matrix:
|
18
|
-
gemfile: [
|
19
|
-
ruby: [2.
|
20
|
+
gemfile: ['rails_7.0', 'rails_7.1']
|
21
|
+
ruby: [3.3, 3.2, 3.1]
|
20
22
|
include:
|
21
23
|
- gemfile: rails_7.0
|
22
|
-
ruby: '3.1'
|
23
|
-
- gemfile: rails_6.1
|
24
|
-
ruby: '3.1'
|
25
|
-
- gemfile: rails_7.0
|
26
|
-
ruby: '3.0'
|
27
|
-
- gemfile: rails_6.1
|
28
24
|
ruby: '3.0'
|
29
|
-
- gemfile:
|
25
|
+
- gemfile: rails_7.0
|
30
26
|
ruby: 2.7
|
31
27
|
- gemfile: rails_6.1
|
32
|
-
ruby: 2.6
|
33
|
-
- gemfile: rails_6.0
|
34
28
|
ruby: 2.7
|
35
29
|
- gemfile: rails_6.0
|
36
|
-
ruby: 2.
|
30
|
+
ruby: 2.7
|
37
31
|
- gemfile: rails_5.2
|
38
|
-
ruby: 2.
|
32
|
+
ruby: 2.7
|
39
33
|
- gemfile: rails_5.1
|
40
|
-
ruby: 2.
|
34
|
+
ruby: 2.7
|
41
35
|
- gemfile: rails_5.0
|
42
|
-
ruby: 2.
|
43
|
-
- gemfile: rails_4.2
|
44
|
-
ruby: 2.6
|
45
|
-
- gemfile: rails_4.2
|
46
|
-
ruby: 2.5
|
36
|
+
ruby: 2.7
|
47
37
|
|
48
38
|
env:
|
49
39
|
BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/${{ matrix.gemfile }}.gemfile
|
40
|
+
CI: true
|
41
|
+
COVERALLS_REPO_TOKEN: izk0cvqAVqD2Vdews2UjsnOZHLgzocyQL
|
50
42
|
steps:
|
51
43
|
- uses: actions/checkout@v2
|
52
44
|
- uses: ruby/setup-ruby@v1
|
53
45
|
with:
|
54
46
|
ruby-version: ${{ matrix.ruby }}
|
55
47
|
bundler-cache: true
|
56
|
-
-
|
48
|
+
- name: RSpec and Rubocop
|
49
|
+
run: |
|
50
|
+
bundle exec rubocop -c .rubocop.yml
|
51
|
+
bundle exec rspec
|
@@ -23,4 +23,4 @@ jobs:
|
|
23
23
|
- name: Create RuboCop challenge pull request
|
24
24
|
env:
|
25
25
|
GITHUB_ACCESS_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
26
|
-
run: bundle exec rubocop_challenger go --base-branch=master --email=rubocop
|
26
|
+
run: bundle exec rubocop_challenger go --exclude-limit=180 --base-branch=master --email=rubocop@payrollhero.com --name="Rubocop Challenger" --mode=random
|
data/.rubocop.yml
CHANGED
@@ -1,12 +1,30 @@
|
|
1
|
+
require:
|
2
|
+
- rubocop-rails
|
3
|
+
- rubocop-rspec
|
4
|
+
- rubocop-performance
|
5
|
+
|
1
6
|
inherit_from:
|
2
7
|
- .rubocop_todo.yml
|
3
|
-
|
8
|
+
|
9
|
+
Rails:
|
10
|
+
Enabled: true
|
4
11
|
|
5
12
|
AllCops:
|
6
13
|
NewCops: enable
|
7
14
|
Exclude:
|
8
15
|
- '*.gemspec'
|
9
16
|
- 'Gemfile'
|
17
|
+
- vendor/bundle/ruby/**/*
|
18
|
+
|
19
|
+
RSpec/NotToNot:
|
20
|
+
SupportedStyles: to_not
|
21
|
+
# disable because an error is being raised
|
22
|
+
Enabled: false
|
23
|
+
|
24
|
+
Style/TrailingCommaInArrayLiteral:
|
25
|
+
EnforcedStyleForMultiline: consistent_comma
|
26
|
+
Style/TrailingCommaInHashLiteral:
|
27
|
+
EnforcedStyleForMultiline: consistent_comma
|
10
28
|
|
11
29
|
Style/Lambda:
|
12
30
|
Enabled: false
|
@@ -55,3 +73,24 @@ Metrics/AbcSize:
|
|
55
73
|
conditions.
|
56
74
|
Enabled: true
|
57
75
|
Max: 30
|
76
|
+
|
77
|
+
Metrics/BlockLength:
|
78
|
+
Max: 25
|
79
|
+
AllowedMethods:
|
80
|
+
- context
|
81
|
+
- describe
|
82
|
+
- define
|
83
|
+
|
84
|
+
Rails/RakeEnvironment:
|
85
|
+
Exclude:
|
86
|
+
- 'Rakefile'
|
87
|
+
|
88
|
+
Rails/ApplicationJob:
|
89
|
+
Exclude:
|
90
|
+
- 'lib/webhook_system/job.rb'
|
91
|
+
|
92
|
+
Rails/ApplicationRecord:
|
93
|
+
Exclude:
|
94
|
+
- 'lib/webhook_system/event_log.rb'
|
95
|
+
- 'lib/webhook_system/subscription.rb'
|
96
|
+
- 'lib/webhook_system/subscription_topic.rb'
|
data/.rubocop_todo.yml
CHANGED
@@ -1,61 +1,29 @@
|
|
1
1
|
# This configuration was generated by
|
2
|
-
# `rubocop --auto-gen-config`
|
3
|
-
# on
|
2
|
+
# `rubocop --auto-gen-config --exclude-limit 180`
|
3
|
+
# on 2023-10-30 03:57:18 UTC using RuboCop version 1.57.2.
|
4
4
|
# The point is for the user to remove these configuration records
|
5
5
|
# one by one as the offenses are removed from the code base.
|
6
6
|
# Note that changes in the inspected code, or installation of new
|
7
7
|
# versions of RuboCop, may require this file to be generated again.
|
8
8
|
|
9
9
|
# Offense count: 1
|
10
|
-
# This cop supports safe
|
10
|
+
# This cop supports safe autocorrection (--autocorrect).
|
11
11
|
# Configuration parameters: TreatCommentsAsGroupSeparators, ConsiderPunctuation, Include.
|
12
12
|
# Include: **/*.gemfile, **/Gemfile, **/gems.rb
|
13
13
|
Bundler/OrderedGems:
|
14
14
|
Exclude:
|
15
|
-
- 'gemfiles/
|
15
|
+
- 'gemfiles/rails_7.1.gemfile'
|
16
16
|
|
17
17
|
# Offense count: 1
|
18
|
-
# This cop supports
|
19
|
-
# Configuration parameters:
|
20
|
-
|
21
|
-
Layout/EmptyLinesAroundBlockBody:
|
22
|
-
Exclude:
|
23
|
-
- 'spec/encoder_spec.rb'
|
24
|
-
|
25
|
-
# Offense count: 2
|
26
|
-
# This cop supports safe auto-correction (--auto-correct).
|
27
|
-
# Configuration parameters: EnforcedStyle.
|
28
|
-
# SupportedStyles: space, no_space
|
29
|
-
Layout/SpaceAroundEqualsInParameterDefault:
|
30
|
-
Exclude:
|
31
|
-
- 'lib/webhook_system/base_event.rb'
|
32
|
-
- 'lib/webhook_system/job.rb'
|
33
|
-
|
34
|
-
# Offense count: 1
|
35
|
-
# This cop supports safe auto-correction (--auto-correct).
|
36
|
-
# Configuration parameters: AllowForAlignment, EnforcedStyleForExponentOperator.
|
37
|
-
# SupportedStylesForExponentOperator: space, no_space
|
38
|
-
Layout/SpaceAroundOperators:
|
18
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
19
|
+
# Configuration parameters: AllowSafeAssignment.
|
20
|
+
Lint/AssignmentInCondition:
|
39
21
|
Exclude:
|
40
22
|
- 'lib/webhook_system/subscription.rb'
|
41
23
|
|
42
|
-
# Offense count: 2
|
43
|
-
# This cop supports safe auto-correction (--auto-correct).
|
44
|
-
# Configuration parameters: EnforcedStyle.
|
45
|
-
# SupportedStyles: require_no_space, require_space
|
46
|
-
Layout/SpaceInLambdaLiteral:
|
47
|
-
Exclude:
|
48
|
-
- 'lib/webhook_system/subscription.rb'
|
49
|
-
|
50
|
-
# Offense count: 2
|
51
|
-
# This cop supports safe auto-correction (--auto-correct).
|
52
|
-
Lint/DeprecatedOpenSSLConstant:
|
53
|
-
Exclude:
|
54
|
-
- 'lib/webhook_system/encoder.rb'
|
55
|
-
|
56
24
|
# Offense count: 1
|
57
|
-
# This cop supports unsafe
|
58
|
-
Lint/
|
25
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
26
|
+
Lint/RedundantDirGlobSort:
|
59
27
|
Exclude:
|
60
28
|
- 'spec/spec_helper.rb'
|
61
29
|
|
@@ -64,114 +32,183 @@ Lint/UnreachableCode:
|
|
64
32
|
Exclude:
|
65
33
|
- 'lib/webhook_system/job.rb'
|
66
34
|
|
67
|
-
# Offense count:
|
68
|
-
# Configuration parameters: CountComments, CountAsOne,
|
69
|
-
|
70
|
-
|
71
|
-
Max: 112
|
35
|
+
# Offense count: 3
|
36
|
+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
37
|
+
Metrics/MethodLength:
|
38
|
+
Max: 18
|
72
39
|
|
73
40
|
# Offense count: 1
|
74
41
|
# Configuration parameters: MinNameLength, AllowNamesEndingInNumbers, AllowedNames, ForbiddenNames.
|
75
|
-
# AllowedNames: at, by, db, id, in, io, ip, of, on, os, pp, to
|
42
|
+
# AllowedNames: as, at, by, cc, db, id, if, in, io, ip, of, on, os, pp, to
|
76
43
|
Naming/MethodParameterName:
|
77
44
|
Exclude:
|
78
45
|
- 'lib/webhook_system/encoder.rb'
|
79
46
|
|
80
47
|
# Offense count: 1
|
81
|
-
# This cop supports safe
|
48
|
+
# This cop supports safe autocorrection (--autocorrect).
|
82
49
|
# Configuration parameters: PreferredName.
|
83
50
|
Naming/RescuedExceptionsVariableName:
|
84
51
|
Exclude:
|
85
|
-
- '
|
52
|
+
- 'spec/support/rails_seven_one.rb'
|
86
53
|
|
87
|
-
# Offense count:
|
88
|
-
#
|
89
|
-
|
54
|
+
# Offense count: 9
|
55
|
+
# Configuration parameters: Prefixes, AllowedPatterns.
|
56
|
+
# Prefixes: when, with, without
|
57
|
+
RSpec/ContextWording:
|
90
58
|
Exclude:
|
91
|
-
- '
|
59
|
+
- 'spec/encoder_spec.rb'
|
60
|
+
- 'spec/event_log_spec.rb'
|
61
|
+
- 'spec/event_spec.rb'
|
92
62
|
|
93
63
|
# Offense count: 1
|
94
|
-
#
|
95
|
-
|
64
|
+
# Configuration parameters: IgnoredMetadata.
|
65
|
+
RSpec/DescribeClass:
|
96
66
|
Exclude:
|
97
|
-
- '
|
67
|
+
- 'spec/dispatching_events_spec.rb'
|
98
68
|
|
99
|
-
#
|
100
|
-
# Configuration parameters:
|
101
|
-
|
102
|
-
|
69
|
+
# Offense count: 7
|
70
|
+
# Configuration parameters: CountAsOne.
|
71
|
+
RSpec/ExampleLength:
|
72
|
+
Max: 24
|
73
|
+
|
74
|
+
# Offense count: 4
|
75
|
+
# Configuration parameters: Include, CustomTransform, IgnoreMethods, SpecSuffixOnly.
|
76
|
+
# Include: **/*_spec*rb*, **/spec/**/*
|
77
|
+
RSpec/FilePath:
|
103
78
|
Exclude:
|
104
|
-
- '
|
79
|
+
- 'spec/encoder_spec.rb'
|
80
|
+
- 'spec/event_log_spec.rb'
|
81
|
+
- 'spec/event_spec.rb'
|
82
|
+
- 'spec/models_spec.rb'
|
105
83
|
|
106
|
-
# Offense count:
|
107
|
-
#
|
108
|
-
|
109
|
-
# SupportedStyles: predicate, comparison
|
110
|
-
Style/NumericPredicate:
|
84
|
+
# Offense count: 11
|
85
|
+
# Configuration parameters: Max, AllowedIdentifiers, AllowedPatterns.
|
86
|
+
RSpec/IndexedLet:
|
111
87
|
Exclude:
|
112
|
-
- 'spec
|
113
|
-
- '
|
88
|
+
- 'spec/dispatching_events_spec.rb'
|
89
|
+
- 'spec/encoder_spec.rb'
|
90
|
+
- 'spec/event_spec.rb'
|
91
|
+
- 'spec/integration_spec.rb'
|
92
|
+
- 'spec/models_spec.rb'
|
114
93
|
|
115
|
-
# Offense count:
|
116
|
-
|
117
|
-
Style/Proc:
|
94
|
+
# Offense count: 3
|
95
|
+
RSpec/LetSetup:
|
118
96
|
Exclude:
|
119
|
-
- '
|
97
|
+
- 'spec/dispatching_events_spec.rb'
|
98
|
+
- 'spec/integration_spec.rb'
|
120
99
|
|
121
|
-
# Offense count:
|
122
|
-
# This cop supports safe
|
123
|
-
|
100
|
+
# Offense count: 3
|
101
|
+
# This cop supports safe autocorrection (--autocorrect).
|
102
|
+
RSpec/MatchArray:
|
124
103
|
Exclude:
|
125
|
-
- '
|
104
|
+
- 'spec/models_spec.rb'
|
126
105
|
|
127
|
-
# Offense count:
|
128
|
-
# This cop supports safe
|
129
|
-
# Configuration parameters: EnforcedStyle
|
130
|
-
# SupportedStyles:
|
131
|
-
|
106
|
+
# Offense count: 10
|
107
|
+
# This cop supports safe autocorrection (--autocorrect).
|
108
|
+
# Configuration parameters: EnforcedStyle.
|
109
|
+
# SupportedStyles: hash, symbol
|
110
|
+
RSpec/MetadataStyle:
|
132
111
|
Exclude:
|
133
112
|
- 'spec/dispatching_events_spec.rb'
|
113
|
+
- 'spec/encoder_spec.rb'
|
114
|
+
- 'spec/event_log_spec.rb'
|
115
|
+
- 'spec/event_spec.rb'
|
116
|
+
- 'spec/integration_spec.rb'
|
117
|
+
- 'spec/models_spec.rb'
|
118
|
+
- 'spec/spec_helper.rb'
|
119
|
+
|
120
|
+
# Offense count: 15
|
121
|
+
# Configuration parameters: AllowSubject.
|
122
|
+
RSpec/MultipleMemoizedHelpers:
|
123
|
+
Max: 8
|
124
|
+
|
125
|
+
# Offense count: 9
|
126
|
+
# Configuration parameters: EnforcedStyle, IgnoreSharedExamples.
|
127
|
+
# SupportedStyles: always, named_only
|
128
|
+
RSpec/NamedSubject:
|
129
|
+
Exclude:
|
130
|
+
- 'spec/event_log_spec.rb'
|
131
|
+
|
132
|
+
# Offense count: 3
|
133
|
+
# Configuration parameters: AllowedGroups.
|
134
|
+
RSpec/NestedGroups:
|
135
|
+
Max: 4
|
136
|
+
|
137
|
+
# Offense count: 3
|
138
|
+
# This cop supports safe autocorrection (--autocorrect).
|
139
|
+
RSpec/ScatteredSetup:
|
140
|
+
Exclude:
|
141
|
+
- 'spec/models_spec.rb'
|
142
|
+
|
143
|
+
# Offense count: 4
|
144
|
+
# Configuration parameters: Include, CustomTransform, IgnoreMethods, IgnoreMetadata.
|
145
|
+
# Include: **/*_spec.rb
|
146
|
+
RSpec/SpecFilePathFormat:
|
147
|
+
Exclude:
|
148
|
+
- 'spec/encoder_spec.rb'
|
149
|
+
- 'spec/event_log_spec.rb'
|
150
|
+
- 'spec/event_spec.rb'
|
151
|
+
- 'spec/models_spec.rb'
|
134
152
|
|
135
153
|
# Offense count: 2
|
136
|
-
#
|
137
|
-
|
154
|
+
# Configuration parameters: IgnoreNameless, IgnoreSymbolicNames.
|
155
|
+
RSpec/VerifiedDoubles:
|
138
156
|
Exclude:
|
139
|
-
- '
|
157
|
+
- 'spec/event_log_spec.rb'
|
140
158
|
|
141
159
|
# Offense count: 1
|
142
|
-
# This cop supports unsafe
|
143
|
-
|
144
|
-
Style/StringConcatenation:
|
160
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
161
|
+
Rails/RedundantPresenceValidationOnBelongsTo:
|
145
162
|
Exclude:
|
163
|
+
- 'lib/webhook_system/event_log.rb'
|
164
|
+
|
165
|
+
# Offense count: 3
|
166
|
+
# Configuration parameters: AllowedConstants.
|
167
|
+
Style/Documentation:
|
168
|
+
Exclude:
|
169
|
+
- 'lib/webhook_system.rb'
|
146
170
|
- 'lib/webhook_system/encoder.rb'
|
171
|
+
- 'lib/webhook_system/subscription_topic.rb'
|
172
|
+
- 'spec/support/rails_seven_one.rb'
|
147
173
|
|
148
|
-
# Offense count:
|
149
|
-
# This cop supports safe
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
EnforcedStyle: brackets
|
174
|
+
# Offense count: 1
|
175
|
+
# This cop supports safe autocorrection (--autocorrect).
|
176
|
+
Style/MultilineIfModifier:
|
177
|
+
Exclude:
|
178
|
+
- 'spec/support/rails_seven_one.rb'
|
154
179
|
|
155
|
-
# Offense count:
|
156
|
-
# This cop supports safe
|
157
|
-
# Configuration parameters:
|
158
|
-
#
|
159
|
-
Style/
|
180
|
+
# Offense count: 1
|
181
|
+
# This cop supports safe autocorrection (--autocorrect).
|
182
|
+
# Configuration parameters: EnforcedStyle, AllowedCompactTypes.
|
183
|
+
# SupportedStyles: compact, exploded
|
184
|
+
Style/RaiseArgs:
|
185
|
+
Exclude:
|
186
|
+
- 'spec/support/rails_seven_one.rb'
|
187
|
+
|
188
|
+
# Offense count: 1
|
189
|
+
# This cop supports safe autocorrection (--autocorrect).
|
190
|
+
Style/RedundantConstantBase:
|
160
191
|
Exclude:
|
161
|
-
- 'spec/dispatching_events_spec.rb'
|
162
192
|
- 'spec/event_spec.rb'
|
163
|
-
- 'spec/integration_spec.rb'
|
164
193
|
|
165
|
-
# Offense count:
|
166
|
-
# This cop supports safe
|
167
|
-
|
168
|
-
# SupportedStylesForMultiline: comma, consistent_comma, no_comma
|
169
|
-
Style/TrailingCommaInHashLiteral:
|
194
|
+
# Offense count: 1
|
195
|
+
# This cop supports safe autocorrection (--autocorrect).
|
196
|
+
Style/RedundantFreeze:
|
170
197
|
Exclude:
|
171
|
-
- 'lib/webhook_system/base_event.rb'
|
172
|
-
- 'lib/webhook_system/encoder.rb'
|
173
|
-
- 'lib/webhook_system/event_log.rb'
|
174
198
|
- 'lib/webhook_system/subscription.rb'
|
175
|
-
|
176
|
-
|
177
|
-
|
199
|
+
|
200
|
+
# Offense count: 1
|
201
|
+
# This cop supports safe autocorrection (--autocorrect).
|
202
|
+
# Configuration parameters: EnforcedStyle, AllowInnerSlashes.
|
203
|
+
# SupportedStyles: slashes, percent_r, mixed
|
204
|
+
Style/RegexpLiteral:
|
205
|
+
Exclude:
|
206
|
+
- 'spec/dispatching_events_spec.rb'
|
207
|
+
|
208
|
+
# Offense count: 1
|
209
|
+
# This cop supports safe autocorrection (--autocorrect).
|
210
|
+
# Configuration parameters: EnforcedStyle.
|
211
|
+
# SupportedStyles: implicit, explicit
|
212
|
+
Style/RescueStandardError:
|
213
|
+
Exclude:
|
214
|
+
- 'spec/support/rails_seven_one.rb'
|
data/Gemfile
CHANGED
data/Rakefile
CHANGED
@@ -20,23 +20,21 @@ task :styleguide do
|
|
20
20
|
require 'faraday'
|
21
21
|
require 'pry'
|
22
22
|
base = "https://raw.githubusercontent.com/payrollhero/styleguide/master/"
|
23
|
-
files = %w
|
23
|
+
files = %w[
|
24
24
|
.rubocop.hound.yml
|
25
25
|
.rubocop.yml
|
26
26
|
.codeclimate.yml
|
27
|
-
|
27
|
+
]
|
28
28
|
files.each do |file|
|
29
29
|
puts "Fetching #{file} ..."
|
30
30
|
url = "#{base}#{file}"
|
31
31
|
rsp = Faraday.get(url)
|
32
32
|
unless rsp.status == 200
|
33
|
-
|
34
|
-
|
33
|
+
warn "failing fetching: #{url}"
|
34
|
+
warn " response: #{rsp.status}: #{rsp.body}"
|
35
35
|
exit 1
|
36
36
|
end
|
37
|
-
File.
|
38
|
-
fh.write(rsp.body)
|
39
|
-
end
|
37
|
+
File.write(file, rsp.body)
|
40
38
|
end
|
41
39
|
end
|
42
40
|
|
data/gemfiles/rails_6.1.gemfile
CHANGED
data/gemfiles/rails_7.0.gemfile
CHANGED
@@ -14,13 +14,17 @@ module WebhookSystem
|
|
14
14
|
attr_reader :event_id
|
15
15
|
|
16
16
|
def event_name
|
17
|
+
# :nocov:
|
17
18
|
mesg = "class #{self.class.name} must implement abstract method `#{self.class.name}#event_name()'."
|
18
19
|
raise with_caller_backtrace(RuntimeError.new(mesg), 2)
|
20
|
+
# :nocov:
|
19
21
|
end
|
20
22
|
|
21
23
|
def payload_attributes
|
24
|
+
# :nocov:
|
22
25
|
mesg = "class #{self.class.name} must implement abstract method `#{self.class.name}#payload_attributes()'."
|
23
26
|
raise with_caller_backtrace(RuntimeError.new(mesg), 2)
|
27
|
+
# :nocov:
|
24
28
|
end
|
25
29
|
|
26
30
|
def as_json
|
@@ -36,25 +40,28 @@ module WebhookSystem
|
|
36
40
|
end
|
37
41
|
|
38
42
|
def self.key_is_reserved?(key)
|
39
|
-
key.to_s.in? %w
|
43
|
+
key.to_s.in? %w[event event_id]
|
40
44
|
end
|
41
45
|
|
42
46
|
def self.dispatch(args)
|
43
|
-
WebhookSystem::Subscription.global.dispatch
|
47
|
+
WebhookSystem::Subscription.global.dispatch build(args)
|
44
48
|
end
|
45
49
|
|
46
50
|
private
|
47
51
|
|
48
|
-
def with_caller_backtrace(exception, backtrack=2)
|
49
|
-
|
52
|
+
def with_caller_backtrace(exception, backtrack = 2)
|
53
|
+
# :nocov:
|
54
|
+
exception.set_backtrace(caller[backtrack..])
|
50
55
|
exception
|
56
|
+
# :nocov:
|
51
57
|
end
|
52
58
|
|
53
59
|
def validate_attribute_name(key)
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
60
|
+
return unless self.class.key_is_reserved?(key)
|
61
|
+
|
62
|
+
message = "#{self.class.name} should not be defining an attribute named #{key} since its reserved"
|
63
|
+
raise ArgumentError, message
|
64
|
+
|
58
65
|
end
|
59
66
|
|
60
67
|
def each_attribute(&block)
|
@@ -66,7 +73,9 @@ module WebhookSystem
|
|
66
73
|
when Hash
|
67
74
|
payload_attributes.each(&block)
|
68
75
|
else
|
76
|
+
# :nocov:
|
69
77
|
raise ArgumentError, "don't know how to deal with payload_attributes: #{payload_attributes.inspect}"
|
78
|
+
# :nocov:
|
70
79
|
end
|
71
80
|
end
|
72
81
|
end
|
@@ -28,9 +28,7 @@ module WebhookSystem
|
|
28
28
|
format = format_for_content_type(headers.fetch('Content-Type'))
|
29
29
|
|
30
30
|
payload_signature = hub_signature(payload_string, secret_string)
|
31
|
-
if signature && signature != payload_signature
|
32
|
-
raise DecodingError, 'signature mismatch'
|
33
|
-
end
|
31
|
+
raise DecodingError, 'signature mismatch' if signature && signature != payload_signature
|
34
32
|
|
35
33
|
Payload.decode(payload_string, secret: secret_string, format: format)
|
36
34
|
end
|
@@ -41,7 +39,7 @@ module WebhookSystem
|
|
41
39
|
def content_type_format_map
|
42
40
|
{
|
43
41
|
'base64+aes256' => 'application/json; base64+aes256',
|
44
|
-
'json' => 'application/json'
|
42
|
+
'json' => 'application/json',
|
45
43
|
}
|
46
44
|
end
|
47
45
|
|
@@ -54,7 +52,7 @@ module WebhookSystem
|
|
54
52
|
end
|
55
53
|
|
56
54
|
def hub_signature(payload_string, secret)
|
57
|
-
|
55
|
+
"sha1=#{OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), secret, payload_string)}"
|
58
56
|
end
|
59
57
|
end
|
60
58
|
end
|
@@ -73,7 +71,7 @@ module WebhookSystem
|
|
73
71
|
end
|
74
72
|
|
75
73
|
def decode(response_body, secret:, format:)
|
76
|
-
payload = JSON.
|
74
|
+
payload = JSON.parse(response_body)
|
77
75
|
|
78
76
|
case format
|
79
77
|
when 'base64+aes256'
|
@@ -88,7 +86,7 @@ module WebhookSystem
|
|
88
86
|
private
|
89
87
|
|
90
88
|
def encode_aes(payload, secret)
|
91
|
-
cipher = OpenSSL::Cipher
|
89
|
+
cipher = OpenSSL::Cipher.new('aes-256-cbc')
|
92
90
|
cipher.encrypt
|
93
91
|
iv = cipher.random_iv
|
94
92
|
cipher.key = key_from_secret(iv, secret)
|
@@ -105,13 +103,13 @@ module WebhookSystem
|
|
105
103
|
encoded = Base64.decode64(payload['payload'])
|
106
104
|
iv = Base64.decode64(payload['iv'])
|
107
105
|
|
108
|
-
cipher = OpenSSL::Cipher
|
106
|
+
cipher = OpenSSL::Cipher.new('aes-256-cbc')
|
109
107
|
cipher.decrypt
|
110
108
|
cipher.iv = iv
|
111
109
|
cipher.key = key_from_secret(iv, secret)
|
112
110
|
decoded = cipher.update(encoded) + cipher.final
|
113
111
|
|
114
|
-
JSON.
|
112
|
+
JSON.parse(decoded)
|
115
113
|
rescue OpenSSL::Cipher::CipherError
|
116
114
|
raise DecodingError, 'Decoding Failed, probably mismatched secret'
|
117
115
|
end
|