-
Notifications
You must be signed in to change notification settings - Fork 2
/
member.rb
107 lines (93 loc) · 2.23 KB
/
member.rb
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
require "fileutils"
# helper function for getting multiple lines of text
def multi_gets
all_text = ""
while all_text << STDIN.gets
return all_text.sub "DONE", "" if all_text["DONE"]
end
end
def main
puts "creating a new member"
# decide JA or SA creation
puts "only JA or SA are supported currently"
print "are you creating a JA? (y/n): "
ja_yes_no = gets.chomp
position = "Senior Analyst"
if ja_yes_no == "y"
position = "Junior Analyst"
puts "starting JA creation process"
else
puts "starting SA creation process"
end
# get member name
print "name: "
name = gets.chomp
name_folder = name.gsub " ", "-"
name_photo = (name.gsub " ", "_") + ".jpg"
# get degree
print "degree (default value 'Bachelor of Commerce - General'): "
degree = gets.chomp
if degree == ""
degree = "Bachelor of Commerce - General"
elsif degree == "BIE"
degree = "Bachelor of International Economics"
end
# get year
print "year (default value 2): "
year = gets.chomp
if year == ""
year = "2"
end
degree_year = degree + " | Year " + year
# get bio
puts "bio (multiline input, type DONE to end): "
bio = multi_gets
# input confirmation
writeback = <<~EOS
---
type: "team"
name: "#{name}"
degree: "#{degree_year}"
position: "#{position}"
management: "False"
research: []
headshot: #{name_photo}
---
#{bio}
EOS
print writeback
print "proceed? (y/n): "
proceed = gets.chomp
if proceed == "n"
return
end
# make folder
folder = "./src/content/Team/" + name_folder
FileUtils.mkdir folder
puts "folder created"
# move headshot
photo_origin = "./memberphotos/" + name_photo
photo_dest = folder + "/" + name_photo
begin
FileUtils.move photo_origin, photo_dest
rescue
puts "photo not found, skipping"
else
puts "photo moved"
end
# write markdown
md_dest = folder + "/index.md"
File.write(md_dest, writeback)
puts "markdown written"
print "process complete, repeat? (y/n): "
repeat = gets.chomp
if repeat == "y"
puts "restarting"
main
end
end
puts "welcome to the member creator"
puts ""
puts "please put analyst photos under a folder called memberphotos, naming convention First_Last.jpg"
puts ""
main