Creating directories using DATA Object

Hi,

Kindly note that I am student and I need some help understanding some
beginner-ruby code.

I am trying to do the following:

1- create a script that accept a command line directory name
2- check whether the directory exists (if yes, I will ask the user to
confirm if he likes to use the existing directory)
3- create directories and sub-directories using the DATA object that
reads the structure after the END

let’s forget about step#2 for now.

This is my script:

if ARGV.empty?
puts “__________________________________________ _ "
puts " "
puts “USAGE: ruby script/generate.rb Your_Site_Name”
puts "
_________________________________________ _ _”

#Process the data that follows END and create directories
elsif Dir.exists?("/home/students/name/public_html/cis113/#{ARGV[0]}")
puts “This directory already exist!”
puts “Would you like to use the existing directory (Y/N)?”

else
#Dir.mkdir("/home/students/name/public_html/cis113/#{ARGV[0]}")
DATA.each do |line|
FileUtils.makedirs
“/home/students/name/public_html/cis113/#{ARGV[0]}/#{line}”
end

end

END

app/views/layouts
app/models
app/controllers
config
db
doc
lib
public/javascripts
public/stylesheets
public/images
log

I executed my script on Linus server and it worked without any error BUT
when I try to delete the main directory (ARGV[0]) from the server, it
says: no such file or directory, the same problem happens when I try to
delete any of the sub-directories.
I am using FTP software that I always use for my file uploads and
deletion.

I would like to know if this is the right way to create the directory
structure given,.

thank you SO MUCH

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs