Sha256: 6b0375189eaaeeec2f8518e65913a744db98ed56e18ac6171f4d22d354a27a85

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 KB

Contents

module Tay
  module CLI
    class Root < ::Thor
      desc 'new NAME', 'Create a new extension'
      method_option 'no-gitignore', :type => :boolean, :default => false,
        :banner => "Don\'t create a .gitignore file"
      method_option 'no-gemfile', :type => :boolean, :default => false,
        :banner => "Don\'t create a Gemfile file"
      method_option 'use-coffeescript', :type => :boolean, :default => false,
        :banner => "Use coffeescript"
      method_option 'use-haml', :type => :boolean, :default => false,
        :banner => "Use haml"
      def new(name)
        outdir = Pathname.new(Utils.filesystem_name(name))
        create_directory_structure(outdir)

        template('Gemfile', outdir.join('Gemfile')) unless options['no-gemfile']
        copy_file('gitignore', outdir.join('.gitignore')) unless options['no-gitignore']
        template('Tayfile', outdir.join('Tayfile'), {
          'name' => name
        }.merge(options))
      end

      protected

      def create_directory_structure(outdir)
        empty_directory(outdir)
        empty_directory(outdir.join('src'))
        empty_directory(outdir.join('src/assets'))
        empty_directory(outdir.join('src/img'))
        empty_directory(outdir.join('src/html'))
        empty_directory(outdir.join('src/javascripts'))
        empty_directory(outdir.join('src/stylesheets'))
        empty_directory(outdir.join('src/templates'))
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tay-0.1.0 lib/tay/cli/new.rb
tay-0.0.5 lib/tay/cli/new.rb