table_fu 0.3.1 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION.yml +2 -2
- data/index.html +1 -1
- data/lib/table_fu.rb +12 -8
- data/table_fu.gemspec +1 -1
- metadata +3 -3
data/VERSION.yml
CHANGED
data/index.html
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
|
11
11
|
<body>
|
12
12
|
<a href="http://www.propublica.org" class="propublica"> </a>
|
13
|
-
<h1>TableFu <small>– Version: 0.3.
|
13
|
+
<h1>TableFu <small>– Version: 0.3.2</small></h1>
|
14
14
|
|
15
15
|
<p><a href="http://github.com/propublica/table-fu">TableFu</a> is a ruby gem for spreadsheet-style handling of arrays (e.g. filtering, formatting, and sorting by "column" or "row"). In addition, it has the ability to <a href="#facet">facet</a> — or group — rows according to cell value. It was developed as a backend for its companion project <a href="http://www.github.com/propublica/table-setter">TableSetter</a>.</p>
|
16
16
|
<p>For example, <strong>TableFu</strong> can consume a csv file and sort on a column:
|
data/lib/table_fu.rb
CHANGED
@@ -1,6 +1,8 @@
|
|
1
1
|
if RUBY_VERSION > "1.9"
|
2
2
|
require 'csv'
|
3
|
-
|
3
|
+
Encoding.default_external = Encoding::UTF_8
|
4
|
+
Encoding.default_internal = Encoding::UTF_8
|
5
|
+
::FasterCSV = CSV unless defined? FasterCSV
|
4
6
|
else
|
5
7
|
require 'fastercsv'
|
6
8
|
end
|
@@ -274,13 +276,15 @@ class TableFu
|
|
274
276
|
# And finally we return a empty string object or the value.
|
275
277
|
#
|
276
278
|
def to_s
|
277
|
-
if macro_value
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
279
|
+
ret = if macro_value
|
280
|
+
macro_value
|
281
|
+
elsif @spreadsheet.formatting && format_method = @spreadsheet.formatting[column_name]
|
282
|
+
TableFu::Formatting.send(format_method, @datum) || ''
|
283
|
+
else
|
284
|
+
@datum || ''
|
285
|
+
end
|
286
|
+
ret.force_encoding("UTF-8") if RUBY_VERSION > "1.9"
|
287
|
+
ret
|
284
288
|
end
|
285
289
|
|
286
290
|
# Returns the macro'd format if there is one
|
data/table_fu.gemspec
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: table_fu
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 3
|
9
|
-
-
|
10
|
-
version: 0.3.
|
9
|
+
- 2
|
10
|
+
version: 0.3.2
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Mark Percival
|