Sha256: 8d2a3a6c608735eb9aa3ca376d8a7a17cb3342ff3c61d97a3857cfb851d214a2

Contents?: true

Size: 1.21 KB

Versions: 22

Compression:

Stored size: 1.21 KB

Contents

class PdfGenerator < Rails::Generator::NamedBase
  def initialize(runtime_args, runtime_options = {})
    runtime_args = ["pdf"].concat(runtime_args) # Skip usage
    super
  end
  
  def manifest
    record do |m|
      # Copy Stylesheets
      m.create_all("stylesheets", "public/stylesheets")

      # Layout and Views
      m.directory "app/views/pdf"
      m.directory "app/views/layouts"
      
      # Layout
      m.template 'layout.html.erb', 'app/views/layouts/print.html.erb'

      # View template for each action.
      actions.each do |action|
        m.template 'view.html.haml', "app/views/pdf/#{action}.html.haml",
          :assigns => { :action => action }
      end
      
      m.puts remember
    end
  end


  protected
    def banner
      "Usage: #{$0} pdf action"
    end
    
    def remember
      <<-MESSAGE

==============================================================================================

  Please remember to add in your controller(s) some like:
  
#{actions.collect { |a| 
"    def generate_pdf_#{a}
      render_pdf :#{a}, '#{a}_file.pdf'
    end" }.join("\n\n")}

==============================================================================================
      MESSAGE
    end    
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
lipsiadmin-4.1.8 lipsiadmin_generators/pdf/pdf_generator.rb
lipsiadmin-3.3.1 lipsiadmin_generators/pdf/pdf_generator.rb
lipsiadmin-2.9 lipsiadmin_generators/pdf/pdf_generator.rb
lipsiadmin-3.0 lipsiadmin_generators/pdf/pdf_generator.rb
lipsiadmin-3.1 lipsiadmin_generators/pdf/pdf_generator.rb
lipsiadmin-3.2 lipsiadmin_generators/pdf/pdf_generator.rb
lipsiadmin-3.3.2 lipsiadmin_generators/pdf/pdf_generator.rb
lipsiadmin-3.3.3 lipsiadmin_generators/pdf/pdf_generator.rb
lipsiadmin-3.3.4 lipsiadmin_generators/pdf/pdf_generator.rb
lipsiadmin-3.4.0 lipsiadmin_generators/pdf/pdf_generator.rb
lipsiadmin-3.4.1 lipsiadmin_generators/pdf/pdf_generator.rb
lipsiadmin-3.4.2 lipsiadmin_generators/pdf/pdf_generator.rb
lipsiadmin-3.3 lipsiadmin_generators/pdf/pdf_generator.rb
lipsiadmin-4.1.1 lipsiadmin_generators/pdf/pdf_generator.rb
lipsiadmin-4.0.0 lipsiadmin_generators/pdf/pdf_generator.rb
lipsiadmin-4.1.0 lipsiadmin_generators/pdf/pdf_generator.rb
lipsiadmin-4.1.2 lipsiadmin_generators/pdf/pdf_generator.rb
lipsiadmin-4.1.4 lipsiadmin_generators/pdf/pdf_generator.rb
lipsiadmin-4.1.3 lipsiadmin_generators/pdf/pdf_generator.rb
lipsiadmin-4.1.5 lipsiadmin_generators/pdf/pdf_generator.rb