brutalitops 1.0.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README +42 -0
- data/bin/brutalitops +57 -56
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90b13fda7a7a5079244ae8b974fb3f0b8ee2acfbbc5ddb6d7b49731b636c5a82
|
4
|
+
data.tar.gz: d11b46b9ff069374d71f949d249d0aca175d40c8b98845473af999a1a569ba00
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22072c221ba4c31f5e25575bbba5754206df46425c5bab6a4ecd3b1b2bc2a5bab0e3dbcb485ea048992b4d3accde513b804c40e96719fdc912c134706c8df40d
|
7
|
+
data.tar.gz: af1bd27da73a058fe3d11458bd7e9f8d3524ba4c5927f1c1e790b04bad9a13d172f1d3a841137e231da3567b5e6779f8c7bd6232bbecd0abaddb33491673fc1a
|
data/README
CHANGED
@@ -1,2 +1,44 @@
|
|
1
1
|
Generates permutations and returns an array, or prints to csv, or prints to console. See https://github.com/andydwyer/brutalitops for usage.
|
2
2
|
|
3
|
+
# Usage
|
4
|
+
|
5
|
+
## Initialization
|
6
|
+
|
7
|
+
```
|
8
|
+
Brutalitops.new( min_length_of_the_permutation, max_length_of_the_permutation, [optional_symbols_and_or_custom_array] )
|
9
|
+
|
10
|
+
Example:
|
11
|
+
b = Brutalitops.new(1,3,[:alpha_lowercase, :alpha_uppercase, :nums, :special_chars, ["ä", "ö", "ü"]])
|
12
|
+
|
13
|
+
:alpha_lowercase = ('a'..'z').to_a
|
14
|
+
:alpha_uppercase = ('A'..'Z').to_a
|
15
|
+
:nums = (0..9).to_a
|
16
|
+
:special_chars = [' ', '!', '@', '#', '$', '%','^', '&', '*', '(', ')', '-', '_', '+', '=', '[', ']', '{', '}', '|', '\\', '?', "/", '<', '>', '.', ',', '~', '`']
|
17
|
+
["ä", "ö", "ü"] = any array of elements
|
18
|
+
|
19
|
+
All arrays passed in as the 3rd argument are concatentated.
|
20
|
+
|
21
|
+
Note: Generating permutations when max_length_of_the_permutation > 3 might take a long time (i.e. hours) depending on your processing power.
|
22
|
+
```
|
23
|
+
|
24
|
+
## Methods
|
25
|
+
|
26
|
+
```
|
27
|
+
b.print_permutations_to_console
|
28
|
+
|
29
|
+
-Prints the resulting permutations to console.
|
30
|
+
-Accepts an optional boolean argument to turn off status-related console messages, e.g. b.print_permutations_to_console(false)
|
31
|
+
```
|
32
|
+
|
33
|
+
```
|
34
|
+
b.print_permutations_to_csv
|
35
|
+
|
36
|
+
-Prints the resulting permutations to a CSV named brutalitops_<time stamp>.csv
|
37
|
+
-Accepts an optional boolean argument to turn off status-related console messages, e.g. b.print_permutations_to_csv(false)
|
38
|
+
```
|
39
|
+
|
40
|
+
```
|
41
|
+
a = b.to_array
|
42
|
+
|
43
|
+
-Returns the resulting permutations to an array
|
44
|
+
```
|
data/bin/brutalitops
CHANGED
@@ -1,75 +1,76 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
class Brutalitops
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
2
|
+
module Brutalitops
|
3
|
+
class Brutalitops
|
4
|
+
|
5
|
+
def initialize(min, max, options=[])
|
6
|
+
alphabet_lowercase = ('a'..'z').to_a
|
7
|
+
alphabet_uppercase = ('A'..'Z').to_a
|
8
|
+
nums = (0..9).to_a
|
9
|
+
specials = [' ', '!', '@', '#', '$', '%','^', '&', '*', '(', ')', '-', '_', '+', '=', '[', ']', '{', '}', '|', '\\', '?', "/", '<', '>', '.', ',', '~', '`']
|
10
|
+
|
11
|
+
@min = min
|
12
|
+
@max = max
|
13
|
+
@selection = []
|
14
|
+
|
15
|
+
if !options.empty?
|
16
|
+
options.each do |option|
|
17
|
+
case option
|
18
|
+
when :alpha_lowercase
|
19
|
+
@selection += alphabet_lowercase
|
20
|
+
when :alpha_uppercase
|
21
|
+
@selection += alphabet_uppercase
|
22
|
+
when :nums
|
23
|
+
@selection += nums
|
24
|
+
when :special_chars
|
25
|
+
@selection += specials
|
26
|
+
else
|
27
|
+
#handle custom array passed in
|
28
|
+
@selection += option
|
29
|
+
end
|
29
30
|
end
|
30
31
|
end
|
31
32
|
end
|
32
|
-
end
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
34
|
+
def print_permutations_to_console(verbose=true)
|
35
|
+
generate_permutations(verbose).each do |permutation|
|
36
|
+
puts permutation
|
37
|
+
end
|
37
38
|
end
|
38
|
-
end
|
39
39
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
40
|
+
def print_permutations_to_csv(verbose=true)
|
41
|
+
puts "Generating csv..." if verbose
|
42
|
+
File.open("brutalitops_#{Time.now.strftime("%Y_%m_%d_%H%M%S").to_s}.csv", "w") do |file|
|
43
|
+
generate_permutations(verbose).each do |permutation|
|
44
|
+
file.puts permutation
|
45
|
+
end
|
45
46
|
end
|
47
|
+
puts "Finished generating csv." if verbose
|
46
48
|
end
|
47
|
-
puts "Finished generating csv." if verbose
|
48
|
-
end
|
49
49
|
|
50
|
-
|
51
|
-
|
52
|
-
|
50
|
+
def to_array
|
51
|
+
generate_permutations
|
52
|
+
end
|
53
53
|
|
54
|
-
private
|
54
|
+
private
|
55
55
|
|
56
|
-
|
57
|
-
|
58
|
-
|
56
|
+
def generate_permutations(verbose=false)
|
57
|
+
permutations = []
|
58
|
+
puts "Generating permutations..." if verbose
|
59
59
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
60
|
+
@min.upto(@max) do |i|
|
61
|
+
puts "Building permutation with #{i} choices. This might take some time." if verbose
|
62
|
+
temp_arr = @selection.repeated_permutation(i).to_a
|
63
|
+
temp_arr.each {|t| permutations << t.join.to_s}
|
64
|
+
puts "Finished building permutation with #{i} choices." if verbose
|
65
|
+
end
|
66
66
|
|
67
|
-
|
68
|
-
|
67
|
+
puts "Finished permutations." if verbose
|
68
|
+
puts "Number of permutations generated: #{permutations.size}" if verbose
|
69
69
|
|
70
|
-
|
71
|
-
|
70
|
+
permutations
|
71
|
+
end
|
72
72
|
|
73
|
+
end
|
73
74
|
end
|
74
75
|
|
75
76
|
#test things out
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: brutalitops
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- andydwyer
|
@@ -10,8 +10,8 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2020-06-04 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description:
|
14
|
-
to console. See https://github.com/andydwyer/brutalitops for usage
|
13
|
+
description: Generates permutations and returns an array, or prints to csv, or prints
|
14
|
+
to console. See https://github.com/andydwyer/brutalitops for usage.
|
15
15
|
email: ktanyag@gmail.com
|
16
16
|
executables:
|
17
17
|
- brutalitops
|