table_print 1.1.1 → 1.1.2

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.
@@ -6,7 +6,7 @@ Feature: Printing hash
6
6
  |First post! | Ryan |
7
7
  |Second post! | John |
8
8
  |Third post! | Peter |
9
- And table_print data
9
+ When I table_print data
10
10
  Then the output should contain
11
11
  """
12
12
  TITLE | AUTHOR
@@ -14,4 +14,38 @@ Feature: Printing hash
14
14
  First post! | Ryan
15
15
  Second post! | John
16
16
  Third post! | Peter
17
- """
17
+ """
18
+
19
+ Scenario: A lambda column
20
+ Given a variable named data with
21
+ |title | author |
22
+ |First post! | Ryan |
23
+ |Second post! | John |
24
+ |Third post! | Peter |
25
+ When I table_print data, [:include => {:two => lambda{|hash| hash[:author]*2}}]
26
+ Then the output should contain
27
+ """
28
+ TITLE | AUTHOR | TWO
29
+ ----------------------------------
30
+ First post! | Ryan | RyanRyan
31
+ Second post! | John | JohnJohn
32
+ Third post! | Peter | PeterPeter
33
+ """
34
+
35
+ Scenario: A method on the object
36
+ Given a variable named data with
37
+ |title | author |
38
+ |First post! | Ryan |
39
+ |Second post! | John |
40
+ |Third post! | Peter |
41
+ When I table_print data, [:include => :size]
42
+ Then the output should contain
43
+ """
44
+ TITLE | AUTHOR | SIZE
45
+ ----------------------------
46
+ First post! | Ryan | 2
47
+ Second post! | John | 2
48
+ Third post! | Peter | 2
49
+ """
50
+
51
+
@@ -36,7 +36,7 @@ module TablePrint
36
36
  display_method = (prefix == "" ? method : "#{prefix}.#{method}")
37
37
  if method.is_a? Proc
38
38
  cell_value = method.call(target)
39
- elsif target.is_a? Hash
39
+ elsif target.is_a? Hash and target.keys.include? method
40
40
  cell_value = target[method.to_sym]
41
41
  else
42
42
  cell_value ||= target.send(method)
@@ -97,6 +97,7 @@ module TablePrint
97
97
  @raw_column_names = @children.collect { |r| r.raw_column_names }.flatten.uniq
98
98
  end
99
99
 
100
+ # this is a development tool, to show the structure of the row/row_group tree
100
101
  def vis(prefix="")
101
102
  puts "#{prefix}group"
102
103
  children.each{|c| c.vis(prefix + " ")}
@@ -106,6 +107,7 @@ module TablePrint
106
107
  @children.each(&:collapse!)
107
108
  end
108
109
 
110
+ # TODO: rename this to_s
109
111
  def format
110
112
  rows = @children
111
113
  rows = @children[1..-1] if @skip_first_row
@@ -131,7 +133,7 @@ module TablePrint
131
133
  @cells = {}
132
134
  end
133
135
 
134
- # helpful for debugging
136
+ # this is a development tool, to show the structure of the row/row_group tree
135
137
  def vis(prefix="")
136
138
  puts "#{prefix}row #{cells.inspect.to_s}"
137
139
  children.each{|c| c.vis(prefix + " ")}
@@ -1,4 +1,4 @@
1
1
  module TablePrint
2
- VERSION = "1.1.1"
2
+ VERSION = "1.1.2"
3
3
  end
4
4
 
@@ -29,7 +29,7 @@ describe Column do
29
29
  end
30
30
 
31
31
  describe "#display_method" do
32
- it "stores the column's display method as a string" do
32
+ it "returns the column's display method as a string" do
33
33
  c = Column.new(:display_method => :boofar)
34
34
  c.display_method.should == "boofar"
35
35
  end
metadata CHANGED
@@ -1,95 +1,88 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: table_print
3
- version: !ruby/object:Gem::Version
4
- hash: 17
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.2
5
5
  prerelease:
6
- segments:
7
- - 1
8
- - 1
9
- - 1
10
- version: 1.1.1
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Chris Doyle
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2013-01-28 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
12
+ date: 2013-02-03 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
21
15
  name: cat
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
24
17
  none: false
25
- requirements:
18
+ requirements:
26
19
  - - ~>
27
- - !ruby/object:Gem::Version
28
- hash: 21
29
- segments:
30
- - 0
31
- - 2
32
- - 1
20
+ - !ruby/object:Gem::Version
33
21
  version: 0.2.1
34
22
  type: :development
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: cucumber
38
23
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 0.2.1
30
+ - !ruby/object:Gem::Dependency
31
+ name: cucumber
32
+ requirement: !ruby/object:Gem::Requirement
40
33
  none: false
41
- requirements:
34
+ requirements:
42
35
  - - ~>
43
- - !ruby/object:Gem::Version
44
- hash: 29
45
- segments:
46
- - 1
47
- - 2
48
- - 1
36
+ - !ruby/object:Gem::Version
49
37
  version: 1.2.1
50
38
  type: :development
51
- version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
53
- name: rspec
54
39
  prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: 1.2.1
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
56
49
  none: false
57
- requirements:
50
+ requirements:
58
51
  - - ~>
59
- - !ruby/object:Gem::Version
60
- hash: 35
61
- segments:
62
- - 2
63
- - 11
64
- - 0
52
+ - !ruby/object:Gem::Version
65
53
  version: 2.11.0
66
54
  type: :development
67
- version_requirements: *id003
68
- - !ruby/object:Gem::Dependency
69
- name: rake
70
55
  prerelease: false
71
- requirement: &id004 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 2.11.0
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
72
65
  none: false
73
- requirements:
66
+ requirements:
74
67
  - - ~>
75
- - !ruby/object:Gem::Version
76
- hash: 63
77
- segments:
78
- - 0
79
- - 9
80
- - 2
68
+ - !ruby/object:Gem::Version
81
69
  version: 0.9.2
82
70
  type: :development
83
- version_requirements: *id004
84
- description: TablePrint turns objects into nicely formatted columns for easy reading. Works great in rails console, works on pure ruby objects, autodetects columns, lets you traverse ActiveRecord associations. Simple, powerful.
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ~>
76
+ - !ruby/object:Gem::Version
77
+ version: 0.9.2
78
+ description: TablePrint turns objects into nicely formatted columns for easy reading.
79
+ Works great in rails console, works on pure ruby objects, autodetects columns, lets
80
+ you traverse ActiveRecord associations. Simple, powerful.
85
81
  email: archslide@gmail.com
86
82
  executables: []
87
-
88
83
  extensions: []
89
-
90
84
  extra_rdoc_files: []
91
-
92
- files:
85
+ files:
93
86
  - .document
94
87
  - .gitignore
95
88
  - .rspec
@@ -130,39 +123,31 @@ files:
130
123
  - spec/table_print_spec.rb
131
124
  - table_print.gemspec
132
125
  homepage: http://tableprintgem.com
133
- licenses:
126
+ licenses:
134
127
  - MIT
135
128
  post_install_message:
136
129
  rdoc_options: []
137
-
138
- require_paths:
130
+ require_paths:
139
131
  - lib
140
- required_ruby_version: !ruby/object:Gem::Requirement
132
+ required_ruby_version: !ruby/object:Gem::Requirement
141
133
  none: false
142
- requirements:
143
- - - ">="
144
- - !ruby/object:Gem::Version
145
- hash: 3
146
- segments:
147
- - 0
148
- version: "0"
149
- required_rubygems_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ! '>='
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ required_rubygems_version: !ruby/object:Gem::Requirement
150
139
  none: false
151
- requirements:
152
- - - ">="
153
- - !ruby/object:Gem::Version
154
- hash: 3
155
- segments:
156
- - 0
157
- version: "0"
140
+ requirements:
141
+ - - ! '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
158
144
  requirements: []
159
-
160
145
  rubyforge_project:
161
146
  rubygems_version: 1.8.19
162
147
  signing_key:
163
148
  specification_version: 3
164
149
  summary: Turn objects into nicely formatted columns for easy reading
165
- test_files:
150
+ test_files:
166
151
  - features/adding_columns.feature
167
152
  - features/configuring_output.feature
168
153
  - features/excluding_columns.feature