Class: Templet::DestroyGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/templet/destroy/destroy_generator.rb

Constant Summary collapse

ALL_DESC =
"Remove all files to do with this framework (default: false)"
CORE_DESC =
"Remove all of the core (framework) files (default: false)"
APP_DESC =
"Remove the application files under app/helpers/app/ and all tests (default: false)"
SPEC_DESC =
"Remove just the tests for the template core (default: false)"
DEST_DESC =
'The directory that the core code will be copied into'

Instance Method Summary collapse

Instance Method Details

#checkObject



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/generators/templet/destroy/destroy_generator.rb', line 22

def check
  if rm_all? or rm_core_rspec? or rm_app? or rm_core?
    unless yes? 'Please confirm that you are about to delete a slew of files?'
      exit
    end
  else
    generate 'templet:destroy --help'

    puts 'Note that at least one option needs to be given'

    exit
  end
end

#rm_app_treesObject



58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# File 'lib/generators/templet/destroy/destroy_generator.rb', line 58

def rm_app_trees
  if app_delete?
    rm 'app/helpers/app.rb'

    rm 'app/helpers/app/'

    rm %w(spec/helpers/app/ spec/support/templet/)

    rm %w(spec/apis/ spec/support/apis/)

    puts "Note that any generated controllers won't have been removed"
    puts "  You'll have to manually delete these yourself"
    puts "  There may also be entries in config/routes.rb"
  end
end

#rm_controllerObject



47
48
49
50
51
# File 'lib/generators/templet/destroy/destroy_generator.rb', line 47

def rm_controller
  if core_delete?
    rm %w(app/controllers/templet/)
  end
end

#rm_coreObject



36
37
38
39
40
41
42
43
44
45
# File 'lib/generators/templet/destroy/destroy_generator.rb', line 36

def rm_core
  if core_delete?
    rm %w(app/helpers/templet/ lib/templet/)
    rm 'app/helpers/templet_helper.rb'

    if ( dest = options['dest'] ).present?
      rm dest
    end
  end
end

#rm_core_rspecObject



74
75
76
77
78
79
80
81
82
# File 'lib/generators/templet/destroy/destroy_generator.rb', line 74

def rm_core_rspec
  if rm_all? or rm_core? or rm_core_rspec?
    rm %w(spec/helpers/templet/)

    rm %w(spec/support/templet/rest_link_procs_assignments.rb
          spec/support/templet/rest_link_procs_helpers.rb
          spec/support/templet/model_parent_helpers.rb)
  end
end

#rm_helpers_rbObject



53
54
55
56
# File 'lib/generators/templet/destroy/destroy_generator.rb', line 53

def rm_helpers_rb
  if core_delete?
  end
end