Sha256: beea9f531efa591acfd56a89c3176cc3bd9eaf6f2cd3c10730e4c01683246921

Contents?: true

Size: 950 Bytes

Versions: 20

Compression:

Stored size: 950 Bytes

Contents

# encoding: utf-8
module TestServer
  module Actions
    class CreateOutput
      private

      attr_reader :name, :output, :engine, :repository, :data

      public

      def initialize(name, output, data, engine = ErbGenerator, repository = TemplateRepository.new)
        @name        = name
        @output      = output
        @data        = data
        @engine      = engine
        @repository  = repository
      end

      def run
        TestServer.ui_logger.info "Creating example configuration:"
        template(name, output, data)
      end

      private

      def template(local_name, local_destination, local_data)
        template = repository.find(local_name)

        generator = engine.new(local_data)
        generator.compile(template, local_destination)
      rescue Errno::ENOENT
        fail Exceptions::ErbTemplateIsUnknown, JSON.dump(message: "Unknown erb template \"#{template_path}\".")
      end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
test_server-0.5.2 lib/test_server/actions/create_output.rb
test_server-0.5.1 lib/test_server/actions/create_output.rb
test_server-0.5.0 lib/test_server/actions/create_output.rb
test_server-0.4.1 lib/test_server/actions/create_output.rb
test_server-0.4.0 lib/test_server/actions/create_output.rb
test_server-0.3.7 lib/test_server/actions/create_output.rb
test_server-0.3.6 lib/test_server/actions/create_output.rb
test_server-0.3.5 lib/test_server/actions/create_output.rb
test_server-0.3.4 lib/test_server/actions/create_output.rb
test_server-0.3.2 lib/test_server/actions/create_output.rb
test_server-0.3.1 lib/test_server/actions/create_output.rb
test_server-0.2.4 lib/test_server/actions/create_output.rb
test_server-0.2.3 lib/test_server/actions/create_output.rb
test_server-0.2.2 lib/test_server/actions/create_output.rb
test_server-0.2.1 lib/test_server/actions/create_output.rb
test_server-0.2.0 lib/test_server/actions/create_output.rb
test_server-0.1.2 lib/test_server/actions/create_output.rb
test_server-0.1.1 lib/test_server/actions/create_output.rb
test_server-0.1.0 lib/test_server/actions/create_output.rb
test_server-0.0.11 lib/test_server/actions/create_output.rb