collatz 0.1.0 → 1.1.0
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/.rubocop.yml +161 -7
- data/.vscode/extensions.json +6 -0
- data/Gemfile +4 -4
- data/Gemfile.lock +46 -37
- data/Makefile +41 -14
- data/README.md +18 -3
- data/Rakefile +1 -1
- data/collatz.gemspec +1 -1
- data/devlog.md +58 -0
- data/lib/collatz/constants.rb +13 -0
- data/lib/collatz/function.rb +78 -0
- data/lib/collatz/hailstone_sequence.rb +208 -0
- data/lib/collatz/tree_graph.rb +183 -0
- data/lib/collatz/utilities.rb +44 -0
- data/lib/collatz/version.rb +2 -1
- data/lib/collatz.rb +13 -225
- metadata +10 -5
- data/BUNDLER.md +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 69964af46354a92d78c808cd4ac791e695943462b28cb71022ef8b1fc15125c6
|
4
|
+
data.tar.gz: 7e1b64c258036ccc52b9546f7f536bbdb83e6d1d969e30ee2688c8d94b4de73d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4e11cb13b4c3fc402db2b6a0c8447fd416673cc6812e7b19d9e6aeca0852f759f453b0c160a47a3e501fc566b2f2e695389873ad0e41a2b9f0654610bd181076
|
7
|
+
data.tar.gz: 511856c95e99576e4e414bd846d1f0bcb39c897f277f14531893bddd8c195a033a6275d4ba3b49c478727d244e5bd50581795f53553b74860271ad85c3726b8a
|
data/.rubocop.yml
CHANGED
@@ -1,12 +1,16 @@
|
|
1
1
|
AllCops:
|
2
|
-
TargetRubyVersion:
|
2
|
+
TargetRubyVersion: 3.0.0
|
3
3
|
UseCache: false
|
4
4
|
SuggestExtensions: false
|
5
5
|
# NewCops: enable # would silence the recommendation
|
6
6
|
# # to enable new, but would hide which ones were run
|
7
7
|
|
8
|
+
Gemspec/AddRuntimeDependency: # new in 1.65
|
9
|
+
Enabled: true
|
8
10
|
Gemspec/DeprecatedAttributeAssignment:
|
9
11
|
Enabled: true
|
12
|
+
Gemspec/DevelopmentDependencies: # new in 1.44
|
13
|
+
Enabled: true
|
10
14
|
Gemspec/RequireMFA:
|
11
15
|
Enabled: false
|
12
16
|
|
@@ -20,6 +24,8 @@ Security/CompoundHash:
|
|
20
24
|
Security/IoMethods:
|
21
25
|
Enabled: true
|
22
26
|
|
27
|
+
Layout/EmptyLineAfterGuardClause:
|
28
|
+
Enabled: false
|
23
29
|
Layout/LineLength:
|
24
30
|
Max: 120
|
25
31
|
Layout/LineContinuationLeadingSpace:
|
@@ -28,15 +34,29 @@ Layout/LineContinuationSpacing:
|
|
28
34
|
Enabled: true
|
29
35
|
Layout/LineEndStringConcatenationIndentation:
|
30
36
|
Enabled: true
|
37
|
+
Layout/MultilineHashBraceLayout:
|
38
|
+
Enabled: false
|
31
39
|
Layout/SpaceAroundOperators:
|
32
40
|
Enabled: false
|
33
41
|
Layout/SpaceBeforeBrackets:
|
34
42
|
Enabled: true
|
35
43
|
|
44
|
+
Metrics/AbcSize:
|
45
|
+
Enabled: false
|
36
46
|
Metrics/BlockLength:
|
37
47
|
AllowedMethods: ['describe', 'context']
|
48
|
+
Metrics/BlockNesting:
|
49
|
+
Enabled: false
|
50
|
+
Metrics/CollectionLiteralLength: # new in 1.47
|
51
|
+
Enabled: true
|
52
|
+
Metrics/CyclomaticComplexity:
|
53
|
+
Enabled: false
|
54
|
+
Metrics/MethodLength:
|
55
|
+
Enabled: false
|
38
56
|
Metrics/ParameterLists:
|
39
57
|
Enabled: false
|
58
|
+
Metrics/PerceivedComplexity:
|
59
|
+
Enabled: false
|
40
60
|
|
41
61
|
Lint/AmbiguousAssignment:
|
42
62
|
Enabled: true
|
@@ -44,34 +64,60 @@ Lint/AmbiguousOperatorPrecedence:
|
|
44
64
|
Enabled: true
|
45
65
|
Lint/AmbiguousRange:
|
46
66
|
Enabled: true
|
67
|
+
Lint/ArrayLiteralInRegexp: # new in 1.71
|
68
|
+
Enabled: true
|
47
69
|
Lint/ConstantOverwrittenInRescue:
|
48
70
|
Enabled: true
|
71
|
+
Lint/ConstantReassignment: # new in 1.70
|
72
|
+
Enabled: true
|
73
|
+
Lint/CopDirectiveSyntax: # new in 1.72
|
74
|
+
Enabled: true
|
49
75
|
Lint/DeprecatedConstants:
|
50
76
|
Enabled: true
|
51
77
|
Lint/DuplicateBranch:
|
52
78
|
Enabled: true
|
79
|
+
Lint/DuplicateMagicComment: # new in 1.37
|
80
|
+
Enabled: true
|
81
|
+
Lint/DuplicateMatchPattern: # new in 1.50
|
82
|
+
Enabled: true
|
53
83
|
Lint/DuplicateRegexpCharacterClassElement:
|
54
84
|
Enabled: true
|
85
|
+
Lint/DuplicateSetElement: # new in 1.67
|
86
|
+
Enabled: true
|
55
87
|
Lint/EmptyBlock:
|
56
88
|
Enabled: true
|
57
89
|
Lint/EmptyClass:
|
58
90
|
Enabled: true
|
59
91
|
Lint/EmptyInPattern:
|
60
92
|
Enabled: true
|
93
|
+
Lint/HashNewWithKeywordArgumentsAsDefault: # new in 1.69
|
94
|
+
Enabled: true
|
61
95
|
Lint/IncompatibleIoSelectWithFiberScheduler:
|
62
96
|
Enabled: true
|
97
|
+
Lint/ItWithoutArgumentsInBlock: # new in 1.59
|
98
|
+
Enabled: true
|
63
99
|
Lint/LambdaWithoutLiteralBlock:
|
64
100
|
Enabled: true
|
101
|
+
Lint/LiteralAssignmentInCondition: # new in 1.58
|
102
|
+
Enabled: true
|
103
|
+
Lint/MixedCaseRange: # new in 1.53
|
104
|
+
Enabled: true
|
65
105
|
Lint/NoReturnInBeginEndBlocks:
|
66
106
|
Enabled: true
|
67
107
|
Lint/NonAtomicFileOperation:
|
68
108
|
Enabled: true
|
69
109
|
Lint/NumberedParameterAssignment:
|
70
110
|
Enabled: true
|
111
|
+
Lint/NumericOperationWithConstantResult: # new in 1.69
|
112
|
+
Enabled: true
|
71
113
|
Lint/OrAssignmentToConstant:
|
72
114
|
Enabled: true
|
73
115
|
Lint/RedundantDirGlobSort:
|
74
116
|
Enabled: true
|
117
|
+
Lint/RedundantRegexpQuantifiers: # new in 1.53
|
118
|
+
Enabled: true
|
119
|
+
Lint/RedundantTypeConversion: # new in 1.72
|
120
|
+
Enabled: true
|
75
121
|
Lint/RefinementImportMethods:
|
76
122
|
Enabled: true
|
77
123
|
Lint/RequireRangeParentheses:
|
@@ -80,6 +126,10 @@ Lint/RequireRelativeSelfPath:
|
|
80
126
|
Enabled: true
|
81
127
|
Lint/ScriptPermission:
|
82
128
|
Enabled: false
|
129
|
+
Lint/SharedMutableDefault: # new in 1.70
|
130
|
+
Enabled: true
|
131
|
+
Lint/SuppressedExceptionInNumberConversion: # new in 1.72
|
132
|
+
Enabled: true
|
83
133
|
Lint/SymbolConversion:
|
84
134
|
Enabled: true
|
85
135
|
Lint/ToEnumArguments:
|
@@ -88,22 +138,48 @@ Lint/TripleQuotes:
|
|
88
138
|
Enabled: true
|
89
139
|
Lint/UnexpectedBlockArity:
|
90
140
|
Enabled: true
|
141
|
+
Lint/UnescapedBracketInRegexp: # new in 1.68
|
142
|
+
Enabled: true
|
91
143
|
Lint/UnmodifiedReduceAccumulator:
|
92
144
|
Enabled: true
|
145
|
+
Lint/UselessConstantScoping: # new in 1.72
|
146
|
+
Enabled: true
|
147
|
+
Lint/UselessDefined: # new in 1.69
|
148
|
+
Enabled: true
|
149
|
+
Lint/UselessNumericOperation: # new in 1.66
|
150
|
+
Enabled: true
|
151
|
+
Lint/UselessRescue: # new in 1.43
|
152
|
+
Enabled: true
|
93
153
|
Lint/UselessRuby2Keywords:
|
94
154
|
Enabled: true
|
95
155
|
|
96
|
-
|
97
|
-
|
156
|
+
Style/AccessModifierDeclarations:
|
157
|
+
EnforcedStyle: inline
|
158
|
+
AllowModifiersOnSymbols: false
|
159
|
+
Style/AmbiguousEndlessMethodDefinition: # new in 1.68
|
98
160
|
Enabled: true
|
99
|
-
EnforcedStyle: double_quotes
|
100
|
-
Style/StringLiteralsInInterpolation:
|
101
|
-
Enabled: true
|
102
|
-
EnforcedStyle: double_quotes
|
103
161
|
Style/ArgumentsForwarding:
|
104
162
|
Enabled: true
|
163
|
+
Style/ArrayIntersect: # new in 1.40
|
164
|
+
Enabled: true
|
165
|
+
Style/BitwisePredicate: # new in 1.68
|
166
|
+
Enabled: true
|
105
167
|
Style/CollectionCompact:
|
106
168
|
Enabled: true
|
169
|
+
Style/CombinableDefined: # new in 1.68
|
170
|
+
Enabled: true
|
171
|
+
Style/ComparableClamp: # new in 1.44
|
172
|
+
Enabled: true
|
173
|
+
Style/ConcatArrayLiterals: # new in 1.41
|
174
|
+
Enabled: true
|
175
|
+
Style/ConditionalAssignment:
|
176
|
+
Enabled: false
|
177
|
+
Style/DataInheritance: # new in 1.49
|
178
|
+
Enabled: true
|
179
|
+
Style/DigChain: # new in 1.69
|
180
|
+
Enabled: true
|
181
|
+
Style/DirEmpty: # new in 1.48
|
182
|
+
Enabled: true
|
107
183
|
Style/DocumentDynamicEvalDefinition:
|
108
184
|
Enabled: true
|
109
185
|
Style/EmptyHeredoc:
|
@@ -112,32 +188,58 @@ Style/EndlessMethod:
|
|
112
188
|
Enabled: true
|
113
189
|
Style/EnvHome:
|
114
190
|
Enabled: true
|
191
|
+
Style/ExactRegexpMatch: # new in 1.51
|
192
|
+
Enabled: true
|
115
193
|
Style/FetchEnvVar:
|
116
194
|
Enabled: true
|
195
|
+
Style/FileEmpty: # new in 1.48
|
196
|
+
Enabled: true
|
197
|
+
Style/FileNull: # new in 1.69
|
198
|
+
Enabled: true
|
117
199
|
Style/FileRead:
|
118
200
|
Enabled: true
|
201
|
+
Style/FileTouch: # new in 1.69
|
202
|
+
Enabled: true
|
119
203
|
Style/FileWrite:
|
120
204
|
Enabled: true
|
205
|
+
Style/For:
|
206
|
+
Enabled: false
|
121
207
|
Style/HashConversion:
|
122
208
|
Enabled: true
|
123
209
|
Style/HashExcept:
|
124
210
|
Enabled: true
|
211
|
+
Style/HashSlice: # new in 1.71
|
212
|
+
Enabled: true
|
125
213
|
Style/IfWithBooleanLiteralBranches:
|
126
214
|
Enabled: true
|
127
215
|
Style/InPatternThen:
|
128
216
|
Enabled: true
|
217
|
+
Style/ItAssignment: # new in 1.70
|
218
|
+
Enabled: true
|
219
|
+
Style/KeywordArgumentsMerging: # new in 1.68
|
220
|
+
Enabled: true
|
221
|
+
Style/Lambda:
|
222
|
+
EnforcedStyle: lambda
|
129
223
|
Style/MagicCommentFormat:
|
130
224
|
Enabled: true
|
131
225
|
Style/MapCompactWithConditionalBlock:
|
132
226
|
Enabled: true
|
227
|
+
Style/MapIntoArray: # new in 1.63
|
228
|
+
Enabled: true
|
133
229
|
Style/MapToHash:
|
134
230
|
Enabled: true
|
231
|
+
Style/MapToSet: # new in 1.42
|
232
|
+
Enabled: true
|
233
|
+
Style/MinMaxComparison: # new in 1.42
|
234
|
+
Enabled: true
|
135
235
|
Style/MultilineInPatternThen:
|
136
236
|
Enabled: true
|
137
237
|
Style/NegatedIfElseCondition:
|
138
238
|
Enabled: true
|
139
239
|
Style/NestedFileDirname:
|
140
240
|
Enabled: true
|
241
|
+
Style/Next:
|
242
|
+
Enabled: false
|
141
243
|
Style/NilLambda:
|
142
244
|
Enabled: true
|
143
245
|
Style/NumberedParameters:
|
@@ -150,17 +252,69 @@ Style/ObjectThen:
|
|
150
252
|
Enabled: true
|
151
253
|
Style/OpenStructUse:
|
152
254
|
Enabled: true
|
255
|
+
Style/OperatorMethodCall: # new in 1.37
|
256
|
+
Enabled: true
|
153
257
|
Style/QuotedSymbols:
|
154
258
|
Enabled: true
|
155
259
|
Style/RedundantArgument:
|
156
260
|
Enabled: true
|
261
|
+
Style/RedundantArrayConstructor: # new in 1.52
|
262
|
+
Enabled: true
|
263
|
+
Style/RedundantConstantBase: # new in 1.40
|
264
|
+
Enabled: true
|
265
|
+
Style/RedundantCurrentDirectoryInPath: # new in 1.53
|
266
|
+
Enabled: true
|
267
|
+
Style/RedundantDoubleSplatHashBraces: # new in 1.41
|
268
|
+
Enabled: true
|
269
|
+
Style/RedundantEach: # new in 1.38
|
270
|
+
Enabled: true
|
271
|
+
Style/RedundantFilterChain: # new in 1.52
|
272
|
+
Enabled: true
|
273
|
+
Style/RedundantFormat: # new in 1.72
|
274
|
+
Enabled: true
|
275
|
+
Style/RedundantHeredocDelimiterQuotes: # new in 1.45
|
276
|
+
Enabled: true
|
157
277
|
Style/RedundantInitialize:
|
158
278
|
Enabled: true
|
279
|
+
Style/RedundantInterpolationUnfreeze: # new in 1.66
|
280
|
+
Enabled: true
|
281
|
+
Style/RedundantLineContinuation: # new in 1.49
|
282
|
+
Enabled: true
|
283
|
+
Style/RedundantParentheses:
|
284
|
+
Enabled: true
|
285
|
+
Style/RedundantRegexpArgument: # new in 1.53
|
286
|
+
Enabled: true
|
287
|
+
Style/RedundantRegexpConstructor: # new in 1.52
|
288
|
+
Enabled: true
|
289
|
+
Style/RedundantSelf:
|
290
|
+
Enabled: false
|
159
291
|
Style/RedundantSelfAssignmentBranch:
|
160
292
|
Enabled: true
|
293
|
+
Style/RedundantStringEscape: # new in 1.37
|
294
|
+
Enabled: true
|
295
|
+
Style/ReturnNilInPredicateMethodDefinition: # new in 1.53
|
296
|
+
Enabled: true
|
297
|
+
Style/SafeNavigationChainLength: # new in 1.68
|
298
|
+
Enabled: true
|
161
299
|
Style/SelectByRegexp:
|
162
300
|
Enabled: true
|
301
|
+
Style/SendWithLiteralMethodName: # new in 1.64
|
302
|
+
Enabled: true
|
303
|
+
Style/SingleLineDoEndBlock: # new in 1.57
|
304
|
+
Enabled: true
|
163
305
|
Style/StringChars:
|
164
306
|
Enabled: true
|
307
|
+
Style/StringLiterals:
|
308
|
+
Enabled: true
|
309
|
+
EnforcedStyle: double_quotes
|
310
|
+
Style/StringLiteralsInInterpolation:
|
311
|
+
Enabled: true
|
312
|
+
EnforcedStyle: double_quotes
|
313
|
+
Style/SuperArguments: # new in 1.64
|
314
|
+
Enabled: true
|
315
|
+
Style/SuperWithArgsParentheses: # new in 1.58
|
316
|
+
Enabled: true
|
165
317
|
Style/SwapValues:
|
166
318
|
Enabled: true
|
319
|
+
Style/YAMLFileRead: # new in 1.53
|
320
|
+
Enabled: true
|
data/Gemfile
CHANGED
@@ -5,10 +5,10 @@ source "https://rubygems.org"
|
|
5
5
|
# Specify your gem's dependencies in collatz.gemspec
|
6
6
|
gemspec
|
7
7
|
|
8
|
-
gem "rake", "~> 13.
|
8
|
+
gem "rake", "~> 13.2"
|
9
9
|
|
10
|
-
gem "rdoc", "~> 6.
|
10
|
+
gem "rdoc", "~> 6.12"
|
11
11
|
|
12
|
-
gem "rspec", "~> 3.
|
12
|
+
gem "rspec", "~> 3.13"
|
13
13
|
|
14
|
-
gem "rubocop", "~> 1.
|
14
|
+
gem "rubocop", "~> 1.72"
|
data/Gemfile.lock
CHANGED
@@ -1,63 +1,72 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
collatz (
|
4
|
+
collatz (1.1.0)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
ast (2.4.2)
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
10
|
+
date (3.4.1)
|
11
|
+
diff-lcs (1.6.0)
|
12
|
+
json (2.10.1)
|
13
|
+
language_server-protocol (3.17.0.4)
|
14
|
+
lint_roller (1.1.0)
|
15
|
+
parallel (1.26.3)
|
16
|
+
parser (3.3.7.1)
|
14
17
|
ast (~> 2.4.1)
|
15
|
-
|
18
|
+
racc
|
19
|
+
psych (5.2.3)
|
20
|
+
date
|
16
21
|
stringio
|
22
|
+
racc (1.8.1)
|
17
23
|
rainbow (3.1.1)
|
18
|
-
rake (13.
|
19
|
-
rdoc (6.
|
24
|
+
rake (13.2.1)
|
25
|
+
rdoc (6.12.0)
|
20
26
|
psych (>= 4.0.0)
|
21
|
-
regexp_parser (2.
|
22
|
-
|
23
|
-
|
24
|
-
rspec-
|
25
|
-
rspec-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
rspec-expectations (3.11.0)
|
27
|
+
regexp_parser (2.10.0)
|
28
|
+
rspec (3.13.0)
|
29
|
+
rspec-core (~> 3.13.0)
|
30
|
+
rspec-expectations (~> 3.13.0)
|
31
|
+
rspec-mocks (~> 3.13.0)
|
32
|
+
rspec-core (3.13.3)
|
33
|
+
rspec-support (~> 3.13.0)
|
34
|
+
rspec-expectations (3.13.3)
|
30
35
|
diff-lcs (>= 1.2.0, < 2.0)
|
31
|
-
rspec-support (~> 3.
|
32
|
-
rspec-mocks (3.
|
36
|
+
rspec-support (~> 3.13.0)
|
37
|
+
rspec-mocks (3.13.2)
|
33
38
|
diff-lcs (>= 1.2.0, < 2.0)
|
34
|
-
rspec-support (~> 3.
|
35
|
-
rspec-support (3.
|
36
|
-
rubocop (1.
|
39
|
+
rspec-support (~> 3.13.0)
|
40
|
+
rspec-support (3.13.2)
|
41
|
+
rubocop (1.72.2)
|
37
42
|
json (~> 2.3)
|
43
|
+
language_server-protocol (~> 3.17.0.2)
|
44
|
+
lint_roller (~> 1.1.0)
|
38
45
|
parallel (~> 1.10)
|
39
|
-
parser (>= 3.
|
46
|
+
parser (>= 3.3.0.2)
|
40
47
|
rainbow (>= 2.2.2, < 4.0)
|
41
|
-
regexp_parser (>=
|
42
|
-
|
43
|
-
rubocop-ast (>= 1.20.1, < 2.0)
|
48
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
49
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
44
50
|
ruby-progressbar (~> 1.7)
|
45
|
-
unicode-display_width (>=
|
46
|
-
rubocop-ast (1.
|
47
|
-
parser (>= 3.
|
48
|
-
ruby-progressbar (1.
|
49
|
-
stringio (3.
|
50
|
-
unicode-display_width (
|
51
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
52
|
+
rubocop-ast (1.38.0)
|
53
|
+
parser (>= 3.3.1.0)
|
54
|
+
ruby-progressbar (1.13.0)
|
55
|
+
stringio (3.1.5)
|
56
|
+
unicode-display_width (3.1.4)
|
57
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
58
|
+
unicode-emoji (4.0.4)
|
51
59
|
|
52
60
|
PLATFORMS
|
61
|
+
ruby
|
53
62
|
x86_64-linux
|
54
63
|
|
55
64
|
DEPENDENCIES
|
56
65
|
collatz!
|
57
|
-
rake (~> 13.
|
58
|
-
rdoc (~> 6.
|
59
|
-
rspec (~> 3.
|
60
|
-
rubocop (~> 1.
|
66
|
+
rake (~> 13.2)
|
67
|
+
rdoc (~> 6.12)
|
68
|
+
rspec (~> 3.13)
|
69
|
+
rubocop (~> 1.72)
|
61
70
|
|
62
71
|
BUNDLED WITH
|
63
|
-
2.
|
72
|
+
2.5.23
|
data/Makefile
CHANGED
@@ -1,45 +1,72 @@
|
|
1
|
-
|
1
|
+
# It's assumed you have https://rvm.io/ -- see "Developing" in the README
|
2
|
+
# https://github.com/Skenvy/Collatz/blob/main/ruby/README.md#developing
|
3
|
+
|
4
|
+
# ruby binaries -- https://rvm.io/binaries/ ~= ubuntu 24 x86
|
5
|
+
DEVELOPMENT_RUBY_VERSION=ruby-3.3.6
|
6
|
+
# https://rubygems.org/gems/bundler
|
7
|
+
DEVELOPMENT_BUNDLER_VERSION=2.5.23
|
8
|
+
# https://rubygems.org/gems/rubygems-update
|
9
|
+
DEVELOPMENT_GEMSYS_VERSION=3.5.23
|
10
|
+
|
11
|
+
RVM=source "$$RVM_DIR/scripts/rvm" && rvm
|
12
|
+
INSTALL_RUBY=$(RVM) install "$(DEVELOPMENT_RUBY_VERSION)"
|
13
|
+
_=$(RVM) use $(DEVELOPMENT_RUBY_VERSION) &&
|
14
|
+
GEM=$(_) gem
|
15
|
+
INSTALL_BUNDLER=$(GEM) install bundler -v $(DEVELOPMENT_BUNDLER_VERSION)
|
16
|
+
UPDATE_RUBYGEMS=$(GEM) update --system $(DEVELOPMENT_GEMSYS_VERSION)
|
17
|
+
# With multiple bundler versions installed, specify which to use with _ver_
|
18
|
+
BUNDLE=$(_) bundle _$(DEVELOPMENT_BUNDLER_VERSION)_
|
19
|
+
RAKE=$(BUNDLE) exec rake
|
20
|
+
|
21
|
+
.PHONY: initialise setup setup_github clean docs test build install push_rubygems push_github
|
2
22
|
SHELL:=/bin/bash
|
3
23
|
|
4
|
-
#
|
5
|
-
|
6
|
-
|
24
|
+
# How to setup for ruby development ~ might require compiling ruby locally.
|
25
|
+
initialise:
|
26
|
+
$(INSTALL_RUBY)
|
27
|
+
$(INSTALL_BUNDLER)
|
28
|
+
$(UPDATE_RUBYGEMS)
|
29
|
+
|
30
|
+
setup: initialise
|
31
|
+
$(BUNDLE) install
|
7
32
|
|
8
33
|
setup_github:
|
9
|
-
|
34
|
+
$(GEM) install keycutter
|
10
35
|
|
11
36
|
clean:
|
12
|
-
|
13
|
-
|
37
|
+
$(RAKE) clean
|
38
|
+
$(RAKE) clobber
|
14
39
|
rm -f collatz-*.gem
|
15
40
|
rm -f pkg/collatz-*.gem
|
16
41
|
|
17
42
|
docs: clean
|
18
|
-
|
43
|
+
$(RAKE) rdoc
|
19
44
|
|
20
45
|
# default (just `rake`) is spec + rubocop, but be pedantic in case this changes.
|
21
46
|
test: clean
|
22
|
-
|
23
|
-
|
47
|
+
$(RAKE) spec
|
48
|
+
|
49
|
+
lint: clean
|
50
|
+
$(RAKE) rubocop
|
24
51
|
|
25
52
|
# We can choose from `gem build collatz.gemspec` or `bundle exec rake build`.
|
26
53
|
# The gem build command creates a ./collatz-$VER.gem file, and the rake build
|
27
54
|
# (within bundle context) creates a ./pkg/collatz-$VER.gem file.
|
28
55
|
build: test
|
29
|
-
|
56
|
+
$(RAKE) build
|
30
57
|
|
31
58
|
# --user-install means no need for sudo or expectation of
|
32
59
|
# changing the folder permissions or access but will need
|
33
60
|
# "gem environment"'s "USER INSTALLATION DIRECTORY" (+ "/bin")
|
34
61
|
# in the PATH to then use any gem executables that it may contain.
|
35
62
|
install: build
|
36
|
-
|
63
|
+
$(GEM) install ./pkg/collatz-$$(grep lib/collatz/version.rb -e "VERSION" | cut -d \" -f 2).gem --user-install
|
37
64
|
|
38
65
|
# Will be run with one "pkg/collatz-*.gem" file
|
39
66
|
# rubygems_api_key and the rubygems host are the default
|
40
67
|
push_rubygems:
|
41
|
-
|
68
|
+
$(GEM) push $$(find . | grep pkg/collatz-*.gem)
|
42
69
|
|
43
70
|
# Will be run with one "pkg/collatz-*.gem" file
|
44
71
|
push_github:
|
45
|
-
|
72
|
+
$(GEM) push --key github --host https://rubygems.pkg.github.com/Skenvy $$(find . | grep pkg/collatz-*.gem)
|
data/README.md
CHANGED
@@ -1,4 +1,11 @@
|
|
1
1
|
# [Collatz](https://github.com/Skenvy/Collatz): [Ruby](https://github.com/Skenvy/Collatz/tree/main/ruby) 🔻💎🔻
|
2
|
+
<p align="center"><img alt="Banner Image, Collatz Coral" src="https://raw.githubusercontent.com/wiki/Skenvy/Collatz/.meta/banners/modifications/_Ruby.png" width=830 height=666/></p>
|
3
|
+
<sub><p align="center"><i>
|
4
|
+
<a href="https://github.com/Skenvy/Collatz/blob/main/.meta/banners/README.md">Colourised Collatz Coral</a>; derived from this
|
5
|
+
<a href="https://twitter.com/Gelada/status/846751901756653568">original by Edmund Harriss</a>
|
6
|
+
</i></p></sub>
|
7
|
+
|
8
|
+
---
|
2
9
|
Functions related to [the Collatz/Syracuse/3N+1 problem](https://en.wikipedia.org/wiki/Collatz_conjecture), implemented in [Ruby](https://www.ruby-lang.org/).
|
3
10
|
## Getting Started
|
4
11
|
[To install the latest from RubyGems](https://rubygems.org/gems/collatz);
|
@@ -12,12 +19,12 @@ gem install collatz --source "https://rubygems.pkg.github.com/skenvy"
|
|
12
19
|
### Add to the Gemfile
|
13
20
|
[Add the RubyGems hosted gem](https://rubygems.org/gems/collatz);
|
14
21
|
```ruby
|
15
|
-
gem "collatz", ">=
|
22
|
+
gem "collatz", ">= 1.0.0
|
16
23
|
```
|
17
24
|
[Add the GitHub hosted gem](https://github.com/Skenvy/Collatz/packages/1636643);
|
18
25
|
```ruby
|
19
26
|
source "https://rubygems.pkg.github.com/skenvy" do
|
20
|
-
gem "collatz", ">=
|
27
|
+
gem "collatz", ">= 1.0.0"
|
21
28
|
end
|
22
29
|
```
|
23
30
|
## Usage
|
@@ -27,6 +34,13 @@ Besides the function and reverse function, there is also functionality to retrie
|
|
27
34
|
The only restriction placed on parameters is that both `P` and `a` can't be `0`.
|
28
35
|
## [RDoc generated docs](https://skenvy.github.io/Collatz/ruby)
|
29
36
|
## Developing
|
37
|
+
You will need to install [rvm](https://rvm.io/) and one of its [ruby binaries](https://rvm.io/binaries/).
|
38
|
+
|
39
|
+
You'll also need to set the `RVM_DIR` in your shell profile e.g. [like this](https://github.com/Skenvy/dotfiles/blob/1de61272c588a30b634a03a7d304ef51e40c72f1/.bash_login#L17). RVM will set some basic initialisation in your shell profile, but changing what it sets to instead use `RVM_DIR` like this allows you to install it somewhere other than the default.
|
40
|
+
|
41
|
+
The `make initialise` in [first time setup](#the-first-time-setup) will install the intended development version for you, but it might not be a precompiled binary, depending on your OS and architecture ~ if it isn't precompiled, contributing your time in compiling to [publish the binary for rvm](https://github.com/rvm/rvm/issues/4921) is probably more worth your time than this lol.
|
42
|
+
|
43
|
+
RVM is locally how we manage proctoring the ruby environment. It is not on the [github runners](https://github.com/actions/runner-images), so the make invocations in the workflows set the RVM proctors empty.
|
30
44
|
### The first time setup
|
31
45
|
```sh
|
32
46
|
git clone https://github.com/Skenvy/Collatz.git && cd Collatz/ruby && make setup
|
@@ -34,4 +48,5 @@ git clone https://github.com/Skenvy/Collatz.git && cd Collatz/ruby && make setup
|
|
34
48
|
### Iterative development
|
35
49
|
The majority of `make` recipes for this are just wrapping a `bundle` invocation of `rake`.
|
36
50
|
* `make docs` will recreate the RDoc docs
|
37
|
-
* `make test` will run
|
51
|
+
* `make test` will run the RSpec tests.
|
52
|
+
* `make lint` will run the RuboCop linter.
|
data/Rakefile
CHANGED
data/collatz.gemspec
CHANGED
@@ -15,7 +15,7 @@ Gem::Specification.new do |spec|
|
|
15
15
|
the hailstone sequence, the \"stopping time\"/\"total stopping time\", or tree-graph.
|
16
16
|
The only restriction placed on parameters is that both P and a can't be 0."
|
17
17
|
spec.homepage = "https://skenvy.github.io/Collatz/ruby/"
|
18
|
-
spec.required_ruby_version = ">=
|
18
|
+
spec.required_ruby_version = ">= 3.0.0"
|
19
19
|
spec.metadata["homepage_uri"] = spec.homepage
|
20
20
|
spec.metadata["source_code_uri"] = "https://github.com/Skenvy/Collatz/tree/main/ruby"
|
21
21
|
# Specify which files should be added to the gem when it is released.
|