table_setter 0.1.11 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +3 -3
- data/documentation/index.html.erb +35 -31
- data/index.html +35 -31
- data/lib/table_setter/app.rb +7 -7
- data/spec/spec_helper.rb +1 -1
- data/spec/table-setter-app_spec.rb +6 -6
- data/spec/table-setter_spec.rb +33 -33
- data/table_setter.gemspec +2 -2
- data/template/views/index.erb +1 -1
- data/template/views/table.erb +2 -2
- metadata +5 -5
data/VERSION.yml
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
</head>
|
9
9
|
<body>
|
10
10
|
<a href="http://www.propublica.org" class="propublica"> </a>
|
11
|
-
<h1>TableSetter <small>– Version: <%=
|
11
|
+
<h1>TableSetter <small>– Version: <%=
|
12
12
|
config = YAML.load(File.read('VERSION.yml'))
|
13
13
|
"#{config[:major]}.#{config[:minor]}.#{config[:patch]}"
|
14
14
|
%></small></h1>
|
@@ -40,7 +40,7 @@ rake install</pre>
|
|
40
40
|
<pre>
|
41
41
|
table-setter install path/to/directory</pre>
|
42
42
|
<p>
|
43
|
-
To start the development server run:
|
43
|
+
To start the development server run:
|
44
44
|
</p>
|
45
45
|
<pre>
|
46
46
|
table-setter start path/to/directory</pre>
|
@@ -106,48 +106,48 @@ Potter Savings and Loans,1100,1000000,http://angelsandwingsmrstewart.com
|
|
106
106
|
<pre>
|
107
107
|
table:
|
108
108
|
title: The title of the table
|
109
|
-
|
109
|
+
|
110
110
|
# google_key:, file:, or url: define how a table is loaded.
|
111
111
|
# only one is necessary
|
112
|
-
file: loads a local CSV file from the /tables directory.
|
113
|
-
url: will load a CSV file from an external server, and
|
112
|
+
file: loads a local CSV file from the /tables directory.
|
113
|
+
url: will load a CSV file from an external server, and
|
114
114
|
google_key: is a google key url from an external google doc (see note).
|
115
|
-
|
115
|
+
|
116
116
|
deck: A HTML string describing the table, appears above the table itself.
|
117
|
-
|
117
|
+
|
118
118
|
footer: A HTML string for notes/caveats etc. Appears below the table.
|
119
|
-
|
119
|
+
|
120
120
|
column_options: # Defines a hash of options that are passed onto TableFu
|
121
|
-
|
121
|
+
|
122
122
|
columns: # A list of columns to include, for example:
|
123
123
|
- Bank # would only include the bank column in the table
|
124
|
-
|
124
|
+
|
125
125
|
style: # A list of style declarations by column, for example:
|
126
126
|
Bank: 'text-align:left;' # would left-align the text in the "Bank" column.
|
127
|
-
|
127
|
+
|
128
128
|
sorted_by: # Defines the sort order and column to sort by of the table.
|
129
129
|
Bank: ascending # would sort by the Bank column in ascending order
|
130
|
-
|
130
|
+
|
131
131
|
total: # Declares which columns should have a totals row.
|
132
132
|
['Funds', 'Spent']
|
133
|
-
|
133
|
+
|
134
134
|
formatting: # Defines which of the TableFu formatters to apply to a column.
|
135
135
|
(%) Spent: bar # applies the bar formatter to the '(%) Spent' column.
|
136
|
-
Link: # Creates a meta column form two other columns
|
136
|
+
Link: # Creates a meta column form two other columns
|
137
137
|
method: link # describes the formatter to use
|
138
138
|
arguments: ['Bank', 'URL'] # Combines Bank and URL as arguments
|
139
|
-
|
139
|
+
|
140
140
|
faceting: # Describes the faceting, or grouping, to apply to a table
|
141
141
|
facet_by: Bank # groups the records by bank name
|
142
|
-
|
142
|
+
|
143
143
|
hard_paginate: true # Dictates that the table should be spread across multiple pages
|
144
144
|
# can't be used with faceting, and disables the user filtering
|
145
|
-
|
145
|
+
|
146
146
|
per_page: 250 # Instructs TableSetter to only page by 250 rows.
|
147
|
-
|
148
|
-
live: true # publishes the table in the index page. Note that even if live is
|
149
|
-
# set to false the table is still accessible directly.
|
150
|
-
|
147
|
+
|
148
|
+
live: true # publishes the table in the index page. Note that even if live is
|
149
|
+
# set to false the table is still accessible directly.
|
150
|
+
|
151
151
|
</pre>
|
152
152
|
|
153
153
|
<h3>NB: A Note About google_key</h3>
|
@@ -184,7 +184,7 @@ ln -s /path/to/table-setter/public /docroot/tables</pre>
|
|
184
184
|
<pre>
|
185
185
|
TableSetter::App.cache_timeout = 60 * 15 # 15 minutes</pre>
|
186
186
|
<p>That line dictates the max age of a request and you'll want to tweak it depending on how frequently changed your tables will be and how many users you expect. If you want to define any <a href="https://github.com/propublica/table-fu">TableFu</a> formatters you should do so in <strong>config.ru</strong>.</p>
|
187
|
-
|
187
|
+
|
188
188
|
<h3>Static</h3>
|
189
189
|
<p>You can also use to pre-build <strong>table-setter</strong> your tables as html and upload the built files to your web server. You can build them using the <strong>table-setter</strong> command:</p>
|
190
190
|
<pre>
|
@@ -219,27 +219,31 @@ script/generate table-setter</pre>
|
|
219
219
|
<li>
|
220
220
|
<a href="http://media.apps.chicagotribune.com/tables/speed.html">In the Wild: Chicago Tribune</a><br>
|
221
221
|
A table showing leniency rates of Chicago area judges in speeding cases.
|
222
|
-
|
222
|
+
|
223
223
|
</li>
|
224
224
|
</ul>
|
225
225
|
<h2><a id="credits" href="#toc">Credits</a></h2>
|
226
226
|
<p><a href="http://github.com/thejefflarson">Jeff Larson</a> (Maintainer), <a href="http://github.com/brianboyer/">Brian Boyer</a>, <a href="http://github.com/kleinmatic">Scott Klein</a>, <a href="http://github.com/markpercival">Mark Percival</a>, <a href="http://github.com/seebq">Charles Brian Quinn</a>, <a href="http://github.com/bouvard">Christopher Groskopf</a>, and <a href="http://github.com/ryanmark">Ryan Mark</a>.</p>
|
227
227
|
<h2><a id="changes" href="#toc">Change Log</a></h2>
|
228
|
-
<strong>
|
228
|
+
<strong>0.2.0</strong>
|
229
|
+
<p><b>Backwards incompatible change:</b> Table urls no longer end in a trailing slash. Please the <strong>url_for</strong> calls in your templates to reflect the change.</p>
|
230
|
+
<strong>0.1.11</strong>
|
231
|
+
<p>Javascript Fixes. <b>Note:</b> You'll need to delete the javascript's folder in the config directory and run <strong>table-setter install</strong> to grab the changes.</p>
|
232
|
+
<strong>0.1.10</strong>
|
229
233
|
<p>New formatters via <a href="http://github.com/ryanmark">Ryan Mark</a>.
|
230
|
-
<strong>1.9</strong>
|
234
|
+
<strong>0.1.9</strong>
|
231
235
|
<p>No Op.</p>
|
232
|
-
<strong>1.8</strong>
|
236
|
+
<strong>0.1.8</strong>
|
233
237
|
<p>Bunch of fixes from <a href="http://github.com/ryanmark">Ryan Mark</a>, and beta markdown functionality. Once Markdown is tested we'll release 0.2.0</p>
|
234
|
-
<strong>1.7</strong>
|
238
|
+
<strong>0.1.7</strong>
|
235
239
|
<p>Bugfix to the build command to place assets in the right place</p>
|
236
|
-
<strong>1.6</strong>
|
240
|
+
<strong>0.1.6</strong>
|
237
241
|
<p>Fix in <strong>build_assets</strong> in command.rb, via <a href="http://github.com/propublica/table-setter/commit/2dd207d57eda4d78520b8a5fa99e6e085952206a">Christopher Groskopf</a></p>
|
238
|
-
<strong>1.5</strong>
|
242
|
+
<strong>0.1.5</strong>
|
239
243
|
<p>Bugfixes.</p>
|
240
|
-
<strong>1.4</strong>
|
244
|
+
<strong>0.1.4</strong>
|
241
245
|
<p>Javascript fixes and thin added as a dependency.</p>
|
242
|
-
<strong>1.3</strong>
|
246
|
+
<strong>0.1.3</strong>
|
243
247
|
<p>Initial release.</p>
|
244
248
|
<h2><a id="license" href="#toc">License</a></h2>
|
245
249
|
<pre><%= File.open("LICENSE").read %></pre>
|
data/index.html
CHANGED
@@ -8,7 +8,7 @@
|
|
8
8
|
</head>
|
9
9
|
<body>
|
10
10
|
<a href="http://www.propublica.org" class="propublica"> </a>
|
11
|
-
<h1>TableSetter <small>– Version: 0.
|
11
|
+
<h1>TableSetter <small>– Version: 0.2.0</small></h1>
|
12
12
|
<p><a href="https://github.com/propublica/table-setter">TableSetter</a> is a Ruby app that provides an easy way to present CSVs hosted locally or remotely (e.g. on google, etc) in custom HTML. TableSetter in the wild: <a href="http://projects.propublica.org/tables/failed-banks">a list of all stimulus projects from last year</a>, <a href="http://projects.propublica.org/tables/stimulus-spending-progress">the stimulus spending progress</a>, or <a href="http://projects.propublica.org/tables/failed-banks">a list of failed banks due to the last recession</a>.</p>
|
13
13
|
<p>Each table is filterable and sortable on multiple columns. Also each column can be formatted in one of many different styles. In production mode, <strong>TableSetter</strong> provides valid expires headers and can be coupled with an upstream cache like <a href="http://rtomayko.github.com/rack-cache/">Rack::Cache</a> or varnish for speedy presentation.</p>
|
14
14
|
<h2><a id="toc">Table of Contents</a></h2>
|
@@ -37,7 +37,7 @@ rake install</pre>
|
|
37
37
|
<pre>
|
38
38
|
table-setter install path/to/directory</pre>
|
39
39
|
<p>
|
40
|
-
To start the development server run:
|
40
|
+
To start the development server run:
|
41
41
|
</p>
|
42
42
|
<pre>
|
43
43
|
table-setter start path/to/directory</pre>
|
@@ -103,48 +103,48 @@ Potter Savings and Loans,1100,1000000,http://angelsandwingsmrstewart.com
|
|
103
103
|
<pre>
|
104
104
|
table:
|
105
105
|
title: The title of the table
|
106
|
-
|
106
|
+
|
107
107
|
# google_key:, file:, or url: define how a table is loaded.
|
108
108
|
# only one is necessary
|
109
|
-
file: loads a local CSV file from the /tables directory.
|
110
|
-
url: will load a CSV file from an external server, and
|
109
|
+
file: loads a local CSV file from the /tables directory.
|
110
|
+
url: will load a CSV file from an external server, and
|
111
111
|
google_key: is a google key url from an external google doc (see note).
|
112
|
-
|
112
|
+
|
113
113
|
deck: A HTML string describing the table, appears above the table itself.
|
114
|
-
|
114
|
+
|
115
115
|
footer: A HTML string for notes/caveats etc. Appears below the table.
|
116
|
-
|
116
|
+
|
117
117
|
column_options: # Defines a hash of options that are passed onto TableFu
|
118
|
-
|
118
|
+
|
119
119
|
columns: # A list of columns to include, for example:
|
120
120
|
- Bank # would only include the bank column in the table
|
121
|
-
|
121
|
+
|
122
122
|
style: # A list of style declarations by column, for example:
|
123
123
|
Bank: 'text-align:left;' # would left-align the text in the "Bank" column.
|
124
|
-
|
124
|
+
|
125
125
|
sorted_by: # Defines the sort order and column to sort by of the table.
|
126
126
|
Bank: ascending # would sort by the Bank column in ascending order
|
127
|
-
|
127
|
+
|
128
128
|
total: # Declares which columns should have a totals row.
|
129
129
|
['Funds', 'Spent']
|
130
|
-
|
130
|
+
|
131
131
|
formatting: # Defines which of the TableFu formatters to apply to a column.
|
132
132
|
(%) Spent: bar # applies the bar formatter to the '(%) Spent' column.
|
133
|
-
Link: # Creates a meta column form two other columns
|
133
|
+
Link: # Creates a meta column form two other columns
|
134
134
|
method: link # describes the formatter to use
|
135
135
|
arguments: ['Bank', 'URL'] # Combines Bank and URL as arguments
|
136
|
-
|
136
|
+
|
137
137
|
faceting: # Describes the faceting, or grouping, to apply to a table
|
138
138
|
facet_by: Bank # groups the records by bank name
|
139
|
-
|
139
|
+
|
140
140
|
hard_paginate: true # Dictates that the table should be spread across multiple pages
|
141
141
|
# can't be used with faceting, and disables the user filtering
|
142
|
-
|
142
|
+
|
143
143
|
per_page: 250 # Instructs TableSetter to only page by 250 rows.
|
144
|
-
|
145
|
-
live: true # publishes the table in the index page. Note that even if live is
|
146
|
-
# set to false the table is still accessible directly.
|
147
|
-
|
144
|
+
|
145
|
+
live: true # publishes the table in the index page. Note that even if live is
|
146
|
+
# set to false the table is still accessible directly.
|
147
|
+
|
148
148
|
</pre>
|
149
149
|
|
150
150
|
<h3>NB: A Note About google_key</h3>
|
@@ -181,7 +181,7 @@ ln -s /path/to/table-setter/public /docroot/tables</pre>
|
|
181
181
|
<pre>
|
182
182
|
TableSetter::App.cache_timeout = 60 * 15 # 15 minutes</pre>
|
183
183
|
<p>That line dictates the max age of a request and you'll want to tweak it depending on how frequently changed your tables will be and how many users you expect. If you want to define any <a href="https://github.com/propublica/table-fu">TableFu</a> formatters you should do so in <strong>config.ru</strong>.</p>
|
184
|
-
|
184
|
+
|
185
185
|
<h3>Static</h3>
|
186
186
|
<p>You can also use to pre-build <strong>table-setter</strong> your tables as html and upload the built files to your web server. You can build them using the <strong>table-setter</strong> command:</p>
|
187
187
|
<pre>
|
@@ -216,27 +216,31 @@ script/generate table-setter</pre>
|
|
216
216
|
<li>
|
217
217
|
<a href="http://media.apps.chicagotribune.com/tables/speed.html">In the Wild: Chicago Tribune</a><br>
|
218
218
|
A table showing leniency rates of Chicago area judges in speeding cases.
|
219
|
-
|
219
|
+
|
220
220
|
</li>
|
221
221
|
</ul>
|
222
222
|
<h2><a id="credits" href="#toc">Credits</a></h2>
|
223
223
|
<p><a href="http://github.com/thejefflarson">Jeff Larson</a> (Maintainer), <a href="http://github.com/brianboyer/">Brian Boyer</a>, <a href="http://github.com/kleinmatic">Scott Klein</a>, <a href="http://github.com/markpercival">Mark Percival</a>, <a href="http://github.com/seebq">Charles Brian Quinn</a>, <a href="http://github.com/bouvard">Christopher Groskopf</a>, and <a href="http://github.com/ryanmark">Ryan Mark</a>.</p>
|
224
224
|
<h2><a id="changes" href="#toc">Change Log</a></h2>
|
225
|
-
<strong>
|
225
|
+
<strong>0.2.0</strong>
|
226
|
+
<p><b>Backwards incompatible change:</b> Table urls no longer end in a trailing slash. Please the <strong>url_for</strong> calls in your templates to reflect the change.</p>
|
227
|
+
<strong>0.1.11</strong>
|
228
|
+
<p>Javascript Fixes. <b>Note:</b> You'll need to delete the javascript's folder in the config directory and run <strong>table-setter install</strong> to grab the changes.</p>
|
229
|
+
<strong>0.1.10</strong>
|
226
230
|
<p>New formatters via <a href="http://github.com/ryanmark">Ryan Mark</a>.
|
227
|
-
<strong>1.9</strong>
|
231
|
+
<strong>0.1.9</strong>
|
228
232
|
<p>No Op.</p>
|
229
|
-
<strong>1.8</strong>
|
233
|
+
<strong>0.1.8</strong>
|
230
234
|
<p>Bunch of fixes from <a href="http://github.com/ryanmark">Ryan Mark</a>, and beta markdown functionality. Once Markdown is tested we'll release 0.2.0</p>
|
231
|
-
<strong>1.7</strong>
|
235
|
+
<strong>0.1.7</strong>
|
232
236
|
<p>Bugfix to the build command to place assets in the right place</p>
|
233
|
-
<strong>1.6</strong>
|
237
|
+
<strong>0.1.6</strong>
|
234
238
|
<p>Fix in <strong>build_assets</strong> in command.rb, via <a href="http://github.com/propublica/table-setter/commit/2dd207d57eda4d78520b8a5fa99e6e085952206a">Christopher Groskopf</a></p>
|
235
|
-
<strong>1.5</strong>
|
239
|
+
<strong>0.1.5</strong>
|
236
240
|
<p>Bugfixes.</p>
|
237
|
-
<strong>1.4</strong>
|
241
|
+
<strong>0.1.4</strong>
|
238
242
|
<p>Javascript fixes and thin added as a dependency.</p>
|
239
|
-
<strong>1.3</strong>
|
243
|
+
<strong>0.1.3</strong>
|
240
244
|
<p>Initial release.</p>
|
241
245
|
<h2><a id="license" href="#toc">License</a></h2>
|
242
246
|
<pre>Copyright (c) 2010 ProPublica
|
data/lib/table_setter/app.rb
CHANGED
@@ -12,18 +12,18 @@ module TableSetter
|
|
12
12
|
not_found do
|
13
13
|
show :"404"
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
error do
|
17
17
|
show :"500"
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
get "/" do
|
21
21
|
headers['Cache-Control'] = "public, max-age=#{TableSetter::App.cache_timeout}"
|
22
22
|
last_modified Table.fresh_yaml_time
|
23
23
|
show :index, :tables => Table.all
|
24
24
|
end
|
25
|
-
|
26
|
-
["/:slug/:page
|
25
|
+
|
26
|
+
["/:slug/:page", "/:slug"].each do |path|
|
27
27
|
get path do
|
28
28
|
headers['Cache-Control'] = "public, max-age=#{TableSetter::App.cache_timeout}"
|
29
29
|
not_found unless Table.exists? params[:slug]
|
@@ -35,13 +35,13 @@ module TableSetter
|
|
35
35
|
show :table, :table => table, :page => page
|
36
36
|
end
|
37
37
|
end
|
38
|
-
|
38
|
+
|
39
39
|
private
|
40
|
-
|
40
|
+
|
41
41
|
def show(page, locals={})
|
42
42
|
erb page, {:layout => true}, locals
|
43
43
|
end
|
44
|
-
|
44
|
+
|
45
45
|
class << self
|
46
46
|
attr_accessor :cache_timeout
|
47
47
|
|
data/spec/spec_helper.rb
CHANGED
@@ -3,22 +3,22 @@ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
3
3
|
|
4
4
|
describe TableSetter::App, "in the application" do
|
5
5
|
include Rack::Test::Methods
|
6
|
-
|
6
|
+
|
7
7
|
def app
|
8
8
|
TableSetter::App
|
9
9
|
end
|
10
10
|
|
11
|
-
|
11
|
+
|
12
12
|
it "should render the homepage" do
|
13
13
|
get '/'
|
14
14
|
last_response.body.include?("All Tables").should be_true
|
15
15
|
end
|
16
|
-
|
17
|
-
|
16
|
+
|
17
|
+
|
18
18
|
it "should render a table" do
|
19
|
-
get '/example
|
19
|
+
get '/example'
|
20
20
|
last_response.ok?.should be_true
|
21
21
|
last_response.body.include?("Failed Banks List").should be_true
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
end
|
data/spec/table-setter_spec.rb
CHANGED
@@ -13,7 +13,7 @@ describe TableSetter::Table do
|
|
13
13
|
before :all do
|
14
14
|
@table = TableSetter::Table.new("example_local")
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
it "should load from a google key, and defer loading when asked" do
|
18
18
|
table = TableSetter::Table.new("example", :defer => true)
|
19
19
|
table.data.should be_nil
|
@@ -21,50 +21,50 @@ describe TableSetter::Table do
|
|
21
21
|
table.data.should_not be_nil
|
22
22
|
table.data.headers.should_not be_nil
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
it 'should be able to find out if a given table exists' do
|
26
26
|
TableSetter::Table.exists?("non_existent_table").should be_false
|
27
27
|
TableSetter::Table.exists?("example").should be_true
|
28
28
|
end
|
29
|
-
|
29
|
+
|
30
30
|
it "should have a slug" do
|
31
31
|
@table.slug.should eql "example_local"
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
it "should have a deck" do
|
35
35
|
@table.deck.should_not be_nil
|
36
36
|
end
|
37
|
-
|
37
|
+
|
38
38
|
it "should have 250 items per page" do
|
39
39
|
@table.per_page.should eql 250
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
it "should be sortable" do
|
43
43
|
@table.sortable?.should be_false
|
44
44
|
end
|
45
|
-
|
45
|
+
|
46
46
|
it "should have a footer" do
|
47
47
|
@table.footer.should_not be_nil
|
48
48
|
end
|
49
|
-
|
49
|
+
|
50
50
|
it "should have a title" do
|
51
51
|
@table.title.should_not be_nil
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
it "should have 5805 rows" do
|
55
55
|
@table.data.rows.length.should eql 5805
|
56
56
|
end
|
57
|
-
|
57
|
+
|
58
58
|
it "should be stylish" do
|
59
59
|
@table.data.rows[1].column_for('State').style.should eql 'text-align:left;'
|
60
60
|
@table.data.rows[1].column_for('Project Description').style.should eql 'text-align:right;'
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
it "should have stylish headers" do
|
64
64
|
@table.data.headers[0].style.should eql 'text-align:left;'
|
65
65
|
@table.data.headers[4].style.length.should eql 0
|
66
66
|
end
|
67
|
-
|
67
|
+
|
68
68
|
it "should be formatted" do
|
69
69
|
@table.data.rows[1].column_for('ARRA Funds Obligated').to_s.should eql '$154,446'
|
70
70
|
end
|
@@ -73,19 +73,19 @@ end
|
|
73
73
|
|
74
74
|
|
75
75
|
describe TableSetter::Table, "with hard pagination" do
|
76
|
-
|
76
|
+
|
77
77
|
before :each do
|
78
78
|
@data = TableSetter::Table.new("example_local")
|
79
79
|
end
|
80
|
-
|
80
|
+
|
81
81
|
it "should not be sortable" do
|
82
82
|
@data.sortable?.should eql false
|
83
83
|
end
|
84
|
-
|
84
|
+
|
85
85
|
it "should be paginated" do
|
86
86
|
@data.hard_paginate?.should eql true
|
87
87
|
end
|
88
|
-
|
88
|
+
|
89
89
|
it "should paginate based on a page" do
|
90
90
|
@data.paginate! 3
|
91
91
|
@data.page.should eql 3
|
@@ -94,65 +94,65 @@ describe TableSetter::Table, "with hard pagination" do
|
|
94
94
|
@data.data.rows.length.should eql @data.per_page
|
95
95
|
@data.data.rows[0].column_for('State').to_s.should eql 'CALIFORNIA'
|
96
96
|
end
|
97
|
-
|
97
|
+
|
98
98
|
it 'should not paginate when given a bad value' do
|
99
99
|
lambda {@data.paginate!(-1)}.should raise_exception(ArgumentError)
|
100
100
|
lambda {@data.paginate!(10000000)}.should raise_exception(ArgumentError)
|
101
101
|
end
|
102
|
-
|
102
|
+
|
103
103
|
it 'should handle first page' do
|
104
104
|
@data.paginate! 1
|
105
105
|
@data.page.should eql 1
|
106
106
|
@data.prev_page.should eql nil
|
107
107
|
end
|
108
|
-
|
108
|
+
|
109
109
|
it 'should handle last page' do
|
110
110
|
@data.paginate! @data.total_pages
|
111
111
|
@data.page.should eql @data.total_pages
|
112
112
|
@data.next_page.should eql nil
|
113
113
|
end
|
114
|
-
|
114
|
+
|
115
115
|
end
|
116
116
|
|
117
117
|
|
118
118
|
describe TableSetter::Table, "with faceting and macros" do
|
119
|
-
|
119
|
+
|
120
120
|
before :all do
|
121
121
|
@data = TableSetter::Table.new("example_faceted")
|
122
122
|
@tables = @data.facets
|
123
123
|
end
|
124
|
-
|
124
|
+
|
125
125
|
it 'should load a faceted_table' do
|
126
126
|
data = TableSetter::Table.new("example_faceted", :defer=> true)
|
127
127
|
data.facets.should be_nil
|
128
128
|
data.load
|
129
129
|
tables = data.facets
|
130
|
-
tables.length.should eql 56
|
130
|
+
tables.length.should eql 56
|
131
131
|
end
|
132
|
-
|
132
|
+
|
133
133
|
it "should be faceted" do
|
134
134
|
@data.faceted?.should be_true
|
135
135
|
end
|
136
|
-
|
136
|
+
|
137
137
|
it "should not be sortable" do
|
138
138
|
@data.sortable?.should be_false
|
139
139
|
end
|
140
|
-
|
141
|
-
|
140
|
+
|
141
|
+
|
142
142
|
it "should have 3 tables" do
|
143
143
|
@tables.length.should eql 56
|
144
144
|
end
|
145
|
-
|
145
|
+
|
146
146
|
it "should have $212,774,529 for Alabama" do
|
147
147
|
@tables[0].total_for('Total Appropriation').to_s.should eql '$212,774,529'
|
148
148
|
end
|
149
|
-
|
149
|
+
|
150
150
|
it "should have $416,075,044 for North Carolina with dead row" do
|
151
151
|
@tables[35].total_for('Total Appropriation').to_s.should eql '$423,318,645'
|
152
152
|
end
|
153
|
-
|
154
153
|
|
155
|
-
|
154
|
+
|
155
|
+
|
156
156
|
end
|
157
157
|
|
158
158
|
describe TableSetter::Table, "group fetchers" do
|
@@ -165,11 +165,11 @@ describe TableSetter::Table, "with urls and google bars" do
|
|
165
165
|
before :each do
|
166
166
|
@table = TableSetter::Table.new("example_formatted")
|
167
167
|
end
|
168
|
-
|
168
|
+
|
169
169
|
it "should have a link row" do
|
170
170
|
@table.data.rows[1].column_for('Agency Webpage').to_s.should eql "<a href=\"http://www.hhs.gov/recovery/\" title=\"Health and Human Services\">Health and Human Services</a>"
|
171
171
|
end
|
172
|
-
|
172
|
+
|
173
173
|
it 'should show a bar' do
|
174
174
|
@table.data.rows[1].column_for('Spent (%)').to_s.should eql "<div class=\"bar\" style=\"width:42.0%\">42.0%</div>"
|
175
175
|
end
|
data/table_setter.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{table_setter}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.2.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Jeff Larson"]
|
12
|
-
s.date = %q{2010-11-
|
12
|
+
s.date = %q{2010-11-08}
|
13
13
|
s.description = %q{A sinatra based app for rendering CSVs hosted on google docs or locally in custom HTML}
|
14
14
|
s.email = %q{thejefflarson@gmail.com}
|
15
15
|
s.executables = ["table-setter", "table-setter"]
|
data/template/views/index.erb
CHANGED
data/template/views/table.erb
CHANGED
@@ -7,9 +7,9 @@
|
|
7
7
|
<% end %>
|
8
8
|
<div id="pager" class="pager">
|
9
9
|
<form>
|
10
|
-
<a href="<%= url_for "/#{table.slug}/#{table.prev_page}
|
10
|
+
<a href="<%= url_for "/#{table.slug}/#{table.prev_page}" if !table.prev_page.nil? %>" class="prev">prev</a>
|
11
11
|
<span class="pagedisplay"/><%= "#{table.page} / #{table.total_pages}" if table.hard_paginate? %></span>
|
12
|
-
<a href="<%= url_for "/#{table.slug}/#{table.next_page}
|
12
|
+
<a href="<%= url_for "/#{table.slug}/#{table.next_page}" if !table.next_page.nil? %>" class="next">next</a>
|
13
13
|
<% if !table.hard_paginate? %>
|
14
14
|
<select class="pagesize">
|
15
15
|
<% (1..4).each do |count|%>
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: table_setter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 2
|
9
|
+
- 0
|
10
|
+
version: 0.2.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Jeff Larson
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2010-11-
|
18
|
+
date: 2010-11-08 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|