table_setter 0.1.7 → 0.1.8
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/Rakefile +2 -1
- data/VERSION.yml +1 -1
- data/index.html +1 -1
- data/lib/table_setter/command.rb +2 -1
- data/lib/table_setter/table.rb +15 -1
- data/lib/table_setter.rb +1 -0
- data/spec/table-setter-command_spec.rb +55 -0
- data/spec/table-setter_spec.rb +2 -2
- data/table_setter.gemspec +10 -5
- data/template/tables/example_faceted.yml +1 -1
- data/template/tables/example_formatted.yml +1 -1
- data/template/tables/example_local.yml +1 -1
- metadata +22 -5
data/Rakefile
CHANGED
|
@@ -14,11 +14,12 @@ begin
|
|
|
14
14
|
gem.add_development_dependency "rspec", ">= 1.2.9"
|
|
15
15
|
gem.add_dependency "rack", ">= 1.1.0"
|
|
16
16
|
gem.add_dependency "thin", ">= 1.2.5"
|
|
17
|
-
gem.add_dependency "table_fu", ">= 0.
|
|
17
|
+
gem.add_dependency "table_fu", ">= 0.2.1"
|
|
18
18
|
gem.add_dependency "sinatra", ">= 1.0.0"
|
|
19
19
|
gem.add_dependency "sinatra-static-assets", ">= 0.5.0"
|
|
20
20
|
gem.add_dependency "emk-sinatra-url-for", ">= 0.2.1"
|
|
21
21
|
gem.add_dependency "curb", ">= 0.6.6.0"
|
|
22
|
+
gem.add_dependency "rdiscount", ">= 1.6.3.1"
|
|
22
23
|
gem.executables << "table-setter"
|
|
23
24
|
end
|
|
24
25
|
|
data/VERSION.yml
CHANGED
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.1.
|
|
11
|
+
<h1>TableSetter <small>– Version: 0.1.7</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>
|
data/lib/table_setter/command.rb
CHANGED
|
@@ -15,7 +15,7 @@ Usage:
|
|
|
15
15
|
commands:
|
|
16
16
|
start run the development server, for deployment use config.ru
|
|
17
17
|
install copy the table-setter assets into the the directory
|
|
18
|
-
build statically build tables in the ./out/
|
|
18
|
+
build statically build tables in the ./out/ directory
|
|
19
19
|
|
|
20
20
|
options:
|
|
21
21
|
EOB
|
|
@@ -98,6 +98,7 @@ options:
|
|
|
98
98
|
|
|
99
99
|
def build_tables(request)
|
|
100
100
|
TableSetter::Table.all.each do |table|
|
|
101
|
+
return if !table.live
|
|
101
102
|
puts "Building #{table.slug}"
|
|
102
103
|
install_file(request.request("GET", "/#{@prefix}/#{table.slug}/").body,
|
|
103
104
|
File.join(@out_dir, table.slug, "index.html"))
|
data/lib/table_setter/table.rb
CHANGED
|
@@ -100,7 +100,7 @@ module TableSetter
|
|
|
100
100
|
# A convienence method to return the sort array for table setter.
|
|
101
101
|
def sort_array
|
|
102
102
|
@data.sorted_by.inject([]) do |memo, (key, value)|
|
|
103
|
-
memo << [@data.columns.index(key), value == 'descending' ?
|
|
103
|
+
memo << [@data.columns.index(key), value == 'descending' ? 1 : 0]
|
|
104
104
|
end
|
|
105
105
|
end
|
|
106
106
|
|
|
@@ -222,5 +222,19 @@ class TableFu::Formatting
|
|
|
222
222
|
end
|
|
223
223
|
"<div class=\"bar\" style=\"width:#{percent}%\">#{percent}%</div>"
|
|
224
224
|
end
|
|
225
|
+
# markdown formatting in tablefu cells
|
|
226
|
+
def markdown(cell)
|
|
227
|
+
RDiscount.new(cell).to_html
|
|
228
|
+
end
|
|
229
|
+
# format as a link, if the href is empty don't make the link active
|
|
230
|
+
def link(linkname, href)
|
|
231
|
+
title = linkname.to_s.gsub(/(["])/, "'")
|
|
232
|
+
if !href.value.nil? && !href.value.empty?
|
|
233
|
+
"<a href=\"#{href}\" title=\"#{title}\">#{linkname}</a>"
|
|
234
|
+
else
|
|
235
|
+
"<a title=\"#{title}\">#{linkname}</a>"
|
|
236
|
+
end
|
|
237
|
+
end
|
|
238
|
+
|
|
225
239
|
end
|
|
226
240
|
end
|
data/lib/table_setter.rb
CHANGED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
|
2
|
+
|
|
3
|
+
describe TableSetter::Command do
|
|
4
|
+
INSTALL_DIRECTORY = File.join "/", "tmp", "table-setter-test", "/"
|
|
5
|
+
TABLE_SETTER = File.join File.dirname(__FILE__), "..", "bin", "table-setter"
|
|
6
|
+
TEMPLATE_DIR = File.join TableSetter::ROOT, "template"
|
|
7
|
+
|
|
8
|
+
def cleanup
|
|
9
|
+
if File.exists? INSTALL_DIRECTORY
|
|
10
|
+
FileUtils.rm_r INSTALL_DIRECTORY
|
|
11
|
+
end
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def install
|
|
15
|
+
`#{TABLE_SETTER} install #{INSTALL_DIRECTORY}`
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
after(:each) do
|
|
19
|
+
cleanup
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
before(:each) do
|
|
23
|
+
install
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'should install the configuration directory in a custom spot' do
|
|
27
|
+
Dir["#{TEMPLATE_DIR}/**/*"].each do |template_file|
|
|
28
|
+
File.exists?(template_file.gsub(TEMPLATE_DIR, INSTALL_DIRECTORY)).should be_true
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def build_and_test(prefix="")
|
|
33
|
+
prefix_option = "-p #{prefix}" if prefix.length > 0
|
|
34
|
+
`#{TABLE_SETTER} build #{INSTALL_DIRECTORY} #{prefix_option}`
|
|
35
|
+
Dir["#{TEMPLATE_DIR}/public/*"].each do |asset|
|
|
36
|
+
corrected_path = asset.gsub(File.join(TEMPLATE_DIR, "public"), File.join(INSTALL_DIRECTORY, "out", "#{prefix}"))
|
|
37
|
+
|
|
38
|
+
File.exists?(corrected_path).should be_true
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'should build the tables and install the assets in the correct folder with prefix' do
|
|
43
|
+
build_and_test "test"
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it 'should build the tables and install the assets in the correct folder without prefix' do
|
|
47
|
+
build_and_test
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it 'should build a table' do
|
|
51
|
+
`#{TABLE_SETTER} build #{INSTALL_DIRECTORY}`
|
|
52
|
+
File.exists?("#{INSTALL_DIRECTORY}/out/example/index.html").should be_true
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
end
|
data/spec/table-setter_spec.rb
CHANGED
|
@@ -157,7 +157,7 @@ end
|
|
|
157
157
|
|
|
158
158
|
describe TableSetter::Table, "group fetchers" do
|
|
159
159
|
it "should return live tables" do
|
|
160
|
-
TableSetter::Table.all.length.should eql
|
|
160
|
+
TableSetter::Table.all.length.should eql 1
|
|
161
161
|
end
|
|
162
162
|
end
|
|
163
163
|
|
|
@@ -167,7 +167,7 @@ describe TableSetter::Table, "with urls and google bars" do
|
|
|
167
167
|
end
|
|
168
168
|
|
|
169
169
|
it "should have a link row" do
|
|
170
|
-
@table.data.rows[1].column_for('Agency Webpage').to_s.should eql "<a href
|
|
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
|
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.1.
|
|
8
|
+
s.version = "0.1.8"
|
|
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-05-
|
|
12
|
+
s.date = %q{2010-05-13}
|
|
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"]
|
|
@@ -99,6 +99,7 @@ Gem::Specification.new do |s|
|
|
|
99
99
|
"spec/spec.opts",
|
|
100
100
|
"spec/spec_helper.rb",
|
|
101
101
|
"spec/table-setter-app_spec.rb",
|
|
102
|
+
"spec/table-setter-command_spec.rb",
|
|
102
103
|
"spec/table-setter_spec.rb",
|
|
103
104
|
"table_setter.gemspec",
|
|
104
105
|
"template/config.ru",
|
|
@@ -131,6 +132,7 @@ Gem::Specification.new do |s|
|
|
|
131
132
|
s.test_files = [
|
|
132
133
|
"spec/spec_helper.rb",
|
|
133
134
|
"spec/table-setter-app_spec.rb",
|
|
135
|
+
"spec/table-setter-command_spec.rb",
|
|
134
136
|
"spec/table-setter_spec.rb"
|
|
135
137
|
]
|
|
136
138
|
|
|
@@ -142,30 +144,33 @@ Gem::Specification.new do |s|
|
|
|
142
144
|
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
|
143
145
|
s.add_runtime_dependency(%q<rack>, [">= 1.1.0"])
|
|
144
146
|
s.add_runtime_dependency(%q<thin>, [">= 1.2.5"])
|
|
145
|
-
s.add_runtime_dependency(%q<table_fu>, [">= 0.
|
|
147
|
+
s.add_runtime_dependency(%q<table_fu>, [">= 0.2.1"])
|
|
146
148
|
s.add_runtime_dependency(%q<sinatra>, [">= 1.0.0"])
|
|
147
149
|
s.add_runtime_dependency(%q<sinatra-static-assets>, [">= 0.5.0"])
|
|
148
150
|
s.add_runtime_dependency(%q<emk-sinatra-url-for>, [">= 0.2.1"])
|
|
149
151
|
s.add_runtime_dependency(%q<curb>, [">= 0.6.6.0"])
|
|
152
|
+
s.add_runtime_dependency(%q<rdiscount>, [">= 1.6.3.1"])
|
|
150
153
|
else
|
|
151
154
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
|
152
155
|
s.add_dependency(%q<rack>, [">= 1.1.0"])
|
|
153
156
|
s.add_dependency(%q<thin>, [">= 1.2.5"])
|
|
154
|
-
s.add_dependency(%q<table_fu>, [">= 0.
|
|
157
|
+
s.add_dependency(%q<table_fu>, [">= 0.2.1"])
|
|
155
158
|
s.add_dependency(%q<sinatra>, [">= 1.0.0"])
|
|
156
159
|
s.add_dependency(%q<sinatra-static-assets>, [">= 0.5.0"])
|
|
157
160
|
s.add_dependency(%q<emk-sinatra-url-for>, [">= 0.2.1"])
|
|
158
161
|
s.add_dependency(%q<curb>, [">= 0.6.6.0"])
|
|
162
|
+
s.add_dependency(%q<rdiscount>, [">= 1.6.3.1"])
|
|
159
163
|
end
|
|
160
164
|
else
|
|
161
165
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
|
162
166
|
s.add_dependency(%q<rack>, [">= 1.1.0"])
|
|
163
167
|
s.add_dependency(%q<thin>, [">= 1.2.5"])
|
|
164
|
-
s.add_dependency(%q<table_fu>, [">= 0.
|
|
168
|
+
s.add_dependency(%q<table_fu>, [">= 0.2.1"])
|
|
165
169
|
s.add_dependency(%q<sinatra>, [">= 1.0.0"])
|
|
166
170
|
s.add_dependency(%q<sinatra-static-assets>, [">= 0.5.0"])
|
|
167
171
|
s.add_dependency(%q<emk-sinatra-url-for>, [">= 0.2.1"])
|
|
168
172
|
s.add_dependency(%q<curb>, [">= 0.6.6.0"])
|
|
173
|
+
s.add_dependency(%q<rdiscount>, [">= 1.6.3.1"])
|
|
169
174
|
end
|
|
170
175
|
end
|
|
171
176
|
|
metadata
CHANGED
|
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
|
5
5
|
segments:
|
|
6
6
|
- 0
|
|
7
7
|
- 1
|
|
8
|
-
-
|
|
9
|
-
version: 0.1.
|
|
8
|
+
- 8
|
|
9
|
+
version: 0.1.8
|
|
10
10
|
platform: ruby
|
|
11
11
|
authors:
|
|
12
12
|
- Jeff Larson
|
|
@@ -14,7 +14,7 @@ autorequire:
|
|
|
14
14
|
bindir: bin
|
|
15
15
|
cert_chain: []
|
|
16
16
|
|
|
17
|
-
date: 2010-05-
|
|
17
|
+
date: 2010-05-13 00:00:00 -04:00
|
|
18
18
|
default_executable:
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
@@ -68,9 +68,9 @@ dependencies:
|
|
|
68
68
|
- !ruby/object:Gem::Version
|
|
69
69
|
segments:
|
|
70
70
|
- 0
|
|
71
|
+
- 2
|
|
71
72
|
- 1
|
|
72
|
-
|
|
73
|
-
version: 0.1.1
|
|
73
|
+
version: 0.2.1
|
|
74
74
|
type: :runtime
|
|
75
75
|
version_requirements: *id004
|
|
76
76
|
- !ruby/object:Gem::Dependency
|
|
@@ -130,6 +130,21 @@ dependencies:
|
|
|
130
130
|
version: 0.6.6.0
|
|
131
131
|
type: :runtime
|
|
132
132
|
version_requirements: *id008
|
|
133
|
+
- !ruby/object:Gem::Dependency
|
|
134
|
+
name: rdiscount
|
|
135
|
+
prerelease: false
|
|
136
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
|
137
|
+
requirements:
|
|
138
|
+
- - ">="
|
|
139
|
+
- !ruby/object:Gem::Version
|
|
140
|
+
segments:
|
|
141
|
+
- 1
|
|
142
|
+
- 6
|
|
143
|
+
- 3
|
|
144
|
+
- 1
|
|
145
|
+
version: 1.6.3.1
|
|
146
|
+
type: :runtime
|
|
147
|
+
version_requirements: *id009
|
|
133
148
|
description: A sinatra based app for rendering CSVs hosted on google docs or locally in custom HTML
|
|
134
149
|
email: thejefflarson@gmail.com
|
|
135
150
|
executables:
|
|
@@ -222,6 +237,7 @@ files:
|
|
|
222
237
|
- spec/spec.opts
|
|
223
238
|
- spec/spec_helper.rb
|
|
224
239
|
- spec/table-setter-app_spec.rb
|
|
240
|
+
- spec/table-setter-command_spec.rb
|
|
225
241
|
- spec/table-setter_spec.rb
|
|
226
242
|
- table_setter.gemspec
|
|
227
243
|
- template/config.ru
|
|
@@ -277,4 +293,5 @@ summary: A sinatra based app for rendering CSVs in custom HTML
|
|
|
277
293
|
test_files:
|
|
278
294
|
- spec/spec_helper.rb
|
|
279
295
|
- spec/table-setter-app_spec.rb
|
|
296
|
+
- spec/table-setter-command_spec.rb
|
|
280
297
|
- spec/table-setter_spec.rb
|