diff --git a/lib/middleman.rb b/lib/middleman.rb index 929a32ef..c0aad995 100755 --- a/lib/middleman.rb +++ b/lib/middleman.rb @@ -161,3 +161,5 @@ module Middleman sandbox end end + +require "middleman/version" diff --git a/lib/middleman/cli.rb b/lib/middleman/cli.rb index 91847165..82ba8f8e 100644 --- a/lib/middleman/cli.rb +++ b/lib/middleman/cli.rb @@ -19,6 +19,7 @@ module Middleman 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 "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) key = options[:template].to_sym unless Middleman::Templates.registered_templates.has_key?(key) diff --git a/lib/middleman/templates.rb b/lib/middleman/templates.rb index b2b152ae..2d0e6a53 100644 --- a/lib/middleman/templates.rb +++ b/lib/middleman/templates.rb @@ -23,6 +23,23 @@ module Middleman::Templates class_option :css_dir, :default => "stylesheets" class_option :js_dir, :default => "javascripts" 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 diff --git a/lib/middleman/templates/blog.rb b/lib/middleman/templates/blog.rb index ba80874a..ef1189e9 100644 --- a/lib/middleman/templates/blog.rb +++ b/lib/middleman/templates/blog.rb @@ -5,13 +5,16 @@ class Middleman::Templates::Blog < Middleman::Templates::Base def build_scaffold 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") 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[:images_dir]) end + + def generate_rack + template "blog/config.ru", File.join(location, "config.ru") + end end Middleman::Templates.register(:blog, Middleman::Templates::Blog) \ No newline at end of file diff --git a/lib/middleman/templates/default.rb b/lib/middleman/templates/default.rb index 0c5e1d8e..f38ff85e 100644 --- a/lib/middleman/templates/default.rb +++ b/lib/middleman/templates/default.rb @@ -5,9 +5,6 @@ class Middleman::Templates::Default < Middleman::Templates::Base def build_scaffold 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/layout.erb", File.join(location, "source/layout.erb") empty_directory File.join(location, "source", options[:css_dir]) diff --git a/lib/middleman/templates/shared/Gemfile.tt b/lib/middleman/templates/shared/Gemfile.tt new file mode 100644 index 00000000..84520bad --- /dev/null +++ b/lib/middleman/templates/shared/Gemfile.tt @@ -0,0 +1,3 @@ +source "http://rubygems.org" + +gem "middleman", "~><%= Middleman::VERSION %>" \ No newline at end of file diff --git a/lib/middleman/version.rb b/lib/middleman/version.rb index a1f8a5e8..66321f87 100644 --- a/lib/middleman/version.rb +++ b/lib/middleman/version.rb @@ -1,3 +1,3 @@ module Middleman - VERSION = "2.0.0.rc99" + VERSION = "2.0.0" end