def create_engine(&block)
      @engine = parent_module.const_set('Engine', Class.new(Rails::Engine) do

        def spark_plugin_path
          parent = Object.const_get(self.class.name.sub(/::Engine/,''))
          Pathname.new parent.instance_variable_get("@gem_path")
        end

        def config
          @config ||= Rails::Engine::Configuration.new(spark_plugin_path)
        end

        engine_name SparkEngine.plugin.name

        require 'spark_engine/middleware'

        # Ensure compiled assets in /public are served
        initializer "#{name}.static_assets" do |app|
          if app.config.public_file_server.enabled
            app.middleware.insert_after ::ActionDispatch::Static, SparkEngine::StaticAssets, "#{root}/public", engine_name: SparkEngine.plugin.name
            app.middleware.insert_before ::ActionDispatch::Static, Rack::Deflater
          end
        end

        initializer "#{name}.view_paths" do |app|
          # Ensure Components are readable from engine paths
          ActiveSupport.on_load :action_controller do
            append_view_path "#{SparkEngine.plugin.paths[:components]}"
          end

        end

        initializer "#{name}.asset_paths" do |app|
          app.config.assets.paths << SparkEngine.plugin.paths[:components]
        end

      end)

      # Autoload engine lib and components path
      @engine.config.autoload_paths.concat [
        File.join(@engine.spark_plugin_path, "lib"),
        SparkEngine.plugin.paths[:components]
      ]

      @engine.config.after_initialize do |app|
        if defined?(SassC) && defined?(SassC::Rails)
          # Inject Sass importer for yaml files
          require "spark_engine/sassc/importer"
          SassC::Rails::Importer::EXTENSIONS << SassC::SparkEngine::Importer::SassYamlExtension.new
        elsif defined?(Sass)
          # Overwrite Sass engine with Yaml support
          require "spark_engine/sass/engine"
        end
      end

      # Takes a block passed an evaluates it in the context of a Rails engine
      # This allows plugins to modify engines when created.
      @engine.instance_eval(&block) if block_given?
    end
def create_engine(&block)
      @engine = parent_module.const_set('Engine', Class.new(Rails::Engine) do

        def spark_plugin_path
          parent = Object.const_get(self.class.name.sub(/::Engine/,''))
          Pathname.new parent.instance_variable_get("@gem_path")
        end

        def config
          @config ||= Rails::Engine::Configuration.new(spark_plugin_path)
        end

        engine_name SparkEngine.plugin.name

        require 'spark_engine/middleware'

        # Ensure compiled assets in /public are served
        initializer "#{name}.static_assets" do |app|
          if app.config.public_file_server.enabled
            app.middleware.insert_after ::ActionDispatch::Static, SparkEngine::StaticAssets, "#{root}/public", engine_name: SparkEngine.plugin.name
            app.middleware.insert_before ::ActionDispatch::Static, Rack::Deflater
          end
        end

        initializer "#{name}.view_paths" do |app|
          # Ensure Components are readable from engine paths
          ActiveSupport.on_load :action_controller do
            append_view_path "#{SparkEngine.plugin.paths[:components]}"
          end

        end

        initializer "#{name}.asset_paths" do |app|
          app.config.assets.paths << SparkEngine.plugin.paths[:components]
        end

      end)

      # Autoload engine lib and components path
      @engine.config.autoload_paths.concat [
        File.join(@engine.spark_plugin_path, "lib"),
        SparkEngine.plugin.paths[:components]
      ]

      @engine.config.after_initialize do |app|
        if defined?(SassC) && defined?(SassC::Rails)
          # Inject Sass importer for yaml files
          require "spark_engine/sassc/importer"
          SassC::Rails::Importer::EXTENSIONS << SassC::SparkEngine::Importer::SassYamlExtension.new
        elsif defined?(Sass)
          # Overwrite Sass engine with Yaml support
          require "spark_engine/sass/engine"
        end
      end

      # Takes a block passed an evaluates it in the context of a Rails engine
      # This allows plugins to modify engines when created.
      @engine.instance_eval(&block) if block_given?
    end
Create a new Rails::Engine