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
|
# File 'lib/skeletal.rb', line 4
def self.create! app_name
@app_dir = File.expand_path(app_name)
puts "Generating application #{app_name}..."
folders = %w( app/models app/helpers app/views app/views/layouts lib logs config tasks db/migrations public/images public/js public/css )
unless options[:classic]
folders << 'app/routes'
end
if options[:rspec]
folders << 'spec'
end
if options[:cucumber]
folders << %w( features/step_definitions features/support )
end
folders.flatten.each do |dir|
puts '> '+dir
FileUtils.mkpath(File.join(@app_dir, dir))
end
@app_file = File.join(File.expand_path(app_name), 'app', "#{app_name}.rb")
@class_name = app_name.downcase.gsub(/[-_\s]+/, ' ').split(' ').map{|word| word.capitalize }.join
puts '> '+@app_file
File.open(@app_file, 'w') do |file|
file.write(%Q{
require 'rubygems'
require 'sinatra'
class #{@class_name} < Sinatra::Application
configure do
# Configuration here
end
end
})
end
['Gemfile', '.gitignore', 'spec/spec_helper.rb', "spec/#{app_name}_spec.rb" ].each do |file|
puts '> '+file
FileUtils.touch(File.join(@app_dir, file))
end
`cd #{@app_dir} && git init && git add . && git commit -m "Initial Commit"`
end
|