From b4edf7cf16b427487590ba7137558052b313ad0d Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Wed, 1 May 2013 09:37:33 -0700 Subject: [PATCH] update the extension template to new class system --- .../templates/extension/Gemfile | 12 +++++----- .../templates/extension/gitignore | 5 +++- .../templates/extension/lib/lib.rb | 23 +++++++++---------- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/middleman-core/lib/middleman-core/templates/extension/Gemfile b/middleman-core/lib/middleman-core/templates/extension/Gemfile index cef80b09..b3031953 100644 --- a/middleman-core/lib/middleman-core/templates/extension/Gemfile +++ b/middleman-core/lib/middleman-core/templates/extension/Gemfile @@ -6,14 +6,14 @@ source 'http://rubygems.org' gemspec group :development do - gem "rake", "~> 0.9.2" - gem "rdoc", "~> 3.9" - gem "yard", "~> 0.8.0" + gem "rake" + gem "rdoc" + gem "yard" end group :test do - gem "cucumber", "~> 1.2.0" + gem "cucumber" gem "fivemat" - gem "aruba", "~> 0.4.11" - gem "rspec", "~> 2.7" + gem "aruba" + gem "rspec" end \ No newline at end of file diff --git a/middleman-core/lib/middleman-core/templates/extension/gitignore b/middleman-core/lib/middleman-core/templates/extension/gitignore index 6f9f5cec..a39017be 100644 --- a/middleman-core/lib/middleman-core/templates/extension/gitignore +++ b/middleman-core/lib/middleman-core/templates/extension/gitignore @@ -1,2 +1,5 @@ # Ignore bundler lock file -Gemfile.lock \ No newline at end of file +/Gemfile.lock + +# Ignore pkg folder +/pkg \ No newline at end of file diff --git a/middleman-core/lib/middleman-core/templates/extension/lib/lib.rb b/middleman-core/lib/middleman-core/templates/extension/lib/lib.rb index c2aa42dc..6140bd82 100644 --- a/middleman-core/lib/middleman-core/templates/extension/lib/lib.rb +++ b/middleman-core/lib/middleman-core/templates/extension/lib/lib.rb @@ -2,19 +2,16 @@ require "middleman-core" # Extension namespace -module MyExtension < Middleman::Extension +class MyExtension < ::Middleman::Extension option :my_option, "default", "An example option" - def initialize(app, options_hash={}) + def initialize(app, options_hash={}, &block) # Call super to build options from the options_hash super # Require libraries only when activated # require 'necessary/library' - # Include helpers or instance methods for the Middleman app - # app.send :include, Helpers - # set up your extension # puts options.my_option end @@ -23,7 +20,11 @@ module MyExtension < Middleman::Extension # Do something end - # module Helpers + # A Sitemap Manipulator + # def manipulate_resource_list(resources) + # end + + # module do # def a_helper # end # end @@ -32,9 +33,7 @@ end # Register extensions which can be activated # Make sure we have the version of Middleman we expect -# ::Middleman::Extensions.register(:extension_name) do -# -# # Return the extension class -# ::MyExtension -# -# end +# Name param may be omited, it will default to underscored +# version of class name + +# MyExtension.register(:my_extension)