Sha256: aab10bc4400892da96925052dc603f5b8867f16142306bb7c1c642034ea3035d

Contents?: true

Size: 993 Bytes

Versions: 39

Compression:

Stored size: 993 Bytes

Contents

module PowerStencil
  module CommandProcessors

    class Edit

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

      def execute
        targets = targets_from_criteria analyse_extra_params, project.engine.root_universe
        targets.each do |target|
          securely_edit_file target.source_uri do |modified_path, _|
            modifications_valid? modified_path, target
          end
        end
      end

      private

      def modifications_valid?(modified_path, original_entity)
        test_entity = UniverseCompiler::Entity::Persistence.load modified_path
        test_entity.valid?
      rescue => e
        logger.debug PowerStencil::Error.report_error(e)
        logger.debug "Modifications applied to '#{original_entity.as_path}' are invalid !"
        false
      end

    end

  end
end

Version data entries

39 entries across 39 versions & 1 rubygems

Version Path
power_stencil-0.4.8 lib/power_stencil/command_processors/edit.rb
power_stencil-0.4.7 lib/power_stencil/command_processors/edit.rb
power_stencil-0.4.6 lib/power_stencil/command_processors/edit.rb
power_stencil-0.4.5 lib/power_stencil/command_processors/edit.rb
power_stencil-0.4.4 lib/power_stencil/command_processors/edit.rb
power_stencil-0.4.3 lib/power_stencil/command_processors/edit.rb
power_stencil-0.4.2 lib/power_stencil/command_processors/edit.rb
power_stencil-0.4.1 lib/power_stencil/command_processors/edit.rb
power_stencil-0.4.0 lib/power_stencil/command_processors/edit.rb
power_stencil-0.3.9 lib/power_stencil/command_processors/edit.rb
power_stencil-0.3.8 lib/power_stencil/command_processors/edit.rb
power_stencil-0.3.7 lib/power_stencil/command_processors/edit.rb
power_stencil-0.3.6 lib/power_stencil/command_processors/edit.rb
power_stencil-0.3.5 lib/power_stencil/command_processors/edit.rb
power_stencil-0.3.4 lib/power_stencil/command_processors/edit.rb
power_stencil-0.3.3 lib/power_stencil/command_processors/edit.rb
power_stencil-0.3.2 lib/power_stencil/command_processors/edit.rb
power_stencil-0.3.1 lib/power_stencil/command_processors/edit.rb
power_stencil-0.3.0 lib/power_stencil/command_processors/edit.rb