Sha256: e277cc5900fc6c9ccf44af2b4f50bb47ba87b483a2f9ec9a5604a8ee5f5afd8f

Contents?: true

Size: 856 Bytes

Versions: 110

Compression:

Stored size: 856 Bytes

Contents

require 'rake'

namespace :dad do
  namespace :generate do

    task :view => :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
      @short_name = @resource.split('_').map(&:first).join
      @model_class = @resource.capitalize.constantize
      @tag_begin = '<%'
      @tag_end = '%>'

      Dir[File.join(template_dir, 'app', 'views', '*.html.erb')].each do |template|
        view_dir = "#{Rails.root}/app/views/#{@resources}"
        FileUtils.mkdir_p(view_dir)

        view_file = "#{view_dir}/#{File.basename(template)}"
        File.write(view_file, ERB.new(File.read(template), 0, '-').result)
      end
    end
    
  end
end

Version data entries

110 entries across 110 versions & 1 rubygems

Version Path
daddy-0.9.9 lib/tasks/generate/view.rake
daddy-0.9.8 lib/tasks/generate/view.rake
daddy-0.9.7 lib/tasks/generate/view.rake
daddy-0.9.6 lib/tasks/generate/view.rake
daddy-0.9.5 lib/tasks/generate/view.rake
daddy-0.9.4 lib/tasks/generate/view.rake
daddy-0.9.3 lib/tasks/generate/view.rake
daddy-0.9.2 lib/tasks/generate/view.rake
daddy-0.9.1 lib/tasks/generate/view.rake
daddy-0.9.0 lib/tasks/generate/view.rake
daddy-0.8.1 lib/tasks/generate/view.rake
daddy-0.8.0 lib/tasks/generate/view.rake
daddy-0.7.9 lib/tasks/generate/view.rake
daddy-0.7.8 lib/tasks/generate/view.rake
daddy-0.7.7 lib/tasks/generate/view.rake
daddy-0.7.6 lib/tasks/generate/view.rake
daddy-0.7.5 lib/tasks/generate/view.rake
daddy-0.7.4 lib/tasks/generate/view.rake
daddy-0.7.3 lib/tasks/generate/view.rake
daddy-0.7.2 lib/tasks/generate/view.rake