Module: RTram::Project
- Defined in:
- lib/rtram/project.rb
Defined Under Namespace
Classes: Error
Class Method Summary collapse
Class Method Details
.create(project_name) ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/rtram/project.rb', line 10 def create(project_name) if project_name working_directory = project_name Dir.mkdir(working_directory) unless Dir.exist?(working_directory) else working_directory = './' end unless Dir.exist?("#{working_directory}/slim") Dir.mkdir("#{working_directory}/slim") FileUtils.cp("#{RTram.root}/slim/index.slim", "#{working_directory}/slim") end unless Dir.exist?("#{working_directory}/sass") Dir.mkdir("#{working_directory}/sass") FileUtils.cp("#{RTram.root}/sass/main.scss", "#{working_directory}/sass") end Dir.mkdir("#{working_directory}/output") unless Dir.exist?("#{working_directory}/output") Dir.mkdir("#{working_directory}/output/css") unless Dir.exist?("#{working_directory}/output/css") Dir.mkdir("#{working_directory}/output/image") unless Dir.exist?("#{working_directory}/output/image") end |
.valid?(project_name) ⇒ Boolean
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/rtram/project.rb', line 33 def valid?(project_name) none_directories = [] none_directories << project_name unless Dir.exist?(project_name) none_directories << "#{project_name}/slim" unless Dir.exist?("#{project_name}/slim") none_directories << "#{project_name}/sass" unless Dir.exist?("#{project_name}/sass") none_directories << "#{project_name}/output" unless Dir.exist?("#{project_name}/output") none_directories << "#{project_name}/output/css" unless Dir.exist?("#{project_name}/output/css") if none_directories.length > 0 raise Error.new <<~EOS \nThe project does not have working directories: #{none_directories.join(', ')}. Use `rtram new {project_name}` command to create working directories. EOS else return true end end |