Sha256: de1f5dd690a49fd92027638c76dbfd7c0008c49c60624714e015af4cdb812d50

Contents?: true

Size: 1.45 KB

Versions: 3

Compression:

Stored size: 1.45 KB

Contents

module PowerStencil
  module CommandProcessors

    class Delete

      include Climatic::Script::UnimplementedProcessor
      include Climatic::Proxy
      include PowerStencil::Project::Proxy
      include PowerStencil::CommandProcessors::EntityHelper

      def execute
        analyse_extra_params.each do |search_criterion|
          begin
            unless project.engine.entity *search_criterion.to_a, project.engine.root_universe
              puts_and_logs "Skipping '#{search_criterion.as_path}'. Entity not found.", check_verbose: false
              next
            end
            puts_and_logs "Deleting entity '#{search_criterion.as_path}'", check_verbose: false
            if project.engine.delete_entity project.engine.root_universe,
                                            *search_criterion.to_a,
                                            delete_files: config[:'delete-files']
              msg = "Deleted '#{search_criterion.as_path}'"
              msg << ' and associated files.' if config[:'delete-files']
              puts_and_logs msg, check_verbose: false
            else
              puts_and_logs 'Cancelled by user input.', check_verbose: false
            end
          rescue => e
            puts_and_logs "Failed to delete '#{search_criterion.as_path}' with message '#{e.message}'.", logs_as: :error, check_verbose: false
            logger.debug PowerStencil::Error.report_error(e)
          end
        end
      end

    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
power_stencil-0.6.3 lib/power_stencil/command_processors/delete.rb
power_stencil-0.6.2 lib/power_stencil/command_processors/delete.rb
power_stencil-0.6.1 lib/power_stencil/command_processors/delete.rb