table_helpers 0.2.1 → 0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +7 -7
 - data/lib/table_helpers.rb +8 -7
 - data/lib/table_list.rb +0 -2
 - data/test/table_helpers_test.rb +13 -21
 - metadata +7 -8
 
    
        data/README
    CHANGED
    
    | 
         @@ -1,20 +1,20 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            TableHelpers
         
     | 
| 
       2 
2 
     | 
    
         
             
            ============
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
       4 
     | 
    
         
            -
            Rails table helpers plugin.
         
     | 
| 
      
 4 
     | 
    
         
            +
            Rails 3.0.x table helpers plugin.
         
     | 
| 
       5 
5 
     | 
    
         | 
| 
       6 
     | 
    
         
            -
             
     | 
| 
      
 6 
     | 
    
         
            +
            Examples
         
     | 
| 
       7 
7 
     | 
    
         
             
            =======
         
     | 
| 
       8 
8 
     | 
    
         | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
      
 9 
     | 
    
         
            +
            <%= table_list :class => 'list' do |t| %>
         
     | 
| 
       10 
10 
     | 
    
         
             
              <%= t.headers ['First column', 'Second column'] %>
         
     | 
| 
       11 
     | 
    
         
            -
                 
     | 
| 
      
 11 
     | 
    
         
            +
                <%= t.tr do |tr| %>
         
     | 
| 
       12 
12 
     | 
    
         
             
                  <%= tr.td 'Example 1' %>
         
     | 
| 
       13 
13 
     | 
    
         
             
                  <%= tr.td 'Example 2' %>
         
     | 
| 
       14 
14 
     | 
    
         
             
                <% end %>
         
     | 
| 
       15 
15 
     | 
    
         
             
            <% end %>
         
     | 
| 
       16 
16 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
      
 17 
     | 
    
         
            +
            HTML output:
         
     | 
| 
       18 
18 
     | 
    
         | 
| 
       19 
19 
     | 
    
         
             
            <table class="list">
         
     | 
| 
       20 
20 
     | 
    
         
             
              <tr>
         
     | 
| 
         @@ -27,13 +27,13 @@ will output: 
     | 
|
| 
       27 
27 
     | 
    
         
             
              </tr>
         
     | 
| 
       28 
28 
     | 
    
         
             
            </table>
         
     | 
| 
       29 
29 
     | 
    
         | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
      
 30 
     | 
    
         
            +
            <%= table_data :label_size => 150 do |t| %>
         
     | 
| 
       31 
31 
     | 
    
         
             
              <%= t.row 'Label name:', 'Data' %>
         
     | 
| 
       32 
32 
     | 
    
         
             
              <%= t.section 'Next section:' %>
         
     | 
| 
       33 
33 
     | 
    
         
             
              <%= t.row 'Label name 2:', 'Data 2' %>
         
     | 
| 
       34 
34 
     | 
    
         
             
            <% end %>
         
     | 
| 
       35 
35 
     | 
    
         | 
| 
       36 
     | 
    
         
            -
             
     | 
| 
      
 36 
     | 
    
         
            +
            HTML output:
         
     | 
| 
       37 
37 
     | 
    
         | 
| 
       38 
38 
     | 
    
         
             
            <table class="info">
         
     | 
| 
       39 
39 
     | 
    
         
             
              <tr>
         
     | 
    
        data/lib/table_helpers.rb
    CHANGED
    
    | 
         @@ -1,3 +1,6 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'table_list'
         
     | 
| 
      
 2 
     | 
    
         
            +
            require 'table_data'
         
     | 
| 
      
 3 
     | 
    
         
            +
             
     | 
| 
       1 
4 
     | 
    
         
             
            module TableHelpers
         
     | 
| 
       2 
5 
     | 
    
         
             
              def get_table_headers(columns=[], widths={})
         
     | 
| 
       3 
6 
     | 
    
         
             
                headers = []
         
     | 
| 
         @@ -13,7 +16,7 @@ module TableHelpers 
     | 
|
| 
       13 
16 
     | 
    
         
             
                  i += 1
         
     | 
| 
       14 
17 
     | 
    
         
             
                end
         
     | 
| 
       15 
18 
     | 
    
         | 
| 
       16 
     | 
    
         
            -
                 
     | 
| 
      
 19 
     | 
    
         
            +
                headers.to_s.html_safe
         
     | 
| 
       17 
20 
     | 
    
         
             
              end
         
     | 
| 
       18 
21 
     | 
    
         | 
| 
       19 
22 
     | 
    
         
             
              def get_sortable_table_headers(columns=[], widths={})
         
     | 
| 
         @@ -44,7 +47,7 @@ module TableHelpers 
     | 
|
| 
       44 
47 
     | 
    
         
             
                  j += 1
         
     | 
| 
       45 
48 
     | 
    
         
             
                end
         
     | 
| 
       46 
49 
     | 
    
         | 
| 
       47 
     | 
    
         
            -
                 
     | 
| 
      
 50 
     | 
    
         
            +
                headers.to_s.html_safe
         
     | 
| 
       48 
51 
     | 
    
         
             
              end
         
     | 
| 
       49 
52 
     | 
    
         | 
| 
       50 
53 
     | 
    
         
             
              def table_list(html_options = {}, &block)
         
     | 
| 
         @@ -57,8 +60,6 @@ module TableHelpers 
     | 
|
| 
       57 
60 
     | 
    
         
             
                    block.call(t)
         
     | 
| 
       58 
61 
     | 
    
         
             
                  end
         
     | 
| 
       59 
62 
     | 
    
         
             
                end
         
     | 
| 
       60 
     | 
    
         
            -
             
     | 
| 
       61 
     | 
    
         
            -
                concat(result)
         
     | 
| 
       62 
63 
     | 
    
         
             
              end
         
     | 
| 
       63 
64 
     | 
    
         | 
| 
       64 
65 
     | 
    
         
             
              def table_data(options = {}, &block)
         
     | 
| 
         @@ -69,7 +70,7 @@ module TableHelpers 
     | 
|
| 
       69 
70 
     | 
    
         
             
                result = content_tag(:table, :class => 'info') do
         
     | 
| 
       70 
71 
     | 
    
         
             
                  block.call(t)
         
     | 
| 
       71 
72 
     | 
    
         
             
                end
         
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
                concat(result)
         
     | 
| 
       74 
73 
     | 
    
         
             
              end
         
     | 
| 
       75 
     | 
    
         
            -
            end
         
     | 
| 
      
 74 
     | 
    
         
            +
            end
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
            ActionView::Base.send :include, TableHelpers
         
     | 
    
        data/lib/table_list.rb
    CHANGED
    
    
    
        data/test/table_helpers_test.rb
    CHANGED
    
    | 
         @@ -10,21 +10,15 @@ class TableHelpersTest < ActionView::TestCase 
     | 
|
| 
       10 
10 
     | 
    
         
             
              include TableHelpers
         
     | 
| 
       11 
11 
     | 
    
         | 
| 
       12 
12 
     | 
    
         
             
              test "table_list_helper_with_headers" do
         
     | 
| 
       13 
     | 
    
         
            -
                result =  
     | 
| 
       14 
     | 
    
         
            -
                   
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
                      capture do 
         
     | 
| 
       23 
     | 
    
         
            -
                        t.tr do |tr| 
         
     | 
| 
       24 
     | 
    
         
            -
                          tr.td('Example 3') +
         
     | 
| 
       25 
     | 
    
         
            -
                          tr.td('Example 4')
         
     | 
| 
       26 
     | 
    
         
            -
                        end
         
     | 
| 
       27 
     | 
    
         
            -
                      end
         
     | 
| 
      
 13 
     | 
    
         
            +
                result = table_list(:class => 'list') do |t|
         
     | 
| 
      
 14 
     | 
    
         
            +
                  t.headers(['Column 1', 'Column 2']) +
         
     | 
| 
      
 15 
     | 
    
         
            +
                  t.tr do |tr|
         
     | 
| 
      
 16 
     | 
    
         
            +
                    tr.td('Example 1') +
         
     | 
| 
      
 17 
     | 
    
         
            +
                    tr.td('Example 2')
         
     | 
| 
      
 18 
     | 
    
         
            +
                  end +
         
     | 
| 
      
 19 
     | 
    
         
            +
                  t.tr do |tr| 
         
     | 
| 
      
 20 
     | 
    
         
            +
                    tr.td('Example 3') +
         
     | 
| 
      
 21 
     | 
    
         
            +
                    tr.td('Example 4')
         
     | 
| 
       28 
22 
     | 
    
         
             
                  end
         
     | 
| 
       29 
23 
     | 
    
         
             
                end
         
     | 
| 
       30 
24 
     | 
    
         | 
| 
         @@ -49,12 +43,10 @@ EOF 
     | 
|
| 
       49 
43 
     | 
    
         
             
              end
         
     | 
| 
       50 
44 
     | 
    
         | 
| 
       51 
45 
     | 
    
         
             
              test "table_data_helper" do
         
     | 
| 
       52 
     | 
    
         
            -
                result =  
     | 
| 
       53 
     | 
    
         
            -
                   
     | 
| 
       54 
     | 
    
         
            -
                    t. 
     | 
| 
       55 
     | 
    
         
            -
             
     | 
| 
       56 
     | 
    
         
            -
                      t.row('Client Name:', 'Bill Gates')
         
     | 
| 
       57 
     | 
    
         
            -
                  end
         
     | 
| 
      
 46 
     | 
    
         
            +
                result = table_data(:label_size => 200) do |t|
         
     | 
| 
      
 47 
     | 
    
         
            +
                  t.row('Firm:', 'Test') +
         
     | 
| 
      
 48 
     | 
    
         
            +
                    t.section +
         
     | 
| 
      
 49 
     | 
    
         
            +
                    t.row('Client Name:', 'Bill Gates')
         
     | 
| 
       58 
50 
     | 
    
         
             
                end
         
     | 
| 
       59 
51 
     | 
    
         | 
| 
       60 
52 
     | 
    
         
             
                expected = <<EOF
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,13 +1,12 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification 
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: table_helpers
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version 
         
     | 
| 
       4 
     | 
    
         
            -
              hash:  
     | 
| 
      
 4 
     | 
    
         
            +
              hash: 13
         
     | 
| 
       5 
5 
     | 
    
         
             
              prerelease: 
         
     | 
| 
       6 
6 
     | 
    
         
             
              segments: 
         
     | 
| 
       7 
7 
     | 
    
         
             
              - 0
         
     | 
| 
       8 
     | 
    
         
            -
              -  
     | 
| 
       9 
     | 
    
         
            -
               
     | 
| 
       10 
     | 
    
         
            -
              version: 0.2.1
         
     | 
| 
      
 8 
     | 
    
         
            +
              - 3
         
     | 
| 
      
 9 
     | 
    
         
            +
              version: "0.3"
         
     | 
| 
       11 
10 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       12 
11 
     | 
    
         
             
            authors: 
         
     | 
| 
       13 
12 
     | 
    
         
             
            - "Damian Ba\xC4\x87kowski"
         
     | 
| 
         @@ -15,7 +14,7 @@ autorequire: 
     | 
|
| 
       15 
14 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       16 
15 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       17 
16 
     | 
    
         | 
| 
       18 
     | 
    
         
            -
            date: 2011- 
     | 
| 
      
 17 
     | 
    
         
            +
            date: 2011-06-16 00:00:00 +02:00
         
     | 
| 
       19 
18 
     | 
    
         
             
            default_executable: 
         
     | 
| 
       20 
19 
     | 
    
         
             
            dependencies: []
         
     | 
| 
       21 
20 
     | 
    
         | 
| 
         @@ -29,10 +28,10 @@ extra_rdoc_files: [] 
     | 
|
| 
       29 
28 
     | 
    
         | 
| 
       30 
29 
     | 
    
         
             
            files: 
         
     | 
| 
       31 
30 
     | 
    
         
             
            - Rakefile
         
     | 
| 
      
 31 
     | 
    
         
            +
            - lib/table_data.rb
         
     | 
| 
       32 
32 
     | 
    
         
             
            - lib/tasks/table_helpers.rake
         
     | 
| 
       33 
33 
     | 
    
         
             
            - lib/table_helpers.rb
         
     | 
| 
       34 
34 
     | 
    
         
             
            - lib/table_list.rb
         
     | 
| 
       35 
     | 
    
         
            -
            - lib/table_data.rb
         
     | 
| 
       36 
35 
     | 
    
         
             
            - rails/init.rb
         
     | 
| 
       37 
36 
     | 
    
         
             
            - test/table_helpers_test.rb
         
     | 
| 
       38 
37 
     | 
    
         
             
            - test/test_helper.rb
         
     | 
| 
         @@ -67,9 +66,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       67 
66 
     | 
    
         
             
            requirements: []
         
     | 
| 
       68 
67 
     | 
    
         | 
| 
       69 
68 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       70 
     | 
    
         
            -
            rubygems_version: 1.6. 
     | 
| 
      
 69 
     | 
    
         
            +
            rubygems_version: 1.6.2
         
     | 
| 
       71 
70 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       72 
71 
     | 
    
         
             
            specification_version: 3
         
     | 
| 
       73 
     | 
    
         
            -
            summary: Table helpers for Rails
         
     | 
| 
      
 72 
     | 
    
         
            +
            summary: Table helpers for Rails 3.0.x
         
     | 
| 
       74 
73 
     | 
    
         
             
            test_files: []
         
     | 
| 
       75 
74 
     | 
    
         |