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.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README +42 -0
  3. data/bin/brutalitops +57 -56
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3fb7ccf41927b8945bc986b4113072a833500e26ef2e6f4198b777e968ac31d4
4
- data.tar.gz: e098e2de80e874745888eefddd0b326284b15fc64afebdb17454baadf712b66d
3
+ metadata.gz: 90b13fda7a7a5079244ae8b974fb3f0b8ee2acfbbc5ddb6d7b49731b636c5a82
4
+ data.tar.gz: d11b46b9ff069374d71f949d249d0aca175d40c8b98845473af999a1a569ba00
5
5
  SHA512:
6
- metadata.gz: 31eedc9cfd8f1062ead44a57cf7e627a4fc074e6b4c0c120791fc8f8cd5e183ecaab0a9b1ec1cfdf6e01548b5ec93ac86505b44421f8e5771c4bce0a5645c397
7
- data.tar.gz: e021209db9b87e5cb35909cff3442e66b273d778b01adbb101c740c086f725c8435dafdd297531819bc0439a67d78eefb465fe4a6599ed3e29514c7c74bf26d6
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
+ ```
@@ -1,75 +1,76 @@
1
1
  #!/usr/bin/env ruby
2
-
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
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
- def print_permutations_to_console(verbose=true)
35
- generate_permutations(verbose).each do |permutation|
36
- puts permutation
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
- 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
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
- def to_array
51
- generate_permutations
52
- end
50
+ def to_array
51
+ generate_permutations
52
+ end
53
53
 
54
- private
54
+ private
55
55
 
56
- def generate_permutations(verbose=false)
57
- permutations = []
58
- puts "Generating permutations..." if verbose
56
+ def generate_permutations(verbose=false)
57
+ permutations = []
58
+ puts "Generating permutations..." if verbose
59
59
 
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
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
- puts "Finished permutations." if verbose
68
- puts "Number of permutations generated: #{permutations.size}" if verbose
67
+ puts "Finished permutations." if verbose
68
+ puts "Number of permutations generated: #{permutations.size}" if verbose
69
69
 
70
- permutations
71
- end
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.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: "Generates permutations and returns an array, or prints to csv, or prints
14
- to console. See https://github.com/andydwyer/brutalitops for usage.\n\n"
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