-
Notifications
You must be signed in to change notification settings - Fork 0
/
creatify
executable file
·103 lines (85 loc) · 2.31 KB
/
creatify
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
#!/usr/bin/ruby
### Creates files containing the mapping of filenames and function prototypes for a project
def create_indexing_files
puts """
Please paste the Holberton project webpage.
(Make sure to include advanced tasks and the
copyright notice at the bottom of the page)"""
File.open(".projectText", "w") do
|f|
x = gets()
while(x and !(x.match(/All rights reserved\./)))
f.puts(x)
x = gets()
end
end
File.open(".projectFileMap", "w") do
|map|
currentproject = 0
File.open(".projectText","r").each_line do
|line|
myMatch = line.match(/^(\d+)\. .*$/)
currentproject = myMatch[1] if myMatch
fileMatch = line.match(/\s*File: (.*)$/)
if fileMatch
files = fileMatch[1].split(", ")
files. each do
|file|
map.puts currentproject.to_s + ":" + file
end
end
end
end
File.open(".projectProtoMap", "w") do
|map|
currentproject = 0
File.open(".projectText","r").each_line do
|line|
myMatch = line.match(/^(\d+)\. .*$/)
currentproject = myMatch[1] if myMatch
protoMatch = line.match(/\s*Prototype: (.*;)$/)
if protoMatch
proto = protoMatch[1]
map.puts currentproject.to_s + ":" + proto
end
end
end
puts "-------------------------------------------"
end
### Creates the files actually used in the project
def create_project_files
unless File.exists?('.projectFileMap')
puts "Error: '.projectFileMap' not found."
exit(1)
end
num = ""
File.open(".projectFileMap", "r").each_line do
|line|
spl = line.split(':')
filename = spl[-1]
new_num = spl[0]
if new_num != num
puts ""
puts "Task #{new_num}:"
num = new_num
end
if filename.include?('/')
path = filename.chomp.split('/')
if path.length() == 1
path = path[0].chomp()
else
path = path[0...-1].join('/')
end
`mkdir -p #{path}`
puts "making dir #{path}"
end
`touch '#{filename.chomp}'`
puts "touching #{filename.chomp}"
end
`touch README.md && echo \"\# This is the root directory for a project for Holberton School\" > README.md`
puts "touching README.md"
puts "Done"
puts "-------------------------------------------"
end
create_indexing_files()
create_project_files()