Sha256: e9241c369ce2c75ee4f48fef09aa8a31ed880c5e99f15a01431ebf1faef1cece

Contents?: true

Size: 1.89 KB

Versions: 17

Compression:

Stored size: 1.89 KB

Contents

module Padrino
  module Generators

    class Mailer < Thor::Group

      # Add this generator to our padrino-gen
      Padrino::Generators.add_generator(:mailer, self)

      # Define the source template root
      def self.source_root; File.expand_path(File.dirname(__FILE__)); end
      def self.banner; "padrino-gen mailer [name]"; end

      # Include related modules
      include Thor::Actions
      include Padrino::Generators::Actions
      include Padrino::Generators::Components::Actions

      desc "Description:\n\n\tpadrino-gen mailer generates a new Padrino mailer"

      argument :name, :desc => "The name of your padrino mailer"
      argument :actions, :desc => "The delivery actions to add to your mailer", :type => :array, :default => []
      class_option :root, :desc => "The root destination", :aliases => '-r', :default => ".", :type => :string
      class_option :app, :desc => "The application destination path", :aliases => '-a', :default => "/app", :type => :string
      class_option :destroy, :aliases => '-d', :default => false, :type => :boolean

      # Show help if no argv given
      require_arguments!

      def create_mailer
        self.destination_root = options[:root]
        if in_app_root?
          app = options[:app]
          check_app_existence(app)
          self.behavior = :revoke if options[:destroy]
          @app_name = fetch_app_name(app)
          @actions = actions.map{|a| a.to_sym}
          @short_name = name.to_s.gsub(/mailer/i, '').underscore.downcase
          @mailer_basename = @short_name.underscore
          template "templates/mailer.rb.tt", destination_root(app, "mailers", "#{@mailer_basename}.rb")
          empty_directory destination_root(app, 'views', 'mailers', @mailer_basename)
        else
          say "You are not at the root of a Padrino application! (config/boot.rb not found)"
        end
      end
    end # Mailer
  end # Generators
end # Padrino

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
padrino-gen-0.10.1 lib/padrino-gen/generators/mailer.rb
padrino-gen-0.10.0 lib/padrino-gen/generators/mailer.rb
padrino-gen-0.9.29 lib/padrino-gen/generators/mailer.rb
padrino-gen-0.9.28 lib/padrino-gen/generators/mailer.rb
padrino-gen-0.9.27 lib/padrino-gen/generators/mailer.rb
padrino-gen-0.9.26 lib/padrino-gen/generators/mailer.rb
padrino-gen-0.9.24 lib/padrino-gen/generators/mailer.rb
padrino-gen-0.9.25 lib/padrino-gen/generators/mailer.rb
padrino-gen-0.9.23 lib/padrino-gen/generators/mailer.rb
padrino-gen-0.9.22 lib/padrino-gen/generators/mailer.rb
padrino-gen-0.9.21 lib/padrino-gen/generators/mailer.rb
padrino-gen-0.9.20 lib/padrino-gen/generators/mailer.rb
padrino-gen-0.9.19 lib/padrino-gen/generators/mailer.rb
padrino-gen-0.9.18 lib/padrino-gen/generators/mailer.rb
padrino-gen-0.9.17 lib/padrino-gen/generators/mailer.rb
padrino-gen-0.9.16 lib/padrino-gen/generators/mailer.rb
padrino-gen-0.9.15 lib/padrino-gen/generators/mailer.rb