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

Version Path
padrino-gen-0.12.8.1 lib/padrino-gen/generators/task.rb
padrino-gen-0.12.8 lib/padrino-gen/generators/task.rb
padrino-gen-0.12.7 lib/padrino-gen/generators/task.rb
padrino-gen-0.12.6 lib/padrino-gen/generators/task.rb
padrino-gen-0.13.1 lib/padrino-gen/generators/task.rb
padrino-gen-0.13.1.beta1 lib/padrino-gen/generators/task.rb
padrino-gen-0.13.0 lib/padrino-gen/generators/task.rb
padrino-gen-0.13.0.beta3 lib/padrino-gen/generators/task.rb
padrino-gen-0.13.0.beta2 lib/padrino-gen/generators/task.rb
padrino-gen-0.12.5 lib/padrino-gen/generators/task.rb
padrino-gen-0.13.0.beta1 lib/padrino-gen/generators/task.rb
padrino-gen-0.12.4 lib/padrino-gen/generators/task.rb
padrino-gen-0.12.3 lib/padrino-gen/generators/task.rb
padrino-gen-0.12.2 lib/padrino-gen/generators/task.rb
padrino-gen-0.12.1 lib/padrino-gen/generators/task.rb
padrino-gen-0.12.0 lib/padrino-gen/generators/task.rb
padrino-gen-0.12.0.rc3 lib/padrino-gen/generators/task.rb
padrino-gen-0.12.0.rc2 lib/padrino-gen/generators/task.rb
padrino-gen-0.12.0.rc1 lib/padrino-gen/generators/task.rb