notebroker 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: 966658274251d2f4ada02bd952ea13089c823290073ba9920abf7450aaa6f84b
4
+ data.tar.gz: 6efd22a408432c4d3becb0f06de6694366d86c93f633553730c3f19e03e89439
5
+ SHA512:
6
+ metadata.gz: 9322946fac86264abc9e05431633c8923c822a85fdad23c66796cd97550e93fb8c2d79453d77822be142765ac072ae08691c5b0ebd06531154c7c27087df58d6
7
+ data.tar.gz: e13c1d6d050e531d1a355d624dc251f9165eb1bf212bcdd4659039ac1760e658fa21561d7ea7e0ffdacb055ff268a68da982e42e7348b426255471918056c43b
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,490 @@
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rake
4
+ - rubocop-rspec
5
+
6
+ # ==================== Main ==========================
7
+ AllCops:
8
+ NewCops: enable
9
+ DisplayCopNames: true
10
+ Exclude:
11
+ - "bin/**/*"
12
+ - "db/schema.rb"
13
+ - "node_modules/**/*"
14
+ - "tmp/**/*"
15
+ - "vendor/**/*"
16
+ Bundler/InsecureProtocolSource:
17
+ AllowHttpProtocol: false
18
+ Gemspec/DateAssignment:
19
+ Enabled: true
20
+ Gemspec/RequireMFA:
21
+ Enabled: true
22
+ Layout/BeginEndAlignment:
23
+ Enabled: true
24
+ EnforcedStyleAlignWith: begin
25
+ Layout/CaseIndentation:
26
+ IndentOneStep: true
27
+ Layout/ClassStructure:
28
+ Enabled: true
29
+ Categories:
30
+ module_inclusion:
31
+ - extend
32
+ - include
33
+ - prepend
34
+ associations:
35
+ - belongs_to
36
+ - has_one
37
+ - has_many
38
+ ExpectedOrder:
39
+ - module_inclusion
40
+ - constants
41
+ - associations
42
+ - public_class_methods
43
+ - initializer
44
+ - public_methods
45
+ - protected_methods
46
+ - private_methods
47
+ Layout/CommentIndentation:
48
+ AllowForAlignment: true
49
+ Layout/EmptyLineAfterMultilineCondition:
50
+ Enabled: true
51
+ Layout/EmptyLinesAroundAttributeAccessor:
52
+ Enabled: true
53
+ AllowAliasSyntax: false
54
+ AllowedMethods: []
55
+ Layout/FirstArrayElementIndentation:
56
+ EnforcedStyle: consistent
57
+ Layout/FirstArrayElementLineBreak:
58
+ Enabled: true
59
+ Layout/FirstHashElementIndentation:
60
+ EnforcedStyle: consistent
61
+ Layout/FirstHashElementLineBreak:
62
+ Enabled: true
63
+ Layout/FirstMethodArgumentLineBreak:
64
+ Enabled: true
65
+ Layout/FirstMethodParameterLineBreak:
66
+ Enabled: true
67
+ Layout/LineEndStringConcatenationIndentation:
68
+ Enabled: true
69
+ IndentationWidth: 0
70
+ Layout/LineLength:
71
+ Max: 100
72
+ Layout/MultilineArrayLineBreaks:
73
+ Enabled: true
74
+ Layout/MultilineAssignmentLayout:
75
+ Enabled: true
76
+ EnforcedStyle: same_line
77
+ Layout/MultilineHashKeyLineBreaks:
78
+ Enabled: true
79
+ Layout/MultilineMethodArgumentLineBreaks:
80
+ Enabled: true
81
+ Layout/RedundantLineBreak:
82
+ Enabled: false
83
+ Layout/SingleLineBlockChain:
84
+ Enabled: true
85
+ Layout/SpaceAroundMethodCallOperator:
86
+ Enabled: true
87
+ Layout/SpaceBeforeBrackets:
88
+ Enabled: true
89
+ Layout/SpaceInsideHashLiteralBraces:
90
+ EnforcedStyle: no_space
91
+ Layout/TrailingWhitespace:
92
+ AllowInHeredoc: false
93
+ Lint/AmbiguousAssignment:
94
+ Enabled: true
95
+ Lint/AmbiguousOperatorPrecedence:
96
+ Enabled: true
97
+ Lint/AmbiguousRange:
98
+ Enabled: true
99
+ Lint/BinaryOperatorWithIdenticalOperands:
100
+ Enabled: true
101
+ Lint/ConstantDefinitionInBlock:
102
+ Enabled: true
103
+ Lint/DeprecatedConstants:
104
+ Enabled: true
105
+ Lint/DeprecatedOpenSSLConstant:
106
+ Enabled: true
107
+ Lint/DuplicateBranch:
108
+ Enabled: true
109
+ Lint/DuplicateElsifCondition:
110
+ Enabled: true
111
+ Lint/DuplicateRegexpCharacterClassElement:
112
+ Enabled: true
113
+ Lint/DuplicateRescueException:
114
+ Enabled: true
115
+ Lint/DuplicateRequire:
116
+ Enabled: true
117
+ Lint/ElseLayout:
118
+ Enabled: false
119
+ Lint/EmptyBlock:
120
+ Enabled: true
121
+ AllowComments: false
122
+ AllowEmptyLambdas: false
123
+ Lint/EmptyClass:
124
+ Enabled: true
125
+ Lint/EmptyConditionalBody:
126
+ Enabled: true
127
+ Lint/EmptyFile:
128
+ Enabled: true
129
+ AllowComments: true
130
+ Lint/EmptyInPattern:
131
+ Enabled: true
132
+ AllowComments: false
133
+ Lint/EmptyWhen:
134
+ AllowComments: false
135
+ Lint/FloatComparison:
136
+ Enabled: true
137
+ Lint/HashCompareByIdentity:
138
+ Enabled: true
139
+ Lint/IdentityComparison:
140
+ Enabled: true
141
+ Lint/IncompatibleIoSelectWithFiberScheduler:
142
+ Enabled: true
143
+ Lint/LambdaWithoutLiteralBlock:
144
+ Enabled: true
145
+ Lint/MissingSuper:
146
+ Enabled: true
147
+ Lint/MixedRegexpCaptureTypes:
148
+ Enabled: true
149
+ Lint/NoReturnInBeginEndBlocks:
150
+ Enabled: true
151
+ Lint/NumberedParameterAssignment:
152
+ Enabled: true
153
+ Lint/OrAssignmentToConstant:
154
+ Enabled: true
155
+ Lint/RaiseException:
156
+ Enabled: true
157
+ Lint/RedundantDirGlobSort:
158
+ Enabled: true
159
+ Lint/RedundantSafeNavigation:
160
+ Enabled: true
161
+ Lint/RequireRelativeSelfPath:
162
+ Enabled: true
163
+ Lint/SelfAssignment:
164
+ Enabled: true
165
+ Lint/StructNewOverride:
166
+ Enabled: true
167
+ Lint/SymbolConversion:
168
+ Enabled: true
169
+ Lint/ToEnumArguments:
170
+ Enabled: true
171
+ Lint/TopLevelReturnWithArgument:
172
+ Enabled: true
173
+ Lint/TrailingCommaInAttributeDeclaration:
174
+ Enabled: true
175
+ Lint/TripleQuotes:
176
+ Enabled: true
177
+ Lint/OutOfRangeRegexpRef:
178
+ Enabled: true
179
+ Lint/UnexpectedBlockArity:
180
+ Enabled: true
181
+ Lint/UnmodifiedReduceAccumulator:
182
+ Enabled: true
183
+ Lint/UnreachableLoop:
184
+ Enabled: true
185
+ Lint/UselessMethodDefinition:
186
+ Enabled: true
187
+ AllowComments: false
188
+ Lint/UselessRuby2Keywords:
189
+ Enabled: true
190
+ Lint/UselessTimes:
191
+ Enabled: true
192
+ Lint/Void:
193
+ CheckForMethodsWithNoSideEffects: true
194
+ Metrics/BlockLength:
195
+ IgnoredMethods:
196
+ - ips
197
+ - refine
198
+ Exclude:
199
+ - "**/*.gemspec"
200
+ - "spec/**/*"
201
+ Metrics/ParameterLists:
202
+ Max: 3
203
+ Naming/BlockForwarding:
204
+ Enabled: true
205
+ Naming/InclusiveLanguage:
206
+ Enabled: true
207
+ Naming/MethodName:
208
+ IgnoredPatterns:
209
+ - Array
210
+ - BigDecimal
211
+ - Complex
212
+ - Float
213
+ - Hash
214
+ - Integer
215
+ - JSON
216
+ - Pathname
217
+ - Rational
218
+ - String
219
+ - URI
220
+ - Version
221
+ Naming/RescuedExceptionsVariableName:
222
+ PreferredName: error
223
+ Naming/VariableNumber:
224
+ EnforcedStyle: snake_case
225
+ AllowedIdentifiers:
226
+ - capture3
227
+ Naming/MethodParameterName:
228
+ AllowNamesEndingInNumbers: false
229
+ Security/IoMethods:
230
+ Enabled: true
231
+ Style/AccessorGrouping:
232
+ Enabled: true
233
+ Style/ArgumentsForwarding:
234
+ Enabled: false
235
+ Style/ArrayCoercion:
236
+ Enabled: true
237
+ Style/AndOr:
238
+ EnforcedStyle: conditionals
239
+ Style/AutoResourceCleanup:
240
+ Enabled: true
241
+ Style/BisectedAttrAccessor:
242
+ Enabled: true
243
+ Style/CaseLikeIf:
244
+ Enabled: true
245
+ Style/ClassEqualityComparison:
246
+ Enabled: true
247
+ Style/ClassMethodsDefinitions:
248
+ Enabled: true
249
+ Style/CombinableLoops:
250
+ Enabled: true
251
+ Style/CollectionCompact:
252
+ Enabled: true
253
+ Style/CollectionMethods:
254
+ Enabled: true
255
+ Style/Documentation:
256
+ Enabled: false
257
+ Style/DocumentDynamicEvalDefinition:
258
+ Enabled: false
259
+ Style/DoubleNegation:
260
+ EnforcedStyle: forbidden
261
+ Style/EmptyLiteral:
262
+ Enabled: false
263
+ Style/EmptyMethod:
264
+ EnforcedStyle: expanded
265
+ Style/EndlessMethod:
266
+ Enabled: true
267
+ Style/ExplicitBlockArgument:
268
+ Enabled: false
269
+ Style/ExponentialNotation:
270
+ Enabled: true
271
+ Style/FileRead:
272
+ Enabled: true
273
+ Style/FileWrite:
274
+ Enabled: true
275
+ Style/FormatStringToken:
276
+ EnforcedStyle: template
277
+ Style/GlobalStdStream:
278
+ Enabled: false
279
+ Style/HashAsLastArrayItem:
280
+ Enabled: true
281
+ Style/HashConversion:
282
+ Enabled: true
283
+ Style/HashEachMethods:
284
+ Enabled: true
285
+ Style/HashExcept:
286
+ Enabled: true
287
+ Style/HashLikeCase:
288
+ Enabled: true
289
+ MinBranchesCount: 2
290
+ Style/HashTransformKeys:
291
+ Enabled: true
292
+ Style/HashTransformValues:
293
+ Enabled: true
294
+ Style/IfWithBooleanLiteralBranches:
295
+ Enabled: true
296
+ Style/ImplicitRuntimeError:
297
+ Enabled: true
298
+ Style/InPatternThen:
299
+ Enabled: true
300
+ Style/IpAddresses:
301
+ Enabled: true
302
+ Style/KeywordParametersOrder:
303
+ Enabled: true
304
+ Style/MapToHash:
305
+ Enabled: true
306
+ Style/MethodCalledOnDoEndBlock:
307
+ Enabled: true
308
+ Style/MethodCallWithArgsParentheses:
309
+ Enabled: false
310
+ EnforcedStyle: omit_parentheses
311
+ AllowParenthesesInChaining: true
312
+ AllowParenthesesInMultilineCall: true
313
+ IgnoreMacros: false
314
+ Style/MethodDefParentheses:
315
+ EnforcedStyle: require_parentheses
316
+ Style/MissingElse:
317
+ Enabled: false
318
+ Style/MultilineInPatternThen:
319
+ Enabled: true
320
+ Style/MultilineMethodSignature:
321
+ Enabled: true
322
+ Style/NegatedIfElseCondition:
323
+ Enabled: true
324
+ Style/NilLambda:
325
+ Enabled: true
326
+ Style/NumberedParameters:
327
+ Enabled: true
328
+ EnforcedStyle: disallow
329
+ Style/NumberedParametersLimit:
330
+ Enabled: true
331
+ Style/NumericLiterals:
332
+ Enabled: false
333
+ Style/OptionalBooleanParameter:
334
+ Enabled: true
335
+ Style/OptionHash:
336
+ Enabled: true
337
+ Style/OpenStructUse:
338
+ Enabled: true
339
+ Style/PercentLiteralDelimiters:
340
+ PreferredDelimiters:
341
+ "%w": "[]"
342
+ "%W": "[]"
343
+ "%i": "[]"
344
+ "%I": "[]"
345
+ "%r": "()"
346
+ Style/QuotedSymbols:
347
+ Enabled: true
348
+ Style/RedundantArgument:
349
+ Enabled: true
350
+ Style/RedundantAssignment:
351
+ Enabled: true
352
+ Style/RedundantSelfAssignment:
353
+ Enabled: true
354
+ Style/RedundantSelfAssignmentBranch:
355
+ Enabled: true
356
+ Style/RedundantFetchBlock:
357
+ Enabled: true
358
+ Style/RedundantFileExtensionInRequire:
359
+ Enabled: true
360
+ Style/RedundantRegexpCharacterClass:
361
+ Enabled: true
362
+ Style/RedundantRegexpEscape:
363
+ Enabled: true
364
+ Style/ReturnNil:
365
+ Enabled: true
366
+ Style/SafeNavigation:
367
+ Enabled: false
368
+ Style/SelectByRegexp:
369
+ Enabled: true
370
+ Style/Send:
371
+ Enabled: true
372
+ Style/SignalException:
373
+ EnforcedStyle: semantic
374
+ Style/SingleArgumentDig:
375
+ Enabled: true
376
+ Style/SlicingWithRange:
377
+ Enabled: true
378
+ Style/SoleNestedConditional:
379
+ Enabled: true
380
+ Style/StaticClass:
381
+ Enabled: true
382
+ Style/StringChars:
383
+ Enabled: true
384
+ Style/StringConcatenation:
385
+ Enabled: false
386
+ Style/StringLiterals:
387
+ EnforcedStyle: double_quotes
388
+ Style/StringLiteralsInInterpolation:
389
+ EnforcedStyle: double_quotes
390
+ Style/StringMethods:
391
+ Enabled: true
392
+ Style/SwapValues:
393
+ Enabled: true
394
+ Style/SymbolArray:
395
+ Enabled: true
396
+ Style/FrozenStringLiteralComment:
397
+ Enabled: true
398
+
399
+ # ====================== Performance =======================
400
+ Performance/AncestorsInclude:
401
+ Enabled: true
402
+ Performance/BigDecimalWithNumericArgument:
403
+ Enabled: true
404
+ Performance/BlockGivenWithExplicitBlock:
405
+ Enabled: true
406
+ Performance/CollectionLiteralInLoop:
407
+ Enabled: true
408
+ Performance/ConcurrentMonotonicTime:
409
+ Enabled: true
410
+ Performance/ConstantRegexp:
411
+ Enabled: true
412
+ Performance/IoReadlines:
413
+ Enabled: true
414
+ Performance/MapCompact:
415
+ Enabled: true
416
+ Performance/MethodObjectAsBlock:
417
+ Enabled: true
418
+ Performance/OpenStruct:
419
+ Enabled: true
420
+ Performance/RedundantEqualityComparisonBlock:
421
+ Enabled: true
422
+ Performance/RedundantSortBlock:
423
+ Enabled: true
424
+ Performance/RedundantSplitRegexpArgument:
425
+ Enabled: true
426
+ Performance/RedundantStringChars:
427
+ Enabled: true
428
+ Performance/ReverseFirst:
429
+ Enabled: true
430
+ Performance/SortReverse:
431
+ Enabled: true
432
+ Performance/StringIdentifierArgument:
433
+ Enabled: true
434
+ Performance/Squeeze:
435
+ Enabled: true
436
+ Performance/StringInclude:
437
+ Enabled: true
438
+ Performance/Sum:
439
+ Enabled: true
440
+
441
+ # ==================== RSpec ============================
442
+ RSpec/BeEq:
443
+ Enabled: true
444
+ RSpec/BeNil:
445
+ Enabled: true
446
+ RSpec/ContextWording:
447
+ Prefixes:
448
+ - when
449
+ - with
450
+ - without
451
+ RSpec/DescribeClass:
452
+ IgnoredMetadata:
453
+ type:
454
+ - feature
455
+ - request
456
+ - task
457
+ RSpec/DescribedClassModuleWrapping:
458
+ Enabled: true
459
+ RSpec/Dialect:
460
+ Enabled: true
461
+ PreferredMethods:
462
+ append_after: after
463
+ append_before: before
464
+ example: it
465
+ example_group: context
466
+ expect_any_instance_of: expect
467
+ is_expected: expect
468
+ its: it
469
+ let!: let
470
+ prepend_after: after
471
+ prepend_before: before
472
+ shared_examples_for: shared_examples
473
+ specify: it
474
+ subject!: subject
475
+ RSpec/ExampleLength:
476
+ Max: 10
477
+ RSpec/ExcessiveDocstringSpacing:
478
+ Enabled: true
479
+ RSpec/FactoryBot/SyntaxMethods:
480
+ Enabled: false
481
+ RSpec/IdenticalEqualityAssertion:
482
+ Enabled: true
483
+ RSpec/NamedSubject:
484
+ IgnoreSharedExamples: false
485
+ RSpec/Rails/AvoidSetupHook:
486
+ Enabled: true
487
+ RSpec/StubbedMock:
488
+ Enabled: true
489
+ RSpec/SubjectDeclaration:
490
+ Enabled: true
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-03-01
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec
6
+
7
+ group :development, :test do
8
+ gem "byebug"
9
+ gem "pry"
10
+ gem "rspec"
11
+ gem "rubocop"
12
+ gem "rubocop-performance"
13
+ gem "rubocop-rake"
14
+ gem "rubocop-rspec"
15
+ gem "solargraph"
16
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,109 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ notebroker (0.1.0)
5
+ dry-cli
6
+ dry-initializer
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ ast (2.4.2)
12
+ backport (1.2.0)
13
+ benchmark (0.2.0)
14
+ byebug (11.1.3)
15
+ coderay (1.1.3)
16
+ diff-lcs (1.5.0)
17
+ dry-cli (0.7.0)
18
+ dry-initializer (3.1.1)
19
+ e2mmap (0.1.0)
20
+ jaro_winkler (1.5.4)
21
+ kramdown (2.3.1)
22
+ rexml
23
+ kramdown-parser-gfm (1.1.0)
24
+ kramdown (~> 2.0)
25
+ method_source (1.0.0)
26
+ nokogiri (1.13.3-x86_64-darwin)
27
+ racc (~> 1.4)
28
+ parallel (1.21.0)
29
+ parser (3.1.1.0)
30
+ ast (~> 2.4.1)
31
+ pry (0.14.1)
32
+ coderay (~> 1.1)
33
+ method_source (~> 1.0)
34
+ racc (1.6.0)
35
+ rainbow (3.1.1)
36
+ regexp_parser (2.2.1)
37
+ reverse_markdown (2.1.1)
38
+ nokogiri
39
+ rexml (3.2.5)
40
+ rspec (3.11.0)
41
+ rspec-core (~> 3.11.0)
42
+ rspec-expectations (~> 3.11.0)
43
+ rspec-mocks (~> 3.11.0)
44
+ rspec-core (3.11.0)
45
+ rspec-support (~> 3.11.0)
46
+ rspec-expectations (3.11.0)
47
+ diff-lcs (>= 1.2.0, < 2.0)
48
+ rspec-support (~> 3.11.0)
49
+ rspec-mocks (3.11.0)
50
+ diff-lcs (>= 1.2.0, < 2.0)
51
+ rspec-support (~> 3.11.0)
52
+ rspec-support (3.11.0)
53
+ rubocop (1.25.1)
54
+ parallel (~> 1.10)
55
+ parser (>= 3.1.0.0)
56
+ rainbow (>= 2.2.2, < 4.0)
57
+ regexp_parser (>= 1.8, < 3.0)
58
+ rexml
59
+ rubocop-ast (>= 1.15.1, < 2.0)
60
+ ruby-progressbar (~> 1.7)
61
+ unicode-display_width (>= 1.4.0, < 3.0)
62
+ rubocop-ast (1.16.0)
63
+ parser (>= 3.1.1.0)
64
+ rubocop-performance (1.13.2)
65
+ rubocop (>= 1.7.0, < 2.0)
66
+ rubocop-ast (>= 0.4.0)
67
+ rubocop-rake (0.6.0)
68
+ rubocop (~> 1.0)
69
+ rubocop-rspec (2.9.0)
70
+ rubocop (~> 1.19)
71
+ ruby-progressbar (1.11.0)
72
+ solargraph (0.44.3)
73
+ backport (~> 1.2)
74
+ benchmark
75
+ bundler (>= 1.17.2)
76
+ diff-lcs (~> 1.4)
77
+ e2mmap
78
+ jaro_winkler (~> 1.5)
79
+ kramdown (~> 2.3)
80
+ kramdown-parser-gfm (~> 1.1)
81
+ parser (~> 3.0)
82
+ reverse_markdown (>= 1.0.5, < 3)
83
+ rubocop (>= 0.52)
84
+ thor (~> 1.0)
85
+ tilt (~> 2.0)
86
+ yard (~> 0.9, >= 0.9.24)
87
+ thor (1.2.1)
88
+ tilt (2.0.10)
89
+ unicode-display_width (2.1.0)
90
+ webrick (1.7.0)
91
+ yard (0.9.27)
92
+ webrick (~> 1.7.0)
93
+
94
+ PLATFORMS
95
+ x86_64-darwin-20
96
+
97
+ DEPENDENCIES
98
+ byebug
99
+ notebroker!
100
+ pry
101
+ rspec
102
+ rubocop
103
+ rubocop-performance
104
+ rubocop-rake
105
+ rubocop-rspec
106
+ solargraph
107
+
108
+ BUNDLED WITH
109
+ 2.3.7
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Nolan J Tait
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,58 @@
1
+ # Notebroker
2
+
3
+ Supports turning ipynb python notebooks into the following formats:
4
+
5
+ - Markdown
6
+
7
+ This library is in alpha and might not support everything. You can see
8
+ the example file which I will make harder over time at `spec/fixtures`.
9
+
10
+ Plans are to support more formats like:
11
+
12
+ - HTML
13
+ - MDX
14
+
15
+ I wrote this library to make it easier to write blog posts through NextJS
16
+ using notebook code. Instead of dealing with the delicate javascript build
17
+ ecosystem I decided to extract it into a more sane ruby gem.
18
+
19
+ ## Installation
20
+
21
+ Add this line to your application's Gemfile:
22
+
23
+ ```ruby
24
+ gem 'notebroker'
25
+ ```
26
+
27
+ And then execute:
28
+
29
+ $ bundle install
30
+
31
+ Or install it yourself as:
32
+
33
+ $ gem install notebroker
34
+
35
+ ## Usage
36
+
37
+ From your terminal you can run the cli:
38
+
39
+ ```
40
+ notebroker --convert notebooks/my-notebook.ipynb --destination ./
41
+ ...
42
+ Converting notebooks/my-notebook.ipynb into markdown...
43
+ Saved markdown file to ./
44
+ ```
45
+
46
+ ## Development
47
+
48
+ 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.
49
+
50
+ 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 the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
51
+
52
+ ## Contributing
53
+
54
+ Bug reports and pull requests are welcome on GitHub at https://github.com/nolantait/notebroker.
55
+
56
+ ## License
57
+
58
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
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
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Notebroker
4
+ module Callable
5
+ def call(args)
6
+ new(args).call
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,45 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Notebroker
4
+ module Cells
5
+ class Code
6
+ extend Dry::Initializer
7
+
8
+ param :input_lines
9
+ param :outputs
10
+
11
+ def to_markdown
12
+ return unless input_lines.any?
13
+
14
+ source = [].tap do |lines|
15
+ lines << wrap_code(input_lines, "python")
16
+ lines << wrap_code(output_lines, "shell") if output_lines.any?
17
+ end
18
+
19
+ source.flatten.join("\n")
20
+ end
21
+
22
+ private
23
+
24
+ def wrap_code(code, language)
25
+ [].tap do |lines|
26
+ lines << "```#{language}"
27
+ lines << normalize(code).join("\n")
28
+ lines << "```\n"
29
+ end
30
+ end
31
+
32
+ def normalize(code)
33
+ code.flatten.map do |line|
34
+ line.delete("\n")
35
+ end
36
+ end
37
+
38
+ def output_lines
39
+ outputs.reduce([]) do |lines, output|
40
+ lines << output[:text]
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Notebroker
4
+ module Cells
5
+ class Markdown
6
+ extend Dry::Initializer
7
+
8
+ param :lines
9
+
10
+ def to_markdown
11
+ return unless lines.any?
12
+
13
+ if lines.last[-1] == "\n"
14
+ lines.join
15
+ else
16
+ lines.join + "\n"
17
+ end
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,43 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Notebroker
4
+ module CLI
5
+ module Commands
6
+ extend Dry::CLI::Registry
7
+
8
+ class Version < Dry::CLI::Command
9
+ desc "Print version"
10
+
11
+ def call(*)
12
+ puts Notebroker::VERSION
13
+ end
14
+ end
15
+
16
+ class Convert < Dry::CLI::Command
17
+ desc "Converts a ipynb file into the requested format"
18
+
19
+ argument :source, required: true, desc: "The source filepath"
20
+ option :destination,
21
+ type: :string,
22
+ default: "./",
23
+ desc: "The output filepath"
24
+
25
+ def call(source:, destination: "./")
26
+ File.write(
27
+ destination + "converted.md",
28
+ Notebroker.to_markdown(File.read(source))
29
+ )
30
+ end
31
+ end
32
+
33
+ register "version", Version, aliases: ["v", "-v", "--version"]
34
+ register "convert", Convert, aliases: ["c", "-c", "--convert"]
35
+ before("convert") do |args|
36
+ puts "Converting #{args.fetch(:source)} into markdown..."
37
+ end
38
+ after("convert") do |args|
39
+ puts "Saved markdown file to #{args.fetch(:destination, "./")}"
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Notebroker
4
+ class Error < StandardError; end
5
+ end
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Notebroker
4
+ class Lexer
5
+ extend Callable
6
+ extend Dry::Initializer
7
+
8
+ param :lines
9
+
10
+ def call
11
+ lines.map do |cell|
12
+ case type = cell[:cell_type]
13
+ when "markdown" then Cells::Markdown.new(cell[:source])
14
+ when "code" then Cells::Code.new(
15
+ cell.fetch(:source, []),
16
+ cell.fetch(:outputs, [])
17
+ )
18
+ else
19
+ fail UnknownCellType, "No handler for #{type}"
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Notebroker
4
+ class Markdown
5
+ extend Callable
6
+ extend Dry::Initializer
7
+
8
+ InvalidSource = Class.new(Error)
9
+
10
+ param :source
11
+
12
+ # @param String
13
+ def call
14
+ parsed = JSON.parse(source, symbolize_names: true)
15
+ result = Lexer.call(parsed[:cells])
16
+ result
17
+ .filter_map(&:to_markdown)
18
+ .join("\n")
19
+ rescue JSON::ParserError
20
+ raise InvalidSource
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Notebroker
4
+ VERSION = "0.1.0"
5
+ end
data/lib/notebroker.rb ADDED
@@ -0,0 +1,20 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "json"
4
+ require "dry-initializer"
5
+ require "dry/cli"
6
+
7
+ require_relative "notebroker/version"
8
+ require_relative "notebroker/callable"
9
+ require_relative "notebroker/error"
10
+ require_relative "notebroker/cells/code"
11
+ require_relative "notebroker/cells/markdown"
12
+ require_relative "notebroker/lexer"
13
+ require_relative "notebroker/markdown"
14
+ require_relative "notebroker/cli"
15
+
16
+ module Notebroker
17
+ def self.to_markdown(source)
18
+ Markdown.call(source)
19
+ end
20
+ end
metadata ADDED
@@ -0,0 +1,92 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: notebroker
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Nolan J Tait
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-03-02 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: dry-cli
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.7.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.7.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: dry-initializer
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 3.1.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 3.1.1
41
+ description: A ruby based CLI to turn python notebook ipynb files into other formats
42
+ email:
43
+ - nolanjtait@gmail.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".rspec"
49
+ - ".rubocop.yml"
50
+ - CHANGELOG.md
51
+ - Gemfile
52
+ - Gemfile.lock
53
+ - LICENSE.txt
54
+ - README.md
55
+ - Rakefile
56
+ - lib/notebroker.rb
57
+ - lib/notebroker/callable.rb
58
+ - lib/notebroker/cells/code.rb
59
+ - lib/notebroker/cells/markdown.rb
60
+ - lib/notebroker/cli.rb
61
+ - lib/notebroker/error.rb
62
+ - lib/notebroker/lexer.rb
63
+ - lib/notebroker/markdown.rb
64
+ - lib/notebroker/version.rb
65
+ homepage: https://github.com/nolantait/notebroker
66
+ licenses:
67
+ - MIT
68
+ metadata:
69
+ homepage_uri: https://github.com/nolantait/notebroker
70
+ source_code_uri: https://github.com/nolantait/notebroker
71
+ changelog_uri: https://github.com/nolantait/notebroker
72
+ rubygems_mfa_required: 'true'
73
+ post_install_message:
74
+ rdoc_options: []
75
+ require_paths:
76
+ - lib
77
+ required_ruby_version: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - ">="
80
+ - !ruby/object:Gem::Version
81
+ version: 3.1.0
82
+ required_rubygems_version: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: '0'
87
+ requirements: []
88
+ rubygems_version: 3.3.3
89
+ signing_key:
90
+ specification_version: 4
91
+ summary: A gem for turning notebooks into other formats
92
+ test_files: []