Permalink
Browse files

Add support for hiding the 'protocols' directory in production mode

  • Loading branch information...
Charles Jolley
Charles Jolley committed Jan 26, 2009
1 parent 9a257cf commit 6cefc5e0780783357e280f084e45f5587319af76
View
@@ -34,6 +34,9 @@ mode :all do
# Do not include debug directory in built project
:load_debug => false,
+ # Do not load protocols in production mode
+ :load_protocols => false,
+
# Do not build tests.
:load_tests => false,
@@ -56,10 +59,11 @@ end
mode :debug do
config :all,
- # in debug mode, load fixtures and debug code
- :load_fixtures => true,
- :load_debug => true,
- :load_tests => true,
+ # in debug mode, load fixtures, debug, tests, and protocols
+ :load_fixtures => true,
+ :load_debug => true,
+ :load_tests => true,
+ :load_protocols => true,
# Do not combine javascript and stylesheet
:combine_javascript => false,
View
@@ -54,7 +54,9 @@ namespace :manifest do
desc "hides structural files that do not belong in build include Buildfiles and debug or fixtures if turned off"
task :hide_buildfiles => :catalog do
# these directories are to be excluded unless CONFIG.load_"dirname" = true
- dirnames = %w(debug tests fixtures).reject { |k| CONFIG["load_#{k}"] }
+ dirnames = %w(debug tests fixtures protocols).reject do |k|
+ CONFIG["load_#{k}"]
+ end
# loop through entries and hide those that do not below...
MANIFEST.entries.each do |entry|
@@ -71,7 +73,7 @@ namespace :manifest do
next if entry.localized? || entry.filename =~ /^.+\.lproj\/.+$/
# allow if in tests, fixtures or debug as well...
- next if entry.filename =~ /^(tests|fixtures|debug)\/.+$/
+ next if entry.filename =~ /^(tests|fixtures|debug|protocols)\/.+$/
# or skip if ext not js
entry.hide! if entry.ext != 'js'
@@ -107,11 +107,15 @@ def _call(env)
end
SC.logger.info "Serving #{target.target_name.to_s.sub(/^\//,'')}:#{entry.filename}"
- [200, {
+
+ # define response headers
+ file_size = File.size(build_path)
+ headers = {
"Last-Modified" => File.mtime(build_path).httpdate,
"Content-Type" => ::Rack::Mime.mime_type(File.extname(build_path), 'text/plain'),
- "Content-Length" => File.size(build_path).to_s
- }, File.open(build_path, 'rb')]
+ "Content-Length" => file_size.to_s
+ }
+ [200, headers, File.open(build_path, 'rb')]
end
attr_reader :project
@@ -89,7 +89,7 @@ def initialize(*projects)
# Now put it behind some useful general optimizers...
@app = ::Rack::Recursive.new(@app)
- #@app = ::Rack::ConditionalGet.new(@app)
+ @app = ::Rack::ConditionalGet.new(@app)
@app = ::Rack::Deflater.new(@app)
end
@@ -41,61 +41,85 @@ def run_task
entry.should_not be_hidden
end
- # CONFIG.load_fixtures
- it "should hide files in /fixtures and /*.lproj/fixtures if CONFIG.load_fixtures is false" do
- @target.config.load_fixtures = false
- run_task
- entry = entry_for('fixtures/sample_fixtures.js')
- entry.should be_hidden
- entry = entry_for('english.lproj/fixtures/sample_fixtures-loc.js')
- entry.should be_hidden
- end
+ describe "CONFIG.load_fixtures" do
+
+ it "should hide files in /fixtures and /*.lproj/fixtures if CONFIG.load_fixtures is false" do
+ @target.config.load_fixtures = false
+ run_task
+ entry = entry_for('fixtures/sample_fixtures.js')
+ entry.should be_hidden
+ entry = entry_for('english.lproj/fixtures/sample_fixtures-loc.js')
+ entry.should be_hidden
+ end
- it "should NOT hide files in /fixtures and /*.lproj/fixtures if CONFIG.load_fixtures is true" do
- @target.config.load_fixtures = true
- run_task
- entry = entry_for('fixtures/sample_fixtures.js')
- entry.should_not be_hidden
- entry = entry_for('english.lproj/fixtures/sample_fixtures-loc.js')
- entry.should_not be_hidden
+ it "should NOT hide files in /fixtures and /*.lproj/fixtures if CONFIG.load_fixtures is true" do
+ @target.config.load_fixtures = true
+ run_task
+ entry = entry_for('fixtures/sample_fixtures.js')
+ entry.should_not be_hidden
+ entry = entry_for('english.lproj/fixtures/sample_fixtures-loc.js')
+ entry.should_not be_hidden
+ end
end
+
+ describe "CONFIG.load_debug" do
+ it "should hide files in /debug and /*.lproj/debug if CONFIG.load_debug is false" do
+ @target.config.load_debug = false
+ run_task
+ entry = entry_for('debug/sample_debug.js')
+ entry.should be_hidden
+ entry = entry_for('english.lproj/debug/sample_debug-loc.js')
+ entry.should be_hidden
+ end
- # CONFIG.load_debug
- it "should hide files in /debug and /*.lproj/debug if CONFIG.load_debug is false" do
- @target.config.load_debug = false
- run_task
- entry = entry_for('debug/sample_debug.js')
- entry.should be_hidden
- entry = entry_for('english.lproj/debug/sample_debug-loc.js')
- entry.should be_hidden
+ it "should NOT hide files in /debug and /*.lproj/debug if CONFIG.load_fixtures is true" do
+ @target.config.load_debug = true
+ run_task
+ entry = entry_for('debug/sample_debug.js')
+ entry.should_not be_hidden
+ entry = entry_for('english.lproj/debug/sample_debug-loc.js')
+ entry.should_not be_hidden
+ end
end
+
+ describe "CONFIG.load_tests" do
+ it "should hide files in /tests and /*.lproj/tests if CONFIG.load_tests is false" do
+ @target.config.load_tests = false
+ run_task
+ entry = entry_for('tests/sample.js')
+ entry.should be_hidden
+ entry = entry_for('english.lproj/tests/sample-loc.js')
+ entry.should be_hidden
+ end
- it "should NOT hide files in /debug and /*.lproj/debug if CONFIG.load_fixtures is true" do
- @target.config.load_debug = true
- run_task
- entry = entry_for('debug/sample_debug.js')
- entry.should_not be_hidden
- entry = entry_for('english.lproj/debug/sample_debug-loc.js')
- entry.should_not be_hidden
+ it "should NOT hide files in /tests and /*.lproj/tests if CONFIG.load_tests is true" do
+ @target.config.load_tests = true
+ run_task
+ entry = entry_for('tests/sample.js')
+ entry.should_not be_hidden
+ entry = entry_for('english.lproj/tests/sample-loc.js')
+ entry.should_not be_hidden
+ end
end
- # CONFIG.load_tests
- it "should hide files in /tests and /*.lproj/tests if CONFIG.load_tests is false" do
- @target.config.load_tests = false
- run_task
- entry = entry_for('tests/sample.js')
- entry.should be_hidden
- entry = entry_for('english.lproj/tests/sample-loc.js')
- entry.should be_hidden
- end
+ describe "CONFIG.load_protocols" do
+ it "should hide files in /protocols and /*.lproj/protocols if config is false" do
+ @target.config.load_protocols = false
+ run_task
+ entry = entry_for('protocols/sample.js')
+ entry.should be_hidden
+ entry = entry_for('english.lproj/protocols/sample-loc.js')
+ entry.should be_hidden
+ end
- it "should NOT hide files in /tests and /*.lproj/tests if CONFIG.load_tests is true" do
- @target.config.load_tests = true
- run_task
- entry = entry_for('tests/sample.js')
- entry.should_not be_hidden
- entry = entry_for('english.lproj/tests/sample-loc.js')
- entry.should_not be_hidden
+ it "should NOT hide files in /protocols and /*.lproj/protocols if config is true" do
+ @target.config.load_protocols = true
+ run_task
+ entry = entry_for('protocols/sample.js')
+ entry.should_not be_hidden
+ entry = entry_for('english.lproj/protocols/sample-loc.js')
+ entry.should_not be_hidden
+ end
end
end

0 comments on commit 6cefc5e

Please sign in to comment.