Sha256: e5ae7d9e527d94a715bb108a17bc97acea6de7232ca16fcf42d9124a20ca32b0

Contents?: true

Size: 743 Bytes

Versions: 7

Compression:

Stored size: 743 Bytes

Contents

require 'rake'
require 'erb'

namespace :dad do
  namespace :generate do

    task :controller => :environment do
      ARGV[1..-1].each do |arg|
        unless arg.index('=')
          task arg.to_sym do ; end

          if @resources.nil?
            @resources = arg.downcase
          end
        end
      end

      @resource = @resources.singularize
      @model_class = @resource.classify.constantize
      @controller_name = @resources.split('_').map{|a| a.capitalize}.join

      template = File.join(File.dirname(__FILE__), 'templates', 'controller.rb.erb')
      controller_file = "#{Rails.root}/app/controllers/#{@resources}_controller.rb"
      File.write(controller_file, ERB.new(File.read(template)).result)
    end

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
daddy-0.3.2 lib/tasks/generate/controller.rake
daddy-0.3.1 lib/tasks/generate/controller.rake
daddy-0.3.0 lib/tasks/generate/controller.rake
daddy-0.2.23 lib/tasks/generate/controller.rake
daddy-0.2.22 lib/tasks/generate/controller.rake
daddy-0.2.21 lib/tasks/generate/controller.rake
daddy-0.2.20 lib/tasks/generate/controller.rake