tests working, building working

This commit is contained in:
tdreyno 2009-07-28 11:06:45 -07:00
parent 7e4916169c
commit 338430f2d5
8 changed files with 31 additions and 19 deletions

2
.gitignore vendored
View file

@ -3,3 +3,5 @@
coverage coverage
rdoc rdoc
pkg pkg
.sass-cache
*.gemspec

3
.gitmodules vendored
View file

@ -4,3 +4,6 @@
[submodule "vendor/sinatra-maruku"] [submodule "vendor/sinatra-maruku"]
path = vendor/sinatra-maruku path = vendor/sinatra-maruku
url = git://github.com/wbzyl/sinatra-maruku.git url = git://github.com/wbzyl/sinatra-maruku.git
[submodule "vendor/rack-test"]
path = vendor/rack-test
url = git://github.com/brynary/rack-test.git

View file

@ -3,8 +3,8 @@
# Require app # Require app
require 'rubygems' require 'rubygems'
require 'templater' require 'templater'
require 'open-uri'
require File.join(File.dirname(__FILE__), '..', 'lib', 'middleman') require File.join(File.dirname(__FILE__), '..', 'lib', 'middleman')
require File.join(File.dirname(__FILE__), '..', 'vendor', 'rack-test', 'lib', 'rack', 'test')
module Generators module Generators
extend Templater::Manifold extend Templater::Manifold
@ -19,7 +19,7 @@ module Generators
def self.template(name, *args, &block) def self.template(name, *args, &block)
return if args.first.include?('layout') return if args.first.include?('layout')
return if File.basename(args.first)[0,1] == '_' return if File.basename(args.first)[0,1] == '_'
if (args[0] === args[1]) if (args[0] === args[1])
newext = case File.extname(args.first) newext = case File.extname(args.first)
when '.haml', '.mab', '.maruku' when '.haml', '.mab', '.maruku'
@ -31,11 +31,12 @@ module Generators
end end
args[1] = args[0].gsub(File.extname(args.first), newext).gsub('views/', '') args[1] = args[0].gsub(File.extname(args.first), newext).gsub('views/', '')
end end
super(name, *args, &block) super(name, *args, &block)
end end
def self.file(name, *args, &block) def self.file(name, *args, &block)
puts args.inspect
args[1] = args[0].gsub('views/', '') if (args[0] === args[1]) args[1] = args[0].gsub('views/', '') if (args[0] === args[1])
super(name, *args, &block) super(name, *args, &block)
end end
@ -53,16 +54,16 @@ module Generators
add :build, Builder add :build, Builder
end end
# Monkey-patch to use a dynamic renderer, not just ERb Middleman.set :root, Dir.pwd
# Monkey-patch to use a dynamic renderer
class Templater::Actions::Template class Templater::Actions::Template
def render def render
return "" request_path = destination.gsub(File.join(Dir.pwd, 'build'), "")
#request_path = destination.gsub(File.join(Dir.pwd, 'build'), "") browser = Rack::Test::Session.new(Rack::MockSession.new(Middleman))
#Rack Handler browser.get(request_path)
browser.last_response.body
end end
end end
# Start app Generators.run_cli(Dir.pwd, 'mm-build', 1, %w(build --force).concat(ARGV))
#Middleman.run!(:root => Dir.pwd) do
Generators.run_cli(Dir.pwd, 'mm-build', 1, %w(build --force).concat(ARGV))
#end

View file

@ -56,8 +56,10 @@ class Middleman < Sinatra::Base
haml(template) haml(template)
elsif File.exists? File.join(options.views, "#{template}.maruku") elsif File.exists? File.join(options.views, "#{template}.maruku")
maruku(template) maruku(template)
else elsif File.exists? File.join(options.views, "#{template}.mab")
markaby(template) markaby(template)
else
pass
end end
elsif path.match /.css$/ elsif path.match /.css$/
content_type 'text/css', :charset => 'utf-8' content_type 'text/css', :charset => 'utf-8'

View file

@ -20,18 +20,22 @@ describe "Builder" do
it "should build markaby files" do it "should build markaby files" do
File.exists?("#{@root_dir}/build/markaby.html").should be_true File.exists?("#{@root_dir}/build/markaby.html").should be_true
File.read("#{@root_dir}/build/markaby.html").should include("<title>Hi Markaby</title>")
end end
it "should build haml files" do it "should build haml files" do
File.exists?("#{@root_dir}/build/index.html").should be_true File.exists?("#{@root_dir}/build/index.html").should be_true
File.read("#{@root_dir}/build/index.html").should include("<h1>Welcome</h1>")
end end
it "should build maruku files" do it "should build maruku files" do
File.exists?("#{@root_dir}/build/maruku.html").should be_true File.exists?("#{@root_dir}/build/maruku.html").should be_true
File.read("#{@root_dir}/build/maruku.html").should include("<h1 class='header' id='hello_maruku'>Hello Maruku</h1>")
end end
it "should build static files" do it "should build static files" do
File.exists?("#{@root_dir}/build/static.html").should be_true File.exists?("#{@root_dir}/build/static.html").should be_true
File.read("#{@root_dir}/build/static.html").should include("Static, no code!")
end end
it "should build subdirectory files" do it "should build subdirectory files" do
@ -40,6 +44,7 @@ describe "Builder" do
it "should build sass files" do it "should build sass files" do
File.exists?("#{@root_dir}/build/stylesheets/site.css").should be_true File.exists?("#{@root_dir}/build/stylesheets/site.css").should be_true
File.read("#{@root_dir}/build/stylesheets/site.css").should include("html, body, div, span, applet, object, iframe")
end end
it "should build static css files" do it "should build static css files" do

View file

@ -0,0 +1,5 @@
mab.html do
head do
title "Hi Markaby"
end
end

View file

@ -1,7 +0,0 @@
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
describe "Middleman" do
it "fails" do
fail "hey buddy, you should probably rename this file and start specing for real"
end
end

1
vendor/rack-test vendored Submodule

@ -0,0 +1 @@
Subproject commit 6d8c25af8592faf2efb3f5ab73b0219eadf30ea4