Class: Deano::AppDestroyer

Inherits:
NameCommand show all
Defined in:
lib/deano/commands/app_destroyer_command.rb

Instance Attribute Summary

Attributes inherited from NameCommand

#args, #name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from NameCommand

#clean_string, inherited, #initialize, #underscored

Methods inherited from Command

#app_path, #cmd, commands, inherited, #rm, #rm_r, #template_path

Constructor Details

This class inherits a constructor from Deano::NameCommand

Class Method Details

.commandObject



4
5
6
# File 'lib/deano/commands/app_destroyer_command.rb', line 4

def self.command
  "destroy:app"
end

.helpObject



8
9
10
# File 'lib/deano/commands/app_destroyer_command.rb', line 8

def self.help
  "app_name"
end

Instance Method Details

#callObject



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
# File 'lib/deano/commands/app_destroyer_command.rb', line 16

def call
  path = app_path("apps", "#{self.underscored}.rb")
  rm path

  path = app_path("apps", "views", self.underscored)
  rm_r path

  path = app_path("spec", "apps", "#{self.underscored}_spec.rb")
  rm path

  path = app_path("assets", "javascripts", "#{self.underscored}.js.coffee")
  rm path

  path = app_path("assets", "stylesheets", "#{self.underscored}.css.scss")
  rm path

  path = app_path("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

#classifiedObject



12
13
14
# File 'lib/deano/commands/app_destroyer_command.rb', line 12

def classified
  "#{self.name.classify}App"
end