Changeset 1226

Show
Ignore:
Timestamp:
12/10/07 20:39:34 (1 year ago)
Author:
mikem836
Message:

template API change

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • ruport/trunk/examples/simple_templating_example.rb

    r1174 r1226  
    11require "ruport" 
    22 
    3 Ruport::Formatter::Template.create(:simple) do |t| 
    4   t.page_format = { 
     3Ruport::Formatter::Template.create(:simple) do |format| 
     4  format.page = { 
    55    :size   => "LETTER", 
    66    :layout => :landscape 
    77  } 
    8   t.text_format = { 
     8  format.text = { 
    99    :font_size => 16 
    1010  } 
    11   t.table_format = { 
     11  format.table = { 
    1212    :font_size      => 16, 
    1313    :show_headings  => false 
    1414  } 
    15   t.column_format = { 
     15  format.column = { 
    1616    :alignment => :center, 
    1717  }                        
    18   t.heading_format = { 
     18  format.heading = { 
    1919    :alignment => :right 
    2020  } 
    21   t.grouping_format = { 
     21  format.grouping = { 
    2222    :style => :separated 
    2323  } 
  • ruport/trunk/lib/ruport/formatter/csv.rb

    r1224 r1226  
    3636    # documentation for the available options and their format. 
    3737    def apply_template 
    38       apply_table_format_template(template.table_format
    39       apply_grouping_format_template(template.grouping_format
     38      apply_table_format_template(template.table
     39      apply_grouping_format_template(template.grouping
    4040 
    4141      options.format_options ||= template.format_options 
  • ruport/trunk/lib/ruport/formatter/html.rb

    r1224 r1226  
    3232    # documentation for the available options and their format. 
    3333    def apply_template 
    34       apply_table_format_template(template.table_format
    35       apply_grouping_format_template(template.grouping_format
     34      apply_table_format_template(template.table
     35      apply_grouping_format_template(template.grouping
    3636    end 
    3737 
  • ruport/trunk/lib/ruport/formatter/pdf.rb

    r1224 r1226  
    5959    # documentation for the available options and their format. 
    6060    def apply_template 
    61       apply_page_format_template(template.page_format
    62       apply_text_format_template(template.text_format
    63       apply_table_format_template(template.table_format
    64       apply_column_format_template(template.column_format
    65       apply_heading_format_template(template.heading_format
    66       apply_grouping_format_template(template.grouping_format
     61      apply_page_format_template(template.page
     62      apply_text_format_template(template.text
     63      apply_table_format_template(template.table
     64      apply_column_format_template(template.column
     65      apply_heading_format_template(template.heading
     66      apply_grouping_format_template(template.grouping
    6767    end 
    6868 
  • ruport/trunk/lib/ruport/formatter/template.rb

    r1225 r1226  
    4747# Example: 
    4848# 
    49 #   Ruport::Formatter::Template.create(:simple) do |t| 
    50 #     t.page_format = { 
     49#   Ruport::Formatter::Template.create(:simple) do |format| 
     50#     format.page = { 
    5151#       :size   => "LETTER", 
    5252#       :layout => :landscape 
     
    5454#   end 
    5555# 
     56# If you define a template with the name :default, then it will be used by 
     57# all formatters unless they either specify a template or explicitly turn off 
     58# the templating functionality by using :template => false. 
     59# 
     60# Example: 
     61# 
     62#   Ruport::Formatter::Template.create(:simple) 
     63#   Ruport::Formatter::Template.create(:default) 
     64# 
     65#   puts g.to_pdf                       #=> uses the :default template 
     66#   puts g.to_pdf(:template => :simple) #=> uses the :simple template 
     67#   puts g.to_pdf(:template => false)   #=> doesn't use a template 
     68# 
    5669# ==== PDF Formatter Options 
    5770# 
    5871#   Option          Key                 Value 
    5972#  
    60 #   page_format     :size               Any size supported by the :paper 
     73#   page            :size               Any size supported by the :paper 
    6174#                                       option to PDF::Writer.new 
    6275#  
    6376#                   :layout             :portrait, :landscape 
    6477#  
    65 #   text_format     Any available to    Corresponding values 
     78#   text            Any available to    Corresponding values 
    6679#                   PDF::Writer#text 
    6780#  
    68 #   table_format    All attributes of   Corresponding values 
     81#   table           All attributes of   Corresponding values 
    6982#                   PDF::SimpleTable 
    7083#  
     
    7992#                                         PDF::SimpleTable::Column::Heading } 
    8093#  
    81 #   column_format   :alignment          :left, :right, :center, :full 
     94#   column          :alignment          :left, :right, :center, :full 
    8295#  
    8396#                   :width              column width 
    8497#  
    85 #   heading_format  :alignment          :left, :right, :center, :full 
     98#   heading         :alignment          :left, :right, :center, :full 
    8699#  
    87100#                   :bold               true or false 
     
    90103#                                       defaults to column name) 
    91104#  
    92 #   grouping_format :style              :inline, :justified, :separated, :offset 
     105#   grouping        :style              :inline, :justified, :separated, :offset 
    93106# 
    94107# 
     
    97110#   Option          Key                 Value 
    98111#  
    99 #   table_format    :show_headings      true or false 
     112#   table           :show_headings      true or false 
    100113#                   :width              Table width 
    101114#                   :ignore_width       true or false 
    102115#  
    103 #   column_format   :alignment          :center 
     116#   column          :alignment          :center 
    104117#                   :maximum_width      Max column width 
    105118#  
    106 #   grouping_format :show_headings      true or false 
     119#   grouping        :show_headings      true or false 
    107120# 
    108121# 
     
    111124#   Option          Key                 Value 
    112125#  
    113 #   table_format    :show_headings      true or false 
     126#   table           :show_headings      true or false 
    114127#  
    115 #   grouping_format :style              :inline, :justified 
     128#   grouping        :style              :inline, :justified 
    116129#                   :show_headings      true or false 
    117130# 
     
    121134#   Option          Key                 Value 
    122135#  
    123 #   table_format    :show_headings      true or false 
     136#   table           :show_headings      true or false 
    124137#  
    125 #   grouping_format :style              :inline, :justified, :raw 
     138#   grouping        :style              :inline, :justified, :raw 
    126139#                   :show_headings      true or false 
    127140#  
  • ruport/trunk/lib/ruport/formatter/text.rb

    r1224 r1226  
    5252    # documentation for the available options and their format. 
    5353    def apply_template 
    54       apply_table_format_template(template.table_format
    55       apply_column_format_template(template.column_format
    56       apply_grouping_format_template(template.grouping_format
     54      apply_table_format_template(template.table
     55      apply_column_format_template(template.column
     56      apply_grouping_format_template(template.grouping
    5757    end 
    5858 
  • ruport/trunk/test/csv_formatter_test.rb

    r1208 r1226  
    1212   
    1313  def setup 
    14     Ruport::Formatter::Template.create(:simple) do |t| 
    15       t.table_format = { 
     14    Ruport::Formatter::Template.create(:simple) do |format| 
     15      format.table = { 
    1616        :show_headings  => false 
    1717      } 
    18       t.grouping_format = { 
     18      format.grouping = { 
    1919        :style          => :justified, 
    2020        :show_headings  => false 
    2121      } 
    22       t.format_options = { :col_sep => ":" } 
     22      format.format_options = { :col_sep => ":" } 
    2323    end 
    2424  end 
  • ruport/trunk/test/html_formatter_test.rb

    r1208 r1226  
    55   
    66  def setup 
    7     Ruport::Formatter::Template.create(:simple) do |t| 
    8       t.table_format = { 
     7    Ruport::Formatter::Template.create(:simple) do |format| 
     8      format.table = { 
    99        :show_headings  => false 
    1010      } 
    11       t.grouping_format = { 
     11      format.grouping = { 
    1212        :style          => :justified, 
    1313        :show_headings  => false 
  • ruport/trunk/test/pdf_formatter_test.rb

    r1208 r1226  
    55   
    66  def setup 
    7     Ruport::Formatter::Template.create(:simple) do |t| 
    8       t.page_format = { 
     7    Ruport::Formatter::Template.create(:simple) do |format| 
     8      format.page = { 
    99        :size   => "LETTER", 
    1010        :layout => :landscape 
    1111      } 
    12       t.text_format = { 
     12      format.text = { 
    1313        :font_size => 16 
    1414      } 
    15       t.table_format = { 
     15      format.table = { 
    1616        :show_headings  => false 
    1717      } 
    18       t.column_format = { 
     18      format.column = { 
    1919        :alignment  => :center, 
    2020        :width      => 50 
    2121      } 
    22       t.heading_format = { 
     22      format.heading = { 
    2323        :alignment  => :right, 
    2424        :bold       => false, 
    2525        :title      => "Test" 
    2626      } 
    27       t.grouping_format = { 
     27      format.grouping = { 
    2828        :style => :separated 
    2929      } 
  • ruport/trunk/test/text_formatter_test.rb

    r1208 r1226  
    55   
    66  def setup 
    7     Ruport::Formatter::Template.create(:simple) do |t| 
    8       t.table_format = { 
     7    Ruport::Formatter::Template.create(:simple) do |format| 
     8      format.table = { 
    99        :show_headings  => false, 
    1010        :width          => 50, 
    1111        :ignore_width   => true 
    1212      } 
    13       t.column_format = { 
     13      format.column = { 
    1414        :maximum_width  => [5,5,7], 
    1515        :alignment => :center 
    1616      } 
    17       t.grouping_format = { 
     17      format.grouping = { 
    1818        :show_headings  => false 
    1919      }