table_fu 0.1.1 → 0.2.0

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 CHANGED
@@ -8,7 +8,7 @@ begin
8
8
  gem.summary = %Q{TableFu makes arrays act like spreadsheets}
9
9
  gem.description = %Q{A library for manipulating tables as arrays}
10
10
  gem.email = "jeff.larson@gmail.com"
11
- gem.homepage = "http://github.com/propublica/table_fu"
11
+ gem.homepage = "http://propublica.github.com/table-fu/"
12
12
  gem.authors = ["Mark Percival", "Jeff Larson"]
13
13
  gem.add_dependency 'fastercsv'
14
14
  gem.add_development_dependency "spec"
data/VERSION.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
- :major: 0
3
- :minor: 1
4
- :patch: 1
2
+ :minor: 2
3
+ :patch: 0
5
4
  :build:
5
+ :major: 0
@@ -95,9 +95,7 @@ end %>
95
95
  <p>For example, you can use the <strong>last_name</strong> formatter to extract the last name of a cell containing a person's name:
96
96
  <%= code_for "last_name" %>
97
97
  </p>
98
- <p>Or you can build a meta column from two others containing an html link like so:
99
- <%= code_for "link" %>
100
- </p>
98
+
101
99
  <p>Of course, you can provide your own macros by patching <a href="http://github.com/propublica/table-fu/blob/master/lib/table_fu/formatting.rb">TableFu::Formatting</a>. <a href="http://www.github.com/propublica/table-setter">TableSetter</a> includes rails view helpers directly in <strong>TableFu::Formatting</strong>.
102
100
  <%= code_for "rails_helpers", false %>
103
101
  </p>
data/index.html CHANGED
@@ -107,21 +107,7 @@ spreadsheet<span class="PunctuationSeparator">.</span><span class="Entity">rows<
107
107
  </pre><em>Returns:</em><pre class="dawn">&quot;Beckett&quot;
108
108
  </pre>
109
109
  </p>
110
- <p>Or you can build a meta column from two others containing an html link like so:
111
- <pre class="dawn">csv <span class="Keyword">=</span> &lt;&lt;-EOF
112
- Website,URL
113
- Propublica,http://www.propublica.org/
114
- EOF
115
110
 
116
- spreadsheet <span class="Keyword">=</span> <span class="Support">TableFu</span><span class="PunctuationSeparator">.</span><span class="Entity">new</span>(csv) <span class="Keyword">do </span><span class="PunctuationSeparator">|</span><span class="Variable">s</span><span class="PunctuationSeparator">|</span>
117
- s<span class="PunctuationSeparator">.</span><span class="Entity">formatting</span> <span class="Keyword">=</span> {&quot;Link&quot; <span class="PunctuationSeparator">=&gt;</span> {'method' <span class="PunctuationSeparator">=&gt;</span> 'link'<span class="PunctuationSeparator">,</span> 'arguments' <span class="PunctuationSeparator">=&gt;</span> ['Website'<span class="PunctuationSeparator">,</span>'URL']}}
118
- s<span class="PunctuationSeparator">.</span><span class="Entity">columns</span> <span class="Keyword">=</span> [&quot;Link&quot;]
119
- <span class="Keyword">end</span>
120
-
121
- spreadsheet<span class="PunctuationSeparator">.</span><span class="Entity">rows</span>[<span class="Constant">0</span>]<span class="PunctuationSeparator">.</span><span class="Entity">column_for</span>('Link')<span class="PunctuationSeparator">.</span>to_s
122
- </pre><em>Returns:</em><pre class="dawn">&quot;&lt;a href='http://www.propublica.org/' title='Propublica'&gt;Propublica&lt;/a&gt;&quot;
123
- </pre>
124
- </p>
125
111
  <p>Of course, you can provide your own macros by patching <a href="http://github.com/propublica/table-fu/blob/master/lib/table_fu/formatting.rb">TableFu::Formatting</a>. <a href="http://www.github.com/propublica/table-setter">TableSetter</a> includes rails view helpers directly in <strong>TableFu::Formatting</strong>.
126
112
  <pre class="dawn"><span class="Keyword">class</span> <span class="Entity">TableFu::Formatting</span>
127
113
  <span class="Keyword">extend</span> <span class="Support">ActionView</span><span class="PunctuationSeparator">::</span><span class="Entity">Helpers</span><span class="PunctuationSeparator">::</span><span class="Entity">NumberHelper</span>
@@ -37,11 +37,6 @@ class TableFu::Formatting
37
37
  "#{last}, #{first}"
38
38
  end
39
39
 
40
- # Returns an html link constructed from link, linkname
41
- def link(linkname, href)
42
- "<a href='#{href}' title='#{linkname}'>#{linkname}</a>"
43
- end
44
-
45
40
  # Returns an error message if the given formatter isn't available
46
41
  def method_missing(method)
47
42
  "#{method.to_s} not a valid formatter!"
@@ -14,10 +14,9 @@ Motorized Bar Stool,45.00,09/17/2009,http://project3.com
14
14
  CSV
15
15
 
16
16
  @spreadsheet = TableFu.new(@csv) do |s|
17
- s.formatting = {'Cost' => 'currency',
18
- 'Link' => {'method'=> 'link', 'arguments' => ['Project', 'URL']}}
17
+ s.formatting = {'Cost' => 'currency'}
19
18
  s.sorted_by = {'Project' => {'order' => 'descending'}}
20
- s.columns = ['Date', 'Project', 'Cost', 'Link']
19
+ s.columns = ['Date', 'Project', 'Cost']
21
20
  end
22
21
 
23
22
  end
@@ -25,7 +24,6 @@ CSV
25
24
  it "should just work" do
26
25
  @spreadsheet.rows[0].column_for('Cost').to_s.should == '$45.00'
27
26
  @spreadsheet.rows[0].columns[1].to_s.should == 'Motorized Bar Stool'
28
- @spreadsheet.rows[0].column_for('Link').to_s.should == "<a href='http://project.com' title='Build Supercollider'>Build Supercollider</a>"
29
27
  end
30
28
 
31
29
  it 'should open a file if passed one' do
data/table_fu.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{table_fu}
8
- s.version = "0.1.1"
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 = ["Mark Percival", "Jeff Larson"]
12
- s.date = %q{2010-03-10}
12
+ s.date = %q{2010-05-13}
13
13
  s.description = %q{A library for manipulating tables as arrays}
14
14
  s.email = %q{jeff.larson@gmail.com}
15
15
  s.extra_rdoc_files = [
@@ -50,7 +50,6 @@ Gem::Specification.new do |s|
50
50
  "examples/faceting.rb",
51
51
  "examples/formatting_options.rb",
52
52
  "examples/last_name.rb",
53
- "examples/link.rb",
54
53
  "examples/only.rb",
55
54
  "examples/rails_helpers.rb",
56
55
  "examples/sort_by_column.rb",
@@ -70,10 +69,10 @@ Gem::Specification.new do |s|
70
69
  "spec/table_fu_spec.rb",
71
70
  "table_fu.gemspec"
72
71
  ]
73
- s.homepage = %q{http://github.com/propublica/table_fu}
72
+ s.homepage = %q{http://propublica.github.com/table-fu/}
74
73
  s.rdoc_options = ["--charset=UTF-8"]
75
74
  s.require_paths = ["lib"]
76
- s.rubygems_version = %q{1.3.5}
75
+ s.rubygems_version = %q{1.3.6}
77
76
  s.summary = %q{TableFu makes arrays act like spreadsheets}
78
77
  s.test_files = [
79
78
  "spec/readme_example_spec.rb",
@@ -84,7 +83,6 @@ Gem::Specification.new do |s|
84
83
  "examples/faceting.rb",
85
84
  "examples/formatting_options.rb",
86
85
  "examples/last_name.rb",
87
- "examples/link.rb",
88
86
  "examples/only.rb",
89
87
  "examples/rails_helpers.rb",
90
88
  "examples/sort_by_column.rb",
metadata CHANGED
@@ -1,7 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: table_fu
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 2
8
+ - 0
9
+ version: 0.2.0
5
10
  platform: ruby
6
11
  authors:
7
12
  - Mark Percival
@@ -10,29 +15,33 @@ autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2010-03-10 00:00:00 -05:00
18
+ date: 2010-05-13 00:00:00 -04:00
14
19
  default_executable:
15
20
  dependencies:
16
21
  - !ruby/object:Gem::Dependency
17
22
  name: fastercsv
18
- type: :runtime
19
- version_requirement:
20
- version_requirements: !ruby/object:Gem::Requirement
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
21
25
  requirements:
22
26
  - - ">="
23
27
  - !ruby/object:Gem::Version
28
+ segments:
29
+ - 0
24
30
  version: "0"
25
- version:
31
+ type: :runtime
32
+ version_requirements: *id001
26
33
  - !ruby/object:Gem::Dependency
27
34
  name: spec
28
- type: :development
29
- version_requirement:
30
- version_requirements: !ruby/object:Gem::Requirement
35
+ prerelease: false
36
+ requirement: &id002 !ruby/object:Gem::Requirement
31
37
  requirements:
32
38
  - - ">="
33
39
  - !ruby/object:Gem::Version
40
+ segments:
41
+ - 0
34
42
  version: "0"
35
- version:
43
+ type: :development
44
+ version_requirements: *id002
36
45
  description: A library for manipulating tables as arrays
37
46
  email: jeff.larson@gmail.com
38
47
  executables: []
@@ -76,7 +85,6 @@ files:
76
85
  - examples/faceting.rb
77
86
  - examples/formatting_options.rb
78
87
  - examples/last_name.rb
79
- - examples/link.rb
80
88
  - examples/only.rb
81
89
  - examples/rails_helpers.rb
82
90
  - examples/sort_by_column.rb
@@ -96,7 +104,7 @@ files:
96
104
  - spec/table_fu_spec.rb
97
105
  - table_fu.gemspec
98
106
  has_rdoc: true
99
- homepage: http://github.com/propublica/table_fu
107
+ homepage: http://propublica.github.com/table-fu/
100
108
  licenses: []
101
109
 
102
110
  post_install_message:
@@ -108,18 +116,20 @@ required_ruby_version: !ruby/object:Gem::Requirement
108
116
  requirements:
109
117
  - - ">="
110
118
  - !ruby/object:Gem::Version
119
+ segments:
120
+ - 0
111
121
  version: "0"
112
- version:
113
122
  required_rubygems_version: !ruby/object:Gem::Requirement
114
123
  requirements:
115
124
  - - ">="
116
125
  - !ruby/object:Gem::Version
126
+ segments:
127
+ - 0
117
128
  version: "0"
118
- version:
119
129
  requirements: []
120
130
 
121
131
  rubyforge_project:
122
- rubygems_version: 1.3.5
132
+ rubygems_version: 1.3.6
123
133
  signing_key:
124
134
  specification_version: 3
125
135
  summary: TableFu makes arrays act like spreadsheets
@@ -132,7 +142,6 @@ test_files:
132
142
  - examples/faceting.rb
133
143
  - examples/formatting_options.rb
134
144
  - examples/last_name.rb
135
- - examples/link.rb
136
145
  - examples/only.rb
137
146
  - examples/rails_helpers.rb
138
147
  - examples/sort_by_column.rb
data/examples/link.rb DELETED
@@ -1,11 +0,0 @@
1
- csv = <<-EOF
2
- Website,URL
3
- Propublica,http://www.propublica.org/
4
- EOF
5
-
6
- spreadsheet = TableFu.new(csv) do |s|
7
- s.formatting = {"Link" => {'method' => 'link', 'arguments' => ['Website','URL']}}
8
- s.columns = ["Link"]
9
- end
10
-
11
- spreadsheet.rows[0].column_for('Link').to_s