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.6.3 lib/power_stencil/command_processors/edit.rb
power_stencil-0.6.2 lib/power_stencil/command_processors/edit.rb
power_stencil-0.6.1 lib/power_stencil/command_processors/edit.rb
power_stencil-0.6.0 lib/power_stencil/command_processors/edit.rb
power_stencil-0.5.1 lib/power_stencil/command_processors/edit.rb
power_stencil-0.5.0 lib/power_stencil/command_processors/edit.rb
power_stencil-0.4.22 lib/power_stencil/command_processors/edit.rb
power_stencil-0.4.21 lib/power_stencil/command_processors/edit.rb
power_stencil-0.4.20 lib/power_stencil/command_processors/edit.rb
power_stencil-0.4.19 lib/power_stencil/command_processors/edit.rb
power_stencil-0.4.18 lib/power_stencil/command_processors/edit.rb
power_stencil-0.4.17 lib/power_stencil/command_processors/edit.rb
power_stencil-0.4.16 lib/power_stencil/command_processors/edit.rb
power_stencil-0.4.15 lib/power_stencil/command_processors/edit.rb
power_stencil-0.4.14 lib/power_stencil/command_processors/edit.rb
power_stencil-0.4.13 lib/power_stencil/command_processors/edit.rb
power_stencil-0.4.12 lib/power_stencil/command_processors/edit.rb
power_stencil-0.4.11 lib/power_stencil/command_processors/edit.rb
power_stencil-0.4.10 lib/power_stencil/command_processors/edit.rb
power_stencil-0.4.9 lib/power_stencil/command_processors/edit.rb