table_setter 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +5 -5
- data/VERSION.yml +2 -2
- data/documentation/index.html.erb +6 -0
- data/index.html +7 -1
- data/lib/table_setter/command.rb +24 -11
- data/lib/table_setter/table.rb +3 -0
- data/table_setter.gemspec +18 -17
- data/template/config.ru +6 -4
- data/template/lib/formatters.rb +6 -0
- metadata +22 -23
data/Rakefile
CHANGED
@@ -13,13 +13,13 @@ begin
|
|
13
13
|
gem.rubyforge_project = "table-setter"
|
14
14
|
gem.add_development_dependency "rspec"
|
15
15
|
gem.add_dependency "rack", ">= 1.1.0"
|
16
|
-
gem.add_dependency "thin", ">= 1.2.
|
17
|
-
gem.add_dependency "table_fu", ">= 0.3.
|
18
|
-
gem.add_dependency "sinatra", ">= 1.
|
16
|
+
gem.add_dependency "thin", ">= 1.2.4"
|
17
|
+
gem.add_dependency "table_fu", ">= 0.3.4"
|
18
|
+
gem.add_dependency "sinatra", ">= 1.2.1"
|
19
19
|
gem.add_dependency "sinatra-static-assets", ">= 0.5.0"
|
20
20
|
gem.add_dependency "emk-sinatra-url-for", ">= 0.2.1"
|
21
|
-
gem.add_dependency "curb", ">= 0.
|
22
|
-
gem.add_dependency "rdiscount", ">= 1.6.
|
21
|
+
gem.add_dependency "curb", ">= 0.7.15"
|
22
|
+
gem.add_dependency "rdiscount", ">= 1.6.8"
|
23
23
|
gem.executables << "table-setter"
|
24
24
|
end
|
25
25
|
|
data/VERSION.yml
CHANGED
@@ -239,6 +239,12 @@ script/generate table-setter</pre>
|
|
239
239
|
<a href="http://github.com/palewire">Ben Welsh</a>, and
|
240
240
|
<a href="http://github.com/jpmckinney">James McKinney</a>.</p>
|
241
241
|
<h2><a id="changes" href="#toc">Change Log</a></h2>
|
242
|
+
<strong>0.2.6</strong>
|
243
|
+
<p>Fixed a bug in <strong>table-setter start</strong> thanks to <a href="http://github.com/jfkeefe">John Keefe</a>
|
244
|
+
merged in some more changes from <a href="http://github.com/jpmckinney">James McKinney</a>
|
245
|
+
and added a <strong>lib/formatters.rb</strong> in the <strong>template</strong>, which is the standard
|
246
|
+
place to stash your custom formatters. Also, the <strong>build</strong> command
|
247
|
+
now errors loudly and exits if there's an error.</p>
|
242
248
|
<strong>0.2.5</strong>
|
243
249
|
<p>Loads of bullet-proofing from <a href="http://github.com/jpmckinney">James McKinney</a> and js fixes from <a href="http://github.com/palewire">Ben Welsh</a>, you'll want to re-run <strong>table-setter install</strong> to grab the changes, as with previous releases.</p>
|
244
250
|
<strong>0.2.4</strong>
|
data/index.html
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
</head>
|
10
10
|
<body>
|
11
11
|
<a href="http://www.propublica.org" class="propublica"> </a>
|
12
|
-
<h1>TableSetter <small>– Version: 0.2.
|
12
|
+
<h1>TableSetter <small>– Version: 0.2.6</small></h1>
|
13
13
|
<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>
|
14
14
|
<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>
|
15
15
|
<h2><a id="toc">Table of Contents</a></h2>
|
@@ -234,6 +234,12 @@ script/generate table-setter</pre>
|
|
234
234
|
<a href="http://github.com/palewire">Ben Welsh</a>, and
|
235
235
|
<a href="http://github.com/jpmckinney">James McKinney</a>.</p>
|
236
236
|
<h2><a id="changes" href="#toc">Change Log</a></h2>
|
237
|
+
<strong>0.2.6</strong>
|
238
|
+
<p>Fixed a bug in <strong>table-setter start</strong> thanks to <a href="http://github.com/jfkeefe">John Keefe</a>
|
239
|
+
merged in some more changes from <a href="http://github.com/jpmckinney">James McKinney</a>
|
240
|
+
and added a <strong>lib/formatters.rb</strong> in the <strong>template</strong>, which is the standard
|
241
|
+
place to stash your custom formatters. Also, the <strong>build</strong> command
|
242
|
+
now errors loudly and exits if there's an error.</p>
|
237
243
|
<strong>0.2.5</strong>
|
238
244
|
<p>Loads of bullet-proofing from <a href="http://github.com/jpmckinney">James McKinney</a> and js fixes from <a href="http://github.com/palewire">Ben Welsh</a>, you'll want to re-run <strong>table-setter install</strong> to grab the changes, as with previous releases.</p>
|
239
245
|
<strong>0.2.4</strong>
|
data/lib/table_setter/command.rb
CHANGED
@@ -74,19 +74,24 @@ options:
|
|
74
74
|
|
75
75
|
def build_rack
|
76
76
|
prefix = @prefix
|
77
|
+
config = File.join(@directory, "config.ru")
|
78
|
+
|
77
79
|
Rack::Builder.app do
|
78
80
|
map prefix do
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
81
|
+
if(File.exists? config)
|
82
|
+
run Rack::Builder.parse_file(config).first
|
83
|
+
else
|
84
|
+
use Rack::CommonLogger, STDERR
|
85
|
+
use Rack::ShowExceptions
|
86
|
+
use Rack::Lint
|
87
|
+
run TableSetter::App
|
88
|
+
end
|
83
89
|
end
|
84
90
|
end
|
85
91
|
end
|
86
92
|
|
87
93
|
def build_index
|
88
|
-
|
89
|
-
File.join(@out_dir, "index.html"))
|
94
|
+
build_file("#{@prefix}", "index.html")
|
90
95
|
end
|
91
96
|
|
92
97
|
def build_assets
|
@@ -95,18 +100,26 @@ options:
|
|
95
100
|
end
|
96
101
|
end
|
97
102
|
|
103
|
+
def build_file(url, out)
|
104
|
+
response = @request.get(url)
|
105
|
+
if response.errors.length > 0
|
106
|
+
puts "ERROR on #{url}:\n#{response.errors}" and exit 1
|
107
|
+
end
|
108
|
+
install_file(response.body, File.join(@out_dir, out))
|
109
|
+
end
|
110
|
+
|
98
111
|
def build_tables
|
99
112
|
TableSetter::Table.all.each do |table|
|
100
|
-
|
113
|
+
next if !table.live
|
101
114
|
puts "Building #{table.slug}"
|
102
|
-
|
103
|
-
|
115
|
+
build_file("#{@prefix}#{table.slug}/", File.join(table.slug, "index.html"))
|
116
|
+
|
104
117
|
if table.hard_paginate?
|
105
118
|
table.load
|
106
119
|
(1..table.total_pages).each do |page|
|
107
120
|
puts "Building #{table.slug} #{page} of #{table.total_pages}"
|
108
|
-
|
109
|
-
File.join(
|
121
|
+
build_file("#{@prefix}#{table.slug}/#{page}/",
|
122
|
+
File.join(table.slug, page.to_s, "index.html"))
|
110
123
|
end
|
111
124
|
end
|
112
125
|
end
|
data/lib/table_setter/table.rb
CHANGED
@@ -26,6 +26,9 @@ module TableSetter
|
|
26
26
|
# We're keeping this explicit to control against unnecessary http requests.
|
27
27
|
def load
|
28
28
|
csv = csv_data
|
29
|
+
if @table_opts[:column_options]
|
30
|
+
@table_opts[:column_options]['style'] ||= {}
|
31
|
+
end
|
29
32
|
@data = TableFu.new(csv_data, @table_opts[:column_options] || {})
|
30
33
|
if @table_opts[:faceting]
|
31
34
|
@data.col_opts[:ignored] = [@table_opts[:faceting][:facet_by]]
|
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.2.
|
8
|
+
s.version = "0.2.6"
|
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{2011-
|
12
|
+
s.date = %q{2011-04-03}
|
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"]
|
@@ -102,6 +102,7 @@ Gem::Specification.new do |s|
|
|
102
102
|
"spec/table-setter_spec.rb",
|
103
103
|
"table_setter.gemspec",
|
104
104
|
"template/config.ru",
|
105
|
+
"template/lib/formatters.rb",
|
105
106
|
"template/public/favicon.ico",
|
106
107
|
"template/public/images/th_arrow_asc.gif",
|
107
108
|
"template/public/images/th_arrow_desc.gif",
|
@@ -141,34 +142,34 @@ Gem::Specification.new do |s|
|
|
141
142
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
142
143
|
s.add_development_dependency(%q<rspec>, [">= 0"])
|
143
144
|
s.add_runtime_dependency(%q<rack>, [">= 1.1.0"])
|
144
|
-
s.add_runtime_dependency(%q<thin>, [">= 1.2.
|
145
|
-
s.add_runtime_dependency(%q<table_fu>, [">= 0.3.
|
146
|
-
s.add_runtime_dependency(%q<sinatra>, [">= 1.
|
145
|
+
s.add_runtime_dependency(%q<thin>, [">= 1.2.4"])
|
146
|
+
s.add_runtime_dependency(%q<table_fu>, [">= 0.3.4"])
|
147
|
+
s.add_runtime_dependency(%q<sinatra>, [">= 1.2.1"])
|
147
148
|
s.add_runtime_dependency(%q<sinatra-static-assets>, [">= 0.5.0"])
|
148
149
|
s.add_runtime_dependency(%q<emk-sinatra-url-for>, [">= 0.2.1"])
|
149
|
-
s.add_runtime_dependency(%q<curb>, [">= 0.
|
150
|
-
s.add_runtime_dependency(%q<rdiscount>, [">= 1.6.
|
150
|
+
s.add_runtime_dependency(%q<curb>, [">= 0.7.15"])
|
151
|
+
s.add_runtime_dependency(%q<rdiscount>, [">= 1.6.8"])
|
151
152
|
else
|
152
153
|
s.add_dependency(%q<rspec>, [">= 0"])
|
153
154
|
s.add_dependency(%q<rack>, [">= 1.1.0"])
|
154
|
-
s.add_dependency(%q<thin>, [">= 1.2.
|
155
|
-
s.add_dependency(%q<table_fu>, [">= 0.3.
|
156
|
-
s.add_dependency(%q<sinatra>, [">= 1.
|
155
|
+
s.add_dependency(%q<thin>, [">= 1.2.4"])
|
156
|
+
s.add_dependency(%q<table_fu>, [">= 0.3.4"])
|
157
|
+
s.add_dependency(%q<sinatra>, [">= 1.2.1"])
|
157
158
|
s.add_dependency(%q<sinatra-static-assets>, [">= 0.5.0"])
|
158
159
|
s.add_dependency(%q<emk-sinatra-url-for>, [">= 0.2.1"])
|
159
|
-
s.add_dependency(%q<curb>, [">= 0.
|
160
|
-
s.add_dependency(%q<rdiscount>, [">= 1.6.
|
160
|
+
s.add_dependency(%q<curb>, [">= 0.7.15"])
|
161
|
+
s.add_dependency(%q<rdiscount>, [">= 1.6.8"])
|
161
162
|
end
|
162
163
|
else
|
163
164
|
s.add_dependency(%q<rspec>, [">= 0"])
|
164
165
|
s.add_dependency(%q<rack>, [">= 1.1.0"])
|
165
|
-
s.add_dependency(%q<thin>, [">= 1.2.
|
166
|
-
s.add_dependency(%q<table_fu>, [">= 0.3.
|
167
|
-
s.add_dependency(%q<sinatra>, [">= 1.
|
166
|
+
s.add_dependency(%q<thin>, [">= 1.2.4"])
|
167
|
+
s.add_dependency(%q<table_fu>, [">= 0.3.4"])
|
168
|
+
s.add_dependency(%q<sinatra>, [">= 1.2.1"])
|
168
169
|
s.add_dependency(%q<sinatra-static-assets>, [">= 0.5.0"])
|
169
170
|
s.add_dependency(%q<emk-sinatra-url-for>, [">= 0.2.1"])
|
170
|
-
s.add_dependency(%q<curb>, [">= 0.
|
171
|
-
s.add_dependency(%q<rdiscount>, [">= 1.6.
|
171
|
+
s.add_dependency(%q<curb>, [">= 0.7.15"])
|
172
|
+
s.add_dependency(%q<rdiscount>, [">= 1.6.8"])
|
172
173
|
end
|
173
174
|
end
|
174
175
|
|
data/template/config.ru
CHANGED
@@ -4,10 +4,10 @@
|
|
4
4
|
# enabled web server.
|
5
5
|
#
|
6
6
|
# For example this will spin up a thin instance:
|
7
|
-
#
|
7
|
+
#
|
8
8
|
# thin start -R ./config.ru
|
9
|
-
#
|
10
|
-
# To run it in apache you should have Passenger enabled, and follow the instructions in the
|
9
|
+
#
|
10
|
+
# To run it in apache you should have Passenger enabled, and follow the instructions in the
|
11
11
|
# passenger docs:
|
12
12
|
#
|
13
13
|
# http://www.modrails.com/documentation/Users%20guide.html#_deploying_a_rack_based_ruby_application
|
@@ -16,6 +16,8 @@ require 'rubygems'
|
|
16
16
|
require 'table_setter'
|
17
17
|
TableSetter.configure(File.dirname(__FILE__))
|
18
18
|
|
19
|
+
# Include custom formatters
|
20
|
+
require "#{File.expand_path(File.dirname(__FILE__))}/lib/formatters.rb"
|
19
21
|
|
20
22
|
# You should probably enable Rack::Cache if you're not behind a caching proxy, by uncommenting the
|
21
23
|
# lines below:
|
@@ -26,7 +28,7 @@ TableSetter.configure(File.dirname(__FILE__))
|
|
26
28
|
# :entitystore => "file:#{TableSetter.config_path}/tmp/body"
|
27
29
|
#
|
28
30
|
# You can tweak the cache timeout for TableSetter by setting the timeout variable on
|
29
|
-
# TableSetter::App:
|
31
|
+
# TableSetter::App:
|
30
32
|
#
|
31
33
|
TableSetter::App.cache_timeout = 60 * 15 # 15 minutes
|
32
34
|
#
|
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: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 6
|
10
|
+
version: 0.2.6
|
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: 2011-
|
18
|
+
date: 2011-04-03 00:00:00 -04:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -56,12 +56,12 @@ dependencies:
|
|
56
56
|
requirements:
|
57
57
|
- - ">="
|
58
58
|
- !ruby/object:Gem::Version
|
59
|
-
hash:
|
59
|
+
hash: 23
|
60
60
|
segments:
|
61
61
|
- 1
|
62
62
|
- 2
|
63
|
-
-
|
64
|
-
version: 1.2.
|
63
|
+
- 4
|
64
|
+
version: 1.2.4
|
65
65
|
type: :runtime
|
66
66
|
version_requirements: *id003
|
67
67
|
- !ruby/object:Gem::Dependency
|
@@ -72,12 +72,12 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - ">="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
hash:
|
75
|
+
hash: 27
|
76
76
|
segments:
|
77
77
|
- 0
|
78
78
|
- 3
|
79
|
-
-
|
80
|
-
version: 0.3.
|
79
|
+
- 4
|
80
|
+
version: 0.3.4
|
81
81
|
type: :runtime
|
82
82
|
version_requirements: *id004
|
83
83
|
- !ruby/object:Gem::Dependency
|
@@ -88,12 +88,12 @@ dependencies:
|
|
88
88
|
requirements:
|
89
89
|
- - ">="
|
90
90
|
- !ruby/object:Gem::Version
|
91
|
-
hash:
|
91
|
+
hash: 29
|
92
92
|
segments:
|
93
93
|
- 1
|
94
|
-
-
|
95
|
-
-
|
96
|
-
version: 1.
|
94
|
+
- 2
|
95
|
+
- 1
|
96
|
+
version: 1.2.1
|
97
97
|
type: :runtime
|
98
98
|
version_requirements: *id005
|
99
99
|
- !ruby/object:Gem::Dependency
|
@@ -136,13 +136,12 @@ dependencies:
|
|
136
136
|
requirements:
|
137
137
|
- - ">="
|
138
138
|
- !ruby/object:Gem::Version
|
139
|
-
hash:
|
139
|
+
hash: 29
|
140
140
|
segments:
|
141
141
|
- 0
|
142
|
-
-
|
143
|
-
-
|
144
|
-
|
145
|
-
version: 0.6.6.0
|
142
|
+
- 7
|
143
|
+
- 15
|
144
|
+
version: 0.7.15
|
146
145
|
type: :runtime
|
147
146
|
version_requirements: *id008
|
148
147
|
- !ruby/object:Gem::Dependency
|
@@ -153,13 +152,12 @@ dependencies:
|
|
153
152
|
requirements:
|
154
153
|
- - ">="
|
155
154
|
- !ruby/object:Gem::Version
|
156
|
-
hash:
|
155
|
+
hash: 31
|
157
156
|
segments:
|
158
157
|
- 1
|
159
158
|
- 6
|
160
|
-
-
|
161
|
-
|
162
|
-
version: 1.6.3.1
|
159
|
+
- 8
|
160
|
+
version: 1.6.8
|
163
161
|
type: :runtime
|
164
162
|
version_requirements: *id009
|
165
163
|
description: A sinatra based app for rendering CSVs hosted on google docs or locally in custom HTML
|
@@ -257,6 +255,7 @@ files:
|
|
257
255
|
- spec/table-setter_spec.rb
|
258
256
|
- table_setter.gemspec
|
259
257
|
- template/config.ru
|
258
|
+
- template/lib/formatters.rb
|
260
259
|
- template/public/favicon.ico
|
261
260
|
- template/public/images/th_arrow_asc.gif
|
262
261
|
- template/public/images/th_arrow_desc.gif
|