From 193f32b9fbee1d6e554221947bafa6369a213bb0 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Mon, 20 Aug 2012 19:37:10 -0700 Subject: [PATCH] Add test gems to extension and a gitignore. Closes #570 --- middleman-core/features/cli_extension.feature | 1 + .../lib/middleman-core/cli/extension.rb | 25 ++++++++++++++----- .../templates/extension/Gemfile | 15 ++++++++++- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/middleman-core/features/cli_extension.feature b/middleman-core/features/cli_extension.feature index f648e3f2..b762664c 100644 --- a/middleman-core/features/cli_extension.feature +++ b/middleman-core/features/cli_extension.feature @@ -11,3 +11,4 @@ Feature: Middleman New Extension CLI | features/support/env.rb | | lib/middleman_extension.rb | | lib/my-extension-library.rb | + | .gitignore | diff --git a/middleman-core/lib/middleman-core/cli/extension.rb b/middleman-core/lib/middleman-core/cli/extension.rb index e15ae255..22a4531e 100644 --- a/middleman-core/lib/middleman-core/cli/extension.rb +++ b/middleman-core/lib/middleman-core/cli/extension.rb @@ -11,12 +11,19 @@ module Middleman::Cli # Required path for the new project to be generated argument :name, :type => :string - + + # Template files are relative to this file + # @return [String] + def self.source_root + File.join(File.dirname(__FILE__), "..", "templates", "extension") + end + desc "extension [options]", "Create Middleman extension scaffold NAME" # The extension task # @param [String] name def extension + generate_gitignore! template "Rakefile", File.join(name, "Rakefile") template "gemspec", File.join(name, "#{name}.gemspec") template "Gemfile", File.join(name, "Gemfile") @@ -26,11 +33,17 @@ module Middleman::Cli empty_directory File.join(name, "fixtures") end - # Template files are relative to this file - # @return [String] - def self.source_root - File.join(File.dirname(__FILE__), "..", "templates", "extension") - end + # Output a .gitignore file + class_option :git, :type => :boolean, :default => true + + no_tasks { + # Write a .gitignore file for project + # @return [void] + def generate_gitignore! + return unless options[:git] + copy_file "gitignore", File.join(name, ".gitignore") + end + } end end diff --git a/middleman-core/lib/middleman-core/templates/extension/Gemfile b/middleman-core/lib/middleman-core/templates/extension/Gemfile index 7081b154..69ea7ad0 100644 --- a/middleman-core/lib/middleman-core/templates/extension/Gemfile +++ b/middleman-core/lib/middleman-core/templates/extension/Gemfile @@ -1,4 +1,17 @@ source :rubygems # Specify your gem's dependencies in <%= name %>.gemspec -gemspec \ No newline at end of file +gemspec + +group :development do + gem "rake", "~> 0.9.2" + gem "rdoc", "~> 3.9" + gem "yard", "~> 0.8.0" +end + +group :test do + gem "cucumber", "~> 1.2.0" + gem "fivemat" + gem "aruba", "~> 0.4.11" + gem "rspec", "~> 2.7" +end \ No newline at end of file