Sha256: f11e3099364042e039845bc699a9cc77d676038f4f684eedde1e38971f769416

Contents?: true

Size: 1.53 KB

Versions: 1

Compression:

Stored size: 1.53 KB

Contents

require 'rails'

module Admin
  module Generators
    class UninstallGenerator < Rails::Generators::Base
      desc "uninstall scaffold style.."
      def concerns_uninitializer_file
        filePath = File.expand_path(File.dirname(File.dirname(__FILE__)))
        currPath = File.expand_path("../../", filePath)
        gemsPath = File.expand_path("../", currPath)
        jbuilderRails = "#{gemsPath}/jbuilder-2.6.0/lib/generators/rails"
        jbuilderRailsBak = "#{gemsPath}/jbuilder-2.6.0/lib/generators/rails_bak"
        railtiesErbTemplates = "#{gemsPath}/railties-5.0.0/lib/rails/generators/erb/scaffold/templates"
        railtiesErbTemplatesBak = "#{gemsPath}/railties-5.0.0/lib/rails/generators/erb/scaffold/templates_bak"
        railtiesScaffoldController = "#{gemsPath}/railties-5.0.0/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb"
        railtiesScaffoldControllerBak = "#{gemsPath}/railties-5.0.0/lib/rails/generators/rails/scaffold_controller/scaffold_controller_generator.rb.bak"

        FileUtils.rm_r jbuilderRails if Dir.exists?(jbuilderRails)
        FileUtils.rm_r railtiesErbTemplates if Dir.exists?(railtiesErbTemplates)
        FileUtils.rm_r railtiesScaffoldController if Dir.exists?(railtiesScaffoldController)
        FileUtils.mv jbuilderRailsBak, jbuilderRails
        FileUtils.mv railtiesErbTemplatesBak, railtiesErbTemplates
        FileUtils.mv railtiesScaffoldControllerBak, railtiesScaffoldController
        puts "卸载重构成功"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
admin-sys-1.1.0 lib/generators/admin/uninstall_generator.rb