Sha256: 35f08c5da17f465e316bb4b2369d3da1411f9a30ed77ab7216eacab44e1de456

Contents?: true

Size: 1.41 KB

Versions: 51

Compression:

Stored size: 1.41 KB

Contents

# CLI Module
module Middleman::Cli

  # A thor task for creating new projects
  class Extension < Thor
    include Thor::Actions

    check_unknown_options!

    namespace :extension

    # 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")
      template "lib/middleman_extension.rb", File.join(name, "lib", "middleman_extension.rb")
      template "lib/lib.rb", File.join(name, "lib", "#{name}.rb")
      template "features/support/env.rb", File.join(name, "features", "support", "env.rb")
      empty_directory File.join(name, "fixtures")
    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

Version data entries

51 entries across 51 versions & 2 rubygems

Version Path
middleman-core-3.2.1 lib/middleman-core/cli/extension.rb
middleman-core-3.2.0 lib/middleman-core/cli/extension.rb
middleman-core-3.1.6 lib/middleman-core/cli/extension.rb
middleman-core-3.1.5 lib/middleman-core/cli/extension.rb
middleman-core-3.1.4 lib/middleman-core/cli/extension.rb
middleman-core-3.1.3 lib/middleman-core/cli/extension.rb
middleman-core-3.1.2 lib/middleman-core/cli/extension.rb
middleman-core-3.1.1 lib/middleman-core/cli/extension.rb
middleman-core-3.1.0 lib/middleman-core/cli/extension.rb
middleman-core-3.1.0.rc.4 lib/middleman-core/cli/extension.rb
middleman-core-3.1.0.rc.3 lib/middleman-core/cli/extension.rb
middleman-core-3.1.0.rc.2 lib/middleman-core/cli/extension.rb
middleman-core-3.1.0.rc.1 lib/middleman-core/cli/extension.rb
middleman-core-x86-mingw32-3.0.14 lib/middleman-core/cli/extension.rb
middleman-core-3.0.14 lib/middleman-core/cli/extension.rb
middleman-core-3.1.0.beta.3 lib/middleman-core/cli/extension.rb
middleman-core-3.1.0.beta.2 lib/middleman-core/cli/extension.rb
middleman-core-3.1.0.beta.1 lib/middleman-core/cli/extension.rb
middleman-core-x86-mingw32-3.0.13 lib/middleman-core/cli/extension.rb
middleman-core-3.0.13 lib/middleman-core/cli/extension.rb