Changeset 1137

Show
Ignore:
Timestamp:
12/28/07 21:43:11 (1 year ago)
Author:
coda.ha..@gmail.com
Message:

Fixed a bug in asset bundling -- now only creating the files once.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/merb/assets.rb

    r1136 r1137  
    7777      # the name of the bundled file. 
    7878      def bundle! 
    79         bundle_files(@bundle_filename, *@files) 
    80         self.class.callbacks.each { |c| c.call(@bundle_filename) } 
     79        # TODO: Move this file check out into an in-memory cache. Also, push it out to the helper level so we don't have to create the helper object. 
     80        unless File.exist?(@bundle_filename) 
     81          bundle_files(@bundle_filename, *@files) 
     82          self.class.callbacks.each { |c| c.call(@bundle_filename) } 
     83        end 
    8184        return @bundle_name 
    8285      end 
  • trunk/spec/merb/assets_spec.rb

    r1136 r1137  
    152152    bundle_name = bundler.bundle! 
    153153    File.read(asset_path(@bundler_klass.asset_type, bundle_name, true)).should == "one\ntwo\nthree\n" 
     154  end 
     155   
     156  it "should not overwrite bundles" do 
     157    File.open(asset_path(@bundler_klass.asset_type, :all, true), "w") { |f| f << "exists" } 
     158    bundler = @bundler_klass.new(true, @asset1, @asset2, @asset3) 
     159    bundle_name = bundler.bundle! 
     160    File.read(asset_path(@bundler_klass.asset_type, bundle_name, true)).should == "exists" 
    154161  end 
    155162