Sha256: 54a7ebff10e7b30d9f3816bc659f271d897f405fdaeedcd169f539d38363a655

Contents?: true

Size: 1.13 KB

Versions: 2

Compression:

Stored size: 1.13 KB

Contents

require 'middleman-core'
require 'middleman/jasmine/jasmine_sprockets_proxy'

module Middleman
  module Jasmine
    class << self
      def registered(app, options_hash={}, &block)
        app.send :include, InstanceMethods

        options = OpenStruct.new(default_options.merge(options_hash))

        yield options if block_given?

        app.map(options.jasmine_url) { run ::JasmineSprocketsProxy.new }
        jasmine_asset_folders(options.fixtures_dir).each do |item|
          app.map("/#{item}") { run ::JasmineSprocketsProxy.new(item) }
        end

        app.after_configuration do
          ::JasmineSprocketsProxy.configure(sprockets)
        end
      end

      private

      def jasmine_asset_folders(fixtures_dir)
        [
          "__jasmine__", "__boot__", "__spec__", fixtures_dir
        ]
      end

      def default_options
        {
          jasmine_url: "/jasmine",
          fixtures_dir: "spec/javascripts/fixtures"
        }        
      end      
    alias :included :registered
    end

    module InstanceMethods
      def jasmine_sprockets
        ::JasmineSprocketsProxy.sprockets_app
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
middleman-jasmine-0.1.1 lib/middleman/jasmine/extension.rb
middleman-jasmine-0.1.0 lib/middleman/jasmine/extension.rb