Sha256: 05845166566abece91696cbd4be36966ed7197eb1d9dfd80726b549338e4e322
Contents?: true
Size: 1.7 KB
Versions: 19
Compression:
Stored size: 1.7 KB
Contents
module Padrino module Generators ## # Responsible for generating new task file for Padrino application. # class Task < Thor::Group include Thor::Actions include Padrino::Generators::Actions include Padrino::Generators::Components::Actions Padrino::Generators.add_generator(:task, self) class << self def source_root; File.expand_path(File.dirname(__FILE__)); end def banner; "padrino-gen task [name]"; end end desc "Description:\n\n\tpadrino-gen task generates a new task file." argument :name, :desc => 'The name of your application task' class_option :root, :desc => 'The root destination', :aliases => '-r', :default => '.', :type => :string class_option :description, :desc => 'The description of your application task', :aliases => '-d', :default => nil, :type => :string class_option :namespace, :desc => 'The namespace of your application task', :aliases => '-n', :default => nil, :type => :string # Show help if no ARGV given require_arguments! def create_task self.destination_root = options[:root] if in_app_root? app = options[:app] @task_name = name.to_s.underscore @namespace = options[:namespace].underscore if options[:namespace] @desc = options[:description] filename = @task_name + ".rake" filename = "#{@namespace}_#{filename}" if @namespace template 'templates/task.rb.tt', destination_root('tasks', filename) else say 'You are not at the root of a Padrino application! (config/boot.rb not found)' end end end end end
Version data entries
19 entries across 19 versions & 1 rubygems