-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerator.rb
More file actions
72 lines (61 loc) · 2.26 KB
/
generator.rb
File metadata and controls
72 lines (61 loc) · 2.26 KB
1
2
3
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
require 'csv'
require 'colorize'
# Instructions
system("clear")
puts "Welcome to Mallory's a/A Practice Assessment Generator".cyan
puts "This generator will create a practice test based on your input. "
puts "This program will generate 3 files in this folder: practice_test, spec, and solution. " \
"Complete the practice_test file, running the spec file (SpecRunner.html) to check your answers. "
puts "You can pick from the following questions names:"
puts "base_converter my_find
binary_search my_flatten
bubble_sort my_inject
caesar_cipher my_join
deep_dup my_reject
digital_root my_reverse
doubler my_rotate
dups my_slice
exponent my_some
factorials_rec permutations
factors pig_latinify
fibs_sum prime_factorization
first_even_numbers_sum primes
inherits quicksort
jumble_sort real_words_in_string
median rec_sum
merge_sort string_include_key
my_bind subsets
my_call symmetric_substrings
my_curry titleize
my_each transpose
my_every two_sum
my_filter
"
# read in csv with test info
tests = CSV.read('list.csv', headers: true, header_converters: :symbol, converters: :all)
# list possible categories
categories = Array.new
tests.each do |test|
categories << test[1]
end
categories = categories.uniq
puts "Possible categories: #{categories.join(", ")}".magenta
puts
# get user request
puts "Input your requests, separated by commas and spaces please"
puts "Example input: " + "two_sum".yellow
input = gets.chomp
# create new test, spec and solution files
practice_test = File.open("practice_test.js", "w")
spec = File.open("spec.js", "w")
solution = File.open("solution.js", "w")
# go through master tests and add text to the new files
practice_test << File.read('problems/'+ input +'.js') << "\n"
spec << File.read('specs/'+ input +'_spec.js') << "\n"
solution << File.read('solutions/'+ input +'_solution.js') << "\n"
# close the files that were just created
practice_test.close
spec.close
solution.close
puts
puts "Done!"