collatz 1.0.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 +135 -8
- 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/collatz.gemspec +1 -1
- data/lib/collatz/function.rb +3 -3
- data/lib/collatz/hailstone_sequence.rb +5 -5
- data/lib/collatz/tree_graph.rb +3 -3
- data/lib/collatz/version.rb +1 -1
- metadata +5 -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
|
|
@@ -43,6 +47,8 @@ Metrics/BlockLength:
|
|
43
47
|
AllowedMethods: ['describe', 'context']
|
44
48
|
Metrics/BlockNesting:
|
45
49
|
Enabled: false
|
50
|
+
Metrics/CollectionLiteralLength: # new in 1.47
|
51
|
+
Enabled: true
|
46
52
|
Metrics/CyclomaticComplexity:
|
47
53
|
Enabled: false
|
48
54
|
Metrics/MethodLength:
|
@@ -58,34 +64,60 @@ Lint/AmbiguousOperatorPrecedence:
|
|
58
64
|
Enabled: true
|
59
65
|
Lint/AmbiguousRange:
|
60
66
|
Enabled: true
|
67
|
+
Lint/ArrayLiteralInRegexp: # new in 1.71
|
68
|
+
Enabled: true
|
61
69
|
Lint/ConstantOverwrittenInRescue:
|
62
70
|
Enabled: true
|
71
|
+
Lint/ConstantReassignment: # new in 1.70
|
72
|
+
Enabled: true
|
73
|
+
Lint/CopDirectiveSyntax: # new in 1.72
|
74
|
+
Enabled: true
|
63
75
|
Lint/DeprecatedConstants:
|
64
76
|
Enabled: true
|
65
77
|
Lint/DuplicateBranch:
|
66
78
|
Enabled: true
|
79
|
+
Lint/DuplicateMagicComment: # new in 1.37
|
80
|
+
Enabled: true
|
81
|
+
Lint/DuplicateMatchPattern: # new in 1.50
|
82
|
+
Enabled: true
|
67
83
|
Lint/DuplicateRegexpCharacterClassElement:
|
68
84
|
Enabled: true
|
85
|
+
Lint/DuplicateSetElement: # new in 1.67
|
86
|
+
Enabled: true
|
69
87
|
Lint/EmptyBlock:
|
70
88
|
Enabled: true
|
71
89
|
Lint/EmptyClass:
|
72
90
|
Enabled: true
|
73
91
|
Lint/EmptyInPattern:
|
74
92
|
Enabled: true
|
93
|
+
Lint/HashNewWithKeywordArgumentsAsDefault: # new in 1.69
|
94
|
+
Enabled: true
|
75
95
|
Lint/IncompatibleIoSelectWithFiberScheduler:
|
76
96
|
Enabled: true
|
97
|
+
Lint/ItWithoutArgumentsInBlock: # new in 1.59
|
98
|
+
Enabled: true
|
77
99
|
Lint/LambdaWithoutLiteralBlock:
|
78
100
|
Enabled: true
|
101
|
+
Lint/LiteralAssignmentInCondition: # new in 1.58
|
102
|
+
Enabled: true
|
103
|
+
Lint/MixedCaseRange: # new in 1.53
|
104
|
+
Enabled: true
|
79
105
|
Lint/NoReturnInBeginEndBlocks:
|
80
106
|
Enabled: true
|
81
107
|
Lint/NonAtomicFileOperation:
|
82
108
|
Enabled: true
|
83
109
|
Lint/NumberedParameterAssignment:
|
84
110
|
Enabled: true
|
111
|
+
Lint/NumericOperationWithConstantResult: # new in 1.69
|
112
|
+
Enabled: true
|
85
113
|
Lint/OrAssignmentToConstant:
|
86
114
|
Enabled: true
|
87
115
|
Lint/RedundantDirGlobSort:
|
88
116
|
Enabled: true
|
117
|
+
Lint/RedundantRegexpQuantifiers: # new in 1.53
|
118
|
+
Enabled: true
|
119
|
+
Lint/RedundantTypeConversion: # new in 1.72
|
120
|
+
Enabled: true
|
89
121
|
Lint/RefinementImportMethods:
|
90
122
|
Enabled: true
|
91
123
|
Lint/RequireRangeParentheses:
|
@@ -94,6 +126,10 @@ Lint/RequireRelativeSelfPath:
|
|
94
126
|
Enabled: true
|
95
127
|
Lint/ScriptPermission:
|
96
128
|
Enabled: false
|
129
|
+
Lint/SharedMutableDefault: # new in 1.70
|
130
|
+
Enabled: true
|
131
|
+
Lint/SuppressedExceptionInNumberConversion: # new in 1.72
|
132
|
+
Enabled: true
|
97
133
|
Lint/SymbolConversion:
|
98
134
|
Enabled: true
|
99
135
|
Lint/ToEnumArguments:
|
@@ -102,27 +138,48 @@ Lint/TripleQuotes:
|
|
102
138
|
Enabled: true
|
103
139
|
Lint/UnexpectedBlockArity:
|
104
140
|
Enabled: true
|
141
|
+
Lint/UnescapedBracketInRegexp: # new in 1.68
|
142
|
+
Enabled: true
|
105
143
|
Lint/UnmodifiedReduceAccumulator:
|
106
144
|
Enabled: true
|
107
|
-
Lint/
|
145
|
+
Lint/UselessConstantScoping: # new in 1.72
|
108
146
|
Enabled: true
|
109
|
-
|
110
|
-
|
111
|
-
Style/StringLiterals:
|
147
|
+
Lint/UselessDefined: # new in 1.69
|
112
148
|
Enabled: true
|
113
|
-
|
114
|
-
Style/StringLiteralsInInterpolation:
|
149
|
+
Lint/UselessNumericOperation: # new in 1.66
|
115
150
|
Enabled: true
|
116
|
-
|
151
|
+
Lint/UselessRescue: # new in 1.43
|
152
|
+
Enabled: true
|
153
|
+
Lint/UselessRuby2Keywords:
|
154
|
+
Enabled: true
|
155
|
+
|
117
156
|
Style/AccessModifierDeclarations:
|
118
157
|
EnforcedStyle: inline
|
119
158
|
AllowModifiersOnSymbols: false
|
159
|
+
Style/AmbiguousEndlessMethodDefinition: # new in 1.68
|
160
|
+
Enabled: true
|
120
161
|
Style/ArgumentsForwarding:
|
121
162
|
Enabled: true
|
163
|
+
Style/ArrayIntersect: # new in 1.40
|
164
|
+
Enabled: true
|
165
|
+
Style/BitwisePredicate: # new in 1.68
|
166
|
+
Enabled: true
|
122
167
|
Style/CollectionCompact:
|
123
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
|
124
175
|
Style/ConditionalAssignment:
|
125
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
|
126
183
|
Style/DocumentDynamicEvalDefinition:
|
127
184
|
Enabled: true
|
128
185
|
Style/EmptyHeredoc:
|
@@ -131,10 +188,18 @@ Style/EndlessMethod:
|
|
131
188
|
Enabled: true
|
132
189
|
Style/EnvHome:
|
133
190
|
Enabled: true
|
191
|
+
Style/ExactRegexpMatch: # new in 1.51
|
192
|
+
Enabled: true
|
134
193
|
Style/FetchEnvVar:
|
135
194
|
Enabled: true
|
195
|
+
Style/FileEmpty: # new in 1.48
|
196
|
+
Enabled: true
|
197
|
+
Style/FileNull: # new in 1.69
|
198
|
+
Enabled: true
|
136
199
|
Style/FileRead:
|
137
200
|
Enabled: true
|
201
|
+
Style/FileTouch: # new in 1.69
|
202
|
+
Enabled: true
|
138
203
|
Style/FileWrite:
|
139
204
|
Enabled: true
|
140
205
|
Style/For:
|
@@ -143,18 +208,30 @@ Style/HashConversion:
|
|
143
208
|
Enabled: true
|
144
209
|
Style/HashExcept:
|
145
210
|
Enabled: true
|
211
|
+
Style/HashSlice: # new in 1.71
|
212
|
+
Enabled: true
|
146
213
|
Style/IfWithBooleanLiteralBranches:
|
147
214
|
Enabled: true
|
148
215
|
Style/InPatternThen:
|
149
216
|
Enabled: true
|
217
|
+
Style/ItAssignment: # new in 1.70
|
218
|
+
Enabled: true
|
219
|
+
Style/KeywordArgumentsMerging: # new in 1.68
|
220
|
+
Enabled: true
|
150
221
|
Style/Lambda:
|
151
222
|
EnforcedStyle: lambda
|
152
223
|
Style/MagicCommentFormat:
|
153
224
|
Enabled: true
|
154
225
|
Style/MapCompactWithConditionalBlock:
|
155
226
|
Enabled: true
|
227
|
+
Style/MapIntoArray: # new in 1.63
|
228
|
+
Enabled: true
|
156
229
|
Style/MapToHash:
|
157
230
|
Enabled: true
|
231
|
+
Style/MapToSet: # new in 1.42
|
232
|
+
Enabled: true
|
233
|
+
Style/MinMaxComparison: # new in 1.42
|
234
|
+
Enabled: true
|
158
235
|
Style/MultilineInPatternThen:
|
159
236
|
Enabled: true
|
160
237
|
Style/NegatedIfElseCondition:
|
@@ -175,19 +252,69 @@ Style/ObjectThen:
|
|
175
252
|
Enabled: true
|
176
253
|
Style/OpenStructUse:
|
177
254
|
Enabled: true
|
255
|
+
Style/OperatorMethodCall: # new in 1.37
|
256
|
+
Enabled: true
|
178
257
|
Style/QuotedSymbols:
|
179
258
|
Enabled: true
|
180
259
|
Style/RedundantArgument:
|
181
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
|
182
277
|
Style/RedundantInitialize:
|
183
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
|
184
289
|
Style/RedundantSelf:
|
185
290
|
Enabled: false
|
186
291
|
Style/RedundantSelfAssignmentBranch:
|
187
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
|
188
299
|
Style/SelectByRegexp:
|
189
300
|
Enabled: true
|
301
|
+
Style/SendWithLiteralMethodName: # new in 1.64
|
302
|
+
Enabled: true
|
303
|
+
Style/SingleLineDoEndBlock: # new in 1.57
|
304
|
+
Enabled: true
|
190
305
|
Style/StringChars:
|
191
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
|
192
317
|
Style/SwapValues:
|
193
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 (1.
|
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/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.
|
data/lib/collatz/function.rb
CHANGED
@@ -10,7 +10,7 @@ module Collatz # rubocop:disable Style/Documentation
|
|
10
10
|
#
|
11
11
|
# @raise FailedSaneParameterCheck If p or a are 0.
|
12
12
|
#
|
13
|
-
# @param +Integer+ p Modulus used to
|
13
|
+
# @param +Integer+ p Modulus used to divide n, iff n is equivalent to (0 mod p)
|
14
14
|
#
|
15
15
|
# @param +Integer+ a Factor by which to multiply n.
|
16
16
|
#
|
@@ -39,7 +39,7 @@ module Collatz # rubocop:disable Style/Documentation
|
|
39
39
|
#
|
40
40
|
# @param +Integer+ *n:* The value on which to perform the Collatz-esque function.
|
41
41
|
#
|
42
|
-
# @param +Integer+ *p:* Modulus used to
|
42
|
+
# @param +Integer+ *p:* Modulus used to divide n, iff n is equivalent to (0 mod p).
|
43
43
|
#
|
44
44
|
# @param +Integer+ *a:* Factor by which to multiply n.
|
45
45
|
#
|
@@ -60,7 +60,7 @@ module Collatz # rubocop:disable Style/Documentation
|
|
60
60
|
#
|
61
61
|
# @param +Integer+ *n:* The value on which to perform the reverse Collatz function.
|
62
62
|
#
|
63
|
-
# @param +Integer+ *p:* Modulus used to
|
63
|
+
# @param +Integer+ *p:* Modulus used to divide n, iff n is equivalent to (0 mod p).
|
64
64
|
#
|
65
65
|
# @param +Integer+ *a:* Factor by which to multiply n.
|
66
66
|
#
|
@@ -27,7 +27,7 @@ module Collatz # rubocop:disable Style/Documentation
|
|
27
27
|
#
|
28
28
|
# @param +Integer+ initial_value The value to begin the hailstone sequence from.
|
29
29
|
#
|
30
|
-
# @param +Integer+ *p:* Modulus used to
|
30
|
+
# @param +Integer+ *p:* Modulus used to divide n, iff n is equivalent to (0 mod p).
|
31
31
|
#
|
32
32
|
# @param +Integer+ *a:* Factor by which to multiply n.
|
33
33
|
#
|
@@ -115,9 +115,9 @@ module Collatz # rubocop:disable Style/Documentation
|
|
115
115
|
if total_stop
|
116
116
|
lambda { |x| x == 1 }
|
117
117
|
elsif n >= 0
|
118
|
-
lambda { |x|
|
118
|
+
lambda { |x| x < n && x.positive? }
|
119
119
|
else
|
120
|
-
lambda { |x|
|
120
|
+
lambda { |x| x > n && x.negative? }
|
121
121
|
end
|
122
122
|
end
|
123
123
|
end
|
@@ -135,7 +135,7 @@ module Collatz # rubocop:disable Style/Documentation
|
|
135
135
|
#
|
136
136
|
# @param +Integer+ *initial_value:* The value to begin the hailstone sequence from.
|
137
137
|
#
|
138
|
-
# @param +Integer+ *p:* Modulus used to
|
138
|
+
# @param +Integer+ *p:* Modulus used to divide n, iff n is equivalent to (0 mod p).
|
139
139
|
#
|
140
140
|
# @param +Integer+ *a:* Factor by which to multiply n.
|
141
141
|
#
|
@@ -170,7 +170,7 @@ module Collatz # rubocop:disable Style/Documentation
|
|
170
170
|
#
|
171
171
|
# @param +Integer+ *initial_value:* The value for which to find the stopping time.
|
172
172
|
#
|
173
|
-
# @param +Integer+ *p:* Modulus used to
|
173
|
+
# @param +Integer+ *p:* Modulus used to divide n, iff n is equivalent to (0 mod p).
|
174
174
|
#
|
175
175
|
# @param +Integer+ *a:* Factor by which to multiply n.
|
176
176
|
#
|
data/lib/collatz/tree_graph.rb
CHANGED
@@ -35,7 +35,7 @@ module Collatz # rubocop:disable Style/Documentation
|
|
35
35
|
#
|
36
36
|
# @param +Integer+ *max_orbit_distance:* The maximum distance/orbit/branch length to travel.
|
37
37
|
#
|
38
|
-
# @param +Integer+ *p:* Modulus used to
|
38
|
+
# @param +Integer+ *p:* Modulus used to divide n, iff n is equivalent to (0 mod p).
|
39
39
|
#
|
40
40
|
# @param +Integer+ *a:* Factor by which to multiply n.
|
41
41
|
#
|
@@ -120,7 +120,7 @@ module Collatz # rubocop:disable Style/Documentation
|
|
120
120
|
#
|
121
121
|
# @param +Integer+ *max_orbit_distance:* The maximum distance/orbit/branch length to travel.
|
122
122
|
#
|
123
|
-
# @param +Integer+ *p:* Modulus used to
|
123
|
+
# @param +Integer+ *p:* Modulus used to divide n, iff n is equivalent to (0 mod p).
|
124
124
|
#
|
125
125
|
# @param +Integer+ *a:* Factor by which to multiply n.
|
126
126
|
#
|
@@ -167,7 +167,7 @@ module Collatz # rubocop:disable Style/Documentation
|
|
167
167
|
# an optional argument like max_stopping_time / max_total_stopping_time, as it is the
|
168
168
|
# intended target of orbits to obtain, rather than a limit to avoid uncapped computation.
|
169
169
|
#
|
170
|
-
# @param +Integer+ *p:* Modulus used to
|
170
|
+
# @param +Integer+ *p:* Modulus used to divide n, iff n is equivalent to (0 mod p).
|
171
171
|
#
|
172
172
|
# @param +Integer+ *a:* Factor by which to multiply n.
|
173
173
|
#
|
data/lib/collatz/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: collatz
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nathan Levett
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-02-23 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: |-
|
14
14
|
Provides the basic functionality to interact with the Collatz conjecture.
|
@@ -24,7 +24,7 @@ extra_rdoc_files: []
|
|
24
24
|
files:
|
25
25
|
- ".rspec"
|
26
26
|
- ".rubocop.yml"
|
27
|
-
-
|
27
|
+
- ".vscode/extensions.json"
|
28
28
|
- Gemfile
|
29
29
|
- Gemfile.lock
|
30
30
|
- LICENSE
|
@@ -54,14 +54,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
54
54
|
requirements:
|
55
55
|
- - ">="
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version:
|
57
|
+
version: 3.0.0
|
58
58
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
60
|
- - ">="
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '0'
|
63
63
|
requirements: []
|
64
|
-
rubygems_version: 3.
|
64
|
+
rubygems_version: 3.5.23
|
65
65
|
signing_key:
|
66
66
|
specification_version: 4
|
67
67
|
summary: Functions Related to the Collatz/Syracuse/3n+1 Problem
|
data/BUNDLER.md
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# Collatz
|
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/collatz`. 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
|
-
Install the gem and add to the application's Gemfile by executing:
|
10
|
-
|
11
|
-
$ bundle add collatz
|
12
|
-
|
13
|
-
If bundler is not being used to manage dependencies, install the gem by executing:
|
14
|
-
|
15
|
-
$ gem install collatz
|
16
|
-
|
17
|
-
## Usage
|
18
|
-
|
19
|
-
TODO: Write usage instructions here
|
20
|
-
|
21
|
-
## Development
|
22
|
-
|
23
|
-
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.
|
24
|
-
|
25
|
-
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).
|
26
|
-
|
27
|
-
## Contributing
|
28
|
-
|
29
|
-
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/collatz. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/collatz/blob/master/CODE_OF_CONDUCT.md).
|
30
|
-
|
31
|
-
## Code of Conduct
|
32
|
-
|
33
|
-
Everyone interacting in the Collatz project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/collatz/blob/master/CODE_OF_CONDUCT.md).
|