Sha256: dd768e51cc974086b435981c10fc9cf0a75e9f142704be774df1c34fc4291dcd
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
module Sinatra class AppDestroyer < Sinatra::NameCommand def self.command "destroy:app" end 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 path = File.expand_path(File.join(@app_dir, "apps", "#{self.underscored}.rb")) begin rm path, verbose: true rescue Errno::ENOENT => e end path = File.expand_path(File.join(@app_dir, "apps", "views", self.underscored)) begin rm_r path, verbose: true rescue Errno::ENOENT => e end path = File.expand_path(File.join(@app_dir, "spec", "apps", "#{self.underscored}_spec.rb")) begin rm path, verbose: true rescue Errno::ENOENT => e end path = File.expand_path(File.join(@app_dir, "config.ru")) old = File.read(path) File.open(path, "w") do |file| map = <<-EOF map "/#{self.underscored}" do run #{self.classified} end EOF file.puts old.gsub(map, "") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sinatra-template-1.2.0 | lib/sinatra/commands/app_destroyer_command.rb |
sinatra-template-1.1.0 | lib/sinatra/commands/app_destroyer_command.rb |