Module: Capo::Capfile

Defined in:
lib/capo/capfile.rb

Class Method Summary collapse

Class Method Details

.generateObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/capo/capfile.rb', line 4

def generate
  files.each do |file, content|
    file = File.join Capo.app_path, file
    if File.exists?(file)
      warn "[skip] '#{file}' already exists"
    elsif File.exists?(file.downcase)
      warn "[skip] '#{file.downcase}' exists, which could conflict with '#{file}'"
    else
      unless File.exists?(File.dirname(file))
        puts "[add] making directory '#{File.dirname file}'"
        FileUtils.mkdir File.dirname(file)
      end
      puts "[add] writing '#{file}'"
      File.open(file, 'w'){|f| f.write content}
    end
  end
end