Skip to content

Commit

Permalink
Adding a package as nil will actually remove the package
Browse files Browse the repository at this point in the history
  • Loading branch information
petebrowne committed Aug 30, 2010
1 parent 18eb854 commit b7b9fb5
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
rack-pack (0.1.0)
rack-pack (0.2.1)
rack (~> 1.2.1)

GEM
Expand Down
10 changes: 7 additions & 3 deletions lib/rack/pack.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,13 @@ def production?
end

def add_package(output_file, source_files)
public_output_file = ::File.join(self.options[:public_dir], output_file.to_s)
package_class = Package[output_file]
packages[output_file] = package_class.new(public_output_file, source_files)
if source_files.nil?
packages.delete(output_file)
else
public_output_file = ::File.join(self.options[:public_dir], output_file.to_s)
package_class = Package[output_file]
packages[output_file] = package_class.new(public_output_file, source_files)
end
end
end

Expand Down
2 changes: 1 addition & 1 deletion lib/rack/pack/version.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Rack
class Pack
VERSION = '0.2.0'
VERSION = '0.2.1'
end
end
12 changes: 12 additions & 0 deletions spec/rack/pack_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,18 @@ def request_for(url = '/')
end
end

context 'with a default package set to nil' do
it 'should not pack the files' do
within_construct do |c|
c.file 'vendor/javascripts/file-1.js', '1'

@app = build_app 'javascripts/application.js' => nil
@app.call(request)
File.exist?('public/javascripts/application.js').should_not be_true
end
end
end

context 'in a production environment' do
before do
Rails = double('rails', :env => double('env', :to_s => 'production'))
Expand Down

0 comments on commit b7b9fb5

Please sign in to comment.