Sha256: 68d3034ada7bb794919bf4ced7fac6e4cd1cb95e7f5eafe134798480c62c9d07

Contents?: true

Size: 1.77 KB

Versions: 30

Compression:

Stored size: 1.77 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
        targets = targets_from_criteria analyse_extra_params, project.engine.root_universe
        targets.each do |target|
          begin
            # unless project.engine.entity *target.to_a, project.engine.root_universe
            #   puts_and_logs "Skipping '#{target.as_path}'. Entity not found.", check_verbose: false
            #   next
            # end
            puts_and_logs "Deleting entity '#{target.as_path}'", check_verbose: false

            msg = "Deleted entity '#{target.as_path}' (and potential dependencies)"
            msg << ' including templates.' if config[:'delete-files']
            msg << '.'
            project.track_action_with_git(msg) do
              if project.engine.delete_entity project.engine.root_universe,
                                              target.type,
                                              target.name,
                                              delete_files: config[:'delete-files']
                msg = "Deleted '#{target.as_path}'"
                msg << ' and template files.' if config[:'delete-files']
                puts_and_logs msg, check_verbose: false
              else
                puts_and_logs 'Cancelled by user input.', check_verbose: false
              end
            end
          rescue => e
            puts_and_logs "Failed to delete '#{target.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

30 entries across 30 versions & 1 rubygems

Version Path
power_stencil-0.10.0 lib/power_stencil/command_processors/delete.rb
power_stencil-0.9.8 lib/power_stencil/command_processors/delete.rb
power_stencil-0.9.7 lib/power_stencil/command_processors/delete.rb
power_stencil-0.9.6 lib/power_stencil/command_processors/delete.rb
power_stencil-0.9.5 lib/power_stencil/command_processors/delete.rb
power_stencil-0.9.4 lib/power_stencil/command_processors/delete.rb
power_stencil-0.9.3 lib/power_stencil/command_processors/delete.rb
power_stencil-0.9.2 lib/power_stencil/command_processors/delete.rb
power_stencil-0.9.1 lib/power_stencil/command_processors/delete.rb
power_stencil-0.9.0 lib/power_stencil/command_processors/delete.rb
power_stencil-0.8.14 lib/power_stencil/command_processors/delete.rb
power_stencil-0.8.13 lib/power_stencil/command_processors/delete.rb
power_stencil-0.8.12 lib/power_stencil/command_processors/delete.rb
power_stencil-0.8.11 lib/power_stencil/command_processors/delete.rb
power_stencil-0.8.10 lib/power_stencil/command_processors/delete.rb
power_stencil-0.8.9 lib/power_stencil/command_processors/delete.rb
power_stencil-0.8.8 lib/power_stencil/command_processors/delete.rb
power_stencil-0.8.7 lib/power_stencil/command_processors/delete.rb
power_stencil-0.8.6 lib/power_stencil/command_processors/delete.rb
power_stencil-0.8.5 lib/power_stencil/command_processors/delete.rb