-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathutil.rb
More file actions
40 lines (35 loc) · 871 Bytes
/
util.rb
File metadata and controls
40 lines (35 loc) · 871 Bytes
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
module MRubyCLI
class Util
class << self
def camelize(string)
string.split("-").map {|w| w.capitalize }.map {|w|
w.split("_").map {|w2| w2.capitalize }.join('')
}.join('')
end
def create_dir_p(dir)
dir.split("/").inject("") do |parent, base|
new_dir =
if parent == ""
base
else
"#{parent}/#{base}"
end
create_dir(new_dir)
new_dir
end
end
def create_dir(dir)
if Dir.exist?(dir)
@output.puts " skip #{dir}"
else
@output.puts " create #{dir}/"
Dir.mkdir(dir)
end
end
def write_file(file, contents)
@output.puts " create #{file}"
File.open(file, 'w') {|file| file.puts contents }
end
end
end
end