Sha256: 7d4b5a03a658727b9489100a983d613f5b87244363a316e937d010547c3c6ac4

Contents?: true

Size: 1.39 KB

Versions: 1

Compression:

Stored size: 1.39 KB

Contents

require 'middleman-core'

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

        app.after_configuration do
          ember_version = 
            if app.ember_variant == :production
              "prod."
            else
              ""
            end

          FileUtils.mkdir_p(ember_asset_path)
          FileUtils.cp(::Ember::Source.bundled_path_for("ember.#{ember_version}js"), ember_asset_path.join("ember.js"))
          FileUtils.cp(::Ember::Data::Source.bundled_path_for("ember-data.#{ember_version}js"), ember_asset_path.join("ember-data.js"))
          sprockets.append_path(ember_asset_path)

          # allow for a local Ember variant
          sprockets.prepend_path(ember_local_path) unless ember_local_path.nil?

          # add in Handlebars path
          sprockets.append_path(handlebars_asset_path)
        end
      end
      alias :included :registered
    end

    module InstanceMethods
      def ember_asset_path
        Pathname.new(File.join("#{root}/tmp/middleman-ember"))
      end

      def handlebars_asset_path
        File.dirname(::Handlebars::Source.bundled_path)
      end

      def ember_local_path
        local_path = "#{root}/vendor/assets/ember"     
        File.directory?(local_path) ? local_path : nil
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
middleman-ember-0.0.2 lib/middleman/ember/extension.rb