diff --git a/Rakefile b/Rakefile index 75357907..85e1d407 100644 --- a/Rakefile +++ b/Rakefile @@ -4,7 +4,19 @@ Bundler::GemHelper.install_tasks require 'cucumber/rake/task' Cucumber::Rake::Task.new(:cucumber, 'Run features that should pass') do |t| - t.cucumber_opts = "--color --tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}" + t.cucumber_opts = "--drb --color --tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}" +end + +namespace :spork do + desc "start spork in background" + task :start do + sh %{spork &} + end + + desc "stop spork" + task :stop do + Process.kill(:TERM, `ps -ef | grep spork | grep -v grep | awk '{ print $2 }'`.to_i) + end end #$LOAD_PATH.unshift 'lib' @@ -12,7 +24,7 @@ end require 'rake/testtask' require 'rake/clean' -task :test => :cucumber +task :test => ["spork:start", "cucumber", "spork:stop"] # rocco depends on rdiscount, which makes me sad. unless defined?(JRUBY_VERSION) diff --git a/features/step_definitions/builder_steps.rb b/features/step_definitions/builder_steps.rb index 013706c8..66adb090 100644 --- a/features/step_definitions/builder_steps.rb +++ b/features/step_definitions/builder_steps.rb @@ -14,7 +14,7 @@ end Given /^cleanup built test app$/ do target = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app", "build") - FileUtils.rm_rf(target) + # FileUtils.rm_rf(target) end Then /^"([^"]*)" should exist and include "([^"]*)"$/ do |target_file, expected| diff --git a/features/step_definitions/env.rb b/features/step_definitions/env.rb deleted file mode 100644 index d5ffc2ed..00000000 --- a/features/step_definitions/env.rb +++ /dev/null @@ -1,9 +0,0 @@ -ENV["MM_DIR"] = File.join(File.dirname(File.dirname(File.dirname(__FILE__))), "fixtures", "test-app") -require File.join(File.dirname(File.dirname(File.dirname(__FILE__))), 'lib', 'middleman') -require "rack/test" - -# absolute views path -# otherwise resolve_template (padrino-core) can't find templates -Before do - Middleman::Server.views = File.join(Middleman::Server.root, "source") -end \ No newline at end of file diff --git a/features/support/env.rb b/features/support/env.rb new file mode 100644 index 00000000..8465f0d6 --- /dev/null +++ b/features/support/env.rb @@ -0,0 +1,53 @@ +require 'rubygems' +require 'spork' + +root_path = File.dirname(File.dirname(File.dirname(__FILE__))) + +Spork.prefork do + # Loading more in this block will cause your tests to run faster. However, + # if you change any configuration or code from libraries loaded here, you'll + # need to restart spork for it take effect. + + ENV["MM_DIR"] = File.join(root_path, "fixtures", "test-app") +end + +Spork.each_run do + # This code will be run each time you run your specs. + require File.join(root_path, 'lib', 'middleman') + require "rack/test" + + # absolute views path + # otherwise resolve_template (padrino-core) can't find templates + Before do + Middleman::Server.views = File.join(Middleman::Server.root, "source") + end +end + +# --- Instructions --- +# Sort the contents of this file into a Spork.prefork and a Spork.each_run +# block. +# +# The Spork.prefork block is run only once when the spork server is started. +# You typically want to place most of your (slow) initializer code in here, in +# particular, require'ing any 3rd-party gems that you don't normally modify +# during development. +# +# The Spork.each_run block is run each time you run your specs. In case you +# need to load files that tend to change during development, require them here. +# With Rails, your application modules are loaded automatically, so sometimes +# this block can remain empty. +# +# Note: You can modify files loaded *from* the Spork.each_run block without +# restarting the spork server. However, this file itself will not be reloaded, +# so if you change any of the code inside the each_run block, you still need to +# restart the server. In general, if you have non-trivial code in this file, +# it's advisable to move it into a separate file so you can easily edit it +# without restarting spork. (For example, with RSpec, you could move +# non-trivial code into a file spec/support/my_helper.rb, making sure that the +# spec/support/* files are require'd from inside the each_run block.) +# +# Any code that is left outside the two blocks will be run during preforking +# *and* during each_run -- that's probably not what you want. +# +# These instructions should self-destruct in 10 seconds. If they don't, feel +# free to delete them. diff --git a/lib/middleman/builder.rb b/lib/middleman/builder.rb index c2b77f9b..af8ddbcc 100644 --- a/lib/middleman/builder.rb +++ b/lib/middleman/builder.rb @@ -84,7 +84,25 @@ module Middleman def handle_directory(lookup) lookup = File.join(lookup, '*') - Dir[lookup].sort.each do |file_source| + results = Dir[lookup].sort do |a, b| + simple_a = a.gsub(Middleman::Server.root + "/", '') + .gsub(Middleman::Server.views + "/", '') + simple_b = b.gsub(Middleman::Server.root + "/", '') + .gsub(Middleman::Server.views + "/", '') + + a_dir = simple_a.split("/").first + b_dir = simple_b.split("/").first + + if a_dir == Middleman::Server.images_dir + -1 + elsif b_dir == Middleman::Server.images_dir + 1 + else + 0 + end + end + + results.each do |file_source| if File.directory?(file_source) handle_directory(file_source) next diff --git a/lib/middleman/features.rb b/lib/middleman/features.rb index a0f205b5..5fa62622 100644 --- a/lib/middleman/features.rb +++ b/lib/middleman/features.rb @@ -78,7 +78,7 @@ module Middleman::Features autoload :Blog, "middleman/features/blog" # Proxy web services requests in dev mode only - # autoload :Proxy, "middleman/features/proxy" + autoload :Proxy, "middleman/features/proxy" # Automatically resize images for mobile devises # autoload :TinySrc, "middleman/features/tiny_src" diff --git a/lib/middleman/renderers/sass.rb b/lib/middleman/renderers/sass.rb index 4fabe73e..e556234b 100644 --- a/lib/middleman/renderers/sass.rb +++ b/lib/middleman/renderers/sass.rb @@ -9,25 +9,27 @@ module Middleman class << self def registered(app) app.after_feature_init do + views_root = File.basename(self.views) ::Compass.configuration do |config| config.cache_path = File.join(self.root, ".sass-cache") # For sassc files config.project_path = self.root - config.sass_dir = File.join(File.basename(self.views), self.css_dir) + config.sass_dir = File.join(views_root, self.css_dir) config.output_style = :nested - config.fonts_dir = File.join(File.basename(self.views), self.fonts_dir) - config.css_dir = File.join(File.basename(self.views), self.css_dir) - config.images_dir = File.join(File.basename(self.views), self.images_dir) + config.fonts_dir = File.join(views_root, self.fonts_dir) + config.css_dir = File.join(views_root, self.css_dir) + config.images_dir = File.join(views_root, self.images_dir) config.http_images_path = self.http_images_path rescue File.join(self.http_prefix || "/", self.images_dir) config.http_stylesheets_path = self.http_css_path rescue File.join(self.http_prefix || "/", self.css_dir) - config.asset_cache_buster { false } + config.asset_cache_buster :none config.add_import_path(config.sass_dir) end configure :build do + build_root = File.basename(self.build_dir) ::Compass.configuration do |config| - config.css_dir = File.join(File.basename(self.build_dir), self.css_dir) - config.images_dir = File.join(File.basename(self.build_dir), self.images_dir) + config.css_dir = File.join(build_root, self.css_dir) + config.images_dir = File.join(build_root, self.images_dir) end end end diff --git a/middleman.gemspec b/middleman.gemspec index c00ec2a4..a13d2b48 100644 --- a/middleman.gemspec +++ b/middleman.gemspec @@ -31,10 +31,11 @@ Gem::Specification.new do |s| s.add_runtime_dependency("haml", ["~> 3.1.0"]) s.add_runtime_dependency("coffee-filter", ["~> 0.1.0"]) s.add_runtime_dependency("sass", ["~> 3.1.0"]) - s.add_runtime_dependency("compass", ["0.11.2"]) + s.add_runtime_dependency("compass", ["~> 0.11.3"]) s.add_runtime_dependency("compass-susy-plugin", ["~> 0.9.0"]) s.add_runtime_dependency("coffee-script", ["~> 2.2.0"]) s.add_runtime_dependency("httparty", ["~> 0.7.0"]) + s.add_development_dependency("spork", ["~> 0.9.0.rc8"]) s.add_development_dependency("cucumber", ["~> 0.10.0"]) s.add_development_dependency("rake", ["0.8.7"]) s.add_development_dependency("rspec", [">= 0"])