allow the generating and installation of a Gemfile

This commit is contained in:
Thomas Reynolds 2011-08-06 14:56:05 -07:00
parent 36a55abf1b
commit 8d7de527cd
7 changed files with 28 additions and 5 deletions

View file

@ -161,3 +161,5 @@ module Middleman
sandbox sandbox
end end
end end
require "middleman/version"

View file

@ -19,6 +19,7 @@ module Middleman
method_option "js_dir", :default => "javascripts", :desc => 'The path to the javascript files' method_option "js_dir", :default => "javascripts", :desc => 'The path to the javascript files'
method_option "images_dir", :default => "images", :desc => 'The path to the image files' method_option "images_dir", :default => "images", :desc => 'The path to the image files'
method_option "rack", :type => :boolean, :default => false, :desc => 'Include a config.ru file' method_option "rack", :type => :boolean, :default => false, :desc => 'Include a config.ru file'
method_option "bundler", :type => :boolean, :default => false, :desc => 'Create a Gemfile and use Bundler to manage gems'
def init(name) def init(name)
key = options[:template].to_sym key = options[:template].to_sym
unless Middleman::Templates.registered_templates.has_key?(key) unless Middleman::Templates.registered_templates.has_key?(key)

View file

@ -23,6 +23,23 @@ module Middleman::Templates
class_option :css_dir, :default => "stylesheets" class_option :css_dir, :default => "stylesheets"
class_option :js_dir, :default => "javascripts" class_option :js_dir, :default => "javascripts"
class_option :images_dir, :default => "images" class_option :images_dir, :default => "images"
class_option :rack, :type => :boolean, :default => false
class_option :bundler, :type => :boolean, :default => false
def generate_rack
if options[:rack]
template "shared/config.ru", File.join(location, "config.ru")
end
end
def generate_bundler
if options[:bundler]
template "shared/Gemfile.tt", File.join(location, "Gemfile")
say_status :run, "bundle install"
print `cd #{location} && "#{Gem.ruby}" -rubygems "#{Gem.bin_path('bundler', 'bundle')}" install`
end
end
end end
end end

View file

@ -5,13 +5,16 @@ class Middleman::Templates::Blog < Middleman::Templates::Base
def build_scaffold def build_scaffold
template "blog/config.tt", File.join(location, "config.rb") template "blog/config.tt", File.join(location, "config.rb")
template "blog/config.ru", File.join(location, "config.ru")
directory "blog/source", File.join(location, "source") directory "blog/source", File.join(location, "source")
empty_directory File.join(location, "source", options[:css_dir]) empty_directory File.join(location, "source", options[:css_dir])
empty_directory File.join(location, "source", options[:js_dir]) empty_directory File.join(location, "source", options[:js_dir])
empty_directory File.join(location, "source", options[:images_dir]) empty_directory File.join(location, "source", options[:images_dir])
end end
def generate_rack
template "blog/config.ru", File.join(location, "config.ru")
end
end end
Middleman::Templates.register(:blog, Middleman::Templates::Blog) Middleman::Templates.register(:blog, Middleman::Templates::Blog)

View file

@ -5,9 +5,6 @@ class Middleman::Templates::Default < Middleman::Templates::Base
def build_scaffold def build_scaffold
template "shared/config.tt", File.join(location, "config.rb") template "shared/config.tt", File.join(location, "config.rb")
if options[:rack]
template "shared/config.ru", File.join(location, "config.ru")
end
copy_file "default/source/index.html.erb", File.join(location, "source/index.html.erb") copy_file "default/source/index.html.erb", File.join(location, "source/index.html.erb")
copy_file "default/source/layout.erb", File.join(location, "source/layout.erb") copy_file "default/source/layout.erb", File.join(location, "source/layout.erb")
empty_directory File.join(location, "source", options[:css_dir]) empty_directory File.join(location, "source", options[:css_dir])

View file

@ -0,0 +1,3 @@
source "http://rubygems.org"
gem "middleman", "~><%= Middleman::VERSION %>"

View file

@ -1,3 +1,3 @@
module Middleman module Middleman
VERSION = "2.0.0.rc99" VERSION = "2.0.0"
end end