ruby_dci 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.rspec +3 -0
- data/.rubocop.yml +480 -0
- data/.travis.yml +5 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +37 -0
- data/LICENSE.txt +21 -0
- data/README.md +39 -0
- data/Rakefile +6 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/lib/dci.rb +25 -0
- data/lib/dci/accessor.rb +9 -0
- data/lib/dci/configuration.rb +11 -0
- data/lib/dci/context.rb +52 -0
- data/lib/dci/event_router.rb +29 -0
- data/lib/dci/null_transaction.rb +7 -0
- data/lib/dci/role.rb +7 -0
- data/lib/dci/version.rb +3 -0
- data/ruby_dci.gemspec +34 -0
- metadata +108 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 762938fa7f8db22e7ea14f8bd054fa80ec846b727b59840ca37d705ca8e70ebc
|
4
|
+
data.tar.gz: 197db7e710f326106b6e651b428ecb9de2209b6d26c8fbd6bea85dbf39b2fe96
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 8d1da22eef9b8f6561b82b2a60277fe05cb6fa4b7dbff602b3202d29041eb4b0805ba6dc84ab4e627bfa4e2b429f63538e21acdbbb0ee057dd1a242c467e8d5c
|
7
|
+
data.tar.gz: 347083758996404aa4aecfb77b94acc064b7a9b85f3ba1ed5413fcfadf145a05e8b386a83b7079fdf7cc19e83896fa6bc5375db50c1cb4e88b36948d07e3b0a2
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,480 @@
|
|
1
|
+
require: rubocop-rspec
|
2
|
+
|
3
|
+
Rails:
|
4
|
+
Enabled: true
|
5
|
+
|
6
|
+
AllCops:
|
7
|
+
Include:
|
8
|
+
- Guardfile
|
9
|
+
- config.ru
|
10
|
+
- Rakefile
|
11
|
+
- "**/*.rake"
|
12
|
+
- Capfile
|
13
|
+
Exclude:
|
14
|
+
- node_modules/**/*
|
15
|
+
- bin/**/*
|
16
|
+
- db/**/*
|
17
|
+
- script/**/*
|
18
|
+
- tmp/**/*
|
19
|
+
- vendor/**/*
|
20
|
+
- gems/**/*
|
21
|
+
|
22
|
+
TargetRubyVersion: 2.5
|
23
|
+
|
24
|
+
TargetRailsVersion: 5.2
|
25
|
+
|
26
|
+
DefaultFormatter: simple
|
27
|
+
|
28
|
+
DisabledByDefault: true
|
29
|
+
|
30
|
+
Layout/BlockAlignment:
|
31
|
+
Enabled: true
|
32
|
+
|
33
|
+
Lint/DeprecatedClassMethods:
|
34
|
+
Enabled: true
|
35
|
+
|
36
|
+
Layout/DefEndAlignment:
|
37
|
+
Enabled: true
|
38
|
+
|
39
|
+
Lint/DuplicateMethods:
|
40
|
+
Enabled: true
|
41
|
+
|
42
|
+
Lint/DuplicateCaseCondition:
|
43
|
+
Enabled: true
|
44
|
+
|
45
|
+
Lint/EmptyEnsure:
|
46
|
+
Enabled: true
|
47
|
+
|
48
|
+
Lint/EmptyExpression:
|
49
|
+
Enabled: true
|
50
|
+
|
51
|
+
Lint/EmptyWhen:
|
52
|
+
Enabled: true
|
53
|
+
|
54
|
+
Layout/EndAlignment:
|
55
|
+
Enabled: true
|
56
|
+
|
57
|
+
Lint/ImplicitStringConcatenation:
|
58
|
+
Enabled: true
|
59
|
+
|
60
|
+
Lint/IneffectiveAccessModifier:
|
61
|
+
Enabled: true
|
62
|
+
|
63
|
+
Lint/NonLocalExitFromIterator:
|
64
|
+
Enabled: true
|
65
|
+
|
66
|
+
Lint/ShadowingOuterLocalVariable:
|
67
|
+
Enabled: true
|
68
|
+
|
69
|
+
Lint/StringConversionInInterpolation:
|
70
|
+
Enabled: true
|
71
|
+
|
72
|
+
Lint/UnreachableCode:
|
73
|
+
Enabled: true
|
74
|
+
|
75
|
+
Lint/UnusedBlockArgument:
|
76
|
+
Enabled: true
|
77
|
+
|
78
|
+
Lint/UnusedMethodArgument:
|
79
|
+
Enabled: true
|
80
|
+
|
81
|
+
Lint/UselessAccessModifier:
|
82
|
+
Enabled: true
|
83
|
+
|
84
|
+
Performance/CompareWithBlock:
|
85
|
+
Enabled: true
|
86
|
+
|
87
|
+
Performance/RangeInclude:
|
88
|
+
Enabled: true
|
89
|
+
|
90
|
+
Performance/StartWith:
|
91
|
+
Enabled: true
|
92
|
+
|
93
|
+
Performance/RedundantMatch:
|
94
|
+
Enabled: true
|
95
|
+
|
96
|
+
Performance/TimesMap:
|
97
|
+
Enabled: true
|
98
|
+
|
99
|
+
Rails/ActionFilter:
|
100
|
+
Enabled: true
|
101
|
+
|
102
|
+
Rails/Delegate:
|
103
|
+
Enabled: true
|
104
|
+
|
105
|
+
Rails/FindBy:
|
106
|
+
Enabled: true
|
107
|
+
|
108
|
+
Rails/Output:
|
109
|
+
Enabled: true
|
110
|
+
|
111
|
+
Rails/PluralizationGrammar:
|
112
|
+
Enabled: true
|
113
|
+
|
114
|
+
Rails/Validation:
|
115
|
+
Enabled: true
|
116
|
+
|
117
|
+
RSpec/DescribeMethod:
|
118
|
+
Enabled: true
|
119
|
+
|
120
|
+
RSpec/ExpectActual:
|
121
|
+
Enabled: true
|
122
|
+
|
123
|
+
RSpec/HookArgument:
|
124
|
+
Enabled: true
|
125
|
+
|
126
|
+
RSpec/ImplicitExpect:
|
127
|
+
Enabled: true
|
128
|
+
|
129
|
+
RSpec/RepeatedDescription:
|
130
|
+
Enabled: true
|
131
|
+
|
132
|
+
RSpec/RepeatedExample:
|
133
|
+
Enabled: true
|
134
|
+
|
135
|
+
Layout/AlignArray:
|
136
|
+
Enabled: true
|
137
|
+
|
138
|
+
Style/SymbolArray:
|
139
|
+
Enabled: true
|
140
|
+
EnforcedStyle: brackets
|
141
|
+
|
142
|
+
Style/WordArray:
|
143
|
+
Enabled: true
|
144
|
+
EnforcedStyle: brackets
|
145
|
+
|
146
|
+
Layout/AlignHash:
|
147
|
+
EnforcedHashRocketStyle: key
|
148
|
+
EnforcedColonStyle: key
|
149
|
+
Enabled: true
|
150
|
+
|
151
|
+
Layout/AlignParameters:
|
152
|
+
EnforcedStyle: with_first_parameter
|
153
|
+
Enabled: true
|
154
|
+
|
155
|
+
Style/AndOr:
|
156
|
+
EnforcedStyle: conditionals
|
157
|
+
Enabled: true
|
158
|
+
|
159
|
+
Style/AsciiComments:
|
160
|
+
Enabled: true
|
161
|
+
|
162
|
+
Style/Attr:
|
163
|
+
Enabled: true
|
164
|
+
|
165
|
+
Style/BlockDelimiters:
|
166
|
+
Enabled: true
|
167
|
+
|
168
|
+
Style/CaseEquality:
|
169
|
+
Enabled: true
|
170
|
+
|
171
|
+
Layout/CaseIndentation:
|
172
|
+
Enabled: true
|
173
|
+
|
174
|
+
Style/ClassAndModuleChildren:
|
175
|
+
Enabled: true
|
176
|
+
AutoCorrect: true
|
177
|
+
|
178
|
+
Style/ClassCheck:
|
179
|
+
Enabled: true
|
180
|
+
|
181
|
+
Layout/ClosingParenthesisIndentation:
|
182
|
+
Enabled: true
|
183
|
+
|
184
|
+
Style/ColonMethodCall:
|
185
|
+
Enabled: true
|
186
|
+
|
187
|
+
Layout/CommentIndentation:
|
188
|
+
Enabled: true
|
189
|
+
|
190
|
+
Style/ConditionalAssignment:
|
191
|
+
Enabled: true
|
192
|
+
|
193
|
+
Style/DefWithParentheses:
|
194
|
+
Enabled: true
|
195
|
+
|
196
|
+
Layout/DotPosition:
|
197
|
+
EnforcedStyle: trailing
|
198
|
+
Enabled: true
|
199
|
+
|
200
|
+
Style/EachWithObject:
|
201
|
+
Enabled: true
|
202
|
+
|
203
|
+
Layout/ElseAlignment:
|
204
|
+
Enabled: true
|
205
|
+
|
206
|
+
Layout/EmptyLineBetweenDefs:
|
207
|
+
Enabled: true
|
208
|
+
|
209
|
+
Layout/EmptyLines:
|
210
|
+
Enabled: true
|
211
|
+
|
212
|
+
Layout/EmptyLinesAroundMethodBody:
|
213
|
+
Enabled: true
|
214
|
+
|
215
|
+
Layout/EmptyLinesAroundModuleBody:
|
216
|
+
Enabled: true
|
217
|
+
|
218
|
+
Layout/ExtraSpacing:
|
219
|
+
Enabled: true
|
220
|
+
|
221
|
+
Style/EmptyElse:
|
222
|
+
Enabled: true
|
223
|
+
|
224
|
+
Layout/EmptyLinesAroundBlockBody:
|
225
|
+
Enabled: true
|
226
|
+
|
227
|
+
Style/EvenOdd:
|
228
|
+
Enabled: true
|
229
|
+
|
230
|
+
Naming/FileName:
|
231
|
+
Enabled: true
|
232
|
+
Exclude:
|
233
|
+
- Gemfile
|
234
|
+
|
235
|
+
Layout/FirstParameterIndentation:
|
236
|
+
Enabled: true
|
237
|
+
|
238
|
+
Style/For:
|
239
|
+
Enabled: true
|
240
|
+
|
241
|
+
Style/HashSyntax:
|
242
|
+
EnforcedStyle: ruby19_no_mixed_keys
|
243
|
+
Enabled: true
|
244
|
+
|
245
|
+
Style/IdenticalConditionalBranches:
|
246
|
+
Enabled: true
|
247
|
+
|
248
|
+
Style/IfInsideElse:
|
249
|
+
Enabled: true
|
250
|
+
|
251
|
+
Layout/IndentArray:
|
252
|
+
Enabled: true
|
253
|
+
|
254
|
+
Layout/IndentAssignment:
|
255
|
+
Enabled: true
|
256
|
+
|
257
|
+
Layout/IndentationConsistency:
|
258
|
+
Enabled: true
|
259
|
+
|
260
|
+
Layout/IndentationWidth:
|
261
|
+
Enabled: true
|
262
|
+
|
263
|
+
Style/MethodCallWithoutArgsParentheses:
|
264
|
+
Enabled: true
|
265
|
+
|
266
|
+
Style/MethodDefParentheses:
|
267
|
+
Enabled: true
|
268
|
+
EnforcedStyle: require_parentheses
|
269
|
+
|
270
|
+
Naming/MethodName:
|
271
|
+
Enabled: true
|
272
|
+
|
273
|
+
Layout/MultilineBlockLayout:
|
274
|
+
Enabled: true
|
275
|
+
|
276
|
+
Layout/MultilineMethodCallBraceLayout:
|
277
|
+
EnforcedStyle: symmetrical
|
278
|
+
Enabled: true
|
279
|
+
|
280
|
+
Layout/MultilineMethodCallIndentation:
|
281
|
+
Enabled: true
|
282
|
+
|
283
|
+
Layout/MultilineOperationIndentation:
|
284
|
+
Enabled: true
|
285
|
+
|
286
|
+
Style/MultilineTernaryOperator:
|
287
|
+
Enabled: true
|
288
|
+
|
289
|
+
Style/MutableConstant:
|
290
|
+
Enabled: true
|
291
|
+
|
292
|
+
Style/NegatedWhile:
|
293
|
+
Enabled: true
|
294
|
+
|
295
|
+
Style/NestedParenthesizedCalls:
|
296
|
+
Enabled: true
|
297
|
+
|
298
|
+
Style/NestedTernaryOperator:
|
299
|
+
Enabled: true
|
300
|
+
|
301
|
+
Style/NumericLiteralPrefix:
|
302
|
+
Enabled: true
|
303
|
+
|
304
|
+
Style/ParenthesesAroundCondition:
|
305
|
+
Enabled: true
|
306
|
+
|
307
|
+
Style/RedundantReturn:
|
308
|
+
Enabled: true
|
309
|
+
|
310
|
+
Style/RedundantSelf:
|
311
|
+
Enabled: true
|
312
|
+
|
313
|
+
Layout/RescueEnsureAlignment:
|
314
|
+
Enabled: true
|
315
|
+
|
316
|
+
Style/SafeNavigation:
|
317
|
+
Enabled: true
|
318
|
+
|
319
|
+
Style/SelfAssignment:
|
320
|
+
Enabled: true
|
321
|
+
|
322
|
+
Style/SignalException:
|
323
|
+
Enabled: true
|
324
|
+
|
325
|
+
Layout/SpaceAfterComma:
|
326
|
+
Enabled: true
|
327
|
+
|
328
|
+
Layout/SpaceAfterColon:
|
329
|
+
Enabled: true
|
330
|
+
|
331
|
+
Layout/SpaceAfterMethodName:
|
332
|
+
Enabled: true
|
333
|
+
|
334
|
+
Layout/SpaceAroundEqualsInParameterDefault:
|
335
|
+
Enabled: true
|
336
|
+
|
337
|
+
Layout/SpaceAroundKeyword:
|
338
|
+
Enabled: true
|
339
|
+
|
340
|
+
Layout/SpaceAroundOperators:
|
341
|
+
Enabled: true
|
342
|
+
|
343
|
+
Layout/SpaceBeforeBlockBraces:
|
344
|
+
Enabled: true
|
345
|
+
|
346
|
+
Layout/SpaceAroundBlockParameters:
|
347
|
+
Enabled: true
|
348
|
+
|
349
|
+
Layout/SpaceBeforeComma:
|
350
|
+
Enabled: true
|
351
|
+
|
352
|
+
Layout/SpaceBeforeComment:
|
353
|
+
Enabled: true
|
354
|
+
|
355
|
+
Layout/SpaceBeforeFirstArg:
|
356
|
+
Enabled: true
|
357
|
+
|
358
|
+
Layout/SpaceInsideBlockBraces:
|
359
|
+
Enabled: true
|
360
|
+
|
361
|
+
Layout/SpaceInsideReferenceBrackets:
|
362
|
+
EnforcedStyle: no_space
|
363
|
+
Enabled: true
|
364
|
+
|
365
|
+
Layout/SpaceInsideHashLiteralBraces:
|
366
|
+
EnforcedStyle: space
|
367
|
+
Enabled: true
|
368
|
+
|
369
|
+
Layout/SpaceInsideParens:
|
370
|
+
Enabled: true
|
371
|
+
|
372
|
+
Layout/SpaceInsideStringInterpolation:
|
373
|
+
EnforcedStyle: space
|
374
|
+
Enabled: true
|
375
|
+
|
376
|
+
Style/StringLiterals:
|
377
|
+
EnforcedStyle: double_quotes
|
378
|
+
Enabled: true
|
379
|
+
|
380
|
+
Style/SymbolLiteral:
|
381
|
+
Enabled: true
|
382
|
+
|
383
|
+
Layout/Tab:
|
384
|
+
Enabled: true
|
385
|
+
|
386
|
+
Layout/TrailingBlankLines:
|
387
|
+
Enabled: true
|
388
|
+
|
389
|
+
Style/TrailingCommaInArguments:
|
390
|
+
Enabled: true
|
391
|
+
|
392
|
+
Style/TrailingCommaInHashLiteral:
|
393
|
+
Enabled: true
|
394
|
+
|
395
|
+
Style/TrailingCommaInArrayLiteral:
|
396
|
+
Enabled: true
|
397
|
+
|
398
|
+
Layout/TrailingWhitespace:
|
399
|
+
Enabled: true
|
400
|
+
|
401
|
+
Naming/VariableName:
|
402
|
+
Enabled: true
|
403
|
+
|
404
|
+
Style/WhileUntilDo:
|
405
|
+
Enabled: true
|
406
|
+
|
407
|
+
Style/ClassMethods:
|
408
|
+
Enabled: true
|
409
|
+
|
410
|
+
Lint/UselessAssignment:
|
411
|
+
Enabled: true
|
412
|
+
|
413
|
+
Lint/Void:
|
414
|
+
Enabled: true
|
415
|
+
|
416
|
+
Rails/Date:
|
417
|
+
EnforcedStyle: flexible
|
418
|
+
Enabled: true
|
419
|
+
|
420
|
+
Rails/DynamicFindBy:
|
421
|
+
Enabled: true
|
422
|
+
|
423
|
+
Rails/TimeZone:
|
424
|
+
Enabled: true
|
425
|
+
|
426
|
+
RSpec/AnyInstance:
|
427
|
+
Enabled: true
|
428
|
+
|
429
|
+
RSpec/MessageSpies:
|
430
|
+
Enabled: true
|
431
|
+
|
432
|
+
RSpec/NamedSubject:
|
433
|
+
Enabled: true
|
434
|
+
|
435
|
+
RSpec/ScatteredSetup:
|
436
|
+
Enabled: true
|
437
|
+
|
438
|
+
RSpec/VerifiedDoubles:
|
439
|
+
Enabled: true
|
440
|
+
|
441
|
+
Style/GuardClause:
|
442
|
+
Enabled: true
|
443
|
+
|
444
|
+
Layout/SpaceInLambdaLiteral:
|
445
|
+
EnforcedStyle: require_space
|
446
|
+
Enabled: true
|
447
|
+
|
448
|
+
Layout/EmptyLinesAroundAccessModifier:
|
449
|
+
Enabled: true
|
450
|
+
|
451
|
+
Style/Lambda:
|
452
|
+
EnforcedStyle: literal
|
453
|
+
|
454
|
+
Style/BracesAroundHashParameters:
|
455
|
+
EnforcedStyle: context_dependent
|
456
|
+
Enabled: true
|
457
|
+
|
458
|
+
Layout/EmptyLinesAroundClassBody:
|
459
|
+
EnforcedStyle: empty_lines_except_namespace
|
460
|
+
Enabled: true
|
461
|
+
|
462
|
+
Layout/EmptyLinesAroundModuleBody:
|
463
|
+
EnforcedStyle: empty_lines_except_namespace
|
464
|
+
Enabled: true
|
465
|
+
|
466
|
+
Layout/EmptyLinesAroundExceptionHandlingKeywords:
|
467
|
+
Enabled: true
|
468
|
+
|
469
|
+
Layout/SpaceInsideArrayLiteralBrackets:
|
470
|
+
EnforcedStyle: no_space
|
471
|
+
|
472
|
+
Style/StabbyLambdaParentheses:
|
473
|
+
Enabled: true
|
474
|
+
|
475
|
+
Layout/AccessModifierIndentation:
|
476
|
+
Enabled: true
|
477
|
+
|
478
|
+
Layout/IndentHash:
|
479
|
+
EnforcedStyle: consistent
|
480
|
+
Enabled: true
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
ruby_dci (0.1.0)
|
5
|
+
|
6
|
+
GEM
|
7
|
+
remote: https://rubygems.org/
|
8
|
+
specs:
|
9
|
+
byebug (10.0.2)
|
10
|
+
diff-lcs (1.3)
|
11
|
+
rake (10.5.0)
|
12
|
+
rspec (3.7.0)
|
13
|
+
rspec-core (~> 3.7.0)
|
14
|
+
rspec-expectations (~> 3.7.0)
|
15
|
+
rspec-mocks (~> 3.7.0)
|
16
|
+
rspec-core (3.7.1)
|
17
|
+
rspec-support (~> 3.7.0)
|
18
|
+
rspec-expectations (3.7.0)
|
19
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
20
|
+
rspec-support (~> 3.7.0)
|
21
|
+
rspec-mocks (3.7.0)
|
22
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
23
|
+
rspec-support (~> 3.7.0)
|
24
|
+
rspec-support (3.7.1)
|
25
|
+
|
26
|
+
PLATFORMS
|
27
|
+
ruby
|
28
|
+
|
29
|
+
DEPENDENCIES
|
30
|
+
bundler (~> 1.16)
|
31
|
+
byebug
|
32
|
+
rake (~> 10.0)
|
33
|
+
rspec (~> 3.0)
|
34
|
+
ruby_dci!
|
35
|
+
|
36
|
+
BUNDLED WITH
|
37
|
+
1.16.1
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2018 Aleksandr Lossenko
|
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,39 @@
|
|
1
|
+
# RubyDci
|
2
|
+
|
3
|
+
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/ruby_dci`. To experiment with that code, run `bin/console` for an interactive prompt.
|
4
|
+
|
5
|
+
TODO: Delete this and the text above, and describe your gem
|
6
|
+
|
7
|
+
## Installation
|
8
|
+
|
9
|
+
Add this line to your application's Gemfile:
|
10
|
+
|
11
|
+
```ruby
|
12
|
+
gem 'ruby_dci'
|
13
|
+
```
|
14
|
+
|
15
|
+
And then execute:
|
16
|
+
|
17
|
+
$ bundle
|
18
|
+
|
19
|
+
Or install it yourself as:
|
20
|
+
|
21
|
+
$ gem install ruby_dci
|
22
|
+
|
23
|
+
## Usage
|
24
|
+
|
25
|
+
TODO: Write usage instructions here
|
26
|
+
|
27
|
+
## Development
|
28
|
+
|
29
|
+
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.
|
30
|
+
|
31
|
+
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).
|
32
|
+
|
33
|
+
## Contributing
|
34
|
+
|
35
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/ruby_dci.
|
36
|
+
|
37
|
+
## License
|
38
|
+
|
39
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "dci"
|
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
data/lib/dci.rb
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
require "dci/version"
|
2
|
+
require "dci/null_transaction"
|
3
|
+
require "dci/configuration"
|
4
|
+
require "dci/accessor"
|
5
|
+
require "dci/event_router"
|
6
|
+
require "dci/context"
|
7
|
+
require "dci/role"
|
8
|
+
|
9
|
+
module DCI
|
10
|
+
class << self
|
11
|
+
attr_accessor :configuration
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.configuration
|
15
|
+
@configuration ||= Configuration.new
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.reset
|
19
|
+
@configuration = Configuration.new
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.configure
|
23
|
+
yield(configuration)
|
24
|
+
end
|
25
|
+
end
|
data/lib/dci/accessor.rb
ADDED
data/lib/dci/context.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
module DCI
|
2
|
+
|
3
|
+
module Context
|
4
|
+
|
5
|
+
include EventRouter
|
6
|
+
include Accessor
|
7
|
+
|
8
|
+
attr_accessor :events
|
9
|
+
|
10
|
+
def self.included(base)
|
11
|
+
base.send :include, InstanceMethods
|
12
|
+
base.extend ClassMethods
|
13
|
+
end
|
14
|
+
|
15
|
+
module InstanceMethods
|
16
|
+
|
17
|
+
def perform_in_transaction
|
18
|
+
old_context = context
|
19
|
+
@events = []
|
20
|
+
self.context = self
|
21
|
+
|
22
|
+
res = nil
|
23
|
+
|
24
|
+
DCI.configuration.transaction_class.transaction do
|
25
|
+
res = call
|
26
|
+
end
|
27
|
+
|
28
|
+
route_events!(events)
|
29
|
+
res
|
30
|
+
ensure
|
31
|
+
self.context = old_context
|
32
|
+
self.events.clear
|
33
|
+
end
|
34
|
+
|
35
|
+
def context=(ctx)
|
36
|
+
Thread.current[:context] = ctx
|
37
|
+
end
|
38
|
+
|
39
|
+
def call
|
40
|
+
raise NotImplementedError.new("implement me")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
module ClassMethods
|
45
|
+
def call(*args)
|
46
|
+
new(*args).perform_in_transaction
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module DCI
|
2
|
+
|
3
|
+
module EventRouter
|
4
|
+
|
5
|
+
private
|
6
|
+
def route_events!(events)
|
7
|
+
Array(events).each(&method(:route_event!))
|
8
|
+
end
|
9
|
+
|
10
|
+
def route_event!(event)
|
11
|
+
DCI.configuration.event_routes[event.class].each do |callback|
|
12
|
+
dispatch_catching_standard_errors do
|
13
|
+
DCI.configuration.route_methods.method(callback).call(event)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def dispatch_catching_standard_errors(&block)
|
19
|
+
begin
|
20
|
+
block.call
|
21
|
+
rescue StandardError => e
|
22
|
+
Rails.logger.error "Failed to dispatch event (transaction was still commited). #{ e }"
|
23
|
+
raise e unless Rails.env.production?
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/lib/dci/role.rb
ADDED
data/lib/dci/version.rb
ADDED
data/ruby_dci.gemspec
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
lib = File.expand_path("../lib", __FILE__)
|
2
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
3
|
+
require "dci/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "ruby_dci"
|
7
|
+
spec.version = ::DCI::VERSION
|
8
|
+
spec.authors = ["Aleksandr Lossenko"]
|
9
|
+
spec.email = ["aleksandr@byteflip.de"]
|
10
|
+
|
11
|
+
spec.summary = %q{Opinionated DCI implementation for ruby.}
|
12
|
+
spec.description = %q{Provides base modules for DCI contexts, roles and event processing that should happen outside of the context transaction.}
|
13
|
+
spec.homepage = "https://github.com/egze/ruby_dci"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
# Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
|
17
|
+
# to allow pushing to a single host or delete this section to allow pushing to any host.
|
18
|
+
if spec.respond_to?(:metadata)
|
19
|
+
spec.metadata["allowed_push_host"] = "https://rubygems.org"
|
20
|
+
else
|
21
|
+
raise "RubyGems 2.0 or newer is required to protect against " \
|
22
|
+
"public gem pushes."
|
23
|
+
end
|
24
|
+
|
25
|
+
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
26
|
+
f.match(%r{^(test|spec|features)/})
|
27
|
+
end
|
28
|
+
|
29
|
+
spec.require_paths = ["lib"]
|
30
|
+
|
31
|
+
spec.add_development_dependency "bundler", "~> 1.16"
|
32
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
33
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
34
|
+
end
|
metadata
ADDED
@@ -0,0 +1,108 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ruby_dci
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Aleksandr Lossenko
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2018-05-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.16'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.16'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
description: Provides base modules for DCI contexts, roles and event processing that
|
56
|
+
should happen outside of the context transaction.
|
57
|
+
email:
|
58
|
+
- aleksandr@byteflip.de
|
59
|
+
executables: []
|
60
|
+
extensions: []
|
61
|
+
extra_rdoc_files: []
|
62
|
+
files:
|
63
|
+
- ".gitignore"
|
64
|
+
- ".rspec"
|
65
|
+
- ".rubocop.yml"
|
66
|
+
- ".travis.yml"
|
67
|
+
- Gemfile
|
68
|
+
- Gemfile.lock
|
69
|
+
- LICENSE.txt
|
70
|
+
- README.md
|
71
|
+
- Rakefile
|
72
|
+
- bin/console
|
73
|
+
- bin/setup
|
74
|
+
- lib/dci.rb
|
75
|
+
- lib/dci/accessor.rb
|
76
|
+
- lib/dci/configuration.rb
|
77
|
+
- lib/dci/context.rb
|
78
|
+
- lib/dci/event_router.rb
|
79
|
+
- lib/dci/null_transaction.rb
|
80
|
+
- lib/dci/role.rb
|
81
|
+
- lib/dci/version.rb
|
82
|
+
- ruby_dci.gemspec
|
83
|
+
homepage: https://github.com/egze/ruby_dci
|
84
|
+
licenses:
|
85
|
+
- MIT
|
86
|
+
metadata:
|
87
|
+
allowed_push_host: https://rubygems.org
|
88
|
+
post_install_message:
|
89
|
+
rdoc_options: []
|
90
|
+
require_paths:
|
91
|
+
- lib
|
92
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '0'
|
102
|
+
requirements: []
|
103
|
+
rubyforge_project:
|
104
|
+
rubygems_version: 2.7.3
|
105
|
+
signing_key:
|
106
|
+
specification_version: 4
|
107
|
+
summary: Opinionated DCI implementation for ruby.
|
108
|
+
test_files: []
|