lib/sinatra/commands/model_generator_command.rb in sinatra-template-1.2.0 vs lib/sinatra/commands/model_generator_command.rb in sinatra-template-1.3.0

- old
+ new

@@ -7,29 +7,24 @@ def self.help "model_name" end - def initialize(*args) - super - @app_dir = File.expand_path(pwd) - end - def call - path = File.expand_path(File.join(@app_dir, "models", "#{self.underscored}.rb")) - mkdir_p File.dirname(path), verbose: true + path = app_path("models", "#{self.underscored}.rb") + FileUtils.mkdir_p File.dirname(path), verbose: true File.open(path, 'w') do |file| file.puts <<-EOF class #{self.classified} include Mongoid::Document include Mongoid::Timestamps end EOF end - path = File.expand_path(File.join(@app_dir, "spec", "models", "#{self.underscored}_spec.rb")) - mkdir_p File.dirname(path), verbose: true + path = app_path("spec", "models", "#{self.underscored}_spec.rb") + FileUtils.mkdir_p File.dirname(path), verbose: true File.open(path, 'w') do |file| file.puts <<-EOF require 'spec_helper' describe #{self.classified} do \ No newline at end of file