tableficate 0.3.0 → 0.3.1

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.markdown CHANGED
@@ -13,20 +13,28 @@ If you're using Bundler, add this to your Gemfile:
13
13
 
14
14
  ## Support
15
15
 
16
- ### Ruby
17
- 1.9+
18
-
19
- ### Rails
20
- 3.1+
21
-
22
- ### Templating
23
- Any templating engine can be used. The default theme uses ERB.
24
-
25
- ### Database Framework
26
- ActiveRecord
27
-
28
- ### Pagination
29
- Any pagination can be used. The default theme has built-in support for Kaminari and will_paginate.
16
+ <table>
17
+ <tr>
18
+ <td><strong>Ruby</strong></td>
19
+ <td>1.9</td>
20
+ </tr>
21
+ <tr>
22
+ <td><strong>Rails</strong></td>
23
+ <td>3.1</td>
24
+ </tr>
25
+ <tr>
26
+ <td><strong>Database Framework</strong></td>
27
+ <td>ActiveRecord</td>
28
+ </tr>
29
+ <tr>
30
+ <td><strong>Templating</strong></td>
31
+ <td>Any templating engine can be used. The default theme uses ERB.</td>
32
+ </tr>
33
+ <tr>
34
+ <td><strong>Pagination</strong></td>
35
+ <td>Any pagination can be used. The default theme has built-in support for Kaminari and will_paginate.</td>
36
+ </tr>
37
+ </table>
30
38
 
31
39
  ## Basic Usage
32
40
  Let's say that we want to create a table that lists active accounts in the system with their time of creation and the name on the account.
@@ -118,6 +126,8 @@ The theme can then be applied to a table.
118
126
  <%= table_for @records, theme: 'foo' do |t| %>
119
127
  ...
120
128
  <% end %>
129
+
130
+ [Find out more about themes.](https://github.com/sei-mi/tableficate/wiki/Custom-Themes)
121
131
 
122
132
  ## Changes Needed to Upgrade From 0.2
123
133
 
data/changelog.markdown CHANGED
@@ -1,3 +1,6 @@
1
+ ## 0.3.1
2
+ * converting scope to an array through functions like `all` no longer breaks
3
+
1
4
  ## 0.3.0
2
5
  * tables no longer take the :html option, all non-recognized options are passed through as HTML attributes
3
6
  * The `options` attribute on a variety of objects has been removed. It has been replaced with specialized functions such as `label_options` and `collection` with all unrecognized options placed into the `attrs` attribute.
@@ -1,18 +1,23 @@
1
1
  module Tableficate
2
2
  module ActiveRecordExtension
3
+ module Functions
4
+ attr_accessor :tableficate_data
5
+ end
6
+
3
7
  extend ActiveSupport::Concern
4
8
 
5
9
  included do
6
10
  extend Tableficate::Finder
7
11
 
8
12
  self.scope :tableficate_ext, ->{} do
9
- def tableficate_add_data(key, value)
10
- @tableficate_data ||= {}
11
- @tableficate_data[key] = value
12
- end
13
+ include Functions
14
+
15
+ def to_a
16
+ a = super.extend(Functions)
17
+
18
+ a.tableficate_data = self.tableficate_data
13
19
 
14
- def tableficate_get_data
15
- @tableficate_data || {}
20
+ a
16
21
  end
17
22
  end
18
23
  end
@@ -92,9 +92,10 @@ module Tableficate
92
92
  sorting[:column] = column.to_sym
93
93
  sorting[:dir] = ['asc', 'desc'].include?(dir) ? dir : 'asc'
94
94
  end
95
- scope.tableficate_add_data(:current_sort, sorting)
95
+ scope.tableficate_data = {}
96
+ scope.tableficate_data[:current_sort] = sorting
96
97
  filters_with_field = @filter ? @filter.select{|name, options| not options.is_a?(Proc) and options and options.has_key?(:field)} : {}
97
- scope.tableficate_add_data(:field_map, Hash[filters_with_field.map{|name, options| [name, options[:field]]}])
98
+ scope.tableficate_data[:field_map] = Hash[filters_with_field.map{|name, options| [name, options[:field]]}]
98
99
  scope
99
100
  end
100
101
 
@@ -1,7 +1,7 @@
1
1
  module Tableficate
2
2
  module Helper
3
3
  def table_for(rows, options = {})
4
- t = Tableficate::Table.new(self, rows, options, rows.tableficate_get_data)
4
+ t = Tableficate::Table.new(self, rows, options, rows.tableficate_data)
5
5
  yield(t)
6
6
  t.template.render(partial: Tableficate::Utils::template_path(t.template, 'table_for', t.theme), locals: {table: t})
7
7
  end
@@ -1,3 +1,3 @@
1
1
  module Tableficate
2
- VERSION = '0.3.0'
2
+ VERSION = '0.3.1'
3
3
  end
@@ -3,7 +3,26 @@ require 'spec_helper'
3
3
  describe 'Tableficate::ActiveRecordExtention' do
4
4
  it 'should add and retreive data from the scope' do
5
5
  scope = NobelPrizeWinner.tableficate_ext
6
- scope.tableficate_add_data(:name, 'Aaron')
7
- scope.tableficate_get_data.should == {name: 'Aaron'}
6
+ scope.tableficate_data = {}
7
+ scope.tableficate_data[:name] = 'Aaron'
8
+ scope.tableficate_data.should == {name: 'Aaron'}
9
+ end
10
+
11
+ it 'maintains functionality if converted to an array' do
12
+ scope = NobelPrizeWinner.tableficate_ext.to_a
13
+ scope.tableficate_data = {}
14
+ scope.tableficate_data[:name] = 'Aaron'
15
+ scope.tableficate_data.should == {name: 'Aaron'}
16
+
17
+ class NobelPrizeWinnerWithDefaultSorting < Tableficate::Base
18
+ scope :nobel_prize_winner
19
+
20
+ default_sort(:first_name)
21
+ end
22
+ scope = NobelPrizeWinnerWithDefaultSorting.tableficate({}).all
23
+ scope.tableficate_data[:current_sort].should == {column: :first_name, dir: 'asc'}
24
+
25
+ scope = NobelPrizeWinnerWithDefaultSorting.tableficate({}).find(1,2)
26
+ scope.tableficate_data[:current_sort].should == {column: :first_name, dir: 'asc'}
8
27
  end
9
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tableficate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-01-02 00:00:00.000000000Z
12
+ date: 2012-01-06 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70355461259820 !ruby/object:Gem::Requirement
16
+ requirement: &70275949519680 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.1'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70355461259820
24
+ version_requirements: *70275949519680
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &70355461255640 !ruby/object:Gem::Requirement
27
+ requirement: &70275949517100 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70355461255640
35
+ version_requirements: *70275949517100
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70355461255140 !ruby/object:Gem::Requirement
38
+ requirement: &70275949515400 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70355461255140
46
+ version_requirements: *70275949515400
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: genspec
49
- requirement: &70355461254700 !ruby/object:Gem::Requirement
49
+ requirement: &70275949511500 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70355461254700
57
+ version_requirements: *70275949511500
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: sqlite3
60
- requirement: &70355461254200 !ruby/object:Gem::Requirement
60
+ requirement: &70275949510000 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70355461254200
68
+ version_requirements: *70275949510000
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: capybara
71
- requirement: &70355461253760 !ruby/object:Gem::Requirement
71
+ requirement: &70275949508160 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70355461253760
79
+ version_requirements: *70275949508160
80
80
  description: A DSL for Rails that provides easy table creation with sorting and filtering.
81
81
  email:
82
82
  - alasseigne@sei-mi.com
@@ -239,7 +239,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
239
239
  version: '0'
240
240
  segments:
241
241
  - 0
242
- hash: -3947316157518683488
242
+ hash: -3271381889509859658
243
243
  required_rubygems_version: !ruby/object:Gem::Requirement
244
244
  none: false
245
245
  requirements:
@@ -248,7 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
248
248
  version: '0'
249
249
  segments:
250
250
  - 0
251
- hash: -3947316157518683488
251
+ hash: -3271381889509859658
252
252
  requirements: []
253
253
  rubyforge_project: tableficate
254
254
  rubygems_version: 1.8.6