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.7.1 lib/tasks/generate/view.rake
daddy-0.7.0 lib/tasks/generate/view.rake
daddy-0.6.6 lib/tasks/generate/view.rake
daddy-0.6.5 lib/tasks/generate/view.rake
daddy-0.6.4 lib/tasks/generate/view.rake
daddy-0.6.3 lib/tasks/generate/view.rake
daddy-0.6.2 lib/tasks/generate/view.rake
daddy-0.6.1 lib/tasks/generate/view.rake
daddy-0.6.0 lib/tasks/generate/view.rake
daddy-0.5.34 lib/tasks/generate/view.rake
daddy-0.5.33 lib/tasks/generate/view.rake
daddy-0.5.32 lib/tasks/generate/view.rake
daddy-0.5.31 lib/tasks/generate/view.rake
daddy-0.5.30 lib/tasks/generate/view.rake
daddy-0.5.29 lib/tasks/generate/view.rake
daddy-0.5.28 lib/tasks/generate/view.rake
daddy-0.5.27 lib/tasks/generate/view.rake
daddy-0.5.26 lib/tasks/generate/view.rake
daddy-0.5.25 lib/tasks/generate/view.rake
daddy-0.5.24 lib/tasks/generate/view.rake