Sha256: e24000606e53c7baff0362f5db3b6e3a10c0db1da92a2c4dff861c89219ba556
Contents?: true
Size: 1.21 KB
Versions: 2
Compression:
Stored size: 1.21 KB
Contents
require 'active_support' require 'active_support/core_ext' require 'tilt' require 'canpe/file_manipulation' require 'canpe/template_renderer' require 'canpe/repository_operation_context' module Canpe class RepositoryOperation include FileManipulation attr_reader :repository, :renderer, :context def initialize(repository) @repository = repository @renderer = TemplateRenderer.new(self) @context = RepositoryOperationContext.new(self) end def prepare_operation(options = {}) context.prepare(options) renderer.prepare(options) end def generate_file(path) if File.directory?(context.source_file_path(path)) create_evaluated_directory(path) else copy_evaluated_file(path) end end def create_evaluated_directory(path) path = renderer.render_string(path) url = File.join(context.destination_root, path) create_directory(url) end def copy_evaluated_file(path) template_file = renderer.render_file(context.source_file_path(path)) copy_file(template_file.path, context.destination_file_path(path)) end def delete_file(path) super context.destination_file_path(path) end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
canpe-0.1.1 | lib/canpe/repository_operation.rb |
canpe-0.1.0 | lib/canpe/repository_operation.rb |