lib/sinatra/commands/app_generator_command.rb in sinatra-template-1.2.0 vs lib/sinatra/commands/app_generator_command.rb in sinatra-template-1.3.0
- old
+ new
@@ -7,53 +7,41 @@
def self.help
"app_name"
end
- def initialize(*args)
- super
- @app_dir = File.expand_path(pwd)
- end
-
def classified
"#{self.name.classify}App"
end
def call
# mkdir self.underscored, verbose: true
%w{apps spec/apps}.each do |dir|
- Dir[File.expand_path(File.join(dir, "**", "*"), Sinatra.template_dir)].each do |f|
+ Dir[template_path("**", "*")].each do |f|
if File.directory?(f)
- mkdir_p clean_string(f), verbose: true
+ FileUtils.mkdir_p clean_string(f), verbose: true
else
- mkdir_p clean_string(File.dirname(f)), verbose: true
+ FileUtils.mkdir_p clean_string(File.dirname(f)), verbose: true
File.open(clean_string(f), 'w') do |file|
file.puts clean_string(File.read(f))
end
end
end
end
- File.open(File.expand_path(File.join(@app_dir, "config.ru")), "a") do |file|
+ File.open(app_path("assets", "javascripts", "#{self.underscored}.js.coffee"), 'w') do |file|
+ file.puts ""
+ end
+ File.open(app_path("assets", "stylesheets", "#{self.underscored}.css.scss"), 'w') do |file|
+ file.puts ""
+ end
+ File.open(app_path("config.ru"), "a") do |file|
file.puts <<-EOF
map "/#{self.underscored}" do
run #{self.classified}
end
EOF
end
- path = File.expand_path(File.join(@app_dir, "spec", "apps", "#{self.underscored}_spec.rb"))
- mkdir_p File.dirname(path), verbose: true
- File.open(path, 'w') do |file|
- file.puts <<-EOF
- require 'spec_helper'
-
- describe #{self.classified} do
-
- it "does something"
-
- end
- EOF
- end
end
end
end
\ No newline at end of file