table_cloth 0.4.2 → 0.4.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.
- checksums.yaml +4 -4
- data/README.md +39 -1
- data/lib/table_cloth.rb +2 -1
- data/lib/table_cloth/base.rb +1 -0
- data/lib/table_cloth/extensions/actions/action.rb +3 -3
- data/lib/table_cloth/extensions/actions/column.rb +2 -2
- data/lib/table_cloth/extensions/actions/jury.rb +4 -4
- data/lib/table_cloth/extensions/row_attributes.rb +36 -0
- data/lib/table_cloth/presenters/default.rb +5 -3
- data/lib/table_cloth/version.rb +1 -1
- data/spec/lib/base_spec.rb +1 -1
- data/spec/lib/column_jury_spec.rb +2 -2
- data/spec/lib/extensions/actions/action_spec.rb +7 -6
- data/spec/lib/extensions/actions/jury_spec.rb +14 -13
- data/spec/lib/presenters/default_spec.rb +7 -1
- data/spec/spec_helper.rb +2 -1
- data/spec/support/dummy_table.rb +5 -2
- data/table_cloth.gemspec +4 -3
- metadata +52 -37
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA1:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 4809a8ece14084a111f90b54211e33a3c167f88a
         | 
| 4 | 
            +
              data.tar.gz: f37ebf4590be9b93002eced4c2d4675381026f1d
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: 058443b491f93508d4ed716cf3983ebd0b25f3c942f1ccad497f53e8c1e4ec678204cbe5f9391a52b3494167a8d33ba10e4f5f886896a805779de31e34af07c1
         | 
| 7 | 
            +
              data.tar.gz: 2387a00d2246a57038d3c6d24f355e08ddf651bfdd9f0b58c27e7fc2e7dd5d82aad5331f2daf2bbffc410d56c85dcf15f9fe04050075268ab5e8e1bd29202def
         | 
    
        data/README.md
    CHANGED
    
    | @@ -92,7 +92,7 @@ You can create your own column by making a class that responds to ```.value(obje | |
| 92 92 |  | 
| 93 93 | 
             
            ```ruby
         | 
| 94 94 | 
             
            class ImageColumn < TableCloth::Column
         | 
| 95 | 
            -
              def value(object, view)
         | 
| 95 | 
            +
              def value(object, view, table)
         | 
| 96 96 | 
             
                view.raw(view.image_tag(object.image_url))
         | 
| 97 97 | 
             
              end
         | 
| 98 98 | 
             
            end
         | 
| @@ -107,6 +107,44 @@ In your table: | |
| 107 107 | 
             
            <% end %>
         | 
| 108 108 | 
             
            ```
         | 
| 109 109 |  | 
| 110 | 
            +
            ## Rows
         | 
| 111 | 
            +
             | 
| 112 | 
            +
            You can add HTML attributes to all rows by passing in a hash.
         | 
| 113 | 
            +
             | 
| 114 | 
            +
            ```ruby
         | 
| 115 | 
            +
            class UserTable < DefaultTable
         | 
| 116 | 
            +
              row_attributes class: "danger", name: "user-table-row"
         | 
| 117 | 
            +
             | 
| 118 | 
            +
              column :name
         | 
| 119 | 
            +
            end
         | 
| 120 | 
            +
            ```
         | 
| 121 | 
            +
            Which would render something like
         | 
| 122 | 
            +
             | 
| 123 | 
            +
            ```html
         | 
| 124 | 
            +
            <tr class="danger" name="user-table-row"><td>dangerous-john</td></tr>
         | 
| 125 | 
            +
            <tr class="danger" name="user-table-row"><td>totally-safe-bridgette</td></tr>
         | 
| 126 | 
            +
            ```
         | 
| 127 | 
            +
             | 
| 128 | 
            +
            Or you can generate attributes for each row by passing in a block that is evaluated each time a row is created. This block must return a hash of attributes.
         | 
| 129 | 
            +
             | 
| 130 | 
            +
            ```ruby
         | 
| 131 | 
            +
            class UserTable < DefaultTable
         | 
| 132 | 
            +
              row_attributes do |user|
         | 
| 133 | 
            +
                 css_class = user.is_dangerous? ? "danger" : ""
         | 
| 134 | 
            +
                {class: css_class, name: "#{user.name}-row"}
         | 
| 135 | 
            +
              end
         | 
| 136 | 
            +
             | 
| 137 | 
            +
              column :name
         | 
| 138 | 
            +
            end
         | 
| 139 | 
            +
            ```
         | 
| 140 | 
            +
             | 
| 141 | 
            +
            which would render something like
         | 
| 142 | 
            +
             | 
| 143 | 
            +
            ```html
         | 
| 144 | 
            +
            <tr class="danger" name="dangerous-john-row"><td>dangerous-john</td></tr>
         | 
| 145 | 
            +
            <tr class="" name="totally-safe-bridgette-row"><td>totally-safe-bridgette</td></tr>
         | 
| 146 | 
            +
            ```
         | 
| 147 | 
            +
             | 
| 110 148 | 
             
            ## Actions
         | 
| 111 149 |  | 
| 112 150 | 
             
            A lot of tables have an actions column to give you the full CRUD effect. They can be painful but Table Cloth incorporates a way to easily add them to your definition:
         | 
    
        data/lib/table_cloth.rb
    CHANGED
    
    | @@ -19,6 +19,7 @@ module TableCloth | |
| 19 19 |  | 
| 20 20 | 
             
              module Extensions
         | 
| 21 21 | 
             
                autoload :Actions, "table_cloth/extensions/actions"
         | 
| 22 | 
            +
                autoload :RowAttributes, "table_cloth/extensions/row_attributes"
         | 
| 22 23 | 
             
              end
         | 
| 23 24 |  | 
| 24 25 | 
             
              class << self
         | 
| @@ -33,4 +34,4 @@ TableCloth::Base.presenter(TableCloth::Presenters::Default) | |
| 33 34 |  | 
| 34 35 | 
             
            ActiveSupport.on_load(:action_view) do
         | 
| 35 36 | 
             
              include TableCloth::ActionViewExtension
         | 
| 36 | 
            -
            end
         | 
| 37 | 
            +
            end
         | 
    
        data/lib/table_cloth/base.rb
    CHANGED
    
    
| @@ -10,12 +10,12 @@ module TableCloth::Extensions::Actions | |
| 10 10 | 
             
                  @jury ||= Jury.new(self)
         | 
| 11 11 | 
             
                end
         | 
| 12 12 |  | 
| 13 | 
            -
                def value(object, view)
         | 
| 14 | 
            -
                  if jury.available?(object)
         | 
| 13 | 
            +
                def value(object, view, table)
         | 
| 14 | 
            +
                  if jury.available?(object, table)
         | 
| 15 15 | 
             
                    view.instance_exec(object, &options[:proc])
         | 
| 16 16 | 
             
                  else
         | 
| 17 17 | 
             
                    ""
         | 
| 18 18 | 
             
                  end
         | 
| 19 19 | 
             
                end
         | 
| 20 20 | 
             
              end
         | 
| 21 | 
            -
            end
         | 
| 21 | 
            +
            end
         | 
| @@ -2,7 +2,7 @@ module TableCloth::Extensions::Actions | |
| 2 2 | 
             
              class Column < ::TableCloth::Column
         | 
| 3 3 | 
             
                def value(object, view, table=nil)
         | 
| 4 4 | 
             
                  actions = action_collection.actions.map do |action|
         | 
| 5 | 
            -
                    action.value(object, view)
         | 
| 5 | 
            +
                    action.value(object, view, table)
         | 
| 6 6 | 
             
                  end
         | 
| 7 7 |  | 
| 8 8 | 
             
                  view.raw(actions.join(separator))
         | 
| @@ -18,4 +18,4 @@ module TableCloth::Extensions::Actions | |
| 18 18 | 
             
                  @action_collection ||= options[:collection]
         | 
| 19 19 | 
             
                end
         | 
| 20 20 | 
             
              end
         | 
| 21 | 
            -
            end
         | 
| 21 | 
            +
            end
         | 
| @@ -6,19 +6,19 @@ module TableCloth::Extensions::Actions | |
| 6 6 | 
             
                  @action = action
         | 
| 7 7 | 
             
                end
         | 
| 8 8 |  | 
| 9 | 
            -
                def available?(object)
         | 
| 9 | 
            +
                def available?(object, table)
         | 
| 10 10 | 
             
                  case action_if
         | 
| 11 11 | 
             
                  when Proc
         | 
| 12 12 | 
             
                    return !!action_if.call(object)
         | 
| 13 13 | 
             
                  when Symbol
         | 
| 14 | 
            -
                    return !! | 
| 14 | 
            +
                    return !!table.send(action_if)
         | 
| 15 15 | 
             
                  end
         | 
| 16 16 |  | 
| 17 17 | 
             
                  case action_unless
         | 
| 18 18 | 
             
                  when Proc
         | 
| 19 19 | 
             
                    return !action_unless.call(object)
         | 
| 20 20 | 
             
                  when Symbol
         | 
| 21 | 
            -
                    return ! | 
| 21 | 
            +
                    return !table.send(action_unless)
         | 
| 22 22 | 
             
                  end
         | 
| 23 23 |  | 
| 24 24 | 
             
                  return true
         | 
| @@ -34,4 +34,4 @@ module TableCloth::Extensions::Actions | |
| 34 34 | 
             
                  action.options[:unless]
         | 
| 35 35 | 
             
                end
         | 
| 36 36 | 
             
              end
         | 
| 37 | 
            -
            end
         | 
| 37 | 
            +
            end
         | 
| @@ -0,0 +1,36 @@ | |
| 1 | 
            +
            module TableCloth
         | 
| 2 | 
            +
              module Extensions
         | 
| 3 | 
            +
                module RowAttributes
         | 
| 4 | 
            +
             | 
| 5 | 
            +
                  extend ActiveSupport::Concern
         | 
| 6 | 
            +
             | 
| 7 | 
            +
                  module ClassMethods
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                    def row_attributes(*args, &block)
         | 
| 10 | 
            +
                      @tr_options ||= {}
         | 
| 11 | 
            +
                      options = args.extract_options! || {}
         | 
| 12 | 
            +
                      options[:proc] = block if block_given?
         | 
| 13 | 
            +
                      @tr_options = options
         | 
| 14 | 
            +
                    end
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                    def tr_options
         | 
| 17 | 
            +
                      @tr_options ||= {}
         | 
| 18 | 
            +
                      if superclass.respond_to? :tr_options
         | 
| 19 | 
            +
                        @tr_options = superclass.tr_options.merge(@tr_options)
         | 
| 20 | 
            +
                      end
         | 
| 21 | 
            +
                      @tr_options
         | 
| 22 | 
            +
                    end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                    def tr_options_for(object)
         | 
| 25 | 
            +
                      options = tr_options
         | 
| 26 | 
            +
                      if options.include?(:proc)
         | 
| 27 | 
            +
                        result = options[:proc].call(object) || {}
         | 
| 28 | 
            +
                        options.except(:proc).merge(result)
         | 
| 29 | 
            +
                      else
         | 
| 30 | 
            +
                        options
         | 
| 31 | 
            +
                      end
         | 
| 32 | 
            +
                    end
         | 
| 33 | 
            +
                  end
         | 
| 34 | 
            +
                end
         | 
| 35 | 
            +
              end
         | 
| 36 | 
            +
            end
         | 
| @@ -5,7 +5,7 @@ module TableCloth | |
| 5 5 | 
             
                    @render_table ||= ElementFactory::Element.new(:table, tag_options(:table)).tap do |table|
         | 
| 6 6 | 
             
                      table << thead
         | 
| 7 7 | 
             
                      table << tbody
         | 
| 8 | 
            -
                    end
         | 
| 8 | 
            +
                    end.to_html
         | 
| 9 9 | 
             
                  end
         | 
| 10 10 |  | 
| 11 11 | 
             
                  def thead
         | 
| @@ -33,7 +33,9 @@ module TableCloth | |
| 33 33 | 
             
                  end
         | 
| 34 34 |  | 
| 35 35 | 
             
                  def row_for_object(object)
         | 
| 36 | 
            -
                     | 
| 36 | 
            +
                    tr_options = table.class.tr_options_for(object)
         | 
| 37 | 
            +
             | 
| 38 | 
            +
                    ElementFactory::Element.new(:tr, tag_options(:tr).merge(tr_options)).tap do |row|
         | 
| 37 39 | 
             
                      columns.each do |column|
         | 
| 38 40 | 
             
                        row << column_for_object(column, object)
         | 
| 39 41 | 
             
                      end
         | 
| @@ -61,4 +63,4 @@ module TableCloth | |
| 61 63 | 
             
                  end
         | 
| 62 64 | 
             
                end
         | 
| 63 65 | 
             
              end
         | 
| 64 | 
            -
            end
         | 
| 66 | 
            +
            end
         | 
    
        data/lib/table_cloth/version.rb
    CHANGED
    
    
    
        data/spec/lib/base_spec.rb
    CHANGED
    
    | @@ -39,7 +39,7 @@ describe TableCloth::Base do | |
| 39 39 | 
             
                end
         | 
| 40 40 |  | 
| 41 41 | 
             
                context "custom" do
         | 
| 42 | 
            -
                  let(:custom_column) {  | 
| 42 | 
            +
                  let(:custom_column) { double(:custom, value: "AN EMAIL") }
         | 
| 43 43 |  | 
| 44 44 | 
             
                  it '.column can take a custom column' do
         | 
| 45 45 | 
             
                    subject.column :email, using: custom_column
         | 
| @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            require "spec_helper"
         | 
| 2 2 |  | 
| 3 3 | 
             
            describe TableCloth::ColumnJury do
         | 
| 4 | 
            -
              let(:dummy_table) {  | 
| 4 | 
            +
              let(:dummy_table) { double(:table, admin?: true, moderator?: false) }
         | 
| 5 5 |  | 
| 6 6 | 
             
              subject { TableCloth::ColumnJury.new(column, dummy_table) }
         | 
| 7 7 |  | 
| @@ -32,4 +32,4 @@ describe TableCloth::ColumnJury do | |
| 32 32 | 
             
                  end
         | 
| 33 33 | 
             
                end
         | 
| 34 34 | 
             
              end
         | 
| 35 | 
            -
            end
         | 
| 35 | 
            +
            end
         | 
| @@ -15,12 +15,13 @@ describe TableCloth::Extensions::Actions::Action do | |
| 15 15 | 
             
              context "#value" do
         | 
| 16 16 | 
             
                let(:model) { FactoryGirl.build(:dummy_model) }
         | 
| 17 17 | 
             
                let(:view_context) { ActionView::Base.new }
         | 
| 18 | 
            +
                let(:table) { TableCloth::Base.new(nil, nil) }
         | 
| 18 19 |  | 
| 19 20 | 
             
                context "string" do
         | 
| 20 21 | 
             
                  let(:action_hash) { {proc: Proc.new{ "something" }} }
         | 
| 21 22 |  | 
| 22 23 | 
             
                  it "returns a string" do
         | 
| 23 | 
            -
                    expect(subject.value(model, view_context)).to match /something/
         | 
| 24 | 
            +
                    expect(subject.value(model, view_context, table)).to match /something/
         | 
| 24 25 | 
             
                  end
         | 
| 25 26 | 
             
                end
         | 
| 26 27 |  | 
| @@ -30,8 +31,8 @@ describe TableCloth::Extensions::Actions::Action do | |
| 30 31 | 
             
                  end
         | 
| 31 32 |  | 
| 32 33 | 
             
                  it "returns a link" do
         | 
| 33 | 
            -
                    expect(subject.value(model, view_context)).to match /href="something"/
         | 
| 34 | 
            -
                    expect(subject.value(model, view_context)).to match />blank</
         | 
| 34 | 
            +
                    expect(subject.value(model, view_context, table)).to match /href="something"/
         | 
| 35 | 
            +
                    expect(subject.value(model, view_context, table)).to match />blank</
         | 
| 35 36 | 
             
                  end
         | 
| 36 37 | 
             
                end
         | 
| 37 38 |  | 
| @@ -45,13 +46,13 @@ describe TableCloth::Extensions::Actions::Action do | |
| 45 46 |  | 
| 46 47 | 
             
                  it "returns the link when the model condition succeeds" do
         | 
| 47 48 | 
             
                    model.stub admin?: true
         | 
| 48 | 
            -
                    expect(subject.value(model, view_context)).to include "something"
         | 
| 49 | 
            +
                    expect(subject.value(model, view_context, table)).to include "something"
         | 
| 49 50 | 
             
                  end
         | 
| 50 51 |  | 
| 51 52 | 
             
                  it "does not return the link when the model condition fails" do
         | 
| 52 53 | 
             
                    model.stub admin?: false
         | 
| 53 | 
            -
                    expect(subject.value(model, view_context)).not_to include "something"
         | 
| 54 | 
            +
                    expect(subject.value(model, view_context, table)).not_to include "something"
         | 
| 54 55 | 
             
                  end
         | 
| 55 56 | 
             
                end
         | 
| 56 57 | 
             
              end
         | 
| 57 | 
            -
            end
         | 
| 58 | 
            +
            end
         | 
| @@ -4,6 +4,7 @@ describe TableCloth::Extensions::Actions::Jury do | |
| 4 4 | 
             
              let(:action) { FactoryGirl.build(:action, options: action_options) }
         | 
| 5 5 | 
             
              subject { described_class.new(action) }
         | 
| 6 6 | 
             
              let(:model) { double("model") }
         | 
| 7 | 
            +
              let(:table) { TableCloth::Base.new(nil, nil) }
         | 
| 7 8 |  | 
| 8 9 | 
             
              context "Proc" do
         | 
| 9 10 | 
             
                context "if .available?" do
         | 
| @@ -11,12 +12,12 @@ describe TableCloth::Extensions::Actions::Jury do | |
| 11 12 |  | 
| 12 13 | 
             
                  it "returns true for valid models" do
         | 
| 13 14 | 
             
                    model.stub state: "valid"
         | 
| 14 | 
            -
                    expect(subject).to be_available(model)
         | 
| 15 | 
            +
                    expect(subject).to be_available(model, table)
         | 
| 15 16 | 
             
                  end
         | 
| 16 17 |  | 
| 17 18 | 
             
                  it "returns false for invalid models" do
         | 
| 18 19 | 
             
                    model.stub state: "invalid"
         | 
| 19 | 
            -
                    expect(subject).not_to be_available(model)
         | 
| 20 | 
            +
                    expect(subject).not_to be_available(model, table)
         | 
| 20 21 | 
             
                  end
         | 
| 21 22 | 
             
                end
         | 
| 22 23 |  | 
| @@ -25,12 +26,12 @@ describe TableCloth::Extensions::Actions::Jury do | |
| 25 26 |  | 
| 26 27 | 
             
                  it "returns true for valid models" do
         | 
| 27 28 | 
             
                    model.stub state: "valid"
         | 
| 28 | 
            -
                    expect(subject).to be_available(model)
         | 
| 29 | 
            +
                    expect(subject).to be_available(model, table)
         | 
| 29 30 | 
             
                  end
         | 
| 30 31 |  | 
| 31 32 | 
             
                  it "returns false for invalid models" do
         | 
| 32 33 | 
             
                    model.stub state: "invalid"
         | 
| 33 | 
            -
                    expect(subject).not_to be_available(model)
         | 
| 34 | 
            +
                    expect(subject).not_to be_available(model, table)
         | 
| 34 35 | 
             
                  end
         | 
| 35 36 | 
             
                end
         | 
| 36 37 | 
             
              end
         | 
| @@ -40,13 +41,13 @@ describe TableCloth::Extensions::Actions::Jury do | |
| 40 41 | 
             
                  let(:action_options) { {if: :valid?} }
         | 
| 41 42 |  | 
| 42 43 | 
             
                  it "returns true for valid?" do
         | 
| 43 | 
            -
                     | 
| 44 | 
            -
                    expect(subject).to be_available(model)
         | 
| 44 | 
            +
                    table.stub valid?: true
         | 
| 45 | 
            +
                    expect(subject).to be_available(model, table)
         | 
| 45 46 | 
             
                  end
         | 
| 46 47 |  | 
| 47 48 | 
             
                  it "returns true for valid?" do
         | 
| 48 | 
            -
                     | 
| 49 | 
            -
                    expect(subject).not_to be_available(model)
         | 
| 49 | 
            +
                    table.stub valid?: false
         | 
| 50 | 
            +
                    expect(subject).not_to be_available(model, table)
         | 
| 50 51 | 
             
                  end
         | 
| 51 52 | 
             
                end
         | 
| 52 53 |  | 
| @@ -54,14 +55,14 @@ describe TableCloth::Extensions::Actions::Jury do | |
| 54 55 | 
             
                  let(:action_options) { {unless: :valid?} }
         | 
| 55 56 |  | 
| 56 57 | 
             
                  it "returns true for valid models" do
         | 
| 57 | 
            -
                     | 
| 58 | 
            -
                    expect(subject).to be_available(model)
         | 
| 58 | 
            +
                    table.stub valid?: false
         | 
| 59 | 
            +
                    expect(subject).to be_available(model, table)
         | 
| 59 60 | 
             
                  end
         | 
| 60 61 |  | 
| 61 62 | 
             
                  it "returns false for invalid models" do
         | 
| 62 | 
            -
                     | 
| 63 | 
            -
                    expect(subject).not_to be_available(model)
         | 
| 63 | 
            +
                    table.stub valid?: true
         | 
| 64 | 
            +
                    expect(subject).not_to be_available(model, table)
         | 
| 64 65 | 
             
                  end
         | 
| 65 66 | 
             
                end
         | 
| 66 67 | 
             
              end
         | 
| 67 | 
            -
            end
         | 
| 68 | 
            +
            end
         | 
| @@ -51,6 +51,12 @@ describe TableCloth::Presenters::Default do | |
| 51 51 | 
             
                  expect(tbody.css('tr').size).to be 3
         | 
| 52 52 | 
             
                end
         | 
| 53 53 |  | 
| 54 | 
            +
                it "creates a row with attributes from row_attributes" do
         | 
| 55 | 
            +
                  tbody = Nokogiri::HTML(subject.tbody.to_s)
         | 
| 56 | 
            +
                  expect(tbody.css('tr:first-child').first.attribute("class").value).to eq("quazimodo-is-awesome")
         | 
| 57 | 
            +
                  expect(tbody.css('tr:first-child').first.attribute("name").value).to eq("What a handsome quazimodo")
         | 
| 58 | 
            +
                end
         | 
| 59 | 
            +
             | 
| 54 60 | 
             
                context 'escaped values' do
         | 
| 55 61 | 
             
                  let(:objects) do
         | 
| 56 62 | 
             
                    FactoryGirl.build_list(:dummy_model, 1,
         | 
| @@ -82,4 +88,4 @@ describe TableCloth::Presenters::Default do | |
| 82 88 | 
             
                  end
         | 
| 83 89 | 
             
                end
         | 
| 84 90 | 
             
              end
         | 
| 85 | 
            -
            end
         | 
| 91 | 
            +
            end
         | 
    
        data/spec/spec_helper.rb
    CHANGED
    
    | @@ -4,6 +4,7 @@ require 'nokogiri' | |
| 4 4 | 
             
            require 'factory_girl'
         | 
| 5 5 | 
             
            require 'pry'
         | 
| 6 6 | 
             
            require 'simplecov'
         | 
| 7 | 
            +
            require 'rspec/collection_matchers'
         | 
| 7 8 |  | 
| 8 9 | 
             
            if ENV["COVERAGE"] == "true"
         | 
| 9 10 | 
             
              SimpleCov.start do
         | 
| @@ -22,4 +23,4 @@ RSpec.configure do |config| | |
| 22 23 | 
             
              config.run_all_when_everything_filtered = true
         | 
| 23 24 | 
             
              config.filter_run :focus
         | 
| 24 25 | 
             
              config.include ElementHelpers
         | 
| 25 | 
            -
            end
         | 
| 26 | 
            +
            end
         | 
    
        data/spec/support/dummy_table.rb
    CHANGED
    
    | @@ -1,4 +1,7 @@ | |
| 1 1 | 
             
            class DummyTable < TableCloth::Base
         | 
| 2 | 
            +
              row_attributes name: "What a handsome quazimodo" do |obj|
         | 
| 3 | 
            +
                {class: "quazimodo-is-awesome"} if obj.present?
         | 
| 4 | 
            +
              end
         | 
| 2 5 | 
             
              column :id, th_options: {class: "th_options_class"}
         | 
| 3 6 | 
             
              column :name
         | 
| 4 7 | 
             
              column :email
         | 
| @@ -7,5 +10,5 @@ end | |
| 7 10 | 
             
            class DummyTableUnlessAdmin < TableCloth::Base
         | 
| 8 11 | 
             
              column :id, unless: :admin?
         | 
| 9 12 | 
             
              column :name
         | 
| 10 | 
            -
              column :email | 
| 11 | 
            -
            end
         | 
| 13 | 
            +
              column :email
         | 
| 14 | 
            +
            end
         | 
    
        data/table_cloth.gemspec
    CHANGED
    
    | @@ -17,7 +17,8 @@ Gem::Specification.new do |gem| | |
| 17 17 | 
             
              gem.test_files    = gem.files.grep(%r{^(test|spec|features)/})
         | 
| 18 18 | 
             
              gem.require_paths = ["lib"]
         | 
| 19 19 |  | 
| 20 | 
            -
              gem.add_development_dependency('rspec', '~> 2. | 
| 20 | 
            +
              gem.add_development_dependency('rspec', '~> 2.99.0')
         | 
| 21 | 
            +
              gem.add_development_dependency('rspec-collection_matchers')
         | 
| 21 22 | 
             
              gem.add_development_dependency('simplecov')
         | 
| 22 23 | 
             
              gem.add_development_dependency('awesome_print')
         | 
| 23 24 | 
             
              gem.add_development_dependency('nokogiri')
         | 
| @@ -27,6 +28,6 @@ Gem::Specification.new do |gem| | |
| 27 28 | 
             
              gem.add_development_dependency('rake')
         | 
| 28 29 | 
             
              gem.add_development_dependency('rb-fsevent', '~> 0.9.4')
         | 
| 29 30 |  | 
| 30 | 
            -
              gem.add_dependency('actionpack', '>= 3.1', '<  | 
| 31 | 
            -
              gem.add_dependency('element_factory', '~> 0.1. | 
| 31 | 
            +
              gem.add_dependency('actionpack', '>= 3.1', '< 5.0')
         | 
| 32 | 
            +
              gem.add_dependency('element_factory', '~> 0.1.3')
         | 
| 32 33 | 
             
            end
         | 
    
        metadata
    CHANGED
    
    | @@ -1,175 +1,189 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: table_cloth
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 0.4. | 
| 4 | 
            +
              version: 0.4.3
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Robert Ross
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2014- | 
| 11 | 
            +
            date: 2014-12-30 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: rspec
         | 
| 15 15 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 16 16 | 
             
                requirements:
         | 
| 17 | 
            -
                - - ~>
         | 
| 17 | 
            +
                - - "~>"
         | 
| 18 18 | 
             
                  - !ruby/object:Gem::Version
         | 
| 19 | 
            -
                    version:  | 
| 19 | 
            +
                    version: 2.99.0
         | 
| 20 20 | 
             
              type: :development
         | 
| 21 21 | 
             
              prerelease: false
         | 
| 22 22 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 23 23 | 
             
                requirements:
         | 
| 24 | 
            -
                - - ~>
         | 
| 24 | 
            +
                - - "~>"
         | 
| 25 25 | 
             
                  - !ruby/object:Gem::Version
         | 
| 26 | 
            -
                    version:  | 
| 26 | 
            +
                    version: 2.99.0
         | 
| 27 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 28 | 
            +
              name: rspec-collection_matchers
         | 
| 29 | 
            +
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 | 
            +
                requirements:
         | 
| 31 | 
            +
                - - ">="
         | 
| 32 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 33 | 
            +
                    version: '0'
         | 
| 34 | 
            +
              type: :development
         | 
| 35 | 
            +
              prerelease: false
         | 
| 36 | 
            +
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 | 
            +
                requirements:
         | 
| 38 | 
            +
                - - ">="
         | 
| 39 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 40 | 
            +
                    version: '0'
         | 
| 27 41 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 28 42 | 
             
              name: simplecov
         | 
| 29 43 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 30 44 | 
             
                requirements:
         | 
| 31 | 
            -
                - -  | 
| 45 | 
            +
                - - ">="
         | 
| 32 46 | 
             
                  - !ruby/object:Gem::Version
         | 
| 33 47 | 
             
                    version: '0'
         | 
| 34 48 | 
             
              type: :development
         | 
| 35 49 | 
             
              prerelease: false
         | 
| 36 50 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 37 51 | 
             
                requirements:
         | 
| 38 | 
            -
                - -  | 
| 52 | 
            +
                - - ">="
         | 
| 39 53 | 
             
                  - !ruby/object:Gem::Version
         | 
| 40 54 | 
             
                    version: '0'
         | 
| 41 55 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 42 56 | 
             
              name: awesome_print
         | 
| 43 57 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 44 58 | 
             
                requirements:
         | 
| 45 | 
            -
                - -  | 
| 59 | 
            +
                - - ">="
         | 
| 46 60 | 
             
                  - !ruby/object:Gem::Version
         | 
| 47 61 | 
             
                    version: '0'
         | 
| 48 62 | 
             
              type: :development
         | 
| 49 63 | 
             
              prerelease: false
         | 
| 50 64 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 51 65 | 
             
                requirements:
         | 
| 52 | 
            -
                - -  | 
| 66 | 
            +
                - - ">="
         | 
| 53 67 | 
             
                  - !ruby/object:Gem::Version
         | 
| 54 68 | 
             
                    version: '0'
         | 
| 55 69 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 56 70 | 
             
              name: nokogiri
         | 
| 57 71 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 58 72 | 
             
                requirements:
         | 
| 59 | 
            -
                - -  | 
| 73 | 
            +
                - - ">="
         | 
| 60 74 | 
             
                  - !ruby/object:Gem::Version
         | 
| 61 75 | 
             
                    version: '0'
         | 
| 62 76 | 
             
              type: :development
         | 
| 63 77 | 
             
              prerelease: false
         | 
| 64 78 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 65 79 | 
             
                requirements:
         | 
| 66 | 
            -
                - -  | 
| 80 | 
            +
                - - ">="
         | 
| 67 81 | 
             
                  - !ruby/object:Gem::Version
         | 
| 68 82 | 
             
                    version: '0'
         | 
| 69 83 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 70 84 | 
             
              name: pry
         | 
| 71 85 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 72 86 | 
             
                requirements:
         | 
| 73 | 
            -
                - -  | 
| 87 | 
            +
                - - ">="
         | 
| 74 88 | 
             
                  - !ruby/object:Gem::Version
         | 
| 75 89 | 
             
                    version: '0'
         | 
| 76 90 | 
             
              type: :development
         | 
| 77 91 | 
             
              prerelease: false
         | 
| 78 92 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 79 93 | 
             
                requirements:
         | 
| 80 | 
            -
                - -  | 
| 94 | 
            +
                - - ">="
         | 
| 81 95 | 
             
                  - !ruby/object:Gem::Version
         | 
| 82 96 | 
             
                    version: '0'
         | 
| 83 97 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 84 98 | 
             
              name: factory_girl
         | 
| 85 99 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 86 100 | 
             
                requirements:
         | 
| 87 | 
            -
                - -  | 
| 101 | 
            +
                - - ">="
         | 
| 88 102 | 
             
                  - !ruby/object:Gem::Version
         | 
| 89 103 | 
             
                    version: '0'
         | 
| 90 104 | 
             
              type: :development
         | 
| 91 105 | 
             
              prerelease: false
         | 
| 92 106 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 93 107 | 
             
                requirements:
         | 
| 94 | 
            -
                - -  | 
| 108 | 
            +
                - - ">="
         | 
| 95 109 | 
             
                  - !ruby/object:Gem::Version
         | 
| 96 110 | 
             
                    version: '0'
         | 
| 97 111 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 98 112 | 
             
              name: guard-rspec
         | 
| 99 113 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 100 114 | 
             
                requirements:
         | 
| 101 | 
            -
                - -  | 
| 115 | 
            +
                - - ">="
         | 
| 102 116 | 
             
                  - !ruby/object:Gem::Version
         | 
| 103 117 | 
             
                    version: '0'
         | 
| 104 118 | 
             
              type: :development
         | 
| 105 119 | 
             
              prerelease: false
         | 
| 106 120 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 107 121 | 
             
                requirements:
         | 
| 108 | 
            -
                - -  | 
| 122 | 
            +
                - - ">="
         | 
| 109 123 | 
             
                  - !ruby/object:Gem::Version
         | 
| 110 124 | 
             
                    version: '0'
         | 
| 111 125 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 112 126 | 
             
              name: rake
         | 
| 113 127 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 114 128 | 
             
                requirements:
         | 
| 115 | 
            -
                - -  | 
| 129 | 
            +
                - - ">="
         | 
| 116 130 | 
             
                  - !ruby/object:Gem::Version
         | 
| 117 131 | 
             
                    version: '0'
         | 
| 118 132 | 
             
              type: :development
         | 
| 119 133 | 
             
              prerelease: false
         | 
| 120 134 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 121 135 | 
             
                requirements:
         | 
| 122 | 
            -
                - -  | 
| 136 | 
            +
                - - ">="
         | 
| 123 137 | 
             
                  - !ruby/object:Gem::Version
         | 
| 124 138 | 
             
                    version: '0'
         | 
| 125 139 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 126 140 | 
             
              name: rb-fsevent
         | 
| 127 141 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 128 142 | 
             
                requirements:
         | 
| 129 | 
            -
                - - ~>
         | 
| 143 | 
            +
                - - "~>"
         | 
| 130 144 | 
             
                  - !ruby/object:Gem::Version
         | 
| 131 145 | 
             
                    version: 0.9.4
         | 
| 132 146 | 
             
              type: :development
         | 
| 133 147 | 
             
              prerelease: false
         | 
| 134 148 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 135 149 | 
             
                requirements:
         | 
| 136 | 
            -
                - - ~>
         | 
| 150 | 
            +
                - - "~>"
         | 
| 137 151 | 
             
                  - !ruby/object:Gem::Version
         | 
| 138 152 | 
             
                    version: 0.9.4
         | 
| 139 153 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 140 154 | 
             
              name: actionpack
         | 
| 141 155 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 142 156 | 
             
                requirements:
         | 
| 143 | 
            -
                - -  | 
| 157 | 
            +
                - - ">="
         | 
| 144 158 | 
             
                  - !ruby/object:Gem::Version
         | 
| 145 159 | 
             
                    version: '3.1'
         | 
| 146 | 
            -
                - - <
         | 
| 160 | 
            +
                - - "<"
         | 
| 147 161 | 
             
                  - !ruby/object:Gem::Version
         | 
| 148 | 
            -
                    version: ' | 
| 162 | 
            +
                    version: '5.0'
         | 
| 149 163 | 
             
              type: :runtime
         | 
| 150 164 | 
             
              prerelease: false
         | 
| 151 165 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 152 166 | 
             
                requirements:
         | 
| 153 | 
            -
                - -  | 
| 167 | 
            +
                - - ">="
         | 
| 154 168 | 
             
                  - !ruby/object:Gem::Version
         | 
| 155 169 | 
             
                    version: '3.1'
         | 
| 156 | 
            -
                - - <
         | 
| 170 | 
            +
                - - "<"
         | 
| 157 171 | 
             
                  - !ruby/object:Gem::Version
         | 
| 158 | 
            -
                    version: ' | 
| 172 | 
            +
                    version: '5.0'
         | 
| 159 173 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 160 174 | 
             
              name: element_factory
         | 
| 161 175 | 
             
              requirement: !ruby/object:Gem::Requirement
         | 
| 162 176 | 
             
                requirements:
         | 
| 163 | 
            -
                - - ~>
         | 
| 177 | 
            +
                - - "~>"
         | 
| 164 178 | 
             
                  - !ruby/object:Gem::Version
         | 
| 165 | 
            -
                    version: 0.1. | 
| 179 | 
            +
                    version: 0.1.3
         | 
| 166 180 | 
             
              type: :runtime
         | 
| 167 181 | 
             
              prerelease: false
         | 
| 168 182 | 
             
              version_requirements: !ruby/object:Gem::Requirement
         | 
| 169 183 | 
             
                requirements:
         | 
| 170 | 
            -
                - - ~>
         | 
| 184 | 
            +
                - - "~>"
         | 
| 171 185 | 
             
                  - !ruby/object:Gem::Version
         | 
| 172 | 
            -
                    version: 0.1. | 
| 186 | 
            +
                    version: 0.1.3
         | 
| 173 187 | 
             
            description: Table Cloth helps you create tables easily.
         | 
| 174 188 | 
             
            email:
         | 
| 175 189 | 
             
            - robert@creativequeries.com
         | 
| @@ -177,9 +191,9 @@ executables: [] | |
| 177 191 | 
             
            extensions: []
         | 
| 178 192 | 
             
            extra_rdoc_files: []
         | 
| 179 193 | 
             
            files:
         | 
| 180 | 
            -
            - .gitignore
         | 
| 181 | 
            -
            - .rspec
         | 
| 182 | 
            -
            - .travis.yml
         | 
| 194 | 
            +
            - ".gitignore"
         | 
| 195 | 
            +
            - ".rspec"
         | 
| 196 | 
            +
            - ".travis.yml"
         | 
| 183 197 | 
             
            - CHANGELOG
         | 
| 184 198 | 
             
            - Gemfile
         | 
| 185 199 | 
             
            - Guardfile
         | 
| @@ -200,6 +214,7 @@ files: | |
| 200 214 | 
             
            - lib/table_cloth/extensions/actions/action_collection.rb
         | 
| 201 215 | 
             
            - lib/table_cloth/extensions/actions/column.rb
         | 
| 202 216 | 
             
            - lib/table_cloth/extensions/actions/jury.rb
         | 
| 217 | 
            +
            - lib/table_cloth/extensions/row_attributes.rb
         | 
| 203 218 | 
             
            - lib/table_cloth/presenter.rb
         | 
| 204 219 | 
             
            - lib/table_cloth/presenters/default.rb
         | 
| 205 220 | 
             
            - lib/table_cloth/version.rb
         | 
| @@ -239,12 +254,12 @@ require_paths: | |
| 239 254 | 
             
            - lib
         | 
| 240 255 | 
             
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 241 256 | 
             
              requirements:
         | 
| 242 | 
            -
              - -  | 
| 257 | 
            +
              - - ">="
         | 
| 243 258 | 
             
                - !ruby/object:Gem::Version
         | 
| 244 259 | 
             
                  version: '0'
         | 
| 245 260 | 
             
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 246 261 | 
             
              requirements:
         | 
| 247 | 
            -
              - -  | 
| 262 | 
            +
              - - ">="
         | 
| 248 263 | 
             
                - !ruby/object:Gem::Version
         | 
| 249 264 | 
             
                  version: '0'
         | 
| 250 265 | 
             
            requirements: []
         |