Sha256: 35cb190c49c63134728edb5742c8428dc638d075e3a6778229f39be9acfb6738

Contents?: true

Size: 980 Bytes

Versions: 1

Compression:

Stored size: 980 Bytes

Contents

require 'fileutils'

module TinyRails
  module Commands
    class New < Thor::Group
      include Thor::Actions
      include Actions

      argument :app_path, :required => true

      # TODO: Move to a base command
      def self.source_root
        "#{File.expand_path('../../../../templates', __FILE__)}/"
      end

      def self.banner
        "tiny-rails new #{self.arguments.map(&:usage).join(' ')} [options]"
      end

      def self.templates
        @templates ||= %w(
          .gitignore
          Gemfile
          boot.rb
          tiny_rails_controller.rb
          index.html.erb
          server
          config.ru
        )
      end

      def create_root
        self.destination_root = File.expand_path(app_path)
        empty_directory '.'
        FileUtils.cd destination_root
      end

      def scaffold
        self.class.templates.each do |template|
          template(template)
        end
        chmod 'server', 0755
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tiny-rails-0.0.2 lib/tiny-rails/commands/new.rb