Skip to content

Instantly share code, notes, and snippets.

@jejacks0n
Created May 25, 2011 01:40

Revisions

  1. jejacks0n revised this gist Aug 31, 2011. 1 changed file with 7 additions and 8 deletions.
    15 changes: 7 additions & 8 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -11,17 +11,16 @@ def application_with_additions(suite)

    app.map "/assets" do
    assets = Rails.application.config.assets
    paths = %W{app/assets/javascripts lib/assets/javascripts vendor/assets/javascripts}.map{ |p| File.join(suite.root, p) }
    if assets.enabled
    paths = %W{app/assets/javascripts lib/assets/javascripts vendor/assets/javascripts}.map{ |p| File.join(suite.root, p) }

    require 'sprockets'
    sprockets = Sprockets::Environment.new(suite.root)
    sprockets.static_root = File.join(suite.root, 'public', assets.prefix)
    if sprockets.respond_to?(:append_path)
    paths.each { |path| sprockets.append_path(path) }
    else
    sprockets.paths.concat paths

    sprockets = Sprockets::Environment.new(suite.root) do |env|
    paths.each { |path| env.append_path(path) }
    env.js_compressor = nil
    end
    sprockets.js_compressor = nil

    run sprockets
    end
    end
  2. jejacks0n revised this gist Aug 5, 2011. 1 changed file with 7 additions and 3 deletions.
    10 changes: 7 additions & 3 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -16,8 +16,12 @@ def application_with_additions(suite)
    require 'sprockets'
    sprockets = Sprockets::Environment.new(suite.root)
    sprockets.static_root = File.join(suite.root, 'public', assets.prefix)
    sprockets.paths.concat paths
    sprockets.js_compressor = nil # is compression useful in specs?
    if sprockets.respond_to?(:append_path)
    paths.each { |path| sprockets.append_path(path) }
    else
    sprockets.paths.concat paths
    end
    sprockets.js_compressor = nil
    run sprockets
    end
    end
    @@ -28,4 +32,4 @@ def application_with_additions(suite)
    alias_method :application, :application_with_additions
    end

    end
    end
  3. jejacks0n created this gist May 25, 2011.
    31 changes: 31 additions & 0 deletions gistfile1.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,31 @@
    # For Rails 3.1 asset packaging / sprockets support
    # 1. Create a /config/evergreen.rb file and put these contents in it
    # 2. Adjust the paths below (the provided ones are generic)
    require ::File.expand_path('../application', __FILE__)

    module Evergreen

    class << self
    def application_with_additions(suite)
    app = application_without_additions(suite)

    app.map "/assets" do
    assets = Rails.application.config.assets
    paths = %W{app/assets/javascripts lib/assets/javascripts vendor/assets/javascripts}.map{ |p| File.join(suite.root, p) }
    if assets.enabled
    require 'sprockets'
    sprockets = Sprockets::Environment.new(suite.root)
    sprockets.static_root = File.join(suite.root, 'public', assets.prefix)
    sprockets.paths.concat paths
    sprockets.js_compressor = nil # is compression useful in specs?
    run sprockets
    end
    end
    app
    end

    alias_method :application_without_additions, :application
    alias_method :application, :application_with_additions
    end

    end